Skip to content

fix(perch): dead-transcript preflight — wake no longer crash-loops on a never-persisted --session id - #376

Merged
kh0pper merged 1 commit into
mainfrom
fix/perch-cycle-dead-session-resume
Sep 14, 2026
Merged

kh0pper merged 1 commit into
mainfrom
fix/perch-cycle-dead-session-resume

Conversation

@kh0pper

@kh0pper kh0pper commented Sep 14, 2026

Copy link
Copy Markdown
Owner

The brick (measured live on R4, 2026-09-13, closing PR-E joint smoke)

pi reports its session id at ready but persists the transcript (<timestamp>_<id>.jsonl) only after the first completed turn. cycle()/control() (or a restart adopt) of a never-conversed session handed pi --session <dead-id>; pi exits code 1 ("No session found"), attachExit parks the session, and the row keeps the dead id — every later wake re-read it: permanent pi_gone crash-loop.

The fix

startChild now preflights the resume against readdirSync(<sessionDir>/sessions) before constructing PiRpc: transcript absent → wake fresh with an honest resume transcript missing log line on the session stream; the reported-id stamp at the tail repairs the row. The transcript is lost either way (no completed turn), so fresh costs nothing real.

Globs the file rather than matching pi stderr because the file is the fact; the stderr is pi phrasing.

Tests

  • tests/perch-interactive.test.js 71/71 (1 new preflight test; the two existing resume-asserting tests — wake + I-1 restart — keep their assertions by planting the transcript a conversed session really leaves; I-1 previously encoded the buggy expectation of resuming a never-conversed session)
  • Neighboring wake-path suites (capacity/controls/dispatch/routes/statebridge) 239/239

No migration, no schema change.

…on a --session id pi never persisted

pi reports its session id at ready but writes the transcript only after
the first COMPLETED turn. cycle()/control() (or a restart adopt) of a
never-conversed session handed pi a --session id it could not find: pi
exited code 1 ("No session found"), attachExit parked, and every later
wake re-read the same dead row id — a permanent pi_gone loop (measured
live on R4 closing PR-E's joint smoke, 2026-09-13).

startChild now globs <sessionDir>/sessions/*_<id>.jsonl before resuming:
absent means wake FRESH with an honest log line, and the reported-id
stamp repairs the row. The two tests that assert resume keep passing by
planting the transcript a conversed session really would have left.

Tests: tests/perch-interactive.test.js 71/71 (+1 new preflight test);
neighboring wake-path suites 239/239.
@kh0pper
kh0pper merged commit fda7f55 into main Sep 14, 2026
3 checks passed
@kh0pper
kh0pper deleted the fix/perch-cycle-dead-session-resume branch September 14, 2026 02:17
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