Repository navigation
Concept Testing And TDD
Testing and TDD is constitution principle P10 plus the repository workflow that enforces behavior changes through tests.
The constitution says all non-trivial logic must have unit tests. Pull requests that add or modify behavior must include corresponding test coverage. Trivial glue code can be exempt, but the bar for "trivial" is high; when in doubt, test.
This repo uses a mandatory RED-GREEN-REFACTOR loop for production code:
- RED: write a test that asserts the desired behavior and run it. It must fail for the intended behavioral reason, not because of a setup error.
- GREEN: write the minimum production code that makes that test pass.
- REFACTOR: clean up the design while preserving behavior. If refactoring changes behavior, start another RED step first.
The loop repeats for each behavior. Bug fixes start with a failing regression test. Features start with a test for the user-observable behavior. Refactors that should not change behavior are protected by existing tests.
Making TDD mandatory was not enough on its own. Nothing prompted an agent to raise methodology before starting, so work began and tests followed. Since Decision-Spec-Kit-Upgrade, both steering files open the work with the question instead.
Two things get answered before any code is written, in the first response, even when nobody asked:
-
Does this need a spec? A new user-facing capability, a new AWS resource
or cost-model change, a required constitution check, or work needing research
first all trigger the hybrid rule in Wiki-Conventions — recommend
/speckit.specifybefore coding. - What is the failing test? Name it before writing the implementation.
Either can be declined, but explicitly and with a reason recorded in the pull request or issue. Silence is not consent. The agent pushes back once, naming the trigger and the concrete cost of skipping it — usually an invented hard number, or a constitution check that never ran — then respects the call and notes the exception.
The tdd skill asks the spec question in its Phase 0, so it lands before the
first failing test rather than after the implementation.
The final repository gate is:
pnpm run validatepackage.json defines that gate as:
lint -> format:check -> typecheck -> build -> test
Concretely, it runs ESLint, Prettier check, TypeScript build mode, workspace builds, and workspace tests. All five must pass before work is considered complete.
For Max Height, tests also protect the constitutional priorities. Personality behavior is guarded by Concept-Personality-Gate, fallback behavior by Concept-Graceful-Degradation, and supply-chain or CI behavior by Concept-Supply-Chain-Discipline.
Documentation-only changes do not require the validation gate unless they change executable examples or documented commands. Production code changes do.
When a targeted test is available, run it during the RED and GREEN steps, then run the full validation gate before completion.
See also: Guide-Validation-Gate, Source-Constitution.
- Concept-Cloud-Only-Inference
- Concept-Budget-Ceiling
- Concept-Personality-Gate
- Concept-IP-And-Legal-Posture
- Concept-Supply-Chain-Discipline
- Concept-Graceful-Degradation
- Concept-Observability
- Concept-Testing-And-TDD
- Concept-Credential-Hygiene
Editing in the browser? Wiki edits are live and bypass wiki:lint. Read
Guide-Wiki-Contributing first.