Skip to content

autoplan guard: name the fix when a phase report's declaration is buried mid-sentence - #4155

Closed
mstormo wants to merge 1 commit into
garrytan:mainfrom
mstormo:fix/autoplan-publication-buried
Closed

mstormo wants to merge 1 commit into
garrytan:mainfrom
mstormo:fix/autoplan-publication-buried

Conversation

@mstormo

@mstormo mstormo commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Problem

On Claude Code 2.1.319 (Opus 5.5), /autoplan stopped after Phase 1 twice in one day with
publication_missing, even though a filled Phase 1 report had been sent in its own message
with only the true autoplan-published ceo no-op.

What happened in the session journal:

  • The report was not saved as a text block. Claude Code journaled the prose between tool
    calls as a thinking block whose signature is tagged narration, holding a paraphrased
    summary
    of the prose, not the prose itself.

  • The guard already reads narration blocks (lib/claude-journal-records.ts,
    publicNarrationText), so this part works as designed.

  • The report message opened with a verification sentence before **Phase 1 complete.**. The
    summary merged the two:

    I checked the packet against the plan and all four edits are in place, with the native
    reviewer's hash matching. Phase 1 is complete with 9 native issues and no outside review,
    so the work moves on to Phase 2.

  • phaseDeclaration accepts a declaration only at the start of a line, so this does not count,
    and the guard said publication_missing. That reads like "the report is not there", which
    sent the agent (and the user) looking for dropped text, and the run was abandoned.

  • Re-sending the report with no preface worked: the summaries became
    "Phase 1 is complete: the outside review was unavailable…" and
    "Phase 1 is done: outside review was unavailable…", and both count.

I ran the guard's own recordEvents + autoplanPhaseCompletions over the journal to confirm.
The first message gives no hit; both re-sends give a Phase 1 hit.

Change 1: the phase-close procedure says the report must open the message

autoplan/sections/phase-close.md.tmpl, step 6, adds:

The message starts with the report's **Phase <report.number> complete.** line: no preface,
status or verification sentence before it. Claude Code may journal prose between tool calls as
a paraphrased summary, and a preface gets folded into the declaration so the guard cannot count
it. Say anything else in an earlier message.

phase-close.md is regenerated with bun run gen:skill-docs. No other generated file changed.

Change 2: a specific denial, publication_buried

When no report counts but a message after the close Read mentions the phase's completion
somewhere other than the start of a line, the guard denies with publication_buried instead of
publication_missing. The text names the fix.

  • Same gate strength. It is still a denial. The new check only picks which corrective text
    to show, and it never counts a buried mention as a report.
  • lib/autoplan-phase-publication.ts: new buriedPhaseDeclaration(text, phase). It matches
    Phase N [(name)] [is] complete|completed|done|finished|wrapped up at a position > 0 on a line,
    skips fenced code, ignores negations ("is not complete"), and keeps 2 and 2.5 apart.
  • autoplan/bin/phase-publication-hook.ts: picks between the two codes where
    publication_missing used to fail.
  • autoplan/bin/guard-reasons.ts: new corrective reason. It doesn't advise a retry, and it
    includes the publish-separately instruction.
  • docs/autoplan-guard-troubleshooting.md: #publication-buried anchor (the reason-inventory
    test requires one per code).

Why not count paraphrased or thinking text more loosely

  • Accepting a declaration anywhere in a sentence would let a summary like "…before Phase 1 is
    complete, …" or a quoted plan line pass.
  • Reading untagged thinking would treat private reasoning as a published report, which defeats
    the "visible parent text" rule.
  • The narration channel is a summary by design, so the reliable fix is making the declaration
    survive summarizing: open the message with it.

Tests

test/autoplan-publication-buried.test.ts:

  • The real summaries from the failing session: the buried one is not counted and is flagged as
    buried; the opening one is counted and not flagged.
  • Negative controls: another phase, a negation, a fenced template, and 2 vs 2.5.
  • Hook replay with the existing guard fixture: a report with a preface gives publication_buried
    with the fix in the text. Controls: no report stays publication_missing, and a normal
    publish() is allowed.
  • test/autoplan-guard-reasons.test.ts still passes (code inventory, no-retry rule, anchors).

Verification

  • bun test test/autoplan-publication-buried.test.ts test/autoplan-guard-reasons.test.ts: 9 pass, 0 fail.
  • Wider run of test/autoplan-*.test.ts, test/*publication*.test.ts and test/skill-docs*.test.ts on Windows 11, before and after this change: 51 failures each, and 50 of them are the same tests. The two that differ are timing flakes. autoplan-review-discovery "canonical global path in copy installations" passed 2 of 3 isolated runs on this branch, and autoplan-token-efficiency "below the cap" failed before this change and passes after. The 50 shared failures are Windows environment issues unrelated to this change (paths, spawning bun by PATH name).

🤖 Generated with Claude Code

…d-sentence

Claude Code can journal prose between tool calls as a paraphrased narration
summary. A report with a preface sentence then reads "... Phase 1 is complete
with 9 issues ...", which the guard rightly does not count, but it said
publication_missing, which looked like dropped text.

- phase-close step 6: the report message opens with the Phase N complete line.
- New corrective denial publication_buried when a completion appears only
  mid-sentence after the close Read; same gate, clearer fix.
- Troubleshooting anchor and tests (detector unit cases from a real journal,
  hook replay with controls).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@trunk-io

trunk-io Bot commented Nov 8, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@capy-ai

capy-ai Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Thanks for the journal replay and the clear write-up. This is on the crew's pick-up list: a crew lane will rebuild it on current main and credit you as co-author when it lands, then close this PR.

capy-ai Bot added a commit that referenced this pull request Nov 8, 2026
…GST-1916) (#4171)

* Count an autoplan phase report that starts after a preface sentence (GST-1916)

Claude Code can journal the prose between tool calls as a paraphrased
narration summary. A Phase 1 report that opened with a check sentence came
back as "I checked the packet... Phase 1 is complete with 9 native issues and
no outside review, so the work moves on to Phase 2.", and the publication
guard denied the next phase with publication_missing because it counted a
declaration only at the start of a line (#4155).

- A declaration that starts a sentence inside a plain prose line now counts.
  Sentences inside double, curly or single quotes or inline code, and list,
  heading, table and quote lines, still don't.
- A "with" result that mentions "no" after its counts is affirmative; a
  result that opens with "no" is still rejected.
- New test replays the captured summary as a narration-journaled report
  through the guard, with quoted, negated and other-phase controls.

Co-authored-by: Marius Storm-Olsen <[email protected]>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* Reject an autoplan phase report that follows a same-line example introduction (GST-1916)

Review-Finding: review-p1/specialist-batched#1 reader=red-team
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* Mention same-line example introductions in the autoplan changelog entry (GST-1916)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

---------

Co-authored-by: Marius Storm-Olsen <[email protected]>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai

capy-ai Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Thanks @mstormo. Your diagnosis landed as #4171 (merged in 23f9d07), rewritten on current main, with you credited as co-author. Rather than adding a new denial code, the publication guard now counts a phase declaration that starts a sentence inside a line, so the narration summary you captured ("I checked the packet... Phase 1 is complete with 9 native issues and no outside review, ...") counts as the Phase 1 report. Quoted, inline-code, negated, future, other-phase and example-introduced mentions still don't count. Closing this in favor of #4171.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant