Skip to content

fix(#834): §7 gates must be reachable — lint /qa's own enforcement chain (§2h has been unwired since it shipped) - #841

Merged
admarble merged 9 commits into
mainfrom
feature/834-fix-qa-7-gates-must-be-reachable-lint-the-skil
Jul 29, 2026
Merged

admarble merged 9 commits into
mainfrom
feature/834-fix-qa-7-gates-must-be-reachable-lint-the-skil

Conversation

@admarble

@admarble admarble commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

§2h declared **CRITICAL:** If CLI registration verification = **Failed**, verdict CANNOT be READY_FOR_MERGE plus a Maximum Verdict gating table. §7's algorithm never evaluated it — no cli_registration_status in step 2, no branch in step 4. The gate had been prose-only since the day it shipped.

  • Wire §2h (AC-3): cli_registration_status = status from Section 2h in §7 step 2, an ELSE IF cli_registration_status == "Failed" → AC_NOT_MET branch in step 4, and §2h's prose pointing at that branch the way §6f's does.
  • scripts/lint-skill-gates.ts (AC-1) — lint:skill-gates, wired as its own CI step after Lint skill calls. Asserts I1–I4 over the skill's own enforcement chain.
  • Extend §7's Manual Test AC Enforcement to evidence-naming ACs (AC-6): corpus check, against several real …, N samples, sampled → PENDING → NEEDS_VERIFICATION when the named artifact is absent. Reuses the existing path; no new verdict branch.

⚠️ Behavior change: a verdict that would previously have reached READY_FOR_MERGE despite a failed CLI-registration check is now AC_NOT_MET. That is the intent.

The invariants

# Invariant Catches
I1 A section declaring a verdict floor has a §7 step-2 token attributed back to it and a step-4 branch on that token §2h, #819 F1
I2 Every step-2 token names a section that exists orphan gates
I3 Every (REQUIRED section that declares an output section is in the Standard checklist and in either the Simple Fix checklist or its explicit omitted list #819 F2
I4 Output-template sections and checklist entries agree in both directions, per mode #819 F1's missing template section

I1 asks §7, not the section. It looks a token up by the section it is attributed to in step 2, never by name-shape. A [a-z_]+_status heuristic would have false-positived on §6a, whose real token is skill_verification. Rejected alternatives: deriving token names from section titles (fuzzy, needs an allowlist); a separate gate-registry file (a second source of truth that drifts).

Every parser fails loud. A region that is present but yields no entries is a PARSE violation, never "no findings" — a silently-empty parser would make this lint the same tautology it exists to stop.

What the lint found on main

I1 flagged §2h as predicted. It also found five gaps I had not:

Inv Finding Fix
I3 §6e Behavior-Rule Survival Check (REQUIRED …) in neither Simple Fix list, and no template section added to both mode checklists + both templates
I3 §10a CHANGELOG Quality Gate (REQUIRED) absent from both Simple Fix lists added to the Simple Fix required list + template
I4 Standard template renders Precheck Findings and CLI Registration Verification; the Standard checklist demanded neither 2 checklist entries
I4 Standard checklist demanded CHANGELOG Verification; the Standard template had no such section added to the template

§6e and §10a went on the Simple Fix required list rather than the omitted list. Both routes satisfy I3, but a #533-class stale-rule survival and a one-line user-facing fix are both plausibly sub-threshold diffs, so omitting them would have recreated #819 F2 — a real gate switched off exactly below the size where the defect is most likely.

Why a lint and not better review

#819's §6f shipped with this same defect in freshly-written code. A human second pass caught it (#830); the automated /qa pass over the same commit reported all six ACs met and missed it. Of that second pass's five findings, the only one automation also caught was the missing CHANGELOG entry — the one finding that was already a wired §7 gate. This is Layer 2 of #22's four validation layers, of which #823's post-mortem records that only Layer 1 ever shipped.

Test plan

  • npm run lint:skill-gates — 19 files scanned, 18 skipped (no verdict algorithm), 0 violations (AC-4, AC-5)
  • 31 unit tests, each invariant with a passing and a failing fixture (AC-2)
  • Full suite: 168 files, 3841 passed, 1 expected fail, 2 skipped
  • npm run build, npm run lint, lint:skill-calls, lint:skill-sync (44/44 synced) — all clean (AC-7)
  • Tautology detector: 0 blocks ("All tests call production code")

Fixtures are the real file. Every invariant's passing fixture is the shipped qa/SKILL.md; its failing fixture is that same content with one specific piece of wiring deleted — the historical defect restored. Nothing is synthesized, so a fixture cannot drift into agreeing with a bug the real file no longer has, and each pair doubles as a live gate.

Mutation verification (recorded per the convention #835 adopts)

Mutation Result
Delete §7 step-4's cli_registration_status branch 6 failed / 23 passed — I1 pass-test, AC-3 wiring test, project scan, and both mutate() target assertions
Delete §2h's prose pointer sentence only exactly 1 failed — the prose test. §6f's identically-shaped sentence untouched
Strip the 4 evidence terms from the grep line exactly 2 failed — both AC-6 pattern-match tests
Strip the 4 evidence terms from the awk line only exactly 1 failed — the behavioral awk test
Remove the awk match block outright exactly 1 failed — the fail-loud test, reporting only the AC-ID attribution half
Delete the CLI Registration Verification Standard checklist entry 4 failed; the lint itself reports the I4 violation with an actionable message

Two findings came out of that mutation pass, not review — both fixed here:

  1. The tautology detector flagged 9/34 blocks (26.5%): the AC-6 tests compiled §7's pattern with a test-local extractor, so nothing validated the extraction and no block called production code. Fixed by moving it to parseEvidenceAcPattern() in the script, which lintSkillContent now uses as a fail-loud check.
  2. Stripping the terms from the awk half alone left all 29 tests green while AC-ID attribution silently stopped working — detection would find the line and then report no AC for it. A half-wired feature with a green suite is exactly the failure mode this issue exists to eliminate. Fixed with parseEvidenceAcIdPattern(); the lint now requires both halves to compile and names which one failed.

Corpus check (AC-6's named evidence — actually run)

AC-6's own wording names its evidence, so reasoning "unchanged by construction" would have repeated #819 AC-4's mistake verbatim. Corpus: 220 real AC-declaration lines from the bodies and comments of 18 recent issues (#761–#822, #533, #552, #683).

Risk assessment

  • Likely failure mode: the lint reads /qa's own prose, so a large reformat of §7 or the Output Verification region could change a parse shape. Mitigated by the fail-loud rule — an unreadable-but-present region is a violation naming the parser to fix, not a silent pass. The failure mode is a noisy build, not a blind gate.
  • Not tested: that a Failed CLI-registration status actually produces AC_NOT_MET at runtime — that is LLM prompt behavior, not code. The lint gates the wiring's presence; the verdict is the model following §7. Same limitation as every other §7 gate.
  • The one judgment call: I4's 4-entry SECTION_ALIASES map, where checklist labels and template headers legitimately differ in wording (Code Review Findings / Code Review). Each entry is justified inline. If it grows past a handful the right fix is renaming the headers, not growing the map.
  • Sibling sites considered: /qa is the only skill with a verdict algorithm (verified by grep across all 19 SKILL.md files); the other 18 are reported as skipped. Extending to other skills' output contracts is explicitly out of scope per the issue.

AC coverage

AC Status Evidence
AC-1 ✅ scripts/lint-skill-gates.ts; exits 1 naming section + missing wiring (see M6 output above)
AC-2 ✅ Each of I1–I4 has passing + failing fixtures, mutation-derived from the real file
AC-3 ✅ §7 step 2 + step 4 + §2h prose pointer; gate-tested and mutation-verified
AC-4 ⚠️ PENDING Passes against main with zero suppressions locally; the "own CI step" half needs this PR's CI run
AC-5 ✅ 18/19 skills skipped without erroring, 0 violations
AC-6 ✅ Patterns extended; #819 AC-4 fixture + 220-line corpus check, 0 false positives
AC-7 ✅ 44/44 synced; lint:skill-calls + lint:skill-sync clean
AC-8 (derived) ✅ Mutation results recorded above

AC-4 is PENDING, not MET — deliberately, since it names CI as its evidence and I cannot produce that artifact locally. Expect NEEDS_VERIFICATION until the CI run is green.

Closes #834

🤖 Generated with Claude Code


Update — QA gaps closed

The QA pass left three gaps open. All three are now fixed, and both behavioral ones were measured against a corpus of 18 real issues (#533–#822) rather than reasoned about.

1. Attribution scope — QA's own framing was too generous

QA called trailing-prose misattribution "fail-safe, acceptable." Measuring it said otherwise: of the 9 attributions the old awk produced across the corpus, 5 were wrong.

Issue Old attribution Actual referent
#683 AC-8 a coverage-table row about AC-7
#749 AC-4 an implementation-plan step
#763 AC-10 QA-finding prose
#795 AC-2 QA verdict prose
#819 AC-6 ×3 prose + rows about AC-4

Crediting a PENDING to the wrong AC is not fail-safe — it points the reader at the wrong requirement. A non-AC heading now clears the current AC. Verified: all 4 true positives survive (including #819's AC-4, the motivating case, and #795's two real Manual Test markers) and all 5 false positives disappear.

2. IGNORECASE is gawk-only

BEGIN{IGNORECASE=1} is a gawk extension and a silent no-op on macOS's awk, so matching was case-sensitive there. Manual test and Corpus check both occur in the corpus and were being missed — the same silent-routing class as the original bug. Replaced with POSIX-portable tolower($0) ~ /…/; all awk literals are now lowercase.

3. /verify execution evidence

Recorded on the issue rather than claiming a §11a override (a new script isn't an approved override category). Both paths exercised — a lint that only ever prints "no violations" proves nothing:

Run Exit Result
Clean tree 0 19 scanned, 18 skipped, no violations
§2h unwired 1 names §2h at file:line + the exact step-2 token and step-4 branch to add

Both new properties are gated, not merely fixed

Neither would fail loudly on its own, so each got a lint check:

  • parseAcScopeResetClause() — removing the scope-reset clause is now a build failure.
  • findUppercaseInAwkPattern() — an uppercase literal matched against tolower($0) can never fire, so reintroducing Manual Test is a build failure rather than a dead term.

Mutation-verified: each produces its own named violation. 37 tests (was 33).

Merge + suite status

origin/main (#837) merged in; one CHANGELOG.md [Unreleased] conflict, resolved keeping both entries.

Full suite on the merged branch: 213/213 files, 4428 passed, exit 0.

Two earlier full-suite runs showed 3–6 intermittent failures, always in subprocess- or lock-heavy files (precheck CLI, semgrep, tui/load, lock-manager, scrollback-harness, tautology-detector-cli), never the same set twice, and all passing in isolation (78/78). None touch anything this PR changes. This PR's test file is 55ms of in-memory string parsing with no subprocesses or timers, so it is not a plausible contention source; the flakiness looks pre-existing and load-dependent. Flagging it rather than burying it — CI is the arbiter.

admarble added 6 commits July 28, 2026 01:37
§2h declared `verdict CANNOT be READY_FOR_MERGE` plus a Maximum Verdict
table, but §7's algorithm never evaluated it: no `cli_registration_status`
in step 2, no branch in step 4. The gate had been prose-only since the day
it shipped, and the #305 bug class it exists to catch is invisible to
TypeScript, build, and unit tests.

- Wire §2h: `cli_registration_status` in §7 step 2, an
  `ELSE IF ... == "Failed" → AC_NOT_MET` branch in step 4, and §2h's prose
  pointing at that branch the way §6f's does. Behavior change: a verdict
  that would previously have reached READY_FOR_MERGE despite a failed
  CLI-registration check is now AC_NOT_MET.
- Add `scripts/lint-skill-gates.ts` (+ `lint:skill-gates`, CI step) asserting
  I1 declared floors are reachable from §7 · I2 no orphan gates ·
  I3 every `(REQUIRED` section has an explicit place in both mode checklists ·
  I4 checklists and templates agree both directions. I1 asks §7 which section
  a token is attributed to rather than deriving names from titles — a
  `[a-z_]+_status` heuristic would false-positive on §6a's
  `skill_verification`. Every parser fails loud: a present-but-unparseable
  region is a violation, never "no findings".
- Fix the five further gaps the lint found on main: §6e and §10a were
  `(REQUIRED` with Simple Fix mode silent about them (added to the required
  list, not the omitted one — both defect classes are plausibly sub-threshold
  diffs, so omitting would recreate #819 F2); the Standard checklist never
  demanded the Precheck Findings or CLI Registration Verification sections its
  template renders, and demanded a CHANGELOG Verification section the template
  had no place for.
- Extend §7's Manual Test AC Enforcement to evidence-naming ACs (corpus check,
  against several real …, N samples, sampled) → PENDING → NEEDS_VERIFICATION
  when the artifact is absent. #819's AC-4 named a corpus check and was marked
  MET on "unchanged by construction"; when the check was finally run it
  surfaced a real false-positive surface.

Gate tests use the real shipped qa/SKILL.md as the passing fixture and that
same content minus one specific piece of wiring as the failing fixture, so
fixtures are mutation-derived from the actual §2h / #819 F1 / #819 F2 defects
rather than synthesized.

Layer 2 of #22's four validation layers (only Layer 1 ever shipped, per
#823's post-mortem). Refs #305, #819, #830, #608, #515.

Fixes #834
…e test

The tautology detector flagged 9 of 34 blocks (26.5%) in the new test file:
the AC-6 tests compiled §7's evidence-naming detection pattern with a
test-local extractor, so nothing validated the extraction itself and no block
called production code. That is a real finding, not a detector artifact.

- Export `parseEvidenceAcPattern()` from lint-skill-gates.ts as the single
  owner of that parse, scoped to the `manual_test_acs=` assignment.
- Use it in `lintSkillContent`: when §7 declares step-3a manual-test
  enforcement but the pattern will not compile, emit a PARSE violation.
  Deleting the shipped pattern is now a build failure rather than a silent
  downgrade — the same prose-only condition I1 catches, one level down.
- Tests call the parser inline per block and assert with toMatch, which also
  stops `RegExp.prototype.test(...)` reading as a test declaration.

Tautology detector: 9 blocks (26.5%) → 0 ("All tests call production code").
29 tests pass.
Found by mutation testing, not review. §7 detects evidence-naming ACs with a
`grep -iE` pattern, then attributes matches to AC IDs with a second `awk`
pattern carrying the same terms. The AC-6 tests extracted only the grep line,
so stripping the four terms from `awk` alone left all 29 tests green while
AC-ID attribution silently stopped working — a half-wired feature with a green
suite, which is the failure mode this issue exists to eliminate.

Adds an assertion scoped to the `manual_ac_ids=` block so the grep line cannot
satisfy it. Mutation-verified: stripping the awk terms fails exactly this test
(1 failed | 29 passed) and stripping the grep terms still fails only the two
pattern-match tests.
Follow-up to the previous commit's awk gate, which asserted literal text and
so tested the pattern's spelling rather than its behavior.

- Add `parseEvidenceAcIdPattern()`, symmetric with `parseEvidenceAcPattern()`,
  compiling the `awk` program's AC-ID attribution pattern.
- `lintSkillContent` now requires BOTH halves to compile and names which one
  failed. Previously only the grep half was checked, so the awk half could be
  removed outright with the lint still green — the same failsafe-off hole one
  level down.
- The awk gate now asserts behavior (#819's AC-4 matches, a control does not)
  instead of literal term presence.

Mutation-verified: stripping the terms from awk alone fails exactly the
behavioral awk test (1 failed | 30 passed); removing the awk match block
outright fails exactly the fail-loud test and reports only the AC-ID
attribution half. 31 tests pass; tautology detector reports 0 blocks.
…was silent

Found by running §7's actual shell pipeline against this issue's own spec
comment during QA: `grep` matched the evidence-naming line, then `awk`
attributed it to NO AC. AC-6 requires evidence-naming ACs to "route to
PENDING"; routing needs an AC ID, so the recognition half worked and the
routing half could not fire.

Cause: the awk anchor was `/^(#+ AC-[0-9]+|\*\*AC-[0-9]+)/` — heading forms
only. Measured across a corpus of 18 recent issues (#533–#822):

  - [ ] **AC-N**   102     #+ AC-N     70
  - [ ] AC-N        32     **AC-N      24

The checkbox forms it missed (134) outnumber the heading forms it matched (94),
so attribution was silent for ~59% of real AC declarations while detection kept
reporting matches. Same class as the #547 awk-anchor bugs §6c documents, and
exactly the failure mode #834 exists to eliminate: a half-wired gate that
reports success.

- Anchor now also matches `- [ ] AC-N` and `- [ ] **AC-N**`.
- `parseAcHeaderPattern()` exposes the anchor so it is gate-tested against all
  five real declaration forms, plus two negatives (prose, indented non-AC
  checklist item) so a loosened anchor cannot misattribute every later match.

End-to-end verified on the real #819 spec-comment AC-4 line
("…corpus check on several recent real issue bodies"): attributes to AC-4 after
the fix, to nothing before it. Mutation-verified: reverting the anchor to the
heading-only form fails exactly this one test (1 failed | 31 passed).

Known residual, fail-safe: the nearest-preceding-declaration heuristic
attributes trailing prose to the last AC seen, so an implementation note
mentioning "corpus check" after the AC list can produce a spurious PENDING.
That errs toward NEEDS_VERIFICATION, never toward a false READY_FOR_MERGE, and
the imprecision is pre-existing to the manual-test terms. Left unchanged —
tightening it would alter pre-existing detection semantics beyond this issue.
…effect gap

Two QA follow-ups on the previous commit.

1. `parseAcHeaderPattern` was exported and behaviorally tested but never wired
   into the fail-loud check, so removing the anchor outright (as opposed to
   weakening it) still left the lint green. It is now the third checked pattern
   alongside detection and AC-ID attribution, with its own regression test.
   Verified: gutting the anchor yields
   "its AC-declaration anchor half has no compilable pattern".

2. A comment on the RegExp-compile fallback claimed an uncompilable ERE was
   "worth surfacing, not something to swallow into a silent null" while the code
   returned null — describing the intent, not the effect, and inviting a future
   reader to conclude the error was dropped. Reworded to state the actual
   mechanism: lintSkillContent converts null from any of these parsers into a
   PARSE violation, which is what makes it fail the build. Claim #1 above is
   what makes the reworded comment true for all three parsers.

33 tests pass; build, eslint, lint:skill-gates, lint:skill-sync (44/44),
tautology detector all clean.
admarble added 3 commits July 28, 2026 10:40
Closes the two gaps QA left open. Both were measured against a corpus of 18
real issues (#533–#822) rather than reasoned about.

Gap 1 — attribution scope. QA documented trailing-prose misattribution as an
acceptable fail-safe. Measuring it showed that was too generous: of 9
attributions the old program produced across the corpus, 5 were WRONG —
including a `| AC-7 | … |` coverage row credited to AC-8 and a `| AC-4 | … |`
row credited to AC-6. Misattributing a PENDING to the wrong AC is not
fail-safe; it points the reader at the wrong requirement. A non-AC heading now
clears the current AC. Verified: all 4 true positives survive (including
#819's AC-4, the motivating case, and #795's two real Manual Test markers) and
all 5 false positives disappear.

Gap 2 — `BEGIN{IGNORECASE=1}` is a gawk extension and a silent no-op on macOS's
awk, so matching was case-sensitive there. `Manual test` and `Corpus check`
both occur in the corpus and were being missed. Replaced with
`tolower($0) ~ /…/`, which is POSIX-portable; all awk literals are now
lowercase.

Both properties are gated, not just fixed:
- `parseAcScopeResetClause()` — the lint fails if the scope-reset clause is
  removed, since its absence is otherwise silent.
- `findUppercaseInAwkPattern()` — an uppercase literal in a pattern matched
  against `tolower($0)` can never fire, so reintroducing `Manual Test` is now
  a build failure rather than a dead term.

Mutation-verified: removing the scope-reset clause and reintroducing an
uppercase literal each produce their own named violation. 37 tests pass; full
suite 168 files / 3847 passed; tautology detector clean.
…gates-must-be-reachable-lint-the-skil

# Conflicts:
#	CHANGELOG.md
…missed it

Asking "what would make this A+" turned up the answer the issue itself
predicted: "this is a structural seam, not a one-off."

I1's phrase list started as the three strings named in the issue, plus a fourth
added on noticing §6e's wording. That was hand-picking — the exact mistake §6c
exists to prevent and the one #547 made three times — and it was never run
against its own corpus. Enumerating every line in qa/SKILL.md that pairs a
constraining verb with a verdict constant found §11 Script/CLI Execution
Verification saying "Do NOT give `READY_FOR_MERGE` verdict until verification is
complete" with no §7 gate. A second §2h, in the same file, shipped straight past
the lint built to catch §2h.

- Phrase list is now DERIVED from that enumeration, with the method recorded so
  the next edit re-runs it instead of guessing.
- §11 wired: `script_verification_status` in §7 step 2, an
  `ELSE IF … == "Not Verified" → AC_MET_BUT_NOT_A_PLUS` branch in step 4,
  explicit status outcomes, and prose pointing at the branch. BEHAVIOR CHANGE:
  `scripts/` changes with no /verify evidence and no approved §11a override can
  no longer reach READY_FOR_MERGE.
- I1 now recognises the second legitimate wiring mechanism. §1 constrains the
  verdict with no gate token because its outcome is an AC status, which §7
  step 1 counts — step 3a blesses this explicitly. Flagging §1 would have been a
  false positive (AC-5). It qualifies only by NAMING `pending_count`; an
  unstated mechanism is indistinguishable from none.
- I2 rejects a gate attributed to a duplicated section number. qa/SKILL.md has
  two `### 1.` sections, so "status from Section 1" would have no single answer.
  Fires only when a token actually points at one, so no renumbering is forced.
- Forward-looking test: the lint's value is stopping the NEXT §2h, and every
  prior I1 test mutated existing wiring. Now simulates a contributor adding
  §6g in each of the four shipped declaration styles.
- CONTRIBUTING.md documents both wiring mechanisms; `check-skill-sync` was
  documented and this was not.

Mutation-verified: narrowing the phrase list back to the original four fails
the forward-looking and AC-routing tests (2 failed | 37 passed); pointing an
existing gate at the duplicated §1 produces the I2 violation.

39 tests; full suite 213 files / 4430 passed; build, eslint, all four skill
lints, tautology detector clean.
@admarble
admarble merged commit 0abdc95 into main Jul 29, 2026
8 checks passed
@admarble
admarble deleted the feature/834-fix-qa-7-gates-must-be-reachable-lint-the-skil branch July 29, 2026 01:41
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.

fix(qa): §7 gates must be reachable — lint the skill's own enforcement chain (§2h has been unwired since it shipped)

1 participant