fix(perch): dead-transcript preflight — wake no longer crash-loops on a never-persisted --session id - #376
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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"),attachExitparks the session, and the row keeps the dead id — every later wake re-read it: permanentpi_gonecrash-loop.The fix
startChildnow preflights the resume againstreaddirSync(<sessionDir>/sessions)before constructing PiRpc: transcript absent → wake fresh with an honestresume transcript missinglog 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.js71/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)No migration, no schema change.