Skip to content

fix(run): PR body falls back to the placeholder when exec writes no "## Summary" heading, dropping exec's mutation markers and AC table #1297

Closed

Description

@admarble

Found: the #1245 run on 2026-10-03 (run 139f3382, sequant 2.19.0 MCP server). PR #1294's body is the placeholder "Automated PR for issue #1245." with no exec summary, AC table or mutation markers.

Cause, read from the exec session's transcript. Exec's final message has ## What changed, ## Acceptance criteria, ## Checks and ## Confidence, but no ## Summary. It wrote its three SEQUANT_MUTATION markers under ## Checks. extractExecSummary (src/lib/workflow/worktree-manager.ts) reads only the last ##/### Summary section, so it returned undefined. buildAutomatedPRBody then fell back to the placeholder, and nothing was recorded as execSummary on the issue's state.

This is the expected case, not an edge case. extractExecSummary's own comment records that 13 of 20 exec sessions on 2026-09-30 ended with no Summary heading. The exec skill's PR Creation step tells exec to put the AC table and every marker inside its final ## Summary (#1247), but that is a prose instruction the model often skips. #1247's promise depends on this path: "QA reads your summary, AC table and mutation markers from the PR body". With a placeholder body, QA's §6i finds no markers for gate-test ACs and floors the verdict, and the precheck's AC literal-diff has nothing to compare.

Prior fixes / producers

AC

  • AC-1: When exec's output has no Summary section, the PR body still carries every SEQUANT_MUTATION marker found anywhere in exec's final output, plus the AC verification table if one is present. Marker text is passed through closing-keyword sanitization. Evidence: npx vitest run src/lib/workflow/worktree-manager.build-pr-body.test.ts with a fixture copied verbatim from the 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 exec output's headings and markers
  • AC-2: A marker inside the Summary section is not duplicated, and truncation at EXEC_SUMMARY_MAX_LENGTH never drops a marker. Evidence: same test file
  • AC-3: The run log or the run output says when the body fell back to the placeholder, so the miss is visible without reading the PR. Evidence: a batch-executor test asserting the warning

Non-Goals

  • Making the model write a ## Summary heading more reliably. The prose instruction exists, and this issue removes the dependence on it.

