Skip to content

Keep /autoplan working after a Claude Code 2.1.317 compaction - #4226

Merged
capy-ai[bot] merged 2 commits into
mainfrom
fix-autoplan-after-2-1-317-compaction
Nov 9, 2026
Merged

capy-ai[bot] merged 2 commits into
mainfrom
fix-autoplan-after-2-1-317-compaction

Conversation

@garrytan

@garrytan garrytan commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

/autoplan no longer gets stuck between phases after Claude Code 2.1.317 compacts a long session. This keeps the planning workflow usable on the current Claude Code release.

What changed

The three 2.1.317 compaction tests fail on main (119ed92) and pass on this branch; the hold cases pass on both

The three 2.1.317 compaction tests fail on main (119ed92) and pass on this branch, and the hold cases pass on both. The before counts cover the preserved-segment file only (20 tests). The after counts also include the 2.1.293 copies file (31 tests).

Before/after as text: The three 2.1.317 compaction tests fail on main (119ed92) and pass on this branch; the hold cases pass on both
--- Before · before.txt · captured output
+++ After · after.txt · captured output
+(pass) records written after the boundary stay owned
+(pass) the next phase entry passes once the close packet is read in full after the compaction
+(pass) three such compactions in one session stay owned and the next phase entry passes
-(fail) records written after the boundary stay owned
-(fail) the next phase entry passes once the close packet is read in full after the compaction
-(fail) three such compactions in one session stay owned and the next phase entry passes
 (pass) a 2.1.300 tail that is the logical parent and not flushed yet still supplies no ownership
 (pass) a preserved list whose last entry is not the segment tail does not continue the boundary
 (pass) a preserved list naming no record of this file does not continue the boundary
@@ ⋯ 1 unchanged ⋯ @@
 (pass) a boundary with an absent logical parent and no compactMetadata still drops what follows
 (pass) a 2.1.300 boundary that cycles back but whose list omits its logical parent is still reported as an unrecognized shape
 (pass) a resumed fork that opens with such a boundary stays a genesis root
+ 31 pass
+ 0 fail
- 17 pass
- 3 fail

On 2.1.317, a compaction's boundary names a parent record (logicalParentUuid) that is never written to the session file. Its compactMetadata.preservedMessages.uuids list ends with the last record kept in place (preservedSegment.tailUuid). The journal reader in lib/claude-journal-records.ts required that tail to equal the logical parent, so it ignored the list. The boundary became an orphan and every record after the compaction was dropped without a word. The guard then judged each phase entry against stale history and refused it on every retry. The fixture shows close_incomplete, and the reporter's real session showed cross_phase_batch.

  • preservedUuids now reads a list of native uuids whose last entry is preservedSegment.tailUuid. It no longer requires that tail to be the logical parent.
  • ownedCausalOrder continues such a boundary from the last listed record that belongs to this file and does not descend from the boundary. It does this only when the logical parent is missing from the file and the boundary is not the file's first record.
  • docs/autoplan-guard-troubleshooting.md now says the guard reads the preserved segments of both 2.1.300 and 2.1.317. This came from /ship's documentation audit.

Why

