specgate/docs v1.8.0

ADR-0036 — A gate a team can trust#

Status#

Accepted — 2026-10-19 (change trust-gate, archived)

Context#

agentkit was built with Specgate: 118 requirements, most of them through the harness. The gate never let a broken requirement through. It did, repeatedly, stop work for reasons that were not defects:

  • <module> inside a code span in a THEN step read as an unfilled Outline placeholder; the fix was rewording the specification.
  • TDD-3 demanded a matrix row for every REQ-NNN written anywhere in a spec — an example id in a scenario was enough; the fix was changing the example.
  • Parallel branches conflicted in docs/specs/traceability.md on every merge, because adjacent rows changed; the merge driver that handles it is registered per clone by harness init, which most clones never run.
  • Two branches allocate ids as max+1 over their own checkout; the collision surfaces after the merge, if at all.
  • The harness needed four wrapper scripts: install dependencies in each worktree, keep the prompt archive out of the merge, tell the agent its requirement, and merge green requirements one after another while keeping the base green.

Decision#

  1. Rules over text ignore what is quoted. Code spans and double-quoted strings are content, not structure; the placeholder and vague-step rules skip them. TDD-3 counts requirements a spec declares (headings and requirement table rows outside fences), not ids it mentions.
  2. Real specification shapes are a regression test. A fixture reproduces what produced false positives on agentkit — without its text, which is private — and validate --strict must pass it with no finding. SPECGATE_CORPUS runs the same test over private projects locally.
  3. Ids are checked against the base, not rewritten. check compares the branch's requirements with the base branch's and fails on the same id with a different title. Renumbering stays manual: by then an id lives in tests, tags and commits.
  4. The generated matrix merges as a union. It is output, regenerated by check; a merge must never stop on it. Git's built-in union driver needs no per-clone setup.
  5. The harness works first time. Setup is detected from the lockfile, the agent gets SPECGATE_REQ and SPECGATE_ATTEMPT, and the prompt archive stays on the requirement's branch — for review and --resume, as before — but never in the merge --chain writes.
  6. --chain is the one place the harness merges, and only on request: each requirement is cut from the head the previous merge produced, merged with a merge commit when its gate passes, and the gate runs again on the merge; a red result is undone and the chain stops. Without --chain the harness still never merges.

Consequences#

  • Specifications no longer have to be worded around the tool.
  • A merged branch can carry a stale matrix until check runs; validate on its own still reports matrix_stale, which is the truth.
  • id_taken_on_base needs the base ref fetched; CI checkouts that are shallow skip it and say so.
  • A team that uses --chain accepts that the harness writes to its branch; the merge commits are one per requirement and revertible.

Alternatives considered#

  • Stop committing the matrix. Ends conflicts too, but twenty readers open the file and reviewers lose the table in the pull request.
  • Allocate ids at archive time and renumber. Rejected for the reason in RequirementRemoval: an id is already in tests and commits by then.
  • Make the merge driver regenerate. It sees three temporary files, not the merged sources, and still needs per-clone registration.