Activity

  1. added
    bug
    on Oct 4, 2026
  2. admarble commented on Oct 4, 2026

    @admarble
    ContributorAuthor

    Runner context (2026-10-04, main @ 2f8dc07)

    Where things are:

    Second live example, beyond #1245. PR #1298 (#1246) had a real ## Summary, but the summary ran past 4,000 characters and was cut mid-sentence ("…the PR update after the sec"). The markers survived only because they came before the cut. AC-2's truncation case should use that shape: a marker after the cut point must still reach the body.

    State fallback: openOrUpdatePR falls back to state.execSummary for a run with no exec pass (stateManager.updateExecSummary). If the markers live outside the summary, decide whether the state fallback carries them too. If not, a qa-only re-run's PR update drops them again. Either answer is fine; say which one in the PR.

    Prior fixes / producers: extractExecSummary has one prior change (#1223), which isn't a class yet. The PR body has one producer, buildAutomatedPRBody.

    Launch constraints:

    • No full npm test in exec or QA; CI runs it. Run the AC test files, plus npx tsc --noEmit and npm run build.
    • batch-executor.test.ts queues child_process mocks in order.
    • Commit WIP about every 10 minutes.
    • End your final message with a ## Summary section that holds the AC table and every SEQUANT_MUTATION marker. Until this issue lands, that's the only way they reach the PR body.
    • PR body: the closing line references this issue only. Any other issue gets Refs, never a closing keyword, even in examples.
  3. admarble commented on Oct 4, 2026

    @admarble
    ContributorAuthor

    Complexity: Standard (3 ACs, 2 directories)

    AC Quality Check

    • AC-1/AC-2 Evidence names a test file that exists today (worktree-manager.build-pr-body.test.ts), but the cases do not, so the gate fails now and passes only with the work. Not vacuous.
    • AC-2 and AC-3 name no specific test case. Give them named cases (below) so the §6i mutation record can point at one.
    • AC-3 "run log or run output" is open. Pick one: a log(chalk.yellow(...)) line in openOrUpdatePR, which is run output. Plan below.

    Scope Assessment

    Non-Goals: present (don't make the model write ## Summary more reliably).

    Metric Value Status
    Feature count 1 ✅
    AC items 3 ✅
    Directory spread 2 (src/lib/workflow/, tests alongside) ✅

    Verdict: ✅ SCOPE_OK

    Acceptance Criteria

    AC-1: No-Summary exec output still yields markers and the AC table in the PR body

    Verification: Unit Test (worktree-manager.build-pr-body.test.ts)
    Scenario: Given exec output with ## What changed / ## Acceptance criteria / ## Checks / ## Confidence and 3 SEQUANT_MUTATION markers under ## Checks (headings and markers copied verbatim from the #1245 transcript) → When buildAutomatedPRBody(1245, {execOutput}) → Then the body contains all 3 markers (parseable by parseMutationMarkers) and the AC table; a marker whose text says Closes #99 is rewritten to Refs #99.
    Assumptions: the fixture must be copied from the real transcript, not synthesized (motivating-example rule).

    AC-2: No duplicate markers; truncation never drops one

    Verification: Unit Test (same file)
    Scenario: (a) marker inside the Summary section → appears once. (b) Summary over 4,000 chars with a marker after the cut point (the #1298 shape) → marker still in body. (c) summary-section marker plus the same marker elsewhere → once.

    AC-3: Placeholder fallback is visible

    Verification: Unit Test (batch-executor.test.ts)
    Scenario: Given an exec result with no Summary and no markers, no state summary → When the PR is created → Then a log warning says the body fell back to the placeholder. No warning when a summary or markers exist, or when no exec ran (qa-only with a state fallback).

    Implementation Plan

    Phase 1: One composer (src/lib/workflow/)

    1. mutation-marker.ts: add renderMutationMarker(marker), the inverse of parseMarkersRaw, so the grammar lives in one file. No second regex. Collect markers with the existing parseMutationMarkers(execOutput); it already ignores fenced or inline-code markers, which is the right behavior for example text.
    2. worktree-manager.ts: add composeExecSummary(execOutput) next to extractExecSummary. It returns the (capped) Summary section; then an uncapped block of markers not already present in that capped text (compare by ac+mutation+failedTest); and, when there is no Summary section, the ## Acceptance criteria section (or a table containing AC-N rows) under a plain label. Cap applies only to the summary prose. Returns undefined when all three parts are empty.
    3. buildAutomatedPRBody: use composeExecSummary(execOutput) ?? opts.execSummary?.trim(), still passed through sanitizeImportedClosingKeywords (covers marker text, AC-1).

    Phase 2: State fallback + visibility (batch-executor.ts)

    1. Line ~2073: updateExecSummary(issueNumber, composeExecSummary(result.output)). State then stores summary + markers, so the qa-only re-run's PR update keeps them. Decision recorded: the state fallback carries markers (no schema change, execSummary stays a string).
    2. openOrUpdatePR (~1204): when the body will be the placeholder (compose and state summary both empty), log(chalk.yellow("! PR body: exec output has no Summary or mutation markers; using placeholder")). Keep the decision(run): a sequant run where no qa ran still ends with a PR — draft+note, require qa, or unchanged (blocked by #1247) #1246 qaNotRun and "QA reviewed latest exec" logic untouched.
    3. Tests: three AC-1/AC-2 cases plus AC-3 test. batch-executor.test.ts queues child_process mocks in order; add the new case without adding git calls. Keep the existing extractExecSummary tests green.

    Design Review

    1. Where does this belong? worktree-manager.ts (the sole PR-body producer) plus mutation-marker.ts for the render side of the marker grammar.
    2. Simplest correct approach? Append markers outside the capped summary. Rejected: raising EXEC_SUMMARY_MAX_LENGTH (still drops after any cap); a new execMarkers state field (schema change for no gain, since a string already round-trips).
    3. Existing pattern / re-patch count? extractExecSummary: one prior change (fix(pr): sequant run PRs double the conventional prefix in the title and ship a placeholder body #1223), then the 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 caller change. Fewer than 2 prior fix issues, so not yet a class; this fix removes the dependence on the heading. Marker parsing is mutation-marker.ts (feat(qa): mutation-verification becomes a parseable §7 gate instead of honor-system prose #939), reused.
    4. Reviewer challenge: "why not make exec always write Summary?" Non-Goal; 13/20 sessions skip it.
    5. Producers/consumers (whole-repo grep): extractExecSummary is called from worktree-manager.ts (buildAutomatedPRBody) and batch-executor.ts:2073 (state write). One body producer. Consumers: QA §6i, precheck AC literal-diff, humans. Both call sites switch to composeExecSummary, so the PR path and the state path cannot disagree.

    Feature Quality Planning

    All standard checks pass. Notable:

    • Markers re-rendered from parsed values drop malformed ones; that is intended (consistent with §6i).
    • A marker in a fenced block in exec output is ignored by the parser. If exec fences its markers, they still miss; flag in PR, not in scope.

    Open Questions

    1. Include the AC table only when there's no Summary? Recommendation: yes (Summary already carries it when present). Impact if wrong: a duplicate table.

    Recommended Workflow

    Phases: exec → qa
    Quality Loop: disabled
    Reasoning: Bug fix, 3 ACs, small surface. AC-1/AC-2 declare unit-test evidence, but the tests are the deliverable and exec writes them, so testgen adds nothing. Skip full npm test (CI runs it); run the two test files, npx tsc --noEmit, npm run build. Gate tests (AC-1/AC-2) need Mutation-verified: records naming the test file path.

    Label Review

    Current: bug. Recommended: bug, planned. No ui labels needed.

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

    @admarble
    ContributorAuthor

    QA Verdict: AC_NOT_MET

    AC coverage: 2/3 met

    Gaps:

  6. added a commit that references this issue on Oct 4, 2026
  7. admarble commented on Oct 4, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_NOT_MET

    AC coverage: 2/3 met

    Gaps:

  8. added a commit that references this issue on Oct 4, 2026
  9. admarble commented on Oct 4, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_NOT_MET

    AC coverage: 3/3 met

    Gaps:

    • ready-gate-run.test.ts mock of worktree-manager.js lacks the new composeExecSummary export, so 9 tests fail
    • composeExecSummary dedups against fenced markers in the Summary, so a marker fenced inside ## Summary is never re-appended in a form QA section 6i can parse, contradicting the CHANGELOG claim
    • A marker inside the AC section is carried twice when there is no Summary
  10. added a commit that references this issue on Oct 4, 2026
  11. admarble commented on Oct 4, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_MET_BUT_NOT_A_PLUS

    AC coverage: 3/3 met

    Gaps:

    • Markers exec fences inside its ## Summary are deduped against the fenced copy and never re-rendered, so QA 6i (code-stripped parse) sees none
    • No test covers fenced markers inside a Summary section
    • Exec-rewrote-PR-body follow-up has no recorded issue number — unresolved
  12. added a commit that references this issue on Oct 4, 2026
  13. admarble commented on Oct 4, 2026

    @admarble
    ContributorAuthor

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

    Runner fixes

    • fe14c52: the no-Summary AC-table cap had no comment guard. A cut at offsets 3973–3975 dropped a marker. Both caps now share capImportedText, and the AC-2e test sweeps the cut offsets.
    • fe14c52: ready-gate-run.test.ts mocked worktree-manager without composeExecSummary, so 9 tests failed. The mock now includes it, and all 7 test files that mock it pass.
    • ae7c25c: a marker fenced inside the Summary was de-duped against a copy QA's parse ignores. The de-dup now uses parseMutationMarkers, and the AC-2f test covers it.

    Each new test fails without its fix and passes with it.

    Ledger

    • QA iteration 3, AC-2 mid-marker cut: fixed in this PR (fe14c52).
    • QA re-run, fenced marker inside the Summary, plus its test gap: fixed in this PR (ae7c25c).
    • QA re-run, the exec-rewrote-the-PR-body follow-up had no issue number: filed fix(exec): under the orchestrator, a loop exec rewrites the PR body itself (gh api PATCH), so later sequant updates are dropped as "edited by hand" #1302.
    • Context comment, does the state fallback carry the markers? Yes, because batch-executor stores the composed summary (markers included) as execSummary. Seen live: before this lands, a qa-only run on this PR fell back to the placeholder, since 2.19.0 stored nothing.
    • Exec, mutation-marker.ts has no test file of its own: dropped. parseMutationMarkersFromExecOutput is covered through the build-pr-body tests (AC-1 verbatim fixture, AC-2f), and the existing mutation-marker tests pass.
  14. added 2 commits that reference this issue on Oct 16, 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

    bugplanned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions