gstack icon indicating copy to clipboard operation
gstack copied to clipboard

autoplan phase publication is unverified when a Remote Control bridge_status record is the journal root

Open exGeni opened this issue 2 weeks ago • 3 comments

What happened

In a Claude Code 2.1.309 session where Remote Control is active before the first prompt, guarded reviewer Agent calls of /autoplan pass, but the publication hook prints:

PreToolUse:Agent says: [autoplan] phase publication was NOT verified for this session (journal shape unrecognized_shape:preamble:system:bridge_status): This Claude Code journal shape is not recognized (unrecognized_shape:preamble:system:bridge_status). Phase-report enforcement was skipped for this call. (code unrecognized_shape:preamble:system:bridge_status, Claude Code 2.1.309).

Phase-publication enforcement is skipped on each of these calls. Our guard log (~/.gstack/analytics/autoplan-guard.jsonl) holds 21 unverified decisions with this code from one day, and no other disposition for it. docs/autoplan-guard-troubleshooting.md (lines 62-74 at 19ed2ac5) describes this code as usually a Claude Code journal format change and asks for the detail and version, which is this report.

The allow-with-warning is the documented fail-open path for unknown shapes, and it works as designed here. The request is to recognise this shape, so a session with Remote Control active from the start is verified like a plain interactive session instead of degrading.

Cause

When Remote Control is active, Claude Code writes a system record with subtype bridge_status as the conversation root (parentUuid: null), and the first user message is its child. The journal head, with values omitted:

{"type":"mode"}
{"type":"permission-mode"}
{"type":"bridge-session", ...}                       # bridgeSessionId, sessionId, ...
{"type":"system","subtype":"bridge_status","parentUuid":null,"isMeta":false,
 "content":"/remote-control is active · Continue here, on your phone, or at https://claude.ai/code/session_…",
 "url":"…","uuid":"A","cwd":"…","version":"2.1.309", ...}
{"type":"user","parentUuid":"A","uuid":"B", ...}       # first user turn
{"type":"attachment","parentUuid":"B", ...}            # SessionStart hook attachments follow

In lib/claude-journal-records.ts at 19ed2ac5, ownedCausalOrder only accepts SessionStart hook attachments before the first message (line 387):

const preamble = top.slice(0, turn).find(n => !n.sessionStart);

sessionStartRecord (line 244) matches only type: 'attachment' with attachment.hookEvent === 'SessionStart'. So the bridge_status root becomes preamble:system:bridge_status (line 389), and autoplan/bin/phase-publication-hook.ts (lines 760-762) turns the second identical read into an unverified allow. The record carries the Remote Control status line (content above) and is the parent of the first user message.

We saw this root form in two journals. In a third, bridge_status sits mid-file with a non-null parent (after a stop_hook_summary), as an ordinary chain node, so the preamble check does not apply there.

Proposed fix

Accept a system record with subtype bridge_status and parentUuid: null as a preamble node, the way a SessionStart attachment is accepted, and nothing broader: every other unknown preamble record (for example the preamble:system:local_command shape the tests pin) stays an unrecognized_shape. Add a fixture with this head to the guard tests. In the root-uniqueness check (candidates and carriesTurn, lines 372-383), message-less root candidates and the walk through their descendants recognize only SessionStart records, so the fix should also be tested against a competing root next to a bridge_status head, for example a second null-parent user record.

Steps to reproduce

  1. Start a Claude Code 2.1.309 session in which Remote Control is already active before the first prompt, in a repo where gstack is installed. Our two affected sessions were started through Remote Control; we have not tried other ways to reach this head.
  2. Run /autoplan on any plan, or anything that dispatches a guarded reviewer Agent call.
  3. Guarded Agent calls print the unrecognized_shape:preamble:system:bridge_status warning above. The session's journal under ~/.claude/projects/<project>/<session>.jsonl starts with the head shown in "Cause".

Readiness report

gstack doctor 1.99.0.0
ok              install root    ~/.claude/skills/gstack: claude global current (1.99.0.0), agy global current (1.99.0.0), codex global current (1.99.0.0)
ok              rescue refs     none in ~/.claude/skills/gstack
ok              state root      ~/.gstack durable=yes (selected by default)
ok              bun             1.4.4 at /usr/local/bin/bun (floor 1.3.3, tested 1.4.2)
ok              hooks           15 hook(s) parse
ok              codex           codex-cli 0.160.1; self-locate ok
ok              artifacts sync  status ok (mode full; queue 0)
ok              browse bundle   browse/dist built
ok              binaries        find-browse, design, pdf, gstack-global-discover launch (4 of 4)
ok              cso             native helper 1.99.0.0 (9ab50347ac37)
ok              claude code     2.1.309 (Claude Code) at /usr/local/bin/claude
ok              session journal no session journals for this project
ok              guard log       90 decisions (5 denied)
ok              CLAUDE.md       no gstack section lists skills (~/.claude/CLAUDE.md)
15 ok, 0 warn, 0 not configured, 0 fail

(Trimmed: two codex model/probe lines. Doctor ran from a different checkout than the affected sessions.)

Environment

  • Host (Claude Code, Codex, Cursor, ...) and its version: Claude Code 2.1.309, Remote Control (bridge) session
  • OS: Linux 7.0.0
  • gstack: installed 1.99.0.0 (9ab50347). The code cited above was checked on main at 19ed2ac5, where it reads the same.
  • Related: earlier autoplan guard journal fixes landed in #3069 and #3209. We found no open or closed issue for bridge_status or unrecognized_shape.

exGeni avatar Nov 11 '26 18:11 exGeni

Thanks @exGeni, this is a very clear report. I confirmed it on main at 4414f4c: ownedCausalOrder in lib/claude-journal-records.ts has no case for a bridge_status system record at the root of the conversation, so sessions that start with Remote Control active fall back to the unverified path. It's queued as a bug fix.

capy-ai[bot] avatar Nov 12 '26 16:11 capy-ai[bot]

Picking this up. A maintainer agent working through a batch of fixes (our tracking thread GSTA-802) will first reproduce this on current main. If it reproduces, the agent fixes it on main and we'll close this issue with a link when the change lands. If it no longer reproduces, we'll close it and say what changed.

capy-ai[bot] avatar Nov 22 '26 05:11 capy-ai[bot]

Fixed in #4681 (merged as b3323f47). /autoplan's phase-report check now accepts the bridge_status record that Claude Code writes first in Remote Control sessions, so the check runs instead of skipping itself with a "not verified" warning. A second competing root still denies. Thanks for the report, @exGeni.

capy-ai[bot] avatar Nov 22 '26 12:11 capy-ai[bot]