specgate/docs v1.8.0

Read a gate failure#

Every failure the gate reports says where, what, its code in brackets, and the fix on the next line. At the end of this page you can read any of them and know what to change — in the code, the test, the scenario or spec.md.

The gate said no — what now: each kind of failure, and the one thing to do Seven kinds of failure on the left, each with its codes, and on the right the one action that answers it. The tests are red, check_tests_failed or acceptance_red: fix the code, not the test, because the tests are the contract. No test names the requirement, apply_no_test: write the test that names it first, with REQ-007 in it, then run apply again. What a person approved has changed, approved_requirement_changed or acceptance_not_sealed: put it back, or a person approves it again — a requirement with specgate change approve and the change id, a sealed acceptance test with specgate change approve, the change id and --layer acceptance. A new file the approved design does not name, file_outside_design: name it in design.md and have the design approved again, or open a change for it with specgate propose. Nobody approved the change, change_not_approved: a person approves it, at a terminal, with specgate change approve. A scenario failed, check_scenarios_failed: make the code do what the scenario says; specgate scenarios with the requirement id runs them one by one. The branch changes the controls, controls_changed_on_branch, a warning named by check --base: the reviewer reads it as part of the pull request. Nobody edits the approval record by hand; every failure prints its fix on the line below it. THE GATE SAID NO — WHAT IT SAYS WHAT NOW — THE ONE THING TO DO The tests are red check_tests_failed · acceptance_red Fix the code, not the test the tests are the contract No test names the requirement apply_no_test Write the test that names it, first name REQ-007 in it, then apply again What a person approved has changed approved_requirement_changed · acceptance_not_sealed Put it back, or a person approves again requirement: specgate change approve <id> sealed test: … approve <id> --layer acceptance A new file the design does not name file_outside_design Name it in design.md, approve again or open a change: specgate propose <change-id> Nobody approved the change change_not_approved A person approves, at a terminal specgate change approve <id> A scenario failed check_scenarios_failed Make the code do what it says specgate scenarios <REQ> runs them one by one The branch changes the controls controls_changed_on_branch warning The reviewer reads it in the PR a warning, named by check --base Never edit the approval record by hand. Every failure prints its fix on the line below it.
Each failure has one move: fix the code, write the test first, put back what a person approved, or have a person approve again.

The shape of a failure#

text
  ✖  Specification   validate --strict

     ◆ specgate · validate   shop

       ✖  --strict-scenarios violations detected: 4 (4 that make a scenario pass without testing anything)
         ✖  features/a-customer-can-place-an-order.feature:5  `given` is not a Gherkin keyword; write `Given`. Cucumber reads it as prose, so the line does nothing.  [keyword_case_invalid]
          fix: Write `Given`.
         ✖  features/a-customer-can-place-an-order.feature:4  scenario_has_no_steps — Cucumber sees no steps here, so this scenario passes without testing anything. If the steps look like they are there, check their keywords: Gherkin is case-sensitive.  [scenario_has_no_steps]
          fix: Write Given / When / Then steps, in that capitalisation.

  ✖  The gate failed: validate --strict.  [check_validate_failed]
     fix: Fix what validate reports above, then run `specgate check` again.

Read it from the bottom: the last line names the stage that failed (check_validate_failed); above it, each finding with its file and line. The stages after a failed one did not run — specgate check --last lists each as not run. In CI the same text is in the job's log; --json gives it as data, each finding with code, file, line and fix.

The stage that failed#

CodeThe stageWhat to do
id_taken_on_baseA requirement id here has another title on the base branch: two branches added the same REQ-NNNRenumber yours to the id the fix names, the next free on both sides
check_change_invalidAn open change's delta does not validatespecgate change validate <id> lists every finding
check_validate_failedThe specification: one of the findings belowFix the findings above it
check_arch_failedYour arch_cmd failedMove the code where the architecture expects it, or change the rule on purpose
check_tests_failedYour test_cmd failed; its output is aboveMake the tests pass
check_scenarios_failedWith bdd: required, a delivered requirement's scenarios failed with bdd_cmdMake the code do what the failing scenarios say; specgate scenarios <REQ> runs one requirement's, scenario by scenario
check_approved_changedWhat a person approved in an open change is not what is there now; approved_requirement_changed above it names the requirementPut it back, or have a person approve the change again: specgate change approve <id>
check_acceptance_failedThe sealed acceptance tests: acceptance_not_sealed, acceptance_red or acceptance_no_command above itFix what the finding above it says
acceptance_redThe acceptance tests a person approved did not pass with acceptance_cmd; the last lines of its output are aboveMake the code do what the approved tests say: the tests are the contract, not the thing to change
acceptance_no_commandAcceptance tests are sealed and the project names no command that runs themspecgate config set acceptance_cmd "<command>", {files} the sealed paths: npx playwright test {files}, pytest {files}
check_quality_failedA quality check found something new, or could not run under --ciEach check's own finding is above it: quality_check_failed
baseline_incompletecheck --baseline was asked to record what a baseline cannot holdFix what validate reports, then record again — Adopt it without a red build
gate_policy_invalid.specgate/gate.yaml names a preset, rule, level or date it cannot readUse what the fix lists — Configure the gate

