Skip to content

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

Merged
capy-ai[bot] merged 3 commits into
mainfrom
capy/autoplan-mid-sentence-phase-report-gst-1916
Nov 8, 2026
Merged

capy-ai[bot] merged 3 commits into
mainfrom
capy/autoplan-mid-sentence-phase-report-gst-1916

Conversation

@garrytan

@garrytan garrytan commented Nov 8, 2026 •

Copy link
Copy Markdown
Owner

/autoplan no longer stops after Phase 1 when Claude Code saves the phase report as a summary that opens with another sentence. This keeps unattended /autoplan runs on Claude Code going past their first phase.

What changed

The guard now counts the captured Phase 1 summary; quoted and example forms still don't count

The guard now counts the captured Phase 1 summary; quoted and example forms still don't count.

Before/after as text: The guard now counts the captured Phase 1 summary; quoted and example forms still don't count
--- Before · before.txt · captured output
+++ After · after.txt · captured output
+counted Phase 1  <-  I checked the packet against the plan and all four edits are in place, with the native ...
-not counted (publication_missing)  <-  I checked the packet against the plan and all four edits are in place, with the native ...
 not counted (publication_missing)  <-  The template says "Done. Phase 1 is complete. Next." for this step.
 not counted (publication_missing)  <-  Example: Done. Phase 1 complete.

Why