"/autoplan gets stuck after compaction on Claude Code 2.1.317" (@vilano93, #4200). After a long session compacted, every later phase entry was refused, and retrying didn't help. Now the reader picks up from the record the compaction kept, so phase entries pass as they did on 2.1.300.

Blast radius

The change only touches the owned journal reader behind the /autoplan publication guard (lib/claude-journal-records.ts, read through lib/claude-owned-journal.ts). The 2.1.300 path is unchanged: when the list's tail is the logical parent, the boundary still continues only if it cycles back through itself. The anchor search now scans the whole list, but in that case the tail descends from the boundary and is excluded, so it picks the same record as before (file:line read, and the hold tests ran). The new branch fires only for lists that main used to reject. Hold tests pin today's outcome for an unflushed 2.1.300 tail, a list whose last entry is not the tail, a list naming no record of this file, a subagent tail, a boundary with no compactMetadata, a 2.1.300 cycle whose list omits its logical parent, and a resumed fork that opens with such a boundary. The change adds no network calls, secrets, permissions, workflows, install scripts or dependencies.

Known limit, kept from #4200: a logical parent that is missing but only late, and not the list's tail, is treated as never written until it lands. When it lands, the boundary reattaches to it.

Summary

People on Claude Code 2.1.317 hit a stuck /autoplan after any compaction. This PR fixes the journal reader so it follows the 2.1.317 compaction layout. It also updates one sentence in the troubleshooting guide to match. The fix is a rewrite on current main of @vilano93's report and fix in #4200, with credit.

Test Coverage

Every new code path has test coverage. The one changed runtime file has a changed test that names it (deterministic coverage audit; no audit reader).
Tests ran: focused 31

Pre-Landing Review

No issues found. The specialist (testing, security, state machines and the Red Team prompt, batched) found nothing. The native adversarial reader raised 3 Low notes, none blocking, listed under Review notes. The outside voice was skipped by the review plan (code class, no numeric claims).

REVIEW_LOOP: passes=1 blocking_found=0 deferred=0 noted=0 fixed=0 scope=frozen ledgers_read=2 dispatches=4

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

Review notes

Below the blocking floor (advisory, informational, test-gap or wording items); recorded here and not fixed in this PR.

  • INFORMATIONAL lib/claude-journal-records.ts:339 A 2.1.317-style boundary with no qualifying anchor is still dropped without a reason (pre-existing; no shipped shape produces it)
  • INFORMATIONAL lib/claude-journal-records.ts:338 An absent logical parent is treated as never written; a build that wrote it later could flip a read from owned to cycle (2.1.317 never writes it)
  • INFORMATIONAL lib/claude-journal-records.ts:325 descends follows raw parents, not remapped ones, so multiple boundaries could in theory form a cycle (pre-existing on 2.1.300; reported as cycle, not silent)

Exploratory QA

Functional smoke over repository-native tests, 2 probes within the 300 s bound, verdict pass. Probe 001 ran the 2.1.317 cases: 10 pass, 0 fail. Probe 002 ran the 2.1.300 regression edge in the preserved-segment and copies files: 12 pass, 0 fail. Limit: no live Claude Code 2.1.317 session was driven, and eval selection defers the autoplan guard E2E cases to release coverage.

Design Review

No frontend files changed, so design review was skipped.

Eval Results

The PR profile selected no behavioral probes or quality judges. Fourteen autoplan and plan-review E2E cases that read this file stay with scheduled and release coverage.

Review bot comments

No review bot comments.

Scope Drift

Scope Check: CLEAN
Intent: keep /autoplan's guard reading the session after a Claude Code 2.1.317 compaction (#4200).
Delivered: the journal reader follows the 2.1.317 preserved segment, plus hold tests, a changelog fragment and one troubleshooting sentence.

Plan Completion

Plan completion audit: not run (no plan is bound to this branch and no docs/designs/ file matches). This is a bug fix with a failing-first test, so it is exempt from plan review.

Issues

Refs #4200

Verification Results

No plan verification items exist for this branch, so the result is skipped.

TODOS

No TODO items completed in this PR.

Documentation

Status: updated. One factual correction, no blockers.

Scope: base 119ed92..ce26cc1 (one commit, #4200), which changes lib/claude-journal-records.ts, adds a test and adds a changelog.d fragment. There were no staged, unstaged or new files. The banned-terms check found no list.

Documentation health:

  • docs/autoplan-guard-troubleshooting.md: Updated. The compaction_unreachable note now says the preserved segments of Claude Code 2.1.300 and 2.1.317 are read.
  • changelog.d/fix-autoplan-after-2-1-317-compaction.md: Current. It already describes the fix.
  • CHANGELOG.md: Skipped. Lanes write fragments only.

Coverage debt: none. The change is an internal journal-reader fix with no new public surface.

Diagram drift: none.

Test plan

  • bun test test/autoplan-compaction-preserved-segment.test.ts test/autoplan-compaction-copies.test.ts: 31 pass, 0 fail (tests_ran=31)
  • Failing first on main 119ed92: the three 2.1.317 tests fail (17 pass, 3 fail)
  • CI is the full free-suite run at the pushed head

🤖 Generated with Claude Code

Agent notes

Lane GSTA-453 (GST-2150) under GStack Minder. The outside PR #4200 was read as a text diff only, never checked out, run or pushed to. Review per R51: the plan gstack-review-plan printed (light depth: one batched specialist plus the native adversarial voice), one round, no fix round needed. The 3 Step 11 notes are listed under Review notes; REVIEW_LOOP counts only Step 9 rows, so it shows noted=0.

Approvals

No approvals recorded for branch fix-autoplan-after-2-1-317-compaction.
Plan: exempt: bug fix
Plan check: exempt bug fix

REVIEW_LOOP: passes=1 blocking_found=0 deferred=0 noted=0 fixed=0 scope=frozen ledgers_read=2 dispatches=4
Gate edits: none detected (2 listed, 0 read; patterns: RH-1,RH-3,RH-4,RH-12,RH-13,RH-14,RH-15,RH-16; unlisted idioms: none)

Refs GSTA-453 GST-2150

{
  "schema_version": 1,
  "pr": 4226,
  "head": "fc846319bcff17a1fffea14b54c1744a5e5774f4",
  "version": "1.98.0.0",
  "base": "main",
  "gate": {
    "focused": {
      "pass": 31,
      "fail": 0,
      "skip": 0
    }
  },
  "session_kind": "unattended",
  "head_tree": "25b6eec097b228ffd19b0e5de791cd18d172acb2",
  "product_patch_id": "ed154e24390b1acf91a32b4a87f1cfefdab9aed4",
  "gstack_version": "1.98.0.0",
  "review_depth": {
    "depth": "light",
    "class": "code",
    "runtime_lines": 22,
    "rules": "66e5174161eecc2c",
    "base": "119ed92f9cd9fb425d87bbc892363fcaa331d529",
    "registry": "119ed92f9cd9fb425d87bbc892363fcaa331d529",
    "gate_scan": {
      "tagged": 0,
      "head": "fc846319bcff17a1fffea14b54c1744a5e5774f4"
    },
    "reasons": [
      "runtime=22"
    ],
    "risk": [],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @25b6eec097b2 (8 checks, current for fc846319bcff)",
  "requires_remote": [
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/42657193733/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=25b6eec097b2 tests=36859 skipped=90 runs=42657193733/1 profiles=ci-reuse/free-tests heads=fc846319bcff verified=2026-11-09T16:52:47.281Z"
  ],
  "issues": {
    "fixes": [],
    "refs": [
      4200
    ],
    "flakes": []
  },
  "docs": {
    "status": "updated",
    "scope": "README.md and docs/ (140 files inventoried; docs/autoplan-guard-troubleshooting.md read and updated)"
  },
  "review_loop": {
    "passes": 1,
    "blocking_found": 0,
    "deferred": 0,
    "noted": 0,
    "fixed": 0,
    "scope": "frozen",
    "rounds": 1,
    "ledgers_read": 2,
    "dispatches": {
      "specialist": 3,
      "red-team": 1
    }
  }
}

On 2.1.317 a compact boundary's logicalParentUuid names a record the
session file never receives, and the preserved list ends with the last
record kept in place. The journal reader required that tail to equal the
logical parent, so the boundary became an orphan, every later record was
dropped, and each phase entry was refused on every retry.

The reader now accepts a preserved list whose last entry is the segment's
tail, and continues a boundary whose logical parent is absent from the
file from that tail. The 2.1.300 path is unchanged: when the tail is the
logical parent it still needs the boundary cycle, so an unflushed tail
supplies no ownership. A boundary that opens the file stays a resumed
fork's root, and lists naming no node of this session still continue
nothing.

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

trunk-io Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

…1.317

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai
capy-ai Bot merged commit 1cc98fc into main Nov 9, 2026
52 checks passed
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