test: name every enforced behaviour in a ledger, and the test that proves it - #71
Merged
Merged
Conversation
…oves it Adds docs/requirements.md, one row per behaviour this repository enforces today (the ADR, link, manifest and boundary gates, the PR title check, the em-dash ban, the test harness guards and the coverage ratchet), each citing the test file that proves it. scripts/lint-requirements.ts is the meta test that holds the ledger honest: every row parses, every named file exists, is a test file and holds a test, ids are unique, the stated row count matches, and every id cited anywhere in the tracked tree resolves to a row. Records the decision as docs/adr/architecture/0103, next free number after 0102 (reserved on another in-flight branch), and adds its register row.
REQ-009 and REQ-010 cover the package-contents gate and the pipeline-wiring test that issue #23 brought; lint:requirements now runs in the Contracts job and in npm run verify; ADR 0103 cites the now-landed ADR 0102; coverage thresholds are raised to what the suite reaches with the new gate covered.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #67 (parent #21)
What this branch does
docs/requirements.mdnames every behaviour this repository guarantees, and for each one the test that fails when it stops being true. Ten rows,REQ-001toREQ-010: the ADR contract, the link contract, the manifest gate, the boundary gate, the pull request title check, the em-dash ban, the test harness guards, the coverage ratchet's integrity, the package-contents gate, and the script-to-workflow wiring check.A behaviour could previously lose its proof without anything saying so. The coverage ratchet notices a line that stops running, but not a test file renamed, emptied or deleted while the code it covered stayed in place, and nothing tied a sentence in the documentation to the test that makes it true.
scripts/lint-requirements.tsholds the ledger honest: every row parses, every named file exists and holds at least one test, ids are unique, the stated row count matches the rows, and every id cited anywhere in the tree resolves to a row. Library first, with a one-line CLI guard, the shape the other gates use.Contractsjob beside the ADR, link and manifest contracts, and innpm run verify. It is a document contract of the same kind as its neighbours, not a code-against-graph check likeboundaries. ADR 0102 asks for the script and its job in one pull request, andtest/pipeline-wiring.test.tsis what would otherwise have failed.Decisions
docs/adr/architecture/0103-a-behaviour-ledger-names-what-a-test-proves.md, citing 0102 for the wiring rule.Two branches came out of
scripts/lint-requirements.tsrather than being covered by a contrived test: a?? ""fallback on a key that comes from the same object being iterated, and an id-shape check already guaranteed by the row pattern, whose capture group isREQ-\d{3}. Neither could fire.The ratchet rises: statements 97.17 to 97.5, branches 87.5 to 88.79, functions 100, lines 96.88 to 97.26.
Verification
Each acceptance criterion was broken on the rebased tree and restored, not just run:
test/adr-contract.test.ts:REQ-001: names 'test/adr-contract.test.ts', which does not existtest/link-contract.test.ts:REQ-002: 'test/link-contract.test.ts' holds no testtest/link-contract.test.ts cites REQ-999, which no row carriesdocs/requirements.md: states 9 rows, holds 10npm run verifyclean, 189 tests.actionlint1.7.7, the version CI pins, clean.Follow-up
The coverage numbers in
README.mdnow lag these thresholds. #69 owns that file and holds it to the configuration with a test, so the refresh lands there.