A trust: entry in .specgate/gate.yaml that is not a level from 1 to 5, or names no capability, is not reported as gate_policy_invalid. It shows inside the specification stage, under Domain language findings, and the gate fails as check_validate_failed:

text
       ✖  Domain language findings: 1
       trust: nowhere is not a capability of this project.
          fix: Use one of: reservations.

What a person approved#

These say that something a person approved is no longer what they approved. The fix is never to edit the record by hand: restore what changed, or have a person approve the new version.

CodeMeansWhat to do
approved_requirement_changedA requirement of an approved change is not what was approvedPut it back, or have a person approve it again: specgate change approve <id>
approval_not_sealedA warning: the change was approved before approvals sealed its requirements, so a change to one would go unseenspecgate change approve <id> seals it
file_outside_designA new source file that the approved design of the change does not name (rule scope)Name it in the change's design.md and have the design approved again, or open a change for it: specgate propose <change-id>
acceptance_not_sealedAn acceptance test a person approved has changed or is gone (rule acceptance)git checkout -- <file>, or a person approves the new version: specgate change approve <id> --layer acceptance
controls_changed_on_branchcheck --base: the branch changes the controls — the guard, .specgate/gate.yaml, a change's approvals, evidence, a sealed acceptance test. A warning by default (rule controls)The reviewer reads it as part of the pull request. Make .specgate/ and docs/specs/changes/*/approvals.json code-owned so that review is required

Refused before the gate#

apply and change approve refuse these before anything is recorded:

CodeMeansWhat to do
change_not_approvedapply: the requirement's change is not approved yet; a requirement is delivered once a person approved its changeA person runs specgate change approve <id>, with the --layer the message names — or approvals: { required: never } in harness.config.yaml
steps_changed_after_codeapply: step definitions were added or changed after the requirement's code began; steps written to agree with the code prove nothingA person reads the steps against the scenarios, then runs in a terminal specgate apply <REQ> --steps-reviewed — or put the steps back and make the code pass them
approve_needs_personchange approve was run where there is no terminal — by an agent or a script. Nothing was recordedA person runs specgate change approve <id> in a terminal, or approves it in the studio's Review

Not failures, said so you know what was not checked: ids_not_compared (no base branch to compare with), check_not_run (a check skipped, with why), gate_rule_reported (findings the policy reports instead of failing).

The specification's findings#

A scenario that cannot fail#

CodeMeansFix
keyword_case_invalidgiven, when, then in lower case: Cucumber reads the line as proseCapitalise the keyword
scenario_has_no_stepsCucumber sees no steps, so the scenario passes without testing anythingWrite Given / When / Then steps
scenario_placeholder_stepA step still holds <the action under test> — allowed in Draft onlyWrite the real state, action and outcome

A delivered requirement without its proof#

From the moment a requirement is Implemented, Verified or Released:

CodeMeansFix
strict_tdd_1No test names the requirement (TDD-1)Write a test whose name or body says REQ-NNN or one of its SCN-NNN — that mention is the link. Or move it back to Draft.
strict_tdd_2Its row has no scenario id (TDD-2)Tag the scenario with @REQ-NNN @SCN-NNN
strict_tdd_3It is in spec.md and not in the matrix (TDD-3)Give it a ## REQ-NNN section and a tagged scenario; specgate new writes both
scenario_not_coveredA scenario of a declared feature file is named by no testName it in a test, or delete the scenario if it no longer describes behaviour
link_without_evidenceThe test artifact names neither the requirement nor its scenariosName the requirement in the test: a path that exists proves nothing
requirement_template_obligationThe obligation in spec.md is still "The system MUST satisfy: …"Write what must hold, when, and how it is observed
CodeMeansFix
declared_artifact_missingA path the matrix declares does not existFix the path, or restore the file
feature_not_in_matrixA feature file no requirement claimsTag its scenario @REQ-NNN @SCN-NNN, or specgate new
scenario_id_not_in_featureThe matrix points at a scenario id the feature file does not carryPut @SCN-NNN above its Scenario: line
matrix_staleThe matrix no longer matches spec.md, the tags and the testsspecgate check regenerates it: commit the result

Pack drift#

validate --against-lock fails when a file a domain pack rendered no longer matches the digest pinned in .specops.lock — a moved tag, a rewritten history, a hand-edited generated file. See Supply chain.

Green here, red in CI#

WhyWhat to do
CI compares the ids with the base branch and your run did notspecgate check --base origin/main locally
CI runs the whole suite, --affected ran part of itspecgate check without --affected
A quality check skipped here (no Docker) must run in CIStart Docker and run specgate check --ci
A shallow clone: the base branch is not therefetch-depth: 0 (GitHub), GIT_DEPTH: 0 (GitLab)
Windows or macOS only: a path or a line endingThe GitHub job runs all three for this reason; .gitattributes keeps line endings stable
CI runs another version of SpecgateThe version is pinned in the CI file: Pin the version

The quality checks' own failures — no report at …, a finding the same on every change, SonarQube's login — are in Quality: When it goes wrong. Anything else: Troubleshooting.

Next#

  • Validating — every rule validate --strict applies, in detail
  • Quality checks — coverage, mutation and security in the gate