"/autoplan stops after Phase 1 with publication_missing" (#4155, found and diagnosed by @mstormo). Claude Code can save the prose between tool calls as a paraphrased summary, and when the report opened with a check sentence the summary folded that sentence in front of "Phase 1 is complete". The guard only looked at the start of a line, so it denied a report that was really there. It now also reads a declaration that starts a sentence in a plain prose line, so the run moves on to Phase 2.

Tests

test/autoplan-publication-mid-sentence.test.ts, written first. On main (15a35ff) it fails 3 of 25: the captured summary, other sentence-start forms, and the guard replay, which returns publication_missing. With the fix, 25 of 25 pass. Negative controls that stay rejected: a declaration inside double, curly or single quotes or inline code, "did not declare Phase 1 complete", "Phase 1 is not complete", "with no outside review", "will be complete", a subordinate "before Phase 1 is complete", Phase 4 and Phase 2.1, list, numbered, heading and quote lines, an example introduced on the previous line or earlier on the same line, and a fenced block. In the guard replay, a quoted, a negated and a Phase 2 summary each stay publication_missing.

Blast radius

Only the autoplan publication detector changes: autoplanPhaseCompletions, read by the phase-publication hook (autoplan/bin/phase-publication-hook.ts:473) and the autoplan test observers. Compared with main it accepts more reports and never fewer, because the new sentence check only runs where main already returned nothing; the 23 test files that use the detector, the hook or its fixtures ran 686 pass, 0 fail on the fixed tree.

Summary

A report like "I checked the packet... Phase 1 is complete with 9 native issues and no outside review, so the work moves on to Phase 2." used to stop the run. The detector now checks each sentence start in a plain prose line. A sentence inside quotes or inline code, one after an example or template introduction on the same line, list, heading, table and quote lines, negated or future forms and other phase numbers still don't count. A "with" result is rejected for "no" only when it opens with "no", so "with 9 native issues and no outside review" counts. Review added the same-line example check.

Test Coverage

All new code paths have test coverage: test/autoplan-publication-mid-sentence.test.ts names the changed file (deterministic coverage map, no audit reader).
Regression proof: the new test fails 3 of 20 on main (15a35ff) and passes on this branch; review added 3 rejected cases that return [1] at e12449f and [] now.
Tests ran: focused, 23 files, 686 pass, 6 skip, 0 fail (bun test on the fixed tree).

Pre-Landing Review

Pre-Landing Review: 1 issue — 1 auto-fixed, 0 asked (0 fixed, 0 skipped), 0 deferred, 8 noted.

  • [AUTO-FIXED] lib/autoplan-phase-publication.ts:45 a declaration after a same-line unquoted example introduction ("Example: Done. Phase 1 complete.") counted → the sentence check now rejects a preface that names an example, template, marker or expected-output introduction (red-team checklist, confirmed by QA capture 002).
  • Fix-check and the native adversarial pass found nothing blocking; their notes are below.

Gate edits: none detected (1 listed, 0 read; patterns: RH-1,RH-3,RH-4,RH-12,RH-13,RH-14,RH-15,RH-16; unlisted idioms: none)

Outside review: not dispatched (review plan: code class, no numeric claims).

Review notes

Below the blocking floor; recorded here and not fixed in this PR.

  • The same-line example guard matches its word list anywhere in the preface, so a real report whose preface mentions "source", "marker", "sample" or "template" ("I read the source files. Phase 1 complete.") is not counted and the guard asks for the report again. Main already rejected every mid-line report, so this is no regression from main; it narrows the gain. Raised by both the fix-check and the adversarial pass. A narrower trigger (only the last sentence before the boundary, or a word followed by ":" or "reads/says") is the likely follow-up.
  • Same-line introducers outside the word list ("E.g. Phase 1 complete.", "For instance. Phase 1 complete.") still count.
  • A line starting with an HTML comment or an "(a)" enumerator ("") still counts.
  • Withdrawals still match only at line start while declarations now also match mid-line; main already behaved this way for line-start declarations.
  • The per-boundary prefix recount is quadratic: a 340 KB line with 20,000 boundaries took about 13 s. Real lines are far smaller.
  • "complete with results: no." now counts; contrived.
  • The boundary lookahead is case-sensitive and accepts only a space or tab, so "phase 1" and non-breaking-space forms are not counted (fails closed).

Exploratory QA

Functional smoke on the detector through a one-line CLI wrapper (report: .gstack/tmp/qa-reports/run-20261108T162343Z/functional/report.md, verdict pass). A preface plus a real Phase 1 report counts ([1], capture 004). "Example: Done. Phase 1 complete." returned [1] before the review fix (capture 002) and [] after (replay 003). The guard hook path is covered by the test file's guard replay tests, not probed here.

Design Review

No frontend files changed — design review skipped.

Eval Results

No eval: this is a detector fix, and the new test replays the captured summary through the real guard hook as a narration-journaled report (R56).

Review bot comments

No review bot comments.

Plan Completion

Plan completion audit: not run (no plan is bound to this branch and no docs/designs/ file matches). Bug fix with a failing-first test, so plan review was skipped (R28).

Issues

Refs #4155

Verification Results

No plan obligations: 0 PASS, 0 FAIL, 0 BLOCKED, 0 NOT RUN.

TODOS

No TODO items completed in this PR.

Documentation

Status: current. No documentation edits were needed.

Scope: base 15a35ff..06c7b49 (3 commits): lib/autoplan-phase-publication.ts now counts an autoplan phase declaration that starts a sentence partway through a plain prose line, and rejects one that follows a same-line example introduction. The candidate has no staged, unstaged or untracked files. The banned-terms check returned none.

Documentation health:

  • docs/autoplan-guard-troubleshooting.md: current. The publication_missing guidance still holds.
  • docs/skill-gates.md: current. The "Phase N complete line" wording still holds.
  • docs/troubleshooting.md: current.
  • autoplan/SKILL.md.tmpl, autoplan/DRIVER.md.tmpl: current.
  • AGENTS.md, CLAUDE.md, README.md: current. The change doesn't affect them.

Coverage debt: the behavior change to which declarations the guard accepts is documented only in the changelog fragment, so there is reference coverage only. This is a minor gap. Diagram drift: none.

Test plan

  • bun run test (carried from CI run 42501101386/1 at tree ae65a45dc3f9): green, 1645 test files, 0 failed
  • bun test on the 23 files that use the detector, the hook or its fixtures: 686 pass, 6 skip, 0 fail
  • bun run typecheck: clean

🤖 Generated with Claude Code

Agent notes

REVIEW_LOOP: passes=1 blocking_found=0 deferred=0 noted=1 fixed=1 scope=frozen ledgers_read=4 fix_checks=1 dispatches=1 est_input_tokens=3341

Gate edits: none detected (1 listed, 0 read; patterns: RH-1,RH-3,RH-4,RH-12,RH-13,RH-14,RH-15,RH-16; unlisted idioms: none)

Approvals

No approvals recorded for branch capy/autoplan-mid-sentence-phase-report-gst-1916.
Plan: exempt: bug fix

Refs GST-1916

{
  "schema_version": 1,
  "pr": 4171,
  "head": "06c7b495d093e6948d5cba47cfaf0ff045477819",
  "version": "1.98.0.0",
  "base": "main",
  "gate": {
    "test": {
      "pass": 36574,
      "fail": 0,
      "skip": 0
    }
  },
  "ci_carried": [
    {
      "lane": "test",
      "run": 42501101386,
      "attempt": 1,
      "tree": "ae65a45dc3f99a2a933d7560746fd30177f34c26"
    }
  ],
  "session_kind": "unattended",
  "head_tree": "ae65a45dc3f99a2a933d7560746fd30177f34c26",
  "product_patch_id": "e365b968e2d790d8d16ff20ffd56d6a228d90b3b",
  "gstack_version": "1.98.0.0",
  "review_depth": {
    "depth": "light",
    "class": "code",
    "runtime_lines": 27,
    "rules": "66e5174161eecc2c",
    "base": "15a35ff1fd365b4e92a09510cf69cfe8b31fdfaf",
    "registry": "15a35ff1fd365b4e92a09510cf69cfe8b31fdfaf",
    "gate_scan": {
      "tagged": 0,
      "head": "06c7b495d093e6948d5cba47cfaf0ff045477819"
    },
    "reasons": [
      "runtime=27"
    ],
    "risk": [],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @ae65a45dc3f9 (8 checks, current for 06c7b495d093)",
  "requires_remote": [
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/42501101386/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=ae65a45dc3f9 tests=36574 skipped=68 runs=42501101386/1 profiles=ci-reuse/free-tests heads=06c7b495d093 verified=2026-11-08T16:48:19.271Z"
  ],
  "issues": {
    "fixes": [],
    "refs": [
      4155
    ],
    "flakes": []
  },
  "docs": {
    "status": "current",
    "scope": "docs/, README.md, AGENTS.md, CLAUDE.md and autoplan/ (templates, sections, guard bins) against 15a35ff..06c7b49"
  },
  "review_loop": {
    "passes": 1,
    "blocking_found": 0,
    "deferred": 0,
    "noted": 1,
    "fixed": 1,
    "scope": "frozen",
    "fix_checks": 1,
    "rounds": 2,
    "est_input_tokens": 3341,
    "ledgers_read": 4,
    "dispatches": {
      "specialist-batched": 1
    }
  }
}

…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>
@trunk-io

trunk-io Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

…oduction (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>

@alikomitekaraj-droid alikomitekaraj-droid left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

…ry (GST-1916)

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

2 participants