Skip to content

test(auto-resume): gate the crash-once claude shim on the create's settled reply - #813

Merged
danshapiro merged 1 commit into
mainfrom
fix/auto-resume-shim-settle-race
Sep 20, 2026
Merged

danshapiro merged 1 commit into
mainfrom
fix/auto-resume-shim-settle-race

Conversation

@danshapiro

Copy link
Copy Markdown
Owner

What

Fixes the second base-gate flake at origin/main: crates/freshell-ws/tests/auto_resume_e2e.rs > successful_auto_resume_respawn_does_not_drop_its_ticket_unarmed timed out waiting for a terminal.created frame (~1-in-7 file runs under cargo test --workspace parallel load; 0/15 isolated; 0/12 single-threaded; reproduced locally and under the gate).

RCA (probe-instrumented, receipts in the investigation)

The claude crash-once shim died within milliseconds of the PTY spawn — racing the create's own post-spawn tail. When the death won:

  1. The b8ke ext r9 dead-PTY guard (commit_session_ref_ownership: "a dead runtime NEVER records Live") refused the create's winner commit (ForeignOperation — confirmed by probe, not from the coordinator's state match).
  2. The create answered the designed typed error error{INTERNAL_ERROR: lost session ownership during spawn} (the Err commit arm's stale-teardown).
  3. Gate 1 worked exactly as designed — the hub's crash event was held (pending=true) until the create answered, then the hub claimed and respawned.
  4. The test only accepts terminal.created, silently consumed the error frame, and burned its whole 30s frame budget.

So the production flow is the designed outcome for "child dies during create settle"; the test was racing its own deliberate crash.

Fix

The shim's first generation now waits on a per-test release marker (50ms poll) that the tests write AFTER terminal.created — the crash is structurally post-settle, with no timing assumption anywhere (the codex sibling's fixed 1.2s sleep is the cruder wall-clock-margin precedent). Both crash_once_claude_spec call sites updated.

Evidence

  • Isolated: 0/15 failed. Single-threaded: 0/12. Parallel pre-fix: ~12% failure. Post-fix parallel: 0/35 failed.
  • cargo fmt --check clean; pre-push gate green.

…he create's settled reply

The claude crash-once shim died within milliseconds of the PTY spawn,
racing the create's post-spawn tail. When the death won, the b8ke ext
r9 dead-PTY guard (commit_session_ref_ownership: 'a dead runtime NEVER
records Live') refused the create's winner commit, and the create
answered the typed lost-ownership error instead of terminal.created —
the crash-once tests consumed the error frame and burned their 30s
frame budget (the origin/main base-gate flake: ~1-in-7 file runs under
parallel load, isolated 0/15, single-threaded 0/12).

RCA receipts (instrumented probe trail): spawn completes in ~35ms,
K6 pre-commit -> ForeignOperation from the dead-PTY arm, the create
replies error{INTERNAL_ERROR lost-session-ownership}, Gate 1 correctly
holds the hub's crash event until the create answers (pending=true ->
requeue), the hub then claims and respawns. The production flow is the
designed outcome; the test was racing its own deliberate crash.

Fix: the shim's first generation now waits on a per-test release
marker (50ms poll) that the tests write AFTER terminal.created — the
crash is structurally post-settle, no timing assumption (the codex
sibling's fixed 1.2s sleep is the cruder wall-clock-margin precedent).
Both crash_once_claude_spec call sites updated. Post-fix: 0/35
parallel file runs (pre-fix ~12% failure rate).

Refs: b8ke ext r9 F2 (dead-PTY commit guard), Gate 1 create-answer
hold (auto_resume.rs).
@danshapiro
danshapiro merged commit 5bd6983 into main Sep 20, 2026
7 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