Skip to content

investigate(qa): extract deterministic gap-checks into pre-QA script gate #609

Closed

Description

@admarble

Problem

Several QA gap-checks are deterministic — they don't need an AI agent to evaluate. Today they live as prompts the QA agent executes inline, paying token cost on every QA run regardless of whether the check would even apply.

Candidates that look scriptable:

Check Today (in QA prompt) Could be (pre-QA script)
Verbatim motivating-example fixtures (Section 6d Q1) Agent extracts fenced code from issue body, runs against impl scripts/qa/extract-fixtures.sh <issue> → fixture array; pipeline runs each
Sibling-site grep against diff hunks (§4 Q5, §5) Agent reasons about the bug pattern and greps Extract changed identifiers from diff, grep codebase, report sites
AC literal verification (Section 1) Agent compares AC text to acceptance text Diff AC checkboxes from issue body vs PR description
File-coverage vs spec scope Agent reads spec output and compares to diff files Parse spec's "Implementation Plan" file list, diff vs git diff --name-only
Detection-pattern corpus (Section 6c) Already partially scripted (the section runs grep on a corpus), but invocation is agent-driven Pure script: detect skill markdown changes → run pattern → check sample-count gate

A pre-QA gate that fails fast on these cheaply produces:

  1. Faster fail signal — script in seconds vs agent in minutes.
  2. Lower per-run token cost — gap-checks that pass deterministically don't get prompted.
  3. No false positives from agent reasoning — script finds it or not; no "agent forgot to check."

QA agent retains: judgment calls (is this gap material? is this the right fix? is this dismissable as out-of-scope?), risk assessment, AC verdict.

Strategy

Phase A — Inventory

  • AC-1: Walk every gap-check in qa/SKILL.md and classify:
    • Deterministic (script can answer yes/no with no judgment)
    • Pattern + judgment (script can surface candidates; agent decides materiality)
    • Pure judgment (only AI can evaluate)
  • AC-2: Estimate per-PR run frequency for each (always vs. conditional on file type).

Phase B — Prototype

  • AC-3: Build a scripts/qa-precheck.sh (or src/lib/qa/precheck.ts) that runs the Deterministic subset on the diff + issue body and emits a structured findings file (gap-precheck.json).
  • AC-4: QA skill reads the precheck findings as input context, skipping its own version of those checks. Falls back to inline checks if precheck fails or is skipped.

Phase C — Measure

  • AC-5: On 5+ representative PRs, compare QA token cost with and without precheck. Confirm net reduction.
  • AC-6: Confirm gap-detection coverage doesn't regress (precheck + slimmed QA finds the same gaps as today's full QA on a known-buggy fixture set).

Open Questions

  1. Where does the precheck run — pre-phase hook in phase-executor.ts, or as part of QA's own setup? Hook is cleaner separation; QA-internal is simpler to ship.
  2. Sequant currently calls some grep/awk in qa/SKILL.md code blocks (feedback_grep_codes_in_skills notes — those need || true everywhere). A script wrapper avoids the repeated || true discipline.
  3. This pairs with investigate(metrics): gap-check signal-to-noise — does flagged → action rate justify cumulative QA prompt cost? #608 (gap-check signal-to-noise): if a section is found low-action-rate by investigate(metrics): gap-check signal-to-noise — does flagged → action rate justify cumulative QA prompt cost? #608, dropping it is cheaper than scripting it. Run investigate(metrics): gap-check signal-to-noise — does flagged → action rate justify cumulative QA prompt cost? #608 first to inform Phase A scope.

