specgate/docs v1.8.0

The gate#

The gate is what stands between a change and your main branch. It proves that every requirement the change delivers is specified, has a scenario that can fail, is linked to a test that names it, and that the tests pass. At the end of this guide your project runs the gate on your machine and in CI, as a check a pull request cannot merge without, and you can read any failure it reports.

You need: a project where specgate init or specgate adopt has run, and git.

PageWhat you do there
On your machineRun the gate before you push; only what changed; a pre-commit hook
In CIThe job ci init writes, for GitHub, GitLab, Azure or Jenkins, made a required check
Adopt it without a red buildToday's findings recorded as debt, so only new ones fail
Read a failureEvery code the gate fails with, what it means and what to do

What it runs#

specgate check runs the stages in this order. A stage that fails stops the ones after it, except the architecture check and the tests, which run side by side.

The eight stages of specgate check, in order specgate check runs eight stages in order. One, ids: no requirement id means something else on the base branch. Two, changes: what a person approved is as it was approved, so the seals are intact. Three, validate: validate --strict over the specs, the links and the coverage. Four, architecture: your arch_cmd. Five, tests: your test_cmd; the architecture check and the tests run side by side. Six, scenarios: with bdd required, the scenarios pass with bdd_cmd. Seven, acceptance: the sealed acceptance tests pass with acceptance_cmd. Eight, quality: the checks of harness.config.yaml, such as coverage, mutation and secrets. When all eight pass, apply delivers the requirement, with evidence. The first stage that fails stops the ones after it and names its fix; you fix what it names and run the gate again. 01 Ids no id means something else on the base branch 02 Changes what a person approved is as approved — seals intact 03 Validate validate --strict specs, links, coverage 04 Architecture your arch_cmd 05 Tests your test_cmd 06 Scenarios with bdd: required, bdd_cmd 07 Acceptance the sealed tests, with acceptance_cmd 08 Quality checks: coverage, mutation, secrets… apply — delivered, with evidence all eight green: the requirement is Implemented The first stage that fails stops the rest and names its fix — check_tests_failed run side by side all green a stage fails fix what it names, run specgate check again
The gate runs its stages in this order; the first one that fails stops the rest and names what to fix, and only a green gate lets apply deliver.
StageWhat it provesFails with
IdsNo requirement id here means something else on the base branch; with --base, what the branch changes in the controls is named for the reviewerid_taken_on_base, controls_changed_on_branch
ChangesEvery open change's delta validates; what a person approved — requirements, design, sealed acceptance tests — is as it was approvedcheck_change_invalid, approved_requirement_changed, file_outside_design, acceptance_not_sealed
Specificationvalidate --strict: specs, scenarios, links, coverage of the matrixcheck_validate_failed
ArchitectureYour arch_cmd (ArchUnit, dependency-cruiser…) passescheck_arch_failed
TestsYour test_cmd passescheck_tests_failed
ScenariosWith bdd: required in the policy: the scenarios of every delivered requirement pass with bdd_cmd. --no-scenarios skips themcheck_scenarios_failed
AcceptanceWhere an open change sealed acceptance tests: they pass with acceptance_cmdacceptance_red, acceptance_no_command
QualityThe checks: of harness.config.yaml — coverage, mutation, secrets…check_quality_failed

A stage with nothing to run is said, not failed: without a test_cmd the gate checks the specification only and says so, and without a base branch the ids are not compared.

Terminal
$ specgate check
  ◆ specgate · check   shop
 
  ·  Ids            not compared with a base — no base branch (pass --base <branch>)
  ✔  Specification   validate --strict
  ✔  Tests           npm test
  ·  Architecture    not checked — specgate config set arch_cmd "<command>"
 
  ✔  Gate passed — the specification and `npm test`

Exit codes: 0 the gate passed, 1 it failed, 2 the command was used wrong. A pipeline needs nothing else.

Which command#

CommandUse it for
specgate checkThe gate. Before you push, and in CI.
specgate check --ciThe same, in CI: a quality check that cannot run fails instead of being skipped, and the ci-stage checks run too.
specgate validate . --strictThe specification alone, without running your tests — the Docker image and the Maven and Gradle plugins run this.
specgate quality runThe quality checks alone, by stage.
specgate check --lastThe last result, without running anything.

What a requirement owes, by status#

The gate does not ask a requirement for everything at once:

  • Draft owes nothing yet. A new project's gate is green on day one, and a scenario may still hold <placeholders>.
  • Approved and later owe a scenario that can fail: real steps, Given, When and Then capitalised.
  • Implemented, Verified and Released owe a test that names the requirement or its scenario, a real obligation in spec.md instead of the sentence Specgate wrote, and files that exist for every path the matrix names.

The details of each rule: What validate checks.

Next#