Skip to content

feat(qa): enforce the follow-up ledger — every deferred item resolves to filed/fixed/dropped; sibling scans search the defect class #1249

Closed

Description

@admarble

Tier: judgment Found: 2026-09-30 re-patch retrospective (tracker #1236, closed): the 41 fix commits since v2.15.0 plus their issue/PR decision trails.

Problem. Root causes are found, then dropped. Across 40 fix issues, an upstream cause or sibling site was raised in 39. Of the 80 raised items, 23 were fixed, 20 filed, 13 deferred with a reason, and 22 dropped: raised by spec, QA or the PR, then never filed or fixed. The dropped ones kept coming back:

The data is already machine-readable: QA's SEQUANT_QA_GAPS findings carry recommendedAction: "document" (GapActionSchema, src/lib/workflow/run-log-schema.ts:182). Nothing makes anyone resolve those, and nothing carries them to the PR.

Two related QA scan gaps from the same audit:

Prior fixes / producers

AC

  • AC-1: QA's verdict section requires every item an earlier phase deferred to end in one of three states: filed #N, fixed in this PR or dropped: <reason>. That covers spec's out-of-scope and follow-up notes, exec's PR-body follow-ups, and QA's own recommendedAction: "document" findings. An unresolved item keeps the verdict below READY_FOR_MERGE. Evidence: a gate test in src/lib/__tests__/qa-followup-ledger-skill.test.ts, scoped to the new QA section in all three copies and mutation-verified
  • AC-2: buildAutomatedPRBody renders a ## Follow-ups checklist from the run's document findings, each line carrying its resolution. It has no effect until the orchestrator is the only PR producer, so this AC is blocked by fix(run): sequant run has two PR producers — exec opens the PR itself and createPR returns it untouched, dropping the QA note, ready-gate report and summary #1247. Evidence: npx vitest run src/lib/workflow/worktree-manager.build-pr-body.test.ts
  • AC-3: The sibling-site scan asks for the defect class, not the symbol being changed. Examples: "every git call in the file without -C <target>", "every writer to a project path". The scan names the class it searched. Evidence: a gate test in src/lib/__tests__/qa-sibling-scan-skill.test.ts, scoped to the Sibling-site Scan section and mutation-verified
  • AC-4: QA may not mark end-to-end delivery "not tested" when it is the AC's promise (for example "surfaces in the PR body"). It must run the path or return NEEDS_VERIFICATION. Evidence: the AC-3 gate test file asserts the rule in the Risk Assessment section, mutation-verified
  • AC-5: The QA skill doesn't grow: the net line count of .claude/skills/qa/SKILL.md is ≤ its count before this change (3,837 at filing). New rules replace or tighten existing text. Evidence: wc -l .claude/skills/qa/SKILL.md against the base branch, and npm run lint:skill-sync

Non-Goals

  • QA filing issues on its own. The gate records a decision; the runner or owner files.
  • Changing SEQUANT_QA_GAPS's schema.

Graph metadata

May touch

  • .claude/skills/qa/SKILL.md, skills/qa/SKILL.md, templates/skills/qa/SKILL.md
  • src/lib/workflow/worktree-manager.ts, src/lib/workflow/worktree-manager.build-pr-body.test.ts
  • src/lib/__tests__/qa-followup-ledger-skill.test.ts, src/lib/__tests__/qa-sibling-scan-skill.test.ts (new)

Activity

  1. added
    enhancement
    on Sep 30, 2026
  2. admarble commented on Oct 3, 2026

    @admarble
    ContributorAuthor

    Runner context (2026-10-03, main @ a14229f)

    Repo state changed since filing. Read this before spec.

    #1247 is merged and shipped in v2.19.0, so AC-2 is unblocked. The orchestrator is now the only PR producer under sequant run. openOrUpdatePR (src/lib/workflow/batch-executor.ts:1119) runs after each successful exec pass and again after QA (:2499). After QA, createPR takes the update path. buildAutomatedPRBody is at src/lib/workflow/worktree-manager.ts:2022. It already takes {qaVerdict, readyGateReport} through createPR (:2118).

    Data flow for AC-2. The QA document findings live in phaseResults[].summary.findings:

    • PhaseResult.summary?: QaSummary (types.ts:429).
    • findings is parsed from SEQUANT_QA_GAPS at phase-executor.ts:711.
    • openOrUpdatePR's after arg doesn't carry them yet.

    Thread them through after → createPR → buildAutomatedPRBody, the same way readyGateReport goes. Use the latest QA pass, not .find(). batch-executor.ts:2379 and :2498 both use .find(), which returns the first QA verdict. That bug is #1245, which runs after this issue in the same region. Don't fix #1245 here, but don't add a third first-match reader either. Read the last QA entry, or add one small accessor #1245 can reuse.

    Prior fixes / producers (checked with git log -S and grep):

    • Sibling-site Scan (.claude/skills/qa/SKILL.md:1908) has had one prior change, feat(qa): add sibling-site scan prompt to first-pass /qa verdict checklist #573. The Risk Assessment "Not tested" line has had one, fix: simplify adversarial self-evaluation to 2-field risk assessment #513. Neither is a class yet, so a local change is fine.
    • The scan has a second producer. scripts/qa/precheck.ts siblingGrep (:242) greps changed identifiers deterministically, and §5 consumes its output. AC-3's "defect class, not the symbol" rule has to say how the two relate: the precheck stays a symbol-level hint, and the class search is the agent's job. If you find AC-3 needs precheck.ts changed, stop and surface it. Don't widen silently.
    • The follow-up drop has a producer inside the QA skill itself. :1912 says "Don't widen scope mid-PR; file a follow-up issue instead." That's the sentence that produces unfiled follow-ups. AC-1's rule should replace or tighten it. Don't add a parallel rule beside it.
    • Risk Assessment appears in three templates (:1898, :3403, :3743), and each has a Not tested: line. AC-4's gate test has to cover the copy (or copies) the rule actually governs. Scope it to the delimited region.

    Launch constraints:

    • AC-5 is a hard cap. .claude/skills/qa/SKILL.md is 3,837 lines on main, and net growth must be ≤ 0. Make the cut in the same files (tighten prose). Don't move text into a new references/ file to dodge the count unless you say so explicitly in the PR.
    • Edit all three copies (.claude/skills, skills, templates/skills) and run npm run lint:skill-sync.
    • Don't run the full npm test in exec or QA. It hits the 30-minute phase wall, and CI runs it. Run the targeted test files, npm run build, npm run lint:skill-sync, and npx tsc --noEmit.
    • Commit WIP every ~10 minutes.
    • Mutation markers: failedTest must start with the test file path, e.g. src/lib/__tests__/qa-followup-ledger-skill.test.ts > <describe> > <case>, or §6i floors AC_NOT_MET.
    • PR body: the closing line references this issue only. Any other issue gets Refs, never a closing keyword, even in examples.
    • Read JSON(C) config with a JSONC-safe parser.
  3. admarble commented on Oct 3, 2026

    @admarble
    ContributorAuthor

    Complexity: Standard (5 ACs, 5 directories)

    AC Quality Check

    The parser finds all 5 ACs, each with Evidence:, and the linter flags none. Each Evidence: was run against origin/main (a14229f):

    • AC-1, AC-3, AC-4: the two test files don't exist yet, so these fail today. ✅
    • ⚠️ AC-2: worktree-manager.build-pr-body.test.ts already passes on main, so this evidence proves nothing on its own. The PR must add a buildAutomatedPRBody — follow-ups (#1249) describe block, and QA should check that block is in the diff.
    • AC-5: wc -l is a cap (3,837), not a change, so it passes today by design. ✅

    Scope Assessment

    Non-Goals: QA doesn't file issues itself, and the SEQUANT_QA_GAPS schema doesn't change.

    Metric Value Status
    Feature count 3 (ledger gate, PR follow-ups, scan rules) ⚠️
    AC items 5 ✅
    Directory spread 5 ⚠️

    Verdict: ⚠️ SCOPE_WARNING. The three QA skill copies are one logical file, so the real spread is the skill plus src/lib/workflow. Keep it as one PR. AC-2 was blocked by #1247, which is now merged.


    Acceptance Criteria

    AC-1: Follow-up ledger gate

    Verification: Unit Test (a skill gate test, mutation-verified)
    Scenario: Given a deferred item from spec, exec's PR body or a QA document finding → When QA writes its verdict → Then every item ends in filed #N, fixed in this PR or dropped: <reason>, and any unresolved item caps the verdict at AC_MET_BUT_NOT_A_PLUS.
    Assumptions: The ledger becomes a §7 verification gate (followup_ledger_status: Resolved/Unresolved/N/A) with a slot in both output templates (Simple Fix and Standard).

    AC-2: ## Follow-ups in the PR body

    Verification: Unit Test
    Scenario: Given the latest QA pass has document findings → When buildAutomatedPRBody runs → Then it renders a ## Follow-ups checklist with one line per finding and that finding's resolution. A run with no findings renders no section.
    Assumptions: The resolution comes from the finding's description, with no schema change (see Open Q1).

    AC-3: Sibling scan searches the defect class

    Verification: Unit Test (a gate test scoped to #### Sibling-site Scan, mutation-verified)
    Scenario: Given a localized fix → When QA runs §5 → Then it states the class it searched (e.g. "every git call without -C <target>") in Sibling sites considered:.

    AC-4: End-to-end delivery can't be "not tested"

    Verification: Unit Test (a gate test scoped to ### 5. Risk Assessment, mutation-verified)
    Scenario: Given an AC that promises delivery (e.g. "surfaces in the PR body") → When QA hasn't run that path → Then the verdict is NEEDS_VERIFICATION, not MET with a "Not tested" note.

    AC-5: No net growth

    Verification: Integration Test (wc -l ≤ 3,837 in all three copies, plus npm run lint:skill-sync)


    Implementation Plan

    Phase 1: QA skill prose (all three copies, one batch)

    1. AC-1. Replace the sentence at qa/SKILL.md:1912, "Don't widen scope mid-PR; file a follow-up issue instead.", with a pointer to the ledger. That sentence is what produces unfiled follow-ups. Then:
      • Add the ledger rule as a short #### Follow-up Ledger block under §7. It lists the three sources (spec Open Questions and out-of-scope notes, exec PR-body follow-ups, QA document findings) and the three terminal states.
      • Add followup_ledger_status to the §7 gate list and the verdict table.
      • Add a one-line ### Follow-up Ledger slot to both templates.
      • Tell QA to write the resolution as a suffix on each document finding's description: — filed #N, — fixed in this PR or — dropped: <reason>.
    2. AC-3. Rewrite the Sibling-site Scan paragraph so QA names the defect class and searches for it. Spell out how it relates to the precheck: scripts/qa/precheck.ts siblingGrep stays a symbol-level hint, and the class search is the agent's job. Don't change precheck.ts; if that turns out to be needed, stop and surface it. The paragraph's closing "Don't automate via grep" contradicts the precheck, so drop it.
    3. AC-4. In §5, after the template block, add: when an AC promises end-to-end delivery, "Not tested" is not allowed; run the path or return NEEDS_VERIFICATION. Tighten the sentence that reserves NEEDS_VERIFICATION for "external/temporal gates" so it includes this case; otherwise the two rules contradict each other. Keep the slot labels **Not tested:**, **Sibling sites considered:** and **Sibling-line audit:**, because scripts/analytics/gap-signal.ts:54,64 anchors on them.
    4. AC-5. Pay for the new lines inside the same file:
      • §4 Q5 restates §5's cross-file/intra-file split.
      • §5 and §6d both carry the duplicated "operationalizes feedback_qa_second_look.md" line.
      • The §6d check list re-describes the sibling scan.
      • Don't move text into references/ unless the PR says so.

    Phase 2: Runtime (AC-2)

    1. Add a small accessor that returns the latest QA PhaseResult, so fix(run): status, PR-body QA note and MCP result use the first qa verdict — a looped AC_NOT_MET→NEEDS_VERIFICATION records ready_for_merge #1245 can reuse it. Use it only to read findings. Don't touch the two .find() verdict readers at batch-executor.ts:2379/:2498; those belong to fix(run): status, PR-body QA note and MCP result use the first qa verdict — a looped AC_NOT_MET→NEEDS_VERIFICATION records ready_for_merge #1245.
    2. Thread followups?: GapFinding[] through four steps: the openOrUpdatePR after argument, then createPR, then buildAutomatedPRBody. This is the same path readyGateReport takes. Filter to recommendedAction === "document".
    3. Render ## Follow-ups after the QA note and before the stack manifest:

    Phase 3: Tests

    1. Add the two new gate-test files, scoped to their delimited regions in all three roots. Reuse the readFromEachRoot pattern from qa-review-dimensions-skill.test.ts.
    2. Add a follow-ups describe block to the build-pr-body tests covering:
      • resolved and unresolved lines
      • a run with no findings (no section)
      • fix_now findings are excluded
      • a closing keyword in a finding is sanitized
    3. Add SEQUANT_MUTATION markers for AC-1, AC-3 and AC-4. Each failedTest must start with the test file path.

    Run the targeted tests, npm run build, npx tsc --noEmit and npm run lint:skill-sync. Don't run the full npm test.


    Design Review

    1. Where does this logic belong?
    2. What's the simplest correct approach? Put the resolution in description, so the PR body reads only the existing marker channel. Rejected: parsing the ledger table from QA prose. That would be a second channel, and fix(run): spec recommendation handoff parses ephemeral chat text — recommended phases silently dropped; move the contract to a structured comment marker #921, bug(qa): parseQaVerdict records the first Verdict mention in the transcript, not the final heading — #1070 passed qa three times and was recorded AC_NOT_MET each time #1119 and fix(qa): parseQaSummary returns null when AC statuses are bold words with no emoji — the SEQUANT_QA_GAPS findings marker is then never read #1194 show what prose regex parsing costs.
    3. What pattern does this follow, and how often has it been re-patched?
    4. What would a senior reviewer challenge? "Why not add a resolution field to GapFindingSchema?" Because it's a Non-Goal. The suffix convention is a parse contract, so the ADR must record it, and a schema field is the upgrade path.
    5. Producers and consumers.
      • Deferred items are produced by spec (Open Questions), exec (PR body), QA (SEQUANT_QA_GAPS) and runner context comments.
      • findings are consumed by parseQaSummary (phase-executor.ts:711), ready-gate.ts:374, /loop, and now buildAutomatedPRBody.
      • The slot labels are consumed by gap-signal.ts.
      • There is one PR-body producer.

    ADR: the plan picks between two designs (suffix vs. a prose ledger parse). The exec PR must add an ADR in docs/adr/ using the next free number; #1250's branch already claims 0005.


    Feature Quality Planning

    The standard checks pass. Two things need attention:


    Open Questions

    1. Where does the resolution come from? Recommendation: a description suffix, no schema change. Impact if wrong: the PR checklist can't tell resolved items from unresolved ones.
    2. Does the ledger gate apply in Simple Fix mode? Recommendation: yes, since spec deferrals exist regardless of diff size. Impact if wrong: small PRs keep dropping items.
    3. What does an unresolved item cap the verdict at? Recommendation: AC_MET_BUT_NOT_A_PLUS, so the run still breaks to a PR and a human resolves it. Impact if wrong: AC_NOT_MET would loop exec on a decision exec can't make.

    Recommended Workflow

    Phases: exec → qa
    Quality Loop: enabled
    Reasoning: The ACs are gate tests that exec writes and mutation-verifies, so I skip testgen; its stubs would duplicate that work. The quality loop is on because the hard line cap and three mirrored copies make a first-pass AC_NOT_MET likely.


    Label Review

    Current: enhancement
    Recommended: enhancement, planned
    Quality Loop: set explicitly above (scope is SCOPE_WARNING).

  4. added
    planned
    on Oct 3, 2026
  5. admarble commented on Oct 3, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_MET_BUT_NOT_A_PLUS

    AC coverage: 5/6 met

    Gaps:

    • Gate-test ACs have no SEQUANT_MUTATION marker in a PR body; add the QA-recorded markers once the PR opens
    • Orchestrated PR bodies have no channel for exec's mutation markers, so §6i reads Missing on every sequant run unless a human edits the body
    • Skill-argument substitution replaces $0 in qa SKILL.md awk programs, silently breaking §6c Step 1 and manual-AC attribution
    • If QA copies the template wording into a description, the PR checklist reads — ⚠️ unresolved — unresolved

    Suggestions:

    • The ledger template writes unresolved items as ⚠️ unresolved. If QA copies that wording into a finding's description, the PR body will show — ⚠️ unresolved — unresolved. This is cosmetic only.
  6. added a commit that references this issue on Oct 3, 2026
  7. admarble commented on Oct 3, 2026

    @admarble
    ContributorAuthor

    Runner verification and follow-up ledger (PR #1288)

    Verified by the runner

    • Tests:
      • The 5 targeted test files passed (187/187), and tsc --noEmit and lint:skill-sync are clean.
      • All three gate ACs are mutation-verified, each failing exactly its own test. The records are in the PR body.
    • AC-5: .claude/skills/qa/SKILL.md went from 3,837 to 3,832 lines.
    • Data flow: read the AC-2 path. It takes the latest QA pass's summary.findings, goes from openOrUpdatePR to createPR to buildAutomatedPRBody, and renders before the stack manifest.

    Run caveat

    The MCP server that ran this was sequant 2.18.0. It opened the PR only after QA, which is #1247's old two-producer behaviour, so QA had no PR body to read. That is the source of QA's "no SEQUANT_MUTATION marker" gap. Restart the MCP server on 2.19.0 before the next run.

    Ledger

    • Spec Open Questions 1–3 (description suffix, gate applies in Simple Fix mode, unresolved caps at A-): fixed in this PR. All three are implemented as recommended, with ADR 0007 covering Q1.
    • QA: gate ACs have no mutation marker in the PR body: fixed in this PR. The runner re-ran each mutation and added the records.
    • QA: orchestrated PR bodies have no channel for exec's mutation markers: dropped. That was the 2.18.0 server. On 2.19.0, exec puts its markers inside its final ## Summary (exec SKILL.md, PR Creation), and extractExecSummary imports that section into the PR body.
    • QA: $0 substitution in the qa SKILL.md awk programs: filed investigation(skills): Claude Code may substitute positional $0 inside qa SKILL.md awk programs when /qa gets an argument #1289. It is unverified; AC-1 there reproduces or refutes it.
    • QA: doubled ⚠️ unresolved — unresolved suffix: fixed in this PR (0d80d67), with a test that fails without the fix.
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

    enhancementplanned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions