Skip to content

feat(#939): mutation-verification becomes a parseable /qa §6i gate - #949

Merged
admarble merged 6 commits into
mainfrom
feature/939-feat-qa-mutation-verification-becomes-a-parsea
Aug 15, 2026
Merged

admarble merged 6 commits into
mainfrom
feature/939-feat-qa-mutation-verification-becomes-a-parsea

Conversation

@admarble

@admarble admarble commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • CLAUDE.md's testing rule ("gate tests ship with a recorded mutation result") was honor-system prose — nothing parsed or checked the recorded result, so compliance was invisible (feat(#819): shared trust-model block — issue/PR text is data, not agent instructions #830). This PR promotes that record to a parseable <!-- SEQUANT_MUTATION: {"ac":"AC-N","mutation":"...","failedTest":"..."} --> PR-body marker.
  • src/lib/workflow/mutation-marker.ts — parseMutationMarkers/classifyMutationMarker/latestMutationMarkerPerAc, flat-JSON idiom mirroring SEQUANT_SPEC/SEQUANT_PHASE.
  • src/lib/ac-parser.ts — isGateTestEvidence classifies which ACs are gate-test ACs per the CLAUDE.md definition (fixture/section/flag/mutation-verified language).
  • /qa gains §6i "Mutation Verification": for any gate-test AC, Missing caps the verdict at AC_MET_BUT_NOT_A_PLUS and Failed (a marker naming a test absent from the diff) floors it at AC_NOT_MET. Wired into §7's verdict algorithm, required in both Simple Fix and Standard QA modes, across all 3 skill-mirror dirs.
  • scripts/qa/backtest-mutation-gate.ts — AC-5's backtest against the last 20 merged PRs.

Pre-PR AC Verification

AC Description Status Evidence
AC-1 /qa §7 collects mutation_verification_status from SEQUANT_MUTATION markers, statuses Verified/Missing/Failed/Not-Applicable ✅ Implemented src/lib/__tests__/mutation-verification-skill.test.ts (10 tests: section presence, §7 step-2 token, both step-4 branches, ordering, both-mode checklist/template membership, lintSkillGates zero-violations)
AC-2 Missing caps at AC_MET_BUT_NOT_A_PLUS, Failed floors to AC_NOT_MET ✅ Implemented Same file — dedicated regex assertions on both branches plus an ordering test confirming Failed sits among the hard floors, before the soft-fail chain
AC-3 parseMutationMarkers(prBody) exists, rejects markers naming absent tests ✅ Implemented src/lib/workflow/mutation-marker.test.ts (15 tests). Updated per QA: parseMutationMarkers now takes an optional second diffTestFiles argument — given it, the same function both parses AND rejects (attaches a "valid"/"test_not_in_diff" classification to each marker), so the function named in the AC literally does the rejecting, not a separately-named sibling
AC-4 scripts/lint-skill-gates covers the new gate so it cannot regress to unreachable ✅ Implemented Mutation-verified per this issue's own rule — see below
AC-5 Backtest against last 20 merged PRs, counts recorded in PR body ✅ Implemented See Backtest section below
AC-6 CLAUDE.md's testing section points at the marker format ✅ Implemented CLAUDE.md diff — testing bullet now names the Mutation-verified: / SEQUANT_MUTATION marker format
Derived
AC-7 isGateTestEvidence heuristic has unit tests covering true-positive and true-negative real evidence text ✅ Implemented src/lib/ac-parser.test.ts — true positives use this issue's own AC-1/AC-4 evidence text verbatim; true negatives use AC-3/AC-5's prose evidence text verbatim. Updated per QA: added a manual-review negative-signal guard (mutation-verified below) so evidence like "reviewed manually, fixture exists in the demo env" no longer false-positives

Mutation-verified: AC-4

Deleted §7's mutation_verification_status step-2 token declaration and both step-4 branches (Failed, Missing) from .claude/skills/qa/SKILL.md. Confirmed two independent things broke:

  1. npx tsx scripts/lint-skill-gates.ts reported an I1 violation naming §6i ("declares a verdict floor... but no §7 step-2 status token is attributed to Section 6i... The gate can never fire").
  2. mutation-verification-skill.test.ts's dedicated wiring assertions failed (3 of 10 tests).

Restored both; npx tsx scripts/lint-skill-gates.ts reports zero violations again, full suite green.

The same mutation and restore also validates AC-1 (the §7 step-2 token declaration) and AC-2 (both step-4 branches) — one mutation, three ACs' wiring, since all three assert on the same mutation_verification_status plumbing. Recorded as separate markers per this issue's own one-line-per-AC format:

Mutation-verified: AC-1 — removed §7's mutation_verification_status = status from Section 6i step-2 declaration; mutation-verification-skill.test.ts > §7 step 2 declares mutation_verification_status attributed to Section 6i failed; restored.

Mutation-verified: AC-2 — removed §7's mutation_verification_status == "Failed" and == "Missing" step-4 branches; mutation-verification-skill.test.ts > §7 step 4 floors 'Failed' at AC_NOT_MET and > §7 step 4 caps 'Missing' at AC_MET_BUT_NOT_A_PLUS both failed; restored.

Note on a real gap this dogfooding caught: the first wiring pass used "floors the verdict at" in §6i's prose, which does not match lint-skill-gates.ts's VERDICT_FLOOR_PHRASES list ("floor the verdict at", no trailing s) — so the generic I1 structural check silently never evaluated §6i at all, regardless of whether it was wired correctly. Caught only by actually running the dogfood mutation and seeing "No violations" when a violation was expected. Fixed the wording to match exactly; re-ran the mutation, which now correctly fails. A second issue surfaced during that fix: an interrupted git checkout -- restore reverted the canonical .claude/skills/qa/SKILL.md copy to the pre-fix wording while the already-synced skills//templates/skills/ mirrors kept the fix, producing a real 3-way divergence — caught by __tests__/integration/skill-sync.integration.test.ts on the next full suite run, not by manual inspection. Both are fixed and verified in the commit history.

QA Follow-up: both flagged gaps fixed

The initial AC_MET_BUT_NOT_A_PLUS QA review named two non-blocking gaps. Both are fixed:

Gap 1 — AC-3's literal wording vs. the shipped two-function split. parseMutationMarkers(prBody) now has an overload: given a second diffTestFiles argument, it returns each marker with a classification field ("valid" or "test_not_in_diff") computed inline — the same function AC-3 names now does the rejecting itself, not a separately-named classifyMutationMarker. The one-argument form is unchanged (still parser-only, no git-diff dependency, existing tests untouched); classifyMutationMarker stays exported for callers that already have a diff-test-file list and want to classify a single marker (e.g. the backtest script). /qa §6i's "How to perform" step 2 now demonstrates the single-call form.

Gap 2 — isGateTestEvidence's false-positive surface. Added MANUAL_REVIEW_NEGATIVE_SIGNALS — a short list ("reviewed manually", "manual review", "human review", "manually verified", "manually confirmed") checked first and short-circuiting to false before the positive keyword match runs. QA's exact named scenario, "reviewed manually, fixture exists in the demo env", is now correctly classified false.

Mutation-verified: AC-7 (the negative-signal guard) — removed the MANUAL_REVIEW_NEGATIVE_SIGNALS short-circuit block from isGateTestEvidence; ac-parser.test.ts > isGateTestEvidence > should return false for a manual-review attestation that mentions a gate-test keyword and the sibling 'human review' test both failed (2/66); restored.

Full suite re-verified green after both fixes: 266 test files, 5466 passed (7 more than the initial pass — the new regression tests), build/lint/lint-skill-gates.ts/check-skill-sync.ts all clean.

Backtest (AC-5)

npx tsx scripts/qa/backtest-mutation-gate.ts --limit 20 — fetched the last 20 merged PRs, extracted each PR's ## Pre-PR AC Verification table, applied isGateTestEvidence to the Evidence column, checked for a SEQUANT_MUTATION marker.

Metric Value
PRs scanned 20
PRs with a Pre-PR AC Verification table 3
Total AC rows found 18
In-scope (gate-test) ACs 7
Missing (no marker) 7 (100%)

100% Missing is the expected finding — none of these PRs predate this feature. The honest finding worth flagging: only 3 of 20 merged PRs actually carry the ## Pre-PR AC Verification table format at all — most historical PRs use free-form summaries instead, so the backtest's population is smaller than "20 PRs" suggests. The authoring-burden signal is 7 gate-test ACs across 20 PRs — a light load, supporting the spec plan's recommendation to ship gate-test-only scope for v1 rather than widening to all declared-evidence ACs immediately.

Scope decision (issue's own "Human decisions required")

Shipped gate-tests-only scope (isGateTestEvidence), not all declared-test-Evidence ACs, per the spec plan's recommendation — confirmed reasonable by the backtest's low volume (7 ACs). Widening to all declared-evidence ACs is a follow-up if the authoring burden argument changes.

Test plan

  • npm run build — clean
  • npm run lint — clean
  • npm test — 266 test files, 5466 passed, 1 expected fail (pre-existing), 2 skipped
  • npx tsx scripts/lint-skill-gates.ts — zero violations
  • npx tsx scripts/check-skill-sync.ts — 44 synced, 0 diverged
  • Mutation-verified AC-1, AC-2, AC-4, AC-7 (see above)
  • Backtest run against real gh data (see above)
  • Both QA-flagged gaps fixed and regression-tested (see QA Follow-up above)

Pre-PR Confidence Check

  • Weakest part: isGateTestEvidence is still a static keyword list (now with a negative-signal override, not a semantic classifier) — it can still under-fire on gate-test phrasing that uses none of its trigger words, or in principle over-fire on unanticipated phrasings the negative-signal list doesn't cover. The QA-named false-positive scenario is now fixed and regression-tested; this is a residual, narrower version of the same class, not a new gap.
  • Coverage gaps: classifyMutationMarker's diff-test-file matching is a simple filename/suffix match (file === namedFile || file.endsWith('/'+namedFile)) — it doesn't validate that the named test file was actually modified in a way relevant to the claimed mutation, only that it exists in the diff's test-file list. Accepted: catching an outright-fabricated marker (a nonexistent file) is the feat(qa): mutation-verification becomes a parseable §7 gate instead of honor-system prose #939 scope; validating the semantic connection between mutation and test would need actually running the mutation, which is explicitly a Non-Goal in the issue ("no automated mutation-testing framework").

Closes #939

🤖 Generated with Claude Code

- parseMutationMarkers/classifyMutationMarker parse SEQUANT_MUTATION
  PR-body markers (flat-JSON idiom, mirrors SEQUANT_SPEC/SEQUANT_PHASE)
- isGateTestEvidence classifies which ACs are gate-test ACs per the
  CLAUDE.md definition
- /qa §6i wires mutation_verification_status into the §7 verdict
  algorithm: Missing caps AC_MET_BUT_NOT_A_PLUS, Failed floors AC_NOT_MET
- scripts/lint-skill-gates.ts reports zero I1-I4 violations against the
  wired skill (structural coverage, no code changes needed)
"floors the verdict at" didn't match the VERDICT_FLOOR_PHRASES list
("floor the verdict at"), so I1 silently never evaluated §6i.

Mutation-verified: AC-4 — deleted §7's mutation_verification_status
step-2 token and both step-4 branches (Failed, Missing); confirmed
`npx tsx scripts/lint-skill-gates.ts` reports an I1 violation naming
§6i, and mutation-verification-skill.test.ts's dedicated wiring
assertions fail (3 of 10 tests); restored both, suite green again.
…estore

The prior wording-fix commit only updated skills/ and templates/skills/
qa/SKILL.md — canonical .claude/skills/qa/SKILL.md still had the stale
"floors the verdict at" wording, because an earlier `git checkout --`
used to restore a dogfood mutation reverted the canonical copy to HEAD
before the wording fix was committed, silently discarding it there
while the already-synced mirrors kept the fix. Caught by
__tests__/integration/skill-sync.integration.test.ts.

npx tsx scripts/check-skill-sync.ts now reports 44 synced, 0 diverged.
- scripts/qa/backtest-mutation-gate.ts backtests the gate-test-AC
  population against merged PRs' Pre-PR AC Verification tables,
  modeled on scripts/spec/measure-corpus.ts's harvest() pattern
- CLAUDE.md's testing rule now names the Mutation-verified: /
  SEQUANT_MUTATION marker format as the required record form
- CHANGELOG [Unreleased] entry for the feature

Real run against the last 20 merged PRs (only 3 carry a Pre-PR AC
Verification table): 7 in-scope gate-test ACs, 100% Missing (expected
— none predate this feature). Sizes the authoring burden for the
scope-widening decision the issue leaves to a human.
…utation-verification-becomes-a-parsea

# Conflicts:
#	CHANGELOG.md
- isGateTestEvidence: add a manual-review negative-signal guard so
  evidence like "reviewed manually, fixture exists in the demo env"
  no longer false-positives as a gate-test AC just because it mentions
  a gate-test keyword. Named QA finding, now regression-tested.
- parseMutationMarkers: add an overload — given a second diffTestFiles
  argument, the same function now both parses AND rejects (attaches a
  "valid"/"test_not_in_diff" classification per marker), making it
  literally the rejecting entry point AC-3 describes, without losing
  the one-argument parser-only form's independence from a git-diff
  dependency. classifyMutationMarker stays exported for standalone use.
- Updated /qa §6i's "How to perform" step 2 to demonstrate the
  single-call form across all 3 skill mirrors; re-synced, lint-skill-
  gates.ts still reports zero violations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(qa): mutation-verification becomes a parseable §7 gate instead of honor-system prose

1 participant