Skip to content

feat(run): one producer for per-AC status — parse the QA phase output, write the state record through updateACStatus, carry acs[] in the run log; unknown is a status #1525

Closed

Description

@admarble

Epic: graph-2026-10-review-surface Tier: judgment Execution: sequant_run Blocked by: #1524, #1504, #1471, #1507

Problem

state-schema.ts defines a per-AC record with status and evidence; StateManager.updateACStatus can write it; nothing calls it. The record is set to pending at registration and stays there (17 of 17 items on this checkout). Every renderer in this graph reads that record (I-2), so it needs one producer: at the point where the QA phase output is already parsed for counts (parseQaSummary, phase-executor.ts:615, consumed at :1272), parse per-AC status with the function RS-01 measured, write each AC through updateACStatus with its evidence text, and copy the list into the run log's issue entry as an optional acs[]. An AC the parse cannot classify is written unknown (I-8). A failed state write is counted through #1504's helper (I-9), which is why this waits for it.

The hook lives in a new sibling module called from one line, because phase-executor.ts is #1471's file and batch-executor.ts is #1507's; this node lands after both.

Acceptance Criteria

  • AC-1: The parse reproduces the fixture's ground truth. Evidence: npx vitest run src/lib/workflow/ac-status.test.ts -t "fixture" → ≥ 10 passed, 0 failed (one case per fixture in __tests__/fixtures/qa-comments/; statuses equal expected.json except the three labels investigation(qa): per-AC status parse coverage over ≥ 60 QA verdict comments, with a hand-labelled fixture — decides parser-now or marker-first (RD-1) #1524's test pins as known parser misses (922 AC-3, 1265 AC-2 and AC-7), which the case overlays as KNOWN_MISSES and fails if a pinned miss appears or disappears; an AC id absent from the comment yields unknown)
  • AC-1 is classified as a gate test by isGateTestEvidence; the PR body carries its SEQUANT_MUTATION record (flip one non-pinned status in expected.json → that fixture's case fails; restore).
  • AC-2: The state record is written through the existing updater against a real temp state file. Evidence: npx vitest run src/lib/workflow/ac-status.integration.test.ts → ≥ 3 passed, 0 failed (real StateManager on a temp dir, no fs mock; after a QA phase result, getAcceptanceCriteria(issue).items carry the parsed statuses and evidence; an AC in the comment but not in the issue is ignored and counted; an issue with no prior AC record gets one registered from its body first, then written; a chmod 0555 state directory makes the write fail and suppressed.byScope.state increments)
  • AC-3: The updater has a caller. Evidence: grep -rn 'updateACStatus(' src --include='*.ts' | grep -v test | grep -vc 'state-manager.ts' → ≥ 1
  • AC-4: The run log carries acs[] as an optional field and the schema version is unchanged. Evidence: grep -c 'acs: z' src/lib/workflow/run-log-schema.ts → ≥ 1 and grep -c 'version: z.literal(1)' src/lib/workflow/run-log-schema.ts → 1
  • AC-5: Renderers do not import the parser (I-2; constraint: holds today, binding on every later PR). Evidence: grep -rl 'ac-status' src/lib/cli-ui src/commands | grep -v test | wc -l | tr -d ' ' → 0
  • AC-6: No test lines are added beyond the two files above and no skill directory is touched. Evidence: git diff --name-only $(git merge-base origin/main HEAD)..HEAD | grep -cE '^(plugin/|\.claude/skills/|templates/skills/)' → 0 (constraint)

Prior fixes / producers

May touch

src/lib/workflow/ac-status.ts (new), ac-status.test.ts, ac-status.integration.test.ts (new), the one call line at the QA summary hook (in phase-executor.ts after #1471, or the module #1507 extracts), src/lib/workflow/log-writer.ts and run-log-schema.ts (optional acs[], after #1504's block), CHANGELOG.

Non-Goals

  • Rendering (RS-03).
  • Changing the QA skill's output (frozen; §10).
  • Any status other than the five: met, not_met, pending, blocked, unknown.
  • Any edit under plugin/, .claude/skills/, templates/skills/ (I-1).

Done when

After a QA phase, state.json's AC items and the run log's acs[] say what QA said, per criterion, with unknown where it could not tell.

Activity

  1. added
    graph-2026-10-review-surface
    on Oct 19, 2026
  2. added a commit that references this issue on Oct 26, 2026
  3. admarble commented on Oct 27, 2026

    @admarble
    ContributorAuthor

    Complexity: Standard (6 ACs, 3 directories)

    ⚠️ Launch gate: RD-1 resolved to marker-first

    The tracker's RD-1 line reads: "parser-now if ≥ 90% … otherwise marker-first after the freeze." #1524 measured 80% (76 comments, 343 ACs; fixture precision 97%, recall 98%). The runner's note on #1524 says the producer work "is scheduled after the plugin freeze". Two documents say otherwise. PROJECT-DISCUSSION RD-B says that below 90%, "RS-02 ships with unknown as the common case and the marker becomes the first post-freeze node", and HANDOFF.md lists #1525 as unblocked.

    Recommendation: ship now under RD-B. The parser rarely says something wrong (97% precision on the fixture); the 20% it cannot read becomes unknown (I-8), not a wrong status. The SEQUANT_AC marker later replaces the parse at the same call site. The owner must confirm this before launch. This plan assumes they confirm.

    AC Quality Check

    Each Evidence command was run against main (d6d66a9):

    • AC-1: the test file does not exist, so the check fails today. Not vacuous.
    • AC-2: ❌ the failure mechanism is wrong. saveState writes to os.tmpdir() and then calls renameSync onto state.json. A rename over a 0444 file succeeds on POSIX (checked locally: the rename succeeded and the content was replaced). Rename permission depends on the directory, not the file. Suggested edit: "a chmod 0555 state directory makes the write fail". Skip the test when process.getuid() === 0.
    • AC-3: 0 today. Gates the work.
    • AC-4: grep -c 'acs' is 0 today but loose: any word containing "acs", such as "traces", would satisfy it. Suggest grep -c 'acs: z'. The second clause is a constraint, 1 today.
    • AC-5 and AC-6: constraints that hold today, as the issue says.

    Scope Assessment

    Non-Goals: present. They exclude rendering, edits to the QA skill, statuses outside the five, and edits under the frozen directories.
    Features: 1. ACs: 6. Directories: src/lib/workflow, scripts/qa, __tests__/fixtures (read only).
    Verdict: ✅ SCOPE_OK

    Findings that change the plan

    1. unknown is not in ACStatusSchema. The schema has pending, met, not_met and blocked, so updateACStatus(…, "unknown") fails Zod validation in saveState. Add unknown to the enum, and add an optional unknown count in updateAcceptanceCriteriaSummary. Older CLIs that read a state.json containing unknown will reject it; name this in the CHANGELOG.
    2. Nothing in the run path registers the AC record. updateAcceptanceCriteria has no caller in src/; only /spec's npx tsx block writes the record. On this checkout 4 of 17 issues have a record. updateACStatus throws "has no acceptance criteria" for the rest, so most runs would write nothing. See OQ-2.
    3. Evidence goes to notes, not evidence. AcceptanceCriterion.evidence holds the issue's declared Evidence: clause (feat(spec/qa): explicit Evidence: clause on ACs — declared verification replaces keyword inference #938), and overwriting it would destroy that clause. updateACStatus's 4th parameter is notes. The QA row text (trimmed rest, capped at about 200 characters) goes there.
    4. The parser is in scripts/qa/ac-status-parse-coverage.ts. Move AcStatus, firstStatusToken, leadingAcIds, proseLines and parseAcStatuses into src/lib/workflow/ac-status.ts. The script re-exports them, so its existing test is unchanged (AC-6). This leaves one copy of the regex.
    5. The parse needs the AC ids that were not asked for. To count ids that appear in the comment but not in the issue, add a small leadingIdsInBody(body) beside parseAcStatuses, or return the extra ids from it.

    Acceptance Criteria

    AC-1: Unit test (gate). Given each of the 12 fixtures and the issue AC ids from expected.json → when parseAcStatuses runs → then each status equals expected.json, and absent ids are unknown. The mutation record is required in the PR body: flip one status in expected.json, and exactly that fixture's case fails.
    AC-2: Integration test, with a real StateManager on a temp dir and no fs mock. Cases: (a) statuses and notes are written; (b) an extra id in the comment is ignored and counted; (c) a read-only state dir → suppressedCounts().byScope.state increments (call resetSuppressed() in beforeEach).
    AC-3: grep. The single call site is in the new module.
    AC-4: grep, with acs: z.array(...).optional() on IssueLogSchema.
    AC-5 and AC-6: constraint greps.

    Implementation Plan

    Phase 1: Parser into src

    1. Create src/lib/workflow/ac-status.ts with the pure parse moved from the script, plus leadingIdsInBody. The script imports and re-exports.
    2. In state-schema.ts, add unknown to ACStatusSchema and an optional unknown count to the summary.

    Phase 2: Producer

    1. In ac-status.ts, add recordAcStatuses({ issueNumber, output, stateManager, logWriter }). It reads getAcceptanceCriteria(issue) for the ids, parses, calls updateACStatus(id, status, notes) once per id, counts ignored extras, and returns acs[]. Each failure goes to noteSuppressed("state", err, "ac-status:recordAcStatuses"). No throw ever reaches the caller.
    2. Add one call line in batch-executor.ts, after the updatePhaseStatus block (about line 2503), guarded by phase === "qa" && result.output. It sits beside the #964 verdict post, which has the same "QA produced a parseable result" gate. mapAgentSuccessCore in phase-executor.ts stays pure: it has no StateManager.

    Phase 3: Run log

    1. run-log-schema.ts: add acs: z.array({ id, status, notes? }).optional() on IssueLogSchema, after feat(cli): cost per run where a user looks — one line in the run summary, cost in the run log and sequant logs, from the metrics record, labelled "SDK estimate" #1527's block. log-writer.ts: add a setAcStatuses(issueNumber, acs) setter that follows setSpecRecommendation, and spread it in the issue builder. The version stays 1.
    2. Tests in the two named files only. Add a CHANGELOG entry.

    Design Review

    1. Where it belongs: in src/lib/workflow/ac-status.ts, which owns the parse and the write. Batch-executor gets one line, so refactor(workflow): split runIssueWithLogging (1,620 lines) into stage functions of ≤ 200 counted lines, behaviour-preserving #1507's split stays intact.
    2. Simplest approach: call the parse at the existing QA hook. The rejected alternative parses inside parseQaSummary, which would enlarge phase-executor.ts and couple counts to the per-AC status.
    3. Pattern and re-patch count: prose-scraping of QA output. Prior fixes: the parseQaVerdict first-match fix (v2.18.0), parseQaSummary (bug(run): orchestrated 'sequant run --phases qa' re-run computes a fresh verdict but never posts it, contradicting the stale comment left visible #964), and qa-gaps-marker.ts. That is ≥ 2 prior fixes, so the stop rule applies. Record it as deliberately local. Reason: the plugin freeze (I-1) forbids the skill-side marker, and unknown bounds the damage. The class is tracked in PROJECT-DISCUSSION §10, but §10 has no issue yet; see OQ-3.
    4. What a reviewer would challenge: "Why ship a parser at 80%?" (the launch gate above). "Why not reuse parseQaSummary?" It produces counts, not per-id rows.
    5. Producers and consumers. The AC record has two producers: updateAcceptanceCriteria (registration, via /spec only) and updateACStatus (new caller). Consumers are updateAcceptanceCriteriaSummary, sequant status, and feat(cli): the AC table on every surface — terminal run summary lines per criterion, an ACs column in sequant status, a block in sequant logs; all read the one record #1526 later. qa-cache.ts:92 has its own enum and is untouched. The run log's acs[] has one producer (log-writer) and one consumer (feat(cli): the AC table on every surface — terminal run summary lines per criterion, an ACs column in sequant status, a block in sequant logs; all read the one record #1526).

    Open Questions

    1. OQ-1: does RS-02 ship now, given 80% < 90%? Recommendation: yes, under RD-B (see the launch gate). Impact if wrong: the producer is built, then retired early by the marker.
    2. OQ-2: what happens when an issue has no AC record (13 of 17 here)? Recommendation: when acceptanceCriteria is absent, register the record first by calling the existing updateAcceptanceCriteria(extractAcceptanceCriteria(body)). The body comes from provider.fetchIssue, one extra gh call on QA only. The registration producer itself is unchanged. Alternative: skip and write only acs[], but then "Done when" fails for most runs and RS-06 would reopen this node. This changes AC-2: add a 4th case, "no prior record → registered then written".
    3. OQ-3: file §10's SEQUANT_AC marker as an issue now? It is needed to complete the Q3 record ("class tracked in #N"). Recommendation: yes, file it, blocked on the freeze lift.
    4. AC-2 and AC-4 text edits (directory chmod; acs: z). The owner edits the AC lines; a comment alone does not change them.

    Recommended Workflow

    Phases: exec → qa
    Quality Loop: enabled
    Reasoning: Judgment tier. The change widens a schema enum and makes state writes in the run path. AC-1 and AC-2 already name their test files, so testgen would add little.

    Label Review

    Current: graph-2026-10-review-surface. Recommended: add enhancement and planned.

  4. added
    planned
    enhancement
    on Oct 27, 2026
  5. admarble commented on Oct 27, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_MET_BUT_NOT_A_PLUS

    AC coverage: 6/6 met

    Gaps:

    • QA phases run by sequant ready and --ready-gate do not write per-AC status, so the record can be stale after the gate
    • Ids that QA reports but the issue does not declare are returned but never surfaced or counted anywhere
    • A flip of any of the 3 overlaid expected.json labels would not fail the AC-1 fixture test
    • The long-term SEQUANT_AC marker producer follow-up has no terminal state
  6. added a commit that references this issue on Oct 28, 2026
  7. admarble commented on Oct 28, 2026

    @admarble
    ContributorAuthor

    QA Verdict: NEEDS_VERIFICATION

    AC coverage: 6/6 met

    Gaps:

  8. admarble commented on Oct 28, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_MET_BUT_NOT_A_PLUS

    AC coverage: 6/6 met

    Gaps:

    • The KNOWN_MISSES overlay replaces the expected.json labels for the three pinned ACs, so an edit to those labels is not detected — unresolved
    • AcStatusEntry is exported but nothing imports it — dropped: knip is advisory and the type is internal
    • Unlocked labels. The KNOWN_MISSES overlay replaces the expected.json label for the three pinned ACs. I changed 922 AC-3's label from met to unknown in expected.json: both ac-status.test.ts and scripts/qa/ac-status-parse-coverage.test.ts still passed (26 of 26), and I restored the file. A parser change on those ACs is caught, but an edit to those three labels is not. The first QA pass found the same gap, and no change since has fixed it.

    Suggestions:

    • Record the expected label next to the parsed value in KNOWN_MISSES, for example { label: "met", parsed: "unknown" }, and assert that expected.json still carries that label.
    • Make AcStatusEntry non-exported, or use it from the run-log type.
  9. added a commit that references this issue on Oct 28, 2026
  10. admarble commented on Oct 28, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_MET_BUT_NOT_A_PLUS

    AC coverage: 6/6 met

    Gaps:

    • A pinned KNOWN_MISSES label edited to a different wrong value (922 AC-3 met to not_met) is not detected — unresolved
    • Spec OQ-3 (file an issue for the SEQUANT_AC marker) has no terminal state — unresolved
    • AcStatusEntry is exported but nothing imports it — dropped: knip is advisory and the type is internal
    • Commit 36cf2a0 only partly closes the last QA's finding. The new check asserts that each pinned expected.json label is different from the pinned parse. It does not assert what the label is. So changing 922 AC-3 from met to unknown is now caught, but changing it from met to not_met still passes. The last QA suggested storing the expected label in KNOWN_MISSES ({label, parsed}), which would close this fully.
    • AcStatusEntry is exported but nothing imports it. This is what fails knip-advisory.
  11. added a commit that references this issue on Oct 28, 2026
  12. admarble commented on Oct 28, 2026

    @admarble
    ContributorAuthor

    QA Verdict: READY_FOR_MERGE

    AC coverage: 6/6 met

    Gaps:

    • Pre-release CLIs and the pinned MCP server reject a state.json containing an unknown AC status until the release ships — dropped: documented in CHANGELOG, inherent to the issue's unknown-is-a-status requirement
  13. added a commit that references this issue on Oct 28, 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

    enhancementgraph-2026-10-review-surfaceplanned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions