specgate/docs v1.8.0

Sealed acceptance tests#

The agent that implements a requirement should not also write the test that judges it: a wrong test is then followed, or written, by the same hand. Sealed acceptance tests separate the roles. Someone else writes them, a person approves them, and from then on the agent cannot change them — the gate runs them with your own test command.

Sealed acceptance tests: who writes, who seals, who cannot change them Six steps. One: a person approves the design, at a terminal. Two: another hand, a person or another agent, writes the acceptance tests; it sees the specification, never the source. Three: a person seals them; each file is recorded by its sha256 in the change's approvals.json. Four: the agent implements the requirement; its tools cannot write a sealed test. Five: the gate runs the sealed tests with your own test command, acceptance_cmd. Six: the outside judge checks the hashes before and after the run. Changing a sealed test is changing the contract, so it goes back to step three: a person approves and seals it again. 1 A person approves the design — at a terminal 2 Another hand writes the tests: it sees the spec, never the source 3 A person seals them each file by its sha256, in approvals.json 4 The agent implements its tools cannot write a sealed test 5 The gate runs them with your own test command, acceptance_cmd 6 The outside judge checks the hashes before and after the run Changing a sealed test = changing the contract — back to step 3 approve again
The tests that judge the agent are written by another hand and sealed by a person; the agent cannot change them, and changing one means approving it again.

Specgate reads no test. It only controls who may change one, so this works in any language your project tests in: JUnit, pytest, Playwright, Cucumber steps.

1. Write them — not the implementing agent#

Write the acceptance tests from the change's specification and design, never from the source: a person, or another agent that sees only spec.md, features/ and docs/specs/. Name the requirement and the scenario in each test's title (REQ-014 SCN-014 — peak rate above the threshold).

List each file in docs/specs/changes/<change-id>/acceptance-tests.md, one line per file, with the scenarios of the change it proves:

markdown
- test/acceptance/pricing.spec.ts — SCN-014, SCN-015
- src/test/java/PricingIT.java — SCN-014

This is not acceptance.md: that file is the business sign-off checklist specgate acceptance <change-id> writes.

2. Approve and seal them — a person, at a terminal#

The change itself is approved first (specgate change approve <change-id>). Then a person reads the tests against the scenarios and seals them:

bash
specgate change approve <change-id> --layer acceptance

Once sealed, it runs them once with acceptance_cmd (step 3) and shows why they fail. Before the code exists they should fail for the code; a test that fails because it loads a file from a wrong path will never pass — fix it and seal it again.

It refuses, recording nothing, when a listed file is missing, when a line names no scenario of the change, or when the change is not approved. Run with no terminal — by an agent's tool — it refuses with approve_needs_person.

Each file is recorded in the change's approvals.json by its sha256.

3. Tell the gate how to run them#

bash
specgate config set acceptance_cmd "npx playwright test {files}"

{files} stands for the sealed paths. Other examples: pytest {files}, mvn -q verify -Dit.test=PricingIT. Specgate installs nothing.

What the gate and the guard do#

specgate check (and so apply) has an acceptance stage:

FindingWhenWhat to do
acceptance_not_sealeda sealed file changed or is gonerestore it (git checkout -- <file>), or have a person approve the new version
acceptance_redacceptance_cmd exits non-zerofix the code — the test is the contract
acceptance_no_commandtests are sealed and no acceptance_cmd is setset it (step 3)

The rule is acceptance in .specgate/gate.yaml: an error in strict and standard, a warning in minimal (gate policy).

Where Specgate's hooks run (the guards), a write, an edit, a patch or a shell command that changes a sealed test is refused with acceptance_sealed; a sealed test that names a requirement counts as the test written first. Where no hook runs, the outside judge sees the change and fails the run.

After the change is archived#

The seal stays. A sealed test of an archived change is still checked and still guarded. To change one, open a change that lists it in its own acceptance-tests.md, and have a person approve it: the new seal replaces the old.

That change needs a real delta. propose writes it as a template, and change approve refuses the template (approve_blocked: the requirement has no kind=, its steps are <placeholders>); a change that is not approved cannot seal (acceptance_change_not_approved). The delta restates the requirement the test proves under ## MODIFIED Requirements, with the scenario the test names, and acceptance-tests.md names that scenario:

bash
specgate propose reseal-pricing --capability pricing
# specs/pricing/spec.md: ## MODIFIED Requirements, then REQ-014 whole,
#   with "#### Scenario: SCN-014 — …" and <!-- specgate:trace kind=functional -->
# acceptance-tests.md:   - test/acceptance/pricing.spec.ts — SCN-014
specgate change approve reseal-pricing                      # a person
specgate change approve reseal-pricing --layer acceptance   # the new seal

Then apply the requirement again and archive the change, as for any MODIFIED requirement.

Next#