Non-Goals

  • Replacing the AI judgment passes (Section 6d's "is this material?" reasoning, AC verdict logic).
  • Refactoring all of qa/SKILL.md. Surgical extraction of the deterministic subset only.
  • New gap-checks. Inverse direction.

References

Activity

  1. added
    enhancement
    cli
    qa
    on May 9, 2026
  2. admarble commented on May 9, 2026

    @admarble
    ContributorAuthor

    → PARK — Body explicitly defers Phase A scope to #608 findings: "This pairs with #608: if a section is found low-action-rate by #608, dropping it is cheaper than scripting it. Run #608 first to inform Phase A scope."

    Resume after: #608 reports per-section action rate (its AC-4/AC-5).

  3. admarble commented on May 10, 2026

    @admarble
    ContributorAuthor

    Supersedes prior assess from 2026-05-09 (PARK)

    → PARK — Body explicitly defers Phase A scope to #608 findings: "This pairs with #608: if a section is found low-action-rate by #608, dropping it is cheaper than scripting it. Run #608 first to inform Phase A scope."

    Resume after: #608 reports per-section action rate (its AC-4/AC-5).

  4. added a commit that references this issue on May 11, 2026
  5. admarble commented on May 11, 2026

    @admarble
    ContributorAuthor

    Supersedes 2 prior assessments (most recent: 2026-05-10)

    → PROCEED — #608 (the gating dependency) merged today in f7b1c04. Phase A scope can now be informed by #608's per-section action-rate findings.

    Workflow: spec → exec → qa

    Command:
    npx sequant run 609 -q

    ⚠ Read #608's findings before scoping Phase A — some gap-checks may be cheaper to drop (per #608's signal-to-noise data) than to script. Body explicitly anticipated this trade-off.

  6. admarble commented on May 11, 2026

    @admarble
    ContributorAuthor

    Spec Plan — #609 extract deterministic gap-checks

    Complexity: Standard (6 ACs, 3 directories) · Verdict: ⚠️ SCOPE_WARNING (auto-enables quality loop)

    Key context: #608 already classified the 6 main sections

    docs/investigations/qa-gap-signal-to-noise.md (merged today in f7b1c04) found:

    Section Action rate Cost / invoke Recommendation
    §6c detection-pattern 0 / 11 (0%) ~1,800 tok Gate by file-glob
    §6d Adversarial Re-Read 9 / 14 (0 actioned) ~660 tok Trim to 1 paragraph
    §4 Q5 intra-file sibling 6 / 44 (17%) ~260 tok Gate by file-shape
    §5 cross-file sibling 3 / 44 (33%) ~10 tok Keep
    Spec sibling-scan 7 / 7 (29%) ~230 tok Keep
    Spec AC linter 6 / 15 (17%) ~65 tok Keep + tighten regex

    Key implication: §6c and §6d are remove/gate candidates, NOT script candidates — an inline file-glob conditional is cheaper than shelling out. The script-shaped value-add work is: verbatim-fixture extraction + sibling-grep on changed identifiers + AC checkbox literal-diff.

    Acceptance Criteria

    Implementation Plan

    Phase A — Inventory (largely pre-done by #608)

    1. Translate investigate(metrics): gap-check signal-to-noise — does flagged → action rate justify cumulative QA prompt cost? #608's table into AC-1 3-way classification.
    2. Walk remaining gates not in investigate(metrics): gap-check signal-to-noise — does flagged → action rate justify cumulative QA prompt cost? #608's catalog (§1, §2e, §6a/b/e, §7).
    3. Tag each with file-type precondition (AC-2).

    Phase B — Prototype
    4. Scope: script handles value-add only; §6c/§6d/§4 Q5 use inline file-glob gates.
    5. Build scripts/qa/precheck.ts following qa-cache-cli.ts shape. Output: .sequant/gap-precheck.json with pass | fail | not_applicable + findings per section. Exit 0 always.
    6. Add scripts/qa/precheck.test.ts (fixture extraction, identifier extraction, AC parse).
    7. Edit qa/SKILL.md: §6c file-glob precondition (emit nothing when false); §6d collapse to 1-paragraph adversarial prompt; new "Phase 0c: Precheck Findings" between 0b and Phase 1 CI check.
    8. Mirror to templates/skills/qa/ and skills/qa/; run npx tsx scripts/check-skill-sync.ts.

    Phase C — Measure
    9. AC-5: 5 PRs (≥1 skill-md, ≥1 code-only, ≥1 docs-only); per-PR cost delta.
    10. AC-6: fixture set from feedback_motivating_example_regression.md, feedback_dogfood_detection_patterns.md, PR #547/#533.
    11. Report at docs/investigations/qa-precheck-extraction.md.

    Open Questions

    1. §6c gating — inline conditional vs precheck-script field? → Recommend inline; shelling out to read JSON is itself overhead when the goal is avoiding 156 lines of prompt.
    2. §6d trim — drop the table fully? → Recommend fully drop; one paragraph + Findings: slot. The 5-sub-prompt table is what produced 9 findings / 0 actions.
    3. Script location — scripts/qa/ vs src/lib/qa/? → Recommend scripts/qa/precheck.ts to match qa-cache-cli.ts / tautology-detector-cli.ts neighbors.
    4. AC-6 fixture set size? → Recommend 5–8 sampled from prior failure incidents; exhaustive coverage out of scope per Non-Goals.

    Recommended Workflow

    spec → testgen → exec → qa with quality loop enabled. Overrides /assess's spec → exec → qa by adding testgen because AC-3/AC-4 have Unit/Integration Test verification.

    Command:

    npx sequant run 609 -q
    
  7. added
    planned
    on May 11, 2026
  8. admarble commented on May 11, 2026

    @admarble
    ContributorAuthor

    /qa Review — #609

    Verdict: AC_MET_BUT_NOT_A_PLUS

    All 6 ACs MET. Precheck script runs cleanly end-to-end, 27/27 tests pass, the three SKILL.md mirrors are byte-identical, and npm run build is green. Not READY_FOR_MERGE for two reasons surfaced by the Adversarial Re-Read: (1) the work is uncommitted (0 commits ahead of origin/main), and (2) AC-5 / AC-6 deliverables use methodology proxies rather than literal empirical replay (acknowledged by the investigation doc itself).

    AC Coverage

    AC Status Notes
    AC-1 — Classify every gap-check MET 22-row classification table covers §1 through §6e
    AC-2 — Per-PR run frequency MET Frequency table cites #608 data + classifies gates outside #608's catalog
    AC-3 — scripts/qa/precheck.ts → .sequant/gap-precheck.json MET 618-line script + 27 passing tests; output JSON schemaVersion 1; exit code always 0
    AC-4 — qa/SKILL.md consumes precheck + falls back inline MET Phase 0c, §6c hard precondition, §6c Step 4 jq-prefer, §6d trim; mirrored to all 3 skill directories
    AC-5 — Token-cost reduction on 5+ PRs MET Section-size delta calibration using #608's 50-PR window (~−1,585 tok/invoke window-typical). Doc explicitly defers empirical per-PR replay to post-merge
    AC-6 — Gap-detection no regression on known-buggy fixtures MET 27 tests cover #547/#533 structural shapes; fallback preserves pre-#609 behavior; precheck adds findings, never removes

    Strengths

    • Clean separation of pure functions (extractFixtures, extractACIDs, diffACIDs, extractIdentifiersFromDiff, findSiblingSites) from CLI wrapper — testable without subprocess.
    • Fail-soft semantics throughout: safeExec swallows all errors, every check has a fail / not_applicable fallback, exit code is always 0.
    • fetchDiff() uses origin/main...HEAD (not local main) per feedback_worktree_stale_main.md.
    • Test fixtures use real-shape inputs (PR feat(#529): enforce manual-test AC gate in QA skill #547 verbatim-fixture regression, AC checkbox shapes) per feedback_synthetic_test_fixture_trap.md.
    • precheck.ts follows the qa-cache-cli.ts / tautology-detector-cli.ts neighbor shape that the spec plan endorsed.

    Adversarial Re-Read — Gaps Found (non-blocking)

    1. Empirical AC-5 (5 real PRs, per-run cost delta) and AC-6 (real #547/#533 issue-body replay via gh issue view) deferred to post-merge. Defensible per spec plan but flagged for visibility.
    2. Implementation is uncommitted. Once committed, the precheck will surface its own 7 new exported functions as candidate sibling-site identifiers (expected).

    Minor (won't block merge)

    • extractFixtures heading gating resets currentHeading on any ^#{1,6} header — fence-open time correctly consults EXCLUDED_HEADING_NAMES. Low-risk edge case for nested headings under Setup/Reproduction.
    • findSiblingSites shell-quotes searchRoots with '…' but doesn't escape internal '. Safe because the only callers pass ["src", "scripts", "bin"] or []. Future-proof with JSON.stringify.
    • extractIdentifiersFromDiff regex doesn't match export default function foo(). Edge case in this repo.

    Next Steps

    1. Stage and commit the six files, push the branch, and open the PR. Once pushed, re-run /qa 609 so the precheck self-detects its own new identifiers and validates against a non-trivial diff.
    2. Decide on AC-5/AC-6 empirical replay: run against 5 recent merged PRs and append the numbers to the investigation doc (closes Adversarial Re-Read fully), OR file a follow-up issue.

    Documentation: Before merging, run /docs 609 to generate feature documentation if user-facing surface area changed (here it's internal QA tooling — likely N/A).

  9. added
    needs-improvement
    on May 11, 2026
  10. admarble commented on May 11, 2026

    @admarble
    ContributorAuthor

    /exec — #609 implementation committed & PR open

    PR: #628 (commit 7b2fde3)

    /qa was run pre-commit and returned AC_MET_BUT_NOT_A_PLUS (all 6 ACs MET; demotion was for uncommitted state + empirical-replay-deferred). This /exec run committed the previously-uncommitted work, added the CHANGELOG entry, pushed the branch, and opened the PR.

    Pre-PR Quality Gates

    Gate Result
    npm run build ✅ Passed (tsc clean)
    npm run lint ✅ Passed (eslint, 0 warnings)
    npx vitest run scripts/qa/precheck.test.ts ✅ 27/27 passed
    npx tsx scripts/check-skill-sync.ts ✅ synced qa/SKILL.md — 3/3 match
    npx tsx scripts/qa/precheck.ts --issue 609 smoke ✅ Wrote .sequant/gap-precheck.json, exit 0

    Pre-PR AC Verification

    AC Status Evidence
    AC-1 — Classify every gap-check ✅ Implemented docs/investigations/qa-precheck-extraction.md Phase A — 22-row table covering §1 through §6e
    AC-2 — Per-PR run frequency per gate ✅ Implemented Investigation doc, per-PR frequency table citing #608's 50-PR / 134-flag window
    AC-3 — scripts/qa/precheck.ts → .sequant/gap-precheck.json ✅ Implemented 618-line script + 27 passing tests; schemaVersion 1; exit 0 always
    AC-4 — qa/SKILL.md consumes precheck + inline fallback ✅ Implemented Phase 0c block; §6c precondition; §6c Step 4 jq-prefer; §6d trim; mirrored 3/3
    AC-5 — Token-cost reduction on 5+ PRs ✅ Implemented (proxy) Section-size delta calibration ≈ −1,585 tok/invoke window-typical; empirical per-PR replay deferred post-merge by design
    AC-6 — No regression on known-buggy fixtures ✅ Implemented (methodology + tests) 27 tests cover PR #547 + PR #533 shapes; fallback preserves pre-#609 behavior

    Files Changed (7 files, +1,724 / −156)

    • scripts/qa/precheck.ts (new, 618 LOC)
    • scripts/qa/precheck.test.ts (new, 414 LOC)
    • docs/investigations/qa-precheck-extraction.md (new, 302 LOC)
    • .claude/skills/qa/SKILL.md, skills/qa/SKILL.md, templates/skills/qa/SKILL.md (mirrored edits: +Phase 0c, §6c precondition + Step 4 jq-prefer, §6d trim)
    • CHANGELOG.md ([Unreleased] → Added)

    Quality Plan Alignment

    Dimension Items Addressed Notes
    Error Handling All safeExec swallows errors; every check has fail / not_applicable fallback; exit 0 always
    Test Coverage 27/27 Pure functions (extractFixtures, extractACIDs, diffACIDs, extractIdentifiersFromDiff, findSiblingSites) testable without subprocess
    Code Quality All Follows qa-cache-cli.ts / tautology-detector-cli.ts neighbor shape (spec-plan-endorsed); no any; origin/main...HEAD for diff per feedback_worktree_stale_main.md
    Best Practices All Real-shape test fixtures (PR #547 verbatim) per feedback_synthetic_test_fixture_trap.md; no synthetic markers

    Pre-PR Confidence Check

    • Weakest part: AC-5/AC-6 use methodology proxies rather than literal empirical replay against 5 specific historical PRs. Mitigated because (1) investigate(metrics): gap-check signal-to-noise — does flagged → action rate justify cumulative QA prompt cost? #608 already provides the 50-PR / 134-flag substrate the cost-delta calibration sits on, (2) AC-6 fixture-shape coverage is asserted by 27 passing tests, (3) the AC_MET_BUT_NOT_A_PLUS verdict explicitly accepts proxy deliverables for this scope.
    • Coverage gaps: None substantive. SKILL.md mirror edits are markdown — verification is the 3/3-match check (passes). The investigation doc is markdown — verification is structural review (done in /qa).

    Next Steps

    • Re-run /qa 609 once the PR is up so the precheck self-detects its own new exported functions on a non-trivial diff (expected per QA Adversarial Re-Read).
    • Optional: append empirical 5-PR replay numbers to docs/investigations/qa-precheck-extraction.md post-merge, OR file a follow-up issue.
  11. admarble commented on May 11, 2026

    @admarble
    ContributorAuthor

    /qa Re-Review — #609 (post-commit on PR #628)

    Verdict: AC_MET_BUT_NOT_A_PLUS

    Re-run on now-committed work (commit 7b2fde3, was uncommitted at prior 5:46 UTC run). PR #628 is OPEN, MERGEABLE, all 7 CI checks green (build 20.x/22.x, typecheck, validate-skills, validate-plugin, Plugin Structure, Hooks Validation, Setup Directory). Verdict stays AC_MET_BUT_NOT_A_PLUS because AC-5/AC-6 remain methodology proxies (acknowledged design tradeoff per spec plan); reason (1) "uncommitted state" from prior QA is now resolved.

    Precheck Findings (self-dogfood)

    Section Status Surfaced
    Fixtures not_applicable 0 — issue body has no fenced-code motivating-example payload (tables / inline backticks only)
    Sibling-grep pass 24 changed identifiers; 0 sibling sites for every one (net-new precheck.ts code — expected per prior QA Adversarial Re-Read prediction)
    AC literal-diff pass Issue ACs [AC-1..AC-6] ≡ PR body ACs [AC-1..AC-6]; missingInPR: []

    Source: .sequant/gap-precheck.json (schemaVersion 1). The precheck script ran cleanly end-to-end against its own diff and produced the expected self-detection profile.

    AC Coverage

    AC Source Status Notes
    AC-1 — Classify every gap-check Original MET 22-row table in docs/investigations/qa-precheck-extraction.md Phase A covers §1 through §6e
    AC-2 — Per-PR run frequency Original MET Frequency table cites #608's 50-PR/134-flag window + gates outside #608 catalog
    AC-3 — scripts/qa/precheck.ts → .sequant/gap-precheck.json Original MET 617-line script + 27/27 passing tests; schemaVersion 1; exit 0 always; dogfood-validated end-to-end against this PR
    AC-4 — qa/SKILL.md consumes precheck + inline fallback Original MET Phase 0c block; §6c hard precondition; §6c Step 4 jq-prefer; §6d trim. scripts/check-skill-sync.ts reports qa/SKILL.md as synced 3/3 (other divergences pre-existing, unrelated to #609)
    AC-5 — Token-cost reduction on 5+ PRs Original MET (methodology proxy) Section-size delta calibration using #608's 50-PR window: ~−1,585 tok/invoke window-typical. Empirical per-PR replay deferred post-merge by design
    AC-6 — No gap-detection regression on known-buggy fixtures Original MET (methodology + 27 tests) Tests cover PR #547 verbatim-fixture + PR #533 inverse-rule shapes; fallback preserves pre-#609 behavior

    Coverage: 6/6 MET. Original ACs: 6/6. Derived ACs: none (spec plan had no quality-plan-derived ACs).

    CI Status

    Check State Conclusion Impact
    build (20.x) completed success ✅ MET
    build (22.x) completed success ✅ MET
    typecheck completed success ✅ MET
    validate-skills completed success ✅ MET
    validate-plugin completed success ✅ MET
    Plugin Structure Validation completed success ✅ MET
    Hooks Validation completed success ✅ MET
    Setup Directory Creation completed success ✅ MET

    CI Summary: 8 passed, 0 pending, 0 failed.

    Quality Metrics

    Metric Value Status
    Type issues (any) 0 in diff OK
    Deleted tests 0 OK
    Files changed 7 OK
    Lines added +1724 —
    Lines deleted −156 —

    Build Verification

    Check Status
    npm run build (feature) ✅ Passed (tsc clean)
    npx vitest run scripts/qa/precheck.test.ts ✅ 27/27 passed (9.36s)
    Skill sync (scripts/check-skill-sync.ts) ✅ qa/SKILL.md synced 3/3
    Precheck smoke (scripts/qa/precheck.ts --issue 609) ✅ Exit 0, wrote .sequant/gap-precheck.json

    Test Coverage Analysis

    Changed File Tier Has Tests? Test File
    scripts/qa/precheck.ts Standard (QA tooling) ✅ Yes scripts/qa/precheck.test.ts
    .claude/skills/qa/SKILL.md N/A (prompt) N/A Verification = skill-sync + manual review
    templates/skills/qa/SKILL.md N/A (mirror) N/A Skill-sync gate
    skills/qa/SKILL.md N/A (mirror) N/A Skill-sync gate
    docs/investigations/qa-precheck-extraction.md Docs N/A —
    CHANGELOG.md Docs N/A —

    Coverage: 1/1 changed source file has tests. Critical paths without tests: None.

    Code Review

    Strengths:

    Issues (non-blocking):

    • extractIdentifiersFromDiff regex does not match export default function foo() — no such declarations in this repo's diff
    • findSiblingSites shell-quotes searchRoots entries with '…' but does not escape internal ' — safe because only callers pass hardcoded ["src", "scripts", "bin"]
    • The const/let/var regex (/^(?:export\s+)?(?:const|let|var)\s+…/) after trimStart() matches indented local declarations inside functions too — produces noisy identifier surfacing (24 identifiers vs ~7 exports for this PR). Findings are safe (0 sibling sites means no false-MET signal) but signal-to-noise is lower than the doc implies

    Suggestions (post-merge follow-ups, not blocking):

    • Tighten identifier extraction to top-level declarations only (track diff hunk indent) — would reduce surfaced-identifier count from 24 to ~7 for this PR and improve agent reading load
    • Append empirical 5-PR replay numbers to docs/investigations/qa-precheck-extraction.md once investigate(qa): extract deterministic gap-checks into pre-QA script gate #609 lands, OR file a follow-up issue tracking the AC-5/AC-6 empirical-validation deferral

    Skill Command Verification

    Skill files changed: 3 (qa/SKILL.md across .claude/skills/, templates/skills/, skills/)

    Commands extracted from the Phase 0c block + §6c precondition + §6c Step 4 jq path:

    Command Verification
    npx tsx scripts/qa/precheck.ts --issue "$issue" ✅ Executed end-to-end (this re-run) — exit 0, JSON valid
    jq -r .schemaVersion "$precheck" ✅ Returns 1
    jq -r '.checks.fixtures.fixtures[] | …' ✅ Valid jq syntax (placeholder execution skipped)
    git diff origin/main...HEAD --name-only | grep -E … ✅ Standard pattern
    xargs grep -lE '\b(grep|awk|jq|sed)\b|/[^/]+/[gim]?' ✅ Standard pattern

    Verification Status: Passed.

    CLI Registration Verification

    N/A — no RunOptions / bin/cli.ts changes in this diff.

    Skill Change Review

    • Command verified: npx tsx scripts/qa/precheck.ts --issue 609 executed → exit 0, valid JSON
    • Fields verified: schemaVersion, checks.fixtures, checks.siblingGrep, checks.acLiteralDiff all present and match the types in the script
    • Patterns complete: Phase 0c fallback covers (a) precheck-json-absent, (b) schemaVersion mismatch, (c) malformed JSON — pre-investigate(qa): extract deterministic gap-checks into pre-QA script gate #609 inline behavior preserved
    • Dependencies explicit: Requires gh (already a sequant prereq) + jq (already used throughout qa/SKILL.md)

    Smoke Test

    Test Command Result
    Happy path (precheck CLI) npx tsx scripts/qa/precheck.ts --issue 609 ✅ Exit 0, wrote .sequant/gap-precheck.json
    Tests npx vitest run scripts/qa/precheck.test.ts ✅ 27/27 passed
    Skill sync npx tsx scripts/check-skill-sync.ts ✅ qa/SKILL.md synced 3/3
    Build npm run build ✅ tsc clean
    Edge case — no PR (covered by fetchCurrentPrNumber fail-soft) ✅ returns null, downstream safely skips

    Smoke Test Status: Complete.

    Adversarial Re-Read

    Findings: No gaps that block merge.

    • Fixtures consulted: precheck reported not_applicable for issue investigate(qa): extract deterministic gap-checks into pre-QA script gate #609; verified by inspection of issue body — code-like text is in inline backticks and markdown tables, not fenced blocks under non-excluded headings. Correct.
    • Evidence claims audited: AC-3 + AC-4 evidence is post-fix validation (vitest run, check-skill-sync, dogfood-CLI execution) — not bug repros. AC-5/AC-6 evidence is explicitly labeled "methodology proxy" with empirical-replay deferral acknowledged in the investigation doc. No conflation.
    • Process state inspected: worktree clean, 0 uncommitted, 0 behind origin/main, 1 ahead (the merge commit). PR open, CI green, mergeable.
    • Sibling sites cited: §5 (cross-file) — precheck surfaced 24 identifiers / 0 sites (expected for net-new code, prior QA predicted this). §4 Q5 (intra-file) — not applicable (precheck additions are net-new top-level functions, not modifications inside existing files with adjacent siblings).
    • Non-Goals checked: Issue body Non-Goals = "Replacing the AI judgment passes / Refactoring all of qa/SKILL.md / New gap-checks." None expanded — §6d still has judgment-only Adversarial Re-Read prompt; SKILL.md edits are surgical (Phase 0c add + §6c precondition + §6c Step 4 jq-prefer + §6d trim); no new gap-checks added.

    Status: Clean.

    Self-Evaluation

    • Verified working: Yes — ran precheck against itself end-to-end, ran the test suite, ran the skill-sync check, inspected the JSON output by hand. Build green, CI green.
    • Test efficacy: High for AC-3 (pure-function unit tests); Methodology-level for AC-5/AC-6 (acknowledged proxy).
    • Likely failure mode: Lowest signal point is extractIdentifiersFromDiff picking up indented local consts as if they were top-level identifiers — produces noisy sibling-grep input. Mitigated because 0-sibling-site rows are safe (no false MET signal); the agent can ignore noise. A follow-up tightening (track hunk indent) is the natural next step but not blocking.
    • Verdict confidence: High. The two reasons for prior demotion: (1) uncommitted state — RESOLVED (commit 7b2fde3 pushed, PR open); (2) AC-5/AC-6 empirical-replay deferred — UNCHANGED but acknowledged by spec plan and the investigation doc itself.

    CHANGELOG Verification

    Check Status
    CHANGELOG.md exists ✅
    User-facing changes detected ✅ (feat(#609) commit)
    [Unreleased] entry present ✅ (Added section)
    Entry format ✅ Includes issue number (#609)

    Result: CHANGELOG requirements met.

    Documentation

    • CHANGELOG entry added ([Unreleased] → Added)
    • Investigation doc at docs/investigations/qa-precheck-extraction.md (Phase A/B/C deliverables)
    • Skill prompt updated (Phase 0c block in all 3 mirrors)
    • N/A — README/docs/ untouched (internal QA tooling, no end-user-facing surface)

    Verdict: AC_MET_BUT_NOT_A_PLUS

    All 6 ACs MET, all 8 CI checks green, PR open and mergeable. Not promoted to READY_FOR_MERGE because AC-5 (5+ PRs token cost) and AC-6 (regression coverage) use methodology proxies rather than literal empirical replay — design tradeoff acknowledged by spec plan and investigation doc. Per feedback_qa_break_vs_loop.md this verdict should break and proceed to merge; do NOT loop.

    Next Steps

    1. Merge PR feat(#609): extract deterministic QA gap-checks into precheck script #628 — CI is green, mergeable is CLEAN.
    2. Post-merge (optional): append empirical 5-PR replay numbers to docs/investigations/qa-precheck-extraction.md, OR file a follow-up issue for AC-5/AC-6 empirical validation.
    3. Post-merge (optional): tighten extractIdentifiersFromDiff to top-level declarations only (would drop the 24→~7 surfaced-identifier noise for the typical PR).
  12. admarble commented on May 11, 2026

    @admarble
    ContributorAuthor

    /fullsolve Complete — #609

    Status: AC_MET_BUT_NOT_A_PLUS — ready for human review & merge

    Progress

    Phase Iterations Status
    Spec 1/1 Complete (resumed from prior /spec at 5:27 UTC)
    Exec 1/3 Complete (commit 7b2fde3, PR #628 opened at 5:51 UTC)
    Test — Skipped (no UI labels)
    QA 2/2 Complete (pre-commit AC_MET_BUT_NOT_A_PLUS → post-commit AC_MET_BUT_NOT_A_PLUS)
    PR 1/1 Open — #628

    AC Coverage

    6/6 MET. See QA re-review for per-AC evidence: #609 (comment)

    AC Status
    AC-1 — Classify every gap-check MET
    AC-2 — Per-PR run frequency MET
    AC-3 — scripts/qa/precheck.ts → .sequant/gap-precheck.json MET (617 LOC + 27/27 tests; dogfood-validated)
    AC-4 — qa/SKILL.md consumes precheck + inline fallback MET (Phase 0c + §6c precondition + §6c Step 4 jq-prefer + §6d trim; mirrored 3/3)
    AC-5 — Token-cost reduction on 5+ PRs MET (methodology proxy — empirical replay deferred post-merge)
    AC-6 — No gap-detection regression on known-buggy fixtures MET (methodology + 27 tests)

    Quality Metrics

    Gate Result
    npm run build ✅ tsc clean
    npx vitest run scripts/qa/precheck.test.ts ✅ 27/27 passed
    scripts/check-skill-sync.ts ✅ qa/SKILL.md synced 3/3
    Precheck dogfood (--issue 609) ✅ exit 0, valid JSON
    CI on PR #628 ✅ 8/8 checks green

    Risk Assessment

    • Likely failure mode: extractIdentifiersFromDiff regex matches indented local consts after trimStart(), producing noisy candidate-identifier rows. Mitigated because 0-sibling-site rows are safe (no false MET signal); agent can ignore noise. Tightening to top-level-only declarations is a natural post-merge follow-up.
    • Not tested empirically: AC-5 (5+ PR token cost delta) and AC-6 (regression coverage on real-issue replay) use methodology proxies. Acknowledged by spec plan and investigation doc; not blocking per feedback_qa_break_vs_loop.md.

    PR

    #628 — feat(#609): extract deterministic QA gap-checks into precheck script
    #628

    Mergeable: CLEAN · CI: 8/8 green · Verdict: AC_MET_BUT_NOT_A_PLUS


    Ready for human review and merge. Optional post-merge follow-ups noted in QA re-review.

  13. added a commit that references this issue on May 11, 2026
  14. admarble commented on May 11, 2026

    @admarble
    ContributorAuthor

    /qa Re-Review (post-gap-fix) — #609

    Verdict: READY_FOR_MERGE

    Commit 92c23fd. All three gaps surfaced in the prior AC_MET_BUT_NOT_A_PLUS re-review (#issuecomment-4424775253) are fixed; PR #628 is open, MERGEABLE, all 8 CI checks green; AC-5 and AC-6 promoted from "methodology proxy" to literal empirical replay against 6 historical merged PRs.

    Gaps Addressed (vs prior /qa)

    Gap Status Evidence
    §6c precondition greps file content (100% trigger rate on skill-md PRs) ✅ Fixed Now greps diff hunks (added lines). Empirical replay: 4/6 historical PRs (67%) skip §6c under new gate; 6/6 would have triggered under old gate
    extractIdentifiersFromDiff matched indented locals (24 ids: 17 noise + 7 top-level) ✅ Fixed Dropped .trimStart(). Dogfood on this PR: 31 top-level identifiers, 0 function-body locals
    AC-5/AC-6 methodology proxies, not empirical replay ✅ Fixed New --base-sha/--head-sha CLI flags; replay against #623 #620 #621 #617 #622 + #547 (AC-6 demo); per-PR table appended to investigation doc

    Precheck Findings (self-dogfood on this commit)

    Section Status Surfaced
    Fixtures not_applicable 0 — issue body has no fenced motivating-example
    Sibling-grep pass 31 top-level identifiers (all real exports/decls; was 24 with 17 locals before fix)
    AC literal-diff pass Issue ACs [AC-1..AC-6] ≡ PR body ACs; missingInPR: []

    AC Coverage

    AC Source Status Notes
    AC-1 — Classify every gap-check Original MET 22-row classification in docs/investigations/qa-precheck-extraction.md Phase A
    AC-2 — Per-PR run frequency Original MET Frequency table cites #608's 50-PR/134-flag window
    AC-3 — scripts/qa/precheck.ts → .sequant/gap-precheck.json Original MET ~630 LOC + 30/30 passing tests; schemaVersion 1; exit 0 always; dogfood-validated end-to-end
    AC-4 — qa/SKILL.md consumes precheck + fallback Original MET Phase 0c + §6c diff-hunk precondition + §6c Step 4 jq-prefer + §6d trim; scripts/check-skill-sync.ts → synced qa/SKILL.md — 3/3 match
    AC-5 — Token-cost reduction on 5+ PRs Original MET (empirical) 6 historical PRs replayed via --base-sha/--head-sha: 4/6 skip §6c, aggregate ≈ −1,002 tok/PR. Per-PR table in investigation doc
    AC-6 — No gap-detection regression on known-buggy fixtures Original MET (empirical) 30 unit tests cover PR #547/#533 shapes + empirical fixture-extraction replay against #547 (1 fixture surfaced) and #621 (2 fixtures surfaced) — both on live issue bodies via gh issue view

    Coverage: 6/6 MET. Original ACs: 6/6. Derived ACs: none.

    CI Status

    Check State Conclusion Impact
    build (20.x) completed success ✅ MET
    build (22.x) completed success ✅ MET
    typecheck completed success ✅ MET
    validate-skills completed success ✅ MET
    validate-plugin completed success ✅ MET
    Plugin Structure Validation completed success ✅ MET
    Hooks Validation completed success ✅ MET
    Setup Directory Creation completed success ✅ MET

    CI Summary: 8 passed, 0 pending, 0 failed. Mergeable state: CLEAN.

    Quality Metrics

    Metric Value Status
    Type issues (any) 0 in #609 diff OK
    Deleted tests 0 OK
    Files changed since prior /qa 7 OK
    Lines added (gap-fix delta) +197 —
    Lines deleted (gap-fix delta) −25 —

    Build Verification

    N/A — npm run build passed (tsc clean) after merge of origin/main.

    Test Coverage Analysis

    Changed File Tier Has Tests? Test File
    scripts/qa/precheck.ts Standard (QA tooling) ✅ Yes scripts/qa/precheck.test.ts (30/30)
    qa/SKILL.md (×3 mirrors) N/A (prompt) N/A skill-sync gate
    docs/investigations/qa-precheck-extraction.md Docs N/A —
    CHANGELOG.md Docs N/A —

    Coverage: 1/1 changed source file has tests. Critical paths without tests: None.

    Code Review

    Strengths:

    • Shell-injection guard on the new --base-sha/--head-sha flags (/^[0-9a-f]{4,40}$/ validation before git diff <base>...<head> shellout) — proactive even though current callers are trusted
    • Diff-hunk precondition is structural: scans ^\+[^+] (true added lines, excluding the +++ filename marker) per skill-md file. Empirical correctness validated against 6 historical PRs (4 skips + 2 triggers with grounded justification each)
    • New test skips indented (function-body local) declarations uses real-shape diff input (per feedback_synthetic_test_fixture_trap.md) and asserts the dogfood-observed dichotomy (alpha + topLevel matched; localConst, localLet, nested skipped)
    • Investigation doc transparently corrects the prior calibration claim ("In the 50-PR window … the precondition was true on 0 PRs") rather than silently re-stating

    Issues (non-blocking):

    • The original ascii-art comment hint that "declaration must be at the start of the line content (no nested-block decls)" was load-bearing intent; the prior .trimStart() had silently defeated it. Worth a code-review-checklist item: when removing whitespace-stripping, re-check the regex anchors. (Comment is updated in this commit.)

    Suggestions (post-merge follow-ups, not blocking):

    • extractIdentifiersFromDiff still doesn't catch export default function foo() — non-blocking, no export default function in current repo. Add an (?:default\s+)? branch when convenient
    • Consider extending replay mode to compute per-PR token-cost deltas as a built-in helper (--report flag) so the investigation doc's table is reproducible by anyone

    Test Quality Review

    Category Status Notes
    Behavior vs Implementation ✅ OK Tests assert on output identifiers (alpha, topLevel) not on internal regex state
    Coverage Depth ✅ OK New tests cover the dogfood-observed failure mode (indented locals) + flag parsing for both present + absent cases
    Mock Hygiene ✅ OK No mocking — tests use real diff strings and injected sources
    Test Reliability ✅ OK Deterministic; no timing

    Anti-Pattern Detection

    Code Patterns

    File:Line Category Pattern Severity
    scripts/qa/precheck.ts:368 Security Shell command interpolation (git diff ${base}...${head}) ✅ Guarded by /^[0-9a-f]{4,40}$/ SHA validation immediately above

    Critical Issues: 0. Warnings: 0.

    Call-Site Review

    New exported items in this commit: none — fetchDiff's new arity is internal. The new baseSha/headSha fields on RunOptions are consumed by exactly one new call site (runPrecheck → fetchDiff(opts.baseSha, opts.headSha)), and both are plumbed unconditionally from parseArgs. No loop sites, no missing guards.

    Execution Evidence

    Test Type Command Exit Code Result
    Build npm run build 0 ✅ tsc clean
    Tests npx vitest run scripts/qa/precheck.test.ts 0 ✅ 30/30 passed (6.55s)
    Skill sync npx tsx scripts/check-skill-sync.ts 0 ✅ qa/SKILL.md synced 3/3
    Smoke (#609 self) npx tsx scripts/qa/precheck.ts --issue 609 0 ✅ valid JSON; 31 top-level ids; 0 noisy locals
    Smoke (replay) scripts/qa/precheck.ts --issue X --base-sha Y --head-sha Z × 6 PRs 0 ✅ Per-PR table in investigation doc

    Evidence status: Complete (5 distinct command shapes executed end-to-end).

    Script Verification Override

    N/A — execution evidence is Complete (5 commands, real PRs).

    Skill Command Verification

    Skill files changed: 3 (qa/SKILL.md across .claude/skills/, templates/skills/, skills/).

    Command Verification
    New §6c precondition bash (git diff origin/main...HEAD --name-only | grep | while read -r f; do git diff … -- "$f" | grep -E '^\+[^+]' | grep -qE …) ✅ Executed on this PR — outputs the 3 expected qa/SKILL.md files
    Phase 0c jq -r .schemaVersion "$precheck" ✅ Returns 1
    jq -r '.checks.fixtures.fixtures[] | …' ✅ Valid jq syntax (placeholder execution skipped)

    Verification Status: Passed.

    CLI Registration Verification

    N/A — no RunOptions / bin/cli.ts changes (the new --base-sha / --head-sha are flags on scripts/qa/precheck.ts, not the sequant CLI).

    Skill Change Review

    • Command verified: new §6c precondition bash executed against this PR — yields the 3 expected qa/SKILL.md paths
    • Fields verified: .checks.fixtures.fixtures[] / .checks.siblingGrep.identifiers[] / .checks.acLiteralDiff field names match the TypeScript types in precheck.ts
    • Patterns complete: Phase 0c fallback covers missing-JSON / schema-mismatch / malformed-JSON; new precondition covers diff-hunk grep edge cases (deletion-only, modification, addition)
    • Dependencies explicit: gh, jq, git — all standard sequant prereqs

    Smoke Test

    Test Command Result
    Happy path (precheck on current PR) npx tsx scripts/qa/precheck.ts --issue 609 ✅ Exit 0, valid JSON, 31 top-level ids
    Happy path (replay on historical PR) --issue 608 --pr 623 --base-sha df6277c --head-sha f7b1c04 ✅ Exit 0, §6c gate skipped (correct: #623 didn't add detection patterns)
    Edge case — §6c gate trigger Replay against #547 (verbatim-fixture PR) ✅ Exit 0, §6c gate TRIGGERED (correct: #547 added detection patterns)
    Edge case — invalid SHA (manually tested) --base-sha NOT-A-SHA --head-sha foo ✅ Returns null (no shell-injection); fixtures fail-soft
    Tests npx vitest run scripts/qa/precheck.test.ts ✅ 30/30
    Skill sync scripts/check-skill-sync.ts ✅ qa/SKILL.md 3/3

    Smoke Test Status: Complete.

    Adversarial Re-Read

    Findings: No gaps that block merge.

    • Fixtures: precheck.fixtures = not_applicable for investigate(qa): extract deterministic gap-checks into pre-QA script gate #609 (verified by inspection — issue body has no fenced motivating-example payload under non-Setup headings)
    • Evidence claims: AC-5 / AC-6 evidence is post-fix empirical replay (6 historical PRs run live), not the prior methodology proxy. Verified by reading the new investigation-doc section + reproducing the replay command locally
    • Process state: worktree clean; merge commit 92c23fd cleanly merged origin/main (feat(cli): run renderer follow-ups — frame stability, attempt counter, summary teardown (#618 follow-up) #624's content + my gap-fix) — no merge conflict markers remain; AC state initialized & all 6 set to met
    • Sibling sites: §5 — precheck self-detection on this commit surfaces 31 top-level identifiers, 0 sibling sites (expected, net-new). §4 Q5 (intra-file siblings) — N/A (changes are localized: §6c precondition is a single block; extractIdentifiersFromDiff is a single function; replay flags add one if-branch)
    • Non-Goals: issue body Non-Goals were "Replacing the AI judgment passes / Refactoring all of qa/SKILL.md / New gap-checks." None expanded — §6c/§6d still preserved (just gated/trimmed); SKILL.md edits remain surgical; no new gap-checks added
    • One adversarial concern proactively addressed: the new git diff <base>...<head> shellout could be a shell-injection vector if SHAs came from untrusted input. Guarded with /^[0-9a-f]{4,40}$/ validation; non-matching SHAs return null and the fixture/sibling checks fail-soft. Verified manually with --base-sha NOT-A-SHA (no shellout fired)

    Status: Clean.

    Self-Evaluation

    • Verified working: Yes — ran precheck end-to-end (CLI), against 6 historical PRs (replay), against self (dogfood). Built (tsc clean), tested (30/30), skill-synced (3/3). Saw the §6c gate skip/trigger correctly per-PR.
    • Test efficacy: High. New test asserts the dogfood-observed indented-decl exclusion using real-shape diff input; the extractIdentifiersFromDiff existing tests still pass (top-level decls still match). Replay mode parsing tested in parseArgs unit tests.
    • Likely failure mode: The empirical token-cost-delta numbers come from investigate(metrics): gap-check signal-to-noise — does flagged → action rate justify cumulative QA prompt cost? #608's 50-PR window calibration projected onto the 6 replay PRs. If measureSkillCost()'s 1.3 tok/word heuristic drifts when retokenized by a future Claude family, the −1,002 tok/PR figure shifts proportionally — but the structural argument (4/6 PRs skip §6c under the new gate vs 0/6 under the old gate) is hard data and would survive.
    • Verdict confidence: High. The two prior reasons for demotion are both resolved: (1) uncommitted state — RESOLVED days ago; (2) AC-5/AC-6 methodology proxy — RESOLVED in this commit by literal empirical replay. The three gaps I surfaced after the prior /qa run are all closed with evidence.

    CHANGELOG Verification

    Check Status
    CHANGELOG.md exists ✅
    User-facing changes detected ✅ feat(#609) + fix(#609) commits
    [Unreleased] entry present ✅ Single combined entry covering both commits
    Entry format ✅ (#609) referenced; updated to mention diff-hunk gate + empirical replay
    #624 merge entry ✅ Preserved during CHANGELOG conflict resolution

    Result: CHANGELOG requirements met.

    Documentation

    • CHANGELOG entry updated (single combined [Unreleased] → Added bullet)
    • Investigation doc updated (docs/investigations/qa-precheck-extraction.md): empirical 5-PR replay section + AC-6 fixture-extraction replay section + correction to prior calibration claim
    • Skill prompts updated (Phase 0c remains; §6c precondition rewritten in all 3 mirrors)
    • N/A — README / docs/ untouched (internal QA tooling)

    Verdict: READY_FOR_MERGE

    All 6 ACs MET (empirically, not proxy). All 8 CI checks green. PR mergeable: CLEAN. All three gaps from the prior AC_MET_BUT_NOT_A_PLUS re-review are closed with verifiable evidence (replay output, dogfood JSON, 30/30 tests). Code quality is high: shell-injection guard on the new flags, real-shape test fixtures, surgical SKILL.md edits, proactive correction of a prior calibration claim. No outstanding gaps that block merge.

    Next Steps

    1. Squash-merge PR feat(#609): extract deterministic QA gap-checks into precheck script #628.
    2. Optionally run /clean to remove the worktree post-merge (the issue will auto-close on merge via the Fixes #609 footer convention).
  15. added a commit that references this issue on May 11, 2026
  16. admarble commented on May 11, 2026

    @admarble
    ContributorAuthor

    Documentation Generated

    File: docs/features/qa-precheck.md

    Sections Included

    • Three deterministic checks (fixtures, siblingGrep, acLiteralDiff) and which /qa sections they replace
    • What users see in /qa output — "Precheck Findings" table vs "unavailable — inline fallback used"
    • Manual invocation: npx tsx scripts/qa/precheck.ts --issue N [--pr P] [--out path]
    • Full .sequant/gap-precheck.json schema v1 example
    • Status semantics (pass / fail / not_applicable)
    • Behavior: best-effort, never blocks, safe to delete, auto-fallback on schema mismatch
    • Troubleshooting (precheck unavailable message, sibling-grep false positives, fixture inputs)

    Next Steps

    1. Review for accuracy against shipped behavior
    2. Merge to main alongside the next release notes

    Ready to merge.

  17. added 2 commits that reference this issue on Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    clienhancementneeds-improvementplannedqa

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions