feat(test-deletion-guardrail): block unjustified test removal in tdd-cycle + verify - #13
Merged
Merged
Conversation
Implements the comparison + gate portion of specs/test-deletion-guardrail.md. scripts/check-test-count.py takes RED/GREEN test-surface snapshots, classifies deltas as added/removed/renamed/replaced, and exits non-zero when tests were removed without an [ADD-TEST-DELETE: ...] commit trailer or an overrides.json record. One-shot --baseline <ref> form is the entry point invoked by /add:verify Gate 3.5. Ships: - scripts/check-test-count.py (stdlib-only; snapshot / compare / gate subcmds) - core/lib/impact-hint.sh (pure shell + jq + grep; AC-018..AC-024) - core/knowledge/test-discovery-patterns.json (Python/TS/JS/Go/Ruby/Rust catalog) - tests/test-deletion-guardrail/ — 15 fixture tests covering the gate matrix - scripts/compile.py now copies core/lib/ and core/knowledge/ into both runtimes Acceptance criteria covered: AC-001..AC-024, AC-028. AC-025..AC-027 (telemetry) are deferred to the companion telemetry-jsonl spec. Part of M3 pre-GA hardening. Spec: specs/test-deletion-guardrail.md. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds snapshot + gate hooks to the TDD sub-agent chain so the guardrail shipped in the previous commit actually runs during a /add:tdd-cycle: - /add:test-writer: capture RED snapshot + commit with standard message (AC-005); fail if zero tests added (AC-006) - /add:tdd-cycle: emit files-likely-affected hint before GREEN; capture GREEN snapshot after GREEN; new --allow-test-rewrite flag for approved rewrites - /add:implementer: consume hint in pre-flight (AC-022); explicit NEVER-delete directive (AC-028); capture GREEN snapshot (AC-007) - /add:verify: new Gate 3.5 "Test Surface Integrity" between Gate 3 and Gate 4; skips cleanly when no cycle dir exists Part of M3 pre-GA hardening. Spec: specs/test-deletion-guardrail.md. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds the Test-Deletion Invariant section to the auto-loaded TDD rule (AC-028):
"Tests added during RED MUST exist (passing) at the end of GREEN. Test deletion
during the cycle is forbidden without --allow-test-rewrite and explicit human
approval. Test renames are permitted; test replacements require approval."
Documents both accepted justification-marker formats:
1. Commit trailer: [ADD-TEST-DELETE: <AC-id or reason>]
2. Per-cycle file: .add/cycles/cycle-{N}/overrides.json with kind:test-rewrite
Both land in telemetry for retro review. Cross-references the enforcement
points in /add:test-writer, /add:implementer, and /add:verify Gate 3.5.
Part of M3 pre-GA hardening. Spec: specs/test-deletion-guardrail.md.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
MountainUnicorn
force-pushed
the
feat/test-deletion-guardrail
branch
from
April 23, 2026 09:40
3db2b50 to
6fce85b
Compare
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.
Summary
Implements
specs/test-deletion-guardrail.md(v0.9.0, M3 pre-GA hardening). Defends ADD's signature TDD claim against the Kent Beck / TDAD-paper failure mode: coding agents prefer to delete the failing test rather than satisfy it, which silently corrupts the RED → GREEN separation.scripts/check-test-count.py— stdlib-only snapshot / compare / gate CLI. One-shot--baseline <ref>form is the entry point invoked by/add:verifyGate 3.5.core/lib/impact-hint.sh— pure shell + jq + grep "files-likely-affected" hint fed to/add:implementerat start of GREEN.core/knowledge/test-discovery-patterns.json— regex catalog covering Python, TS/JS, Go, Ruby, Rust (extensible per project)./add:verify, between Gate 3 and Gate 4.core/rules/tdd-enforcement.mdgains the "Test-Deletion Invariant" section (AC-028).scripts/compile.pynow shipscore/lib/+core/knowledge/into both runtimes.Acceptance Criteria
telemetry-jsonlspec; integration contract documented in this PR)Justification markers accepted by the gate:
base..HEAD:[ADD-TEST-DELETE: <reason>].add/cycles/cycle-{N}/overrides.jsonwithkind: "test-rewrite"Test plan
tests/test-deletion-guardrail/covering the gate matrix: count-same, count-increased, count-decreased (no override → FAIL), count-decreased-with-approval, empty-before (bootstrap), rename, replacement-without-approval, replacement-with-approval, missing-green, compare-json-shape, rename-detection, compare-summary-format, discovery-python-basic, empty-red-fails, impact-hint-basicpython3 scripts/compile.py --checkpasses (no drift)python3 scripts/validate-frontmatter.pypassesbash tests/hooks/test-filter-learnings.shpasses (regression check)python3 scripts/check-test-count.py --baseline origin/mainreturns PASS (net test count increased from 0 to 0 in harness terms; no removals)Part of
M3 pre-GA hardening (Cycle 3). Spec:
specs/test-deletion-guardrail.md. Complementstelemetry-jsonl(Cycle 3) which owns the JSONL emitter referenced by AC-025..AC-027.Files Touched
core/skills/tdd-cycle/SKILL.mdcore/skills/verify/SKILL.mdcore/skills/test-writer/SKILL.mdcore/skills/implementer/SKILL.mdcore/rules/tdd-enforcement.mdcore/knowledge/test-discovery-patterns.jsoncore/lib/impact-hint.shscripts/check-test-count.pyscripts/compile.pycore/lib/+core/knowledge/into both runtimestests/test-deletion-guardrail/docs/plans/test-deletion-guardrail-plan.mdCHANGELOG.md[Unreleased]🤖 Generated with Claude Code