Skip to content

feat(#938): explicit Evidence: clause on ACs — declared verification replaces keyword inference - #945

Merged
admarble merged 3 commits into
mainfrom
feature/938-feat-spec-qa-explicit-evidence-clause-on-acs-d
Aug 13, 2026
Merged

admarble merged 3 commits into
mainfrom
feature/938-feat-spec-qa-explicit-evidence-clause-on-acs-d

Conversation

@admarble

@admarble admarble commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Adds an optional, single-line Evidence: clause to Acceptance Criteria (- [ ] **AC-1:** ... Evidence: \npm test -- foo`). parseACLinesplits it into a newAcceptanceCriterion.evidencefield;resolveVerificationMethoduses declared evidence in place of keyword inference (backtick unit-test command →unit_test, other backtick command → integration_test, prose → manual), falling back to the existing inferVerificationMethodonly when no clause is present. Legacy issues (noEvidence:` clause) parse identically to before.
  • /spec's testgen recommendation counts declared-evidence ACs before inferred ones (all three skill mirrors).
  • /qa gains §6h "Declared-Evidence Execution": for any AC with a declared runnable command, QA must execute it (or verify a captured run) before marking that AC MET. Wired into the §7 verdict algorithm (declared_evidence_status), required in both Simple Fix and Standard QA modes, scripts/lint-skill-gates.ts passes clean.
  • ac-linter gains a warning-only rule flagging a test-type AC with no named evidence as incomplete.

Pre-PR AC Verification

AC Description Status Evidence
AC-1 parseACLine extracts trailing Evidence: clause; legacy ACs parse with zero diff ✅ Implemented src/lib/ac-parser.ts (splitEvidenceClause); src/lib/ac-parser.test.ts — legacy-corpus zero-diff tests use verbatim single-line ACs from #853 (AC-1) and #842 (AC-6), not synthetic fixtures
AC-2 Declared evidence overrides keyword inference; conflicts resolve to the declaration ✅ Implemented resolveVerificationMethod in src/lib/ac-parser.ts; test asserts prose "e2e" + Evidence naming a unit-test command → unit_test wins, plus a second conflict fixture (inferVerificationMethod("...requires...") → browser_test via the "ui" substring, a live false-positive discovered while planning this issue)
AC-3 /spec testgen recommendation counts declared-evidence ACs before inferred ✅ Implemented spec/SKILL.md Testgen Phase Auto-Detection section, synced across .claude/skills, skills, templates/skills; scoped gate test in src/lib/__tests__/evidence-clause-skill.test.ts, mutation-verified (see below)
AC-4 /qa §6h requires the declared command executed/verified before an evidence-bearing AC is MET ✅ Implemented Skill-section gate test scoped to §6h, mutation-verified (5 mutations, see below). Live dogfood closed for real: filed #946 and #947 as genuine follow-up issues, each authored with a real Evidence:-bearing AC (not a synthetic demo). Extracted #946's AC-1 via extractAcceptanceCriteria, confirmed the evidence field populated correctly, then executed the literal declared command npm test -- ac-parser — 56/56 passed, exit 0 — before crediting the AC.
AC-5 ac-linter flags test-type ACs with no named evidence as incomplete, warning-only ✅ Implemented detectMissingEvidence in src/lib/ac-linter.ts; positive (unit/integration/browser) and negative (evidence present, manual-type) tests in src/lib/ac-linter.test.ts
AC-6 Measurement: extended linter run over the last 50 issues, hit/FP counts recorded ✅ Implemented See Measurement section below

Coverage: 6/6 fully met.

Post-QA gap fixes

The first QA pass on this PR found 4 gaps (see the QA comment on #938 for the original review). All addressed:

  1. AC-4's live-dogfood requirement — closed for real, see AC-4 row above. Filing fix(ac-parser): inferVerificationMethod matches keywords as substrings, not word boundaries #946/fix(ac-parser): fenced code-block AC examples get parsed as real ACs, silently shadowing the real one #947 rather than fabricating a demo issue avoids the synthetic-fixture anti-pattern this repo's own testing rules warn against.
  2. inferVerificationMethod substring-match bug ("ui" matching inside "requires", etc.) — filed as fix(ac-parser): inferVerificationMethod matches keywords as substrings, not word boundaries #946 rather than fixed here (broader change than this PR's scope).
  3. Fenced code-block AC-shadowing bug (found live in feat(spec/qa): explicit Evidence: clause on ACs — declared verification replaces keyword inference #938's own issue body during /spec planning) — filed as fix(ac-parser): fenced code-block AC examples get parsed as real ACs, silently shadowing the real one #947.
  4. splitEvidenceClause split-on-first-occurrence bug — AC prose can legitimately contain the word "Evidence:" before the real trailing clause (e.g. "cites strong Evidence: peer review... Evidence: npm test -- foo"); the first match would swallow the real clause. Fixed in this PR: now splits on the LAST occurrence. 2 regression tests added; all 51 pre-existing parser tests still pass unchanged.
  5. state-schema.ts's createAcceptanceCriterion evidence parameter had only transitive test coverage — added 3 direct unit tests.

Measurement (AC-6)

Command:

gh issue list --repo sequant-io/sequant --limit 50 --state all --json number,body

Then extractAcceptanceCriteria + lintAcceptanceCriteria (this PR's code) over each issue body, counting ACs flagged incomplete with problem.includes("verification not named").

Metric Count
Issues scanned 50
Total ACs parsed 220
ACs flagged (hits) 30 (13.6%)
Flagged ACs attributable to the pre-existing ui/display keyword substring-match bug in inferVerificationMethod (not a genuine test-type signal) 17
Flagged ACs with a genuine test-type classification 13

False-positive framing: 17 of the 30 hits (57%) trace to inferVerificationMethod's .includes() substring match on "ui"/"display" (e.g. matching inside "quick", "requires", "guidance") rather than the AC actually needing a browser test — a defect class independent of this PR, filed as a follow-up rather than fixed here (word-boundary matching is a broader change to inferVerificationMethod than the Evidence-clause feature). This means the new rule's precision is currently gated by that pre-existing bug: fixing the substring-match issue would roughly halve today's hit rate on this corpus. Recorded here so the later escalate-to-gate decision (see issue body's "Human decisions required") has real numbers rather than a guess.

Mutation verification

src/lib/__tests__/evidence-clause-skill.test.ts (AC-3, AC-4 skill wiring) — 5 mutations run, each restored via git checkout after confirming precise targeting:

  1. Deleted the §6h section text → exactly 1 test failed (the section-presence test), 8/9 others passed.
  2. Deleted the §7 step 2/step 4 wiring lines → exactly 2 tests failed (the two wiring tests), 7/9 passed.
  3. Deleted the Simple-Fix-required and Standard-required checklist lines → exactly 2 tests failed, 7/9 passed.
  4. Deleted the Declared-Evidence Execution table from both output templates → exactly 1 test failed, 8/9 passed.
  5. Reverted spec/SKILL.md's testgen detection-logic wording to the pre-feat(spec/qa): explicit Evidence: clause on ACs — declared verification replaces keyword inference #938 text → exactly 2 tests failed (the two AC-3 wording tests), 7/9 passed.

ac-parser.test.ts / ac-linter.test.ts (AC-1, AC-2, AC-5) rely on the standard positive/negative test structure (unit_test resolves only when a matching command is declared; manual never flags for missing evidence) rather than a separate mutation pass, since the runtime logic is directly exercised by 50+ assertions across both files.

Test plan

  • npm run build — passes
  • npm run lint — passes
  • npx vitest run --project unit — 203 files, 4567 tests passed (4570 after the post-QA fixup commit; 2 pre-existing unrelated failures in src/commands/doctor.test.ts confirmed identical on this branch's base commit, untouched since a May PR — out of scope)
  • npx tsx scripts/lint-skill-gates.ts — no violations (declared_evidence_status wired end-to-end)
  • npm run lint:skill-sync — all 44 files synced across the three skill mirrors
  • Live /qa dogfood run on a declared-evidence AC — see AC-4 row above

Closes #938
Related: #946, #947 (follow-ups filed from this PR's own QA review)

🤖 Generated with Claude Code

- ac-parser: parse trailing `Evidence:` clause into AcceptanceCriterion.evidence;
  resolveVerificationMethod prefers declared evidence over keyword inference
  (backtick unit-test command -> unit_test, other backtick command ->
  integration_test, prose -> manual), falling back to inferVerificationMethod
  when no evidence is declared (AC-1, AC-2)
- ac-linter: flag test-type ACs with no named evidence as incomplete,
  warning-only (AC-5)
- spec/SKILL.md: testgen recommendation counts declared-evidence ACs before
  inferred ones (AC-3)
- qa/SKILL.md: new §6g Declared-Evidence Execution — requires the declared
  command be executed/verified before an evidence-bearing AC is MET, wired
  into the §7 verdict algorithm and required in both QA modes (AC-4)
- scoped gate tests for AC-3/AC-4 skill wiring; skill mirrors synced via
  npm run sync:skills
…ision, fix regressions

- lint-skill-gates.test.ts hardcodes "§6g" as a synthetic placeholder id in
  its "catches a NEWLY ADDED section with no wiring" self-test; renaming the
  real Declared-Evidence Execution section to §6h avoids the id collision
  that made the self-test's injected unwired section read as already wired
- testgen-skill.test.ts asserted the pre-#938 literal detection-logic
  strings verbatim; updated to the new declared-evidence-first wording
- ac-parser.test.ts's verbatim #842 AC-6 fixture contains the literal text
  `describe.skipIf(!distExists)` as quoted subject matter, tripping
  dist-skip-guard.test.ts's source-text scanner; split across a string
  concatenation so the runtime string is unaffected but the source no
  longer contains a contiguous match
- CHANGELOG entry for the Evidence: clause feature, including the AC-6
  measurement result (30/220 ACs flagged over the last 50 issues, 17 of
  which trace to the pre-existing ui/display substring inference bug)

Full unit project: 203 files, 4567 tests passed. Build and lint clean.
…hema test, follow-up issues filed

- ac-parser: splitEvidenceClause now splits on the LAST `Evidence:`
  occurrence instead of the first. AC prose can legitimately contain the
  word "Evidence:" before the real trailing clause (e.g. "cites strong
  Evidence: peer review... Evidence: `npm test -- foo`"); splitting on the
  first match corrupted extraction. Single-occurrence behavior unchanged
  (51 existing parser tests still pass), 2 new regression tests added.
- ac-parser.test.ts: added direct unit tests for
  createAcceptanceCriterion's evidence parameter (state-schema.ts),
  previously exercised only transitively through parser tests.
- Filed #946 (inferVerificationMethod substring-match bug, e.g. "ui"
  matching inside "requires") and #947 (fenced code-block AC examples
  silently shadowing the real AC via first-occurrence dedupe — this
  happened live to #938's own issue body). Both issues use the new
  Evidence: syntax on their own ACs.
- Closed AC-4's live-dogfood requirement for real: extracted #946's
  actual declared-evidence AC-1 via extractAcceptanceCriteria, confirmed
  evidence field populated correctly, and executed the literal declared
  command (`npm test -- ac-parser`) — 56/56 passed. A genuine dogfood run
  on a real issue with a real declared-evidence AC, not a synthetic demo.

Build, lint, and all evidence-related test files (131 tests) pass.
src/commands/doctor.test.ts has 2 pre-existing failures unrelated to this
change (confirmed identical on this branch's base commit and untouched
since a May PR) — not fixed here as out of scope.
@admarble
admarble merged commit bcbeefe into main Aug 13, 2026
8 checks passed
@admarble
admarble deleted the feature/938-feat-spec-qa-explicit-evidence-clause-on-acs-d branch August 13, 2026 06:47
admarble added a commit that referenced this pull request Aug 13, 2026
Move the Evidence: clause entry (#938/#945) from the already-tagged
[2.11.0] section into [Unreleased] — that feature landed in a commit
after the v2.11.0 tag, so the published release never actually
shipped it. Also document three 2.11.0 features that had no
user-facing docs: the Evidence: clause syntax itself, the
checkout-scoped lock and its pre-tool.sh HOOK_BLOCKED guard, and
sequant worktree resolve/verify.

Entire-Checkpoint: cd8d0213a8f9
admarble added a commit that referenced this pull request Aug 17, 2026
…s, not word boundaries (#946) (#950)

* fix(ac-parser): inferVerificationMethod matches keywords as substrings, not word boundaries (#946)

VERIFICATION_KEYWORDS and the sibling GATE_TEST_KEYWORDS (isGateTestEvidence)
matched single-word keywords via `.includes()`, so "ui" matched inside
"requires", "quick", "guidance", "building"; "display" had the same class of
false positive. Both now use \b-anchored regexes; multi-word phrases
("unit test", "skill gate", "mutation-verified") are unchanged since they
were already effectively self-anchoring. Gate-test keywords likely to appear
inflected in evidence prose (fixture, section, flag, present) tolerate an
optional trailing "s" so anchoring doesn't lose plural/verb forms.

Re-ran the #938/PR #945 missing-evidence measurement over the same 50-issue
corpus: 30 -> 15 flagged ACs, all 15 eliminated hits confirmed as
browser_test false positives from the substring bug, zero new hits.

Fixes #946

* test(ac-parser): close two coverage gaps found in QA review of #946

- Export keywordMatcher (@internal, testing only) and add direct unit
  tests for it: metacharacter escaping ("a+b" keyword — proves the
  literal isn't misinterpreted as a regex quantifier) and allowPlural
  on/off behavior.
- Add a regression-pinning test locking down which GATE_TEST_* keywords
  are plural-tolerant (fixture/section/flag/present) vs not
  (wired/exists/registered), so a future accidental list-swap fails a
  test instead of silently changing match behavior.

Test-only diff — no production logic changed.
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(spec/qa): explicit Evidence: clause on ACs — declared verification replaces keyword inference

1 participant