Repository navigation
fix(native-chat): close a structured session whose provider child is gone - #19155
brennanb2025 wants to merge 4 commits into
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between 909c747cdae82bb137e3ed15f34e5b4515154076 and 65f98a1. 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughNative session renewal now evicts records with proven-dead owners and protects active handoffs. Provider root-exit and pre-spawn errors count as successful stops, while uncertain outcomes remain retryable. Renderer structured worktree creation now tracks the starting agent, displays agent-specific progress and recovery text, seeds setup in the background, and avoids activation after selection changes. Tests cover session expiry, activation behavior, tab preservation, and agent-specific copy. Merge Risk: 🔵 Low · up to Structured launches now show provider-specific startup progress, but this new label is not localized and may appear in English for users of other locales. This is a bounded presentation issue and does not block the lifecycle fixes. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Linked Issues checkExplanation The PR addresses the linked issue's lifecycle, native-owner reconciliation, slow-launch progress, and provider-specific recovery requirements. However, Electron QA reproduced the original close failure when the adapter returns false instead of AgentSessionAcquisitionRootExitObservedError, and that path remains unresolved. Resolution Update the adapter or eviction flow so the remaining false-return close path correctly handles a provider root that has exited while preserving fail-closed behavior for genuinely unproven exits, live roots, and proven-live descendants. Add a regression test for this exact path and verify the original issue scenario closes successfully. Full details: Docstring CoverageExplanation Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 17 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: aa00019b-b2a0-4a96-9076-0e0ed3e01cc4
📒 Files selected for processing (14)
src/main/native-chat/agent-session-wire/structured-agent-session-eviction.tssrc/main/native-chat/agent-session-wire/structured-agent-session-expired-claude.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-lease-renewer.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/lib/pending-worktree-creation.tssrc/renderer/src/lib/worktree-activation-structured-commands.test.tssrc/renderer/src/lib/worktree-activation-surface-caller-wiring.test.tssrc/renderer/src/lib/worktree-creation-chat-setup.test.tssrc/renderer/src/lib/worktree-creation-flow-execute.tssrc/renderer/src/lib/worktree-creation-structured-recovery.tssrc/renderer/src/lib/worktree-creation-structured-session.test.tssrc/renderer/src/lib/worktree-creation-structured-session.tssrc/renderer/src/lib/worktree-creation-structured-unknown-outcome.test.tssrc/renderer/src/store/slices/worktree-helpers.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review.
| if (entry.startingChatAgent) { | ||
| return `Starting ${TUI_AGENT_DISPLAY_NAMES[entry.startingChatAgent] ?? entry.startingChatAgent} chat…` |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Localize the starting-chat progress label.
getCreationProgressLabel is rendered by the localized worktree panel and sidebar. When startingChatAgent is set, this branch returns a raw template literal, so the label can remain English in other UI languages. Reuse the existing components.native-chat.structuredSessionLaunchPending translation ID with named interpolation for the agent display name.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Eviction accepts root-exit proof with unverifiable descendants —
stop-provider-childnow catchesAgentSessionAcquisitionRootExitObservedErrorand proceeds through drain, sink close, lease release, and forget. I traced the Claude adapter: it throws that error only for{ root: 'exited', tree: 'unverifiable' }; a live root returnsfalse(abort) and a known-live descendant yieldsAgentSessionAcquisitionExitUnprovenError(abort), so fail-closed survives for live children. The boundary is the right one — the lease keys on the root pid, which is provably gone, and the adapter retains its uncertainexitsentry. - Lease renewer reconciles expired native owners — the new native branch gates eviction on
leaseDeadlineAt <= nowANDisProvenDeadProbe(probe), routing through the fence-checkedevictProvenDeadOwner. Expiry alone,indeterminate, andidentity-matchedprobes still fail closed (verified againstisProvenDeadProbe/isProvenAliveProbeand theadjudicateAgentSessionRestartdispositions). - Retained creation panel with agent-specific copy — the panel is held with a
Starting <Agent> chat…label while the launch settles; recovery copy resolves the brand throughTUI_AGENT_DISPLAY_NAMESinstead of hardcoding Codex. - Activation no longer yanks the user back —
launchStructuredWorktreeSessiondisables activation on selection change and guards against double activation withif (!activation).
The new integration test reconstructs the exact captured record shape and pins exact claimStatus/deathEvidence/sessions.size/close values (not theatre — the assertions would fail without the eviction catch), and the renderer tests cover the parameterized label and selection scenarios.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Electron QA evidence (PR #19155 / #19154)Isolated background instance ( Pending launch label (full-window, surrounding Orca chrome)Starting Claude chat… — pending creation surface in the content panel and sidebar row: Starting Codex chat… — same surface, agent-specific copy: Navigate away during in-flight pending launchClicked the existing Real composer → structured native chatNew Workspace composer (Agent = Claude) with Chat UI + structured native chat enabled. Request Without those experimental flags, the same composer launched a Claude TUI ( Console / runtimeNo renderer errors from the pending-label or structured-launch path. Isolated-profile noise only: Linear Gaps (not claimed verified)
QA worktrees |
Review status: PASSRecommendation: land, with the residual QA gaps below kept explicit.
Residual risk, not a proven blocker:
|
|
Follow-up commit What changed: the new native dead-owner branch in the lease renewer no longer requires the lease deadline to have passed before reconciling an owner the host has already proven dead. Why: the dead-TUI-owner branch immediately below it never required that. A confirmed-dead native owner was therefore left un-reconciled until expiry for a reason its sibling branch doesn't share — an inconsistency introduced by this PR, not pre-existing. Positive death evidence now settles it on its own; the deadline still guards the case it was actually meant for, a live owner that simply hasn't renewed yet. This does not loosen any liveness check: Verification: new test Note for reviewers: CI will re-run against the new head. The residual risk called out earlier is unchanged — an end-to-end dead-provider-root close has still not been reproduced live, only proven by ablation in tests. |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Native eviction no longer waits for lease expiry —
structured-agent-session-lease-renewer.tsdrops theleaseDeadlineAt <= nowgate from the native branch, so a proven-dead native owner (exit-observed/pid-absent/identity-mismatch) is evicted immediately through the fence-checkedevictProvenDeadOwner, matching the existing dead-TUI-owner branch. - Added a red/green test for pre-expiry reclamation —
structured-agent-session-expired-claude.test.tsproves apid-absentowner is released before its deadline; theclaimStatus: 'released'assertion would fail against the old deadline-gated code.
I traced the safety of dropping the deadline. The owner probe is PID-reuse-safe and fails closed: pid-absent is returned only on ESRCH, identity-mismatch only on positive contradictory identity evidence (token or start-time), and indeterminate otherwise, so a live owner always probes identity-matched and is renewed rather than evicted. evictProvenDeadOwner re-runs adjudicateAgentSessionRestart under a fence assertion and throws agent_session_ownership_unknown for any non-evicted disposition, so the fail-closed property holds without the deadline.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
3f51510 to
a1d3371
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
|
Rebased onto current main (89 commits) and force-pushed once: The force-push was deliberate and batched — an earlier review pass approved The PR body has been corrected. The earlier version stated the mechanism as "the child never wrote stderr". That was wrong. The real trigger is a race: the descendant snapshot latches to null when the root exits before an admissible walk completes. stderr matters only because the first byte is what arms the walk. The body now carries live instrumentation showing both branches in a running app, and the measured window (~139ms latches unverifiable; ~267ms proves exit). Two things checked since the last review:
CI is re-running against the new head. |
|
New commit The defect. Removing the lease-deadline precondition let the renewer evict a proven-dead native owner the instant its child exited. That is correct for an idle owner, but a suspend parks a live owner at The fix, at two layers. The renewer now reclaims only an owner with no handoff in flight, and the eviction transition takes an optional expected handoff stage so the write is a compare-and-swap — a stage that drifted between the scan and the mutation raises Which layer actually holds. Ablation says the compare-and-swap is load-bearing and the renewer guard is defence in depth: removing the renewer's Placement. The guard sits beside the other eviction preconditions rather than in the record store, and the store now reuses the transition's input type instead of restating it. That was forced by the Gates on this head: 5 files / 98 tests passing, |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Handoff-guard on native dead-owner eviction — the lease renewer now only evicts a proven-dead native owner when
record.lease.handoffStage === null, so an in-flight handoff's own stop transition and fence are no longer preempted by the renewer. - Compare-and-swap stage guard —
evictAgentSessionOwneraccepts an optionalexpectedHandoffStageand throwsagent_session_checkpoint_stalewhen the stage has drifted since the scan;evictProvenDeadOwnerthreads it through, checked against the freshly-read record inside the serializedtransact. - Red/green coverage for the race — the new renewer test starts a handoff mid-probe (
transitionHandofftopreparing) and asserts the eviction is refused and the handoff completes cleanly viastopStoredAgentSessionOwnerForHandoff.
I traced the guard's correctness. setAgentSessionHandoffStage leaves the fence untouched at preparing, so the CAS stage check — not assertFence — is what fires in the drift case, and both re-check the freshly-read record inside the serialized mutation, so there is no read-check-then-write race. For a mid-handoff owner whose probe comes back dead, the renewer falls through to renewal, which fails closed (renewAgentSessionLease requires identity-matched); the handoff owns the stop. The new test would fail against the prior commit (runtimeFence would advance and claimStatus would read released), so it is real coverage, not theatre. Other evictProvenDeadOwner callers (recovery-resolution) omit the guard (undefined → no CAS) and are gated by structuredSessionRecoveryIsResolvable, so they are unaffected.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
Not ready to merge. The Electron QA reproduced the original user-visible failure on this branch's build, and it is a case this PR does not cover. What happened. Across five workspaces driven through the real create dialog at The build genuinely contained the fix. Verified from the compiled bundle rather than assumed — the eviction step reads Why it still failed. The fix only handles the adapter throwing that error.
A Two independent discriminators point at the same place. The QA's: failing session has Proposed fix, not yet made. Make the adapter consistent instead of widening the eviction catch: when the root is proven exited and only the descendant tree is unverifiable, Blanket-accepting Note on scope: the QA did not build main, so it correctly did not claim this is a regression. On the evidence so far this is a pre-existing hole that the current fix narrows but does not close. |
…for expiry The new native branch required the lease deadline to have passed before it would reconcile an owner the host had already proven dead. The dead-TUI-owner branch immediately below it has never required that, so a confirmed-dead native owner sat un-reconciled until expiry for no reason the sibling branch shares. Positive death evidence now settles it on its own. The deadline still guards the case it was meant for: a live owner that simply has not renewed yet.
…a dead owner Removing the lease-deadline precondition let the renewer evict a proven-dead native owner the instant its child exited. That is right for an idle owner, but a suspend parks a live owner at handoffStage 'preparing', and the handoff transition requires that exact stage, its operation id, and a non-null ownerProcess. An eviction landing in that window nulls the owner and bumps the fence, so the handoff then fails agent_session_ownership_unknown. The renewer now reclaims only an owner with no handoff in flight, and the eviction transition takes an optional expected handoff stage so the write is a compare-and-swap: a stage that drifted between the scan and the mutation raises agent_session_checkpoint_stale instead of clobbering the handoff. The guard lives beside the other eviction preconditions rather than in the record store, and the store now reuses the transition's input type instead of restating it. Found by review of the preceding commit, which widened a window the deadline had been masking.
…path Closing a structured chat could still fail permanently at stop-provider-child. The exit ladder computes a three-valued observation — root exited/live/processless and a descendant tree exited/unverifiable/live — and the acquisition path already classified it, but the published-session close and the acquisition-cancel path returned a bare false regardless. A false conflates "root still alive" with "root exited, descendants unknowable", so the owner could not tell a retryable refusal from a session it was free to release, and the tab stayed unclosable. Both paths now report through the same classifier. Only the classes the owner can act on are raised; a genuinely unproven exit stays a retryable false, which the published-session cleanup contract depends on. Eviction, as the owner, decides: a root proven gone releases the writer even when its descendants are unknowable, and a session that never spawned has nothing to stop. Exit genuinely unproven still aborts the eviction. The regression test drives the shape live QA reproduced: a published session whose close returns false after root exit with no descendant proof.
909c747 to
65f98a1
Compare
There was a problem hiding this comment.
Important
The close-verdict reporting is correct and well-covered, but it raises errors from closeSession that only the eviction owner was updated to catch — the native→TUI handoff's suspendNative is now a throwing path it doesn't handle (see the inline comment).
Reviewed changes
claude-structured-session-close.ts— the published-session close and acquisition-cancel paths now classify afalseclose throughclaudeAcquisitionCleanupError, raisingAgentSessionAcquisitionRootExitObservedError/AgentSessionPreSpawnErrorso the owner can decide, while keeping a genuinely unproven exit a retryablefalse.structured-agent-session-eviction.ts—stop-provider-childadditionally catchesAgentSessionPreSpawnError(processless root = nothing to stop) alongside the existingRootExitObservedErrorcatch.structured-agent-session-expired-claude.test.ts— new regression test drives the published-sessionclose() === falsepath withexitVerdict { root: 'exited', tree: 'unverifiable' }and asserts eviction succeeds; it would fail against the prior bare-falsecode.
I traced the classification: claudeAcquisitionCleanupError yields PreSpawnError only for root === 'processless', RootExitObservedError only for root === 'exited' && tree === 'unverifiable', and ExitUnprovenError otherwise — so a live root and a known-live descendant still fail closed (eviction aborts), and the retryable-false contract holds where it should.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
| new Error('provider close unproven') | ||
| ) | ||
| if (!(reported instanceof AgentSessionAcquisitionExitUnprovenError)) { | ||
| throw reported |
There was a problem hiding this comment.
closeSession now throws AgentSessionAcquisitionRootExitObservedError (and AgentSessionPreSpawnError in the closeClaudeSession branch below) instead of returning false, but the eviction owner is the only consumer updated to catch them. The native→TUI handoff's suspendNative (structured-agent-session-host-handoff.ts:79) still treats closeSession as a pure boolean, so a child that dies mid-suspend (root exited, tree unverifiable) now fails the handoff with a misleading provider close unproven message instead of the clean agent_session_owner_exit_unproven refusal.
Technical details
# closeSession throws reach consumers except eviction
## Affected sites
- src/main/claude/claude-structured-session-close.ts:86 — `finalizeClaudePublishedSession` raises `RootExitObservedError`/`PreSpawnError` on a false close result.
- src/main/claude/claude-structured-session-close.ts:256 — `closeClaudeSession` cancellation branch raises the same classes.
- src/main/native-chat/agent-session-wire/structured-agent-session-host-handoff.ts:79 — `suspendNative` awaits `deps.adapter.closeSession(sessionId)` and reads `exited !== true`, expecting a boolean return only (no try/catch). A throw here propagates to `handoffStructuredSessionToTui`, which rolls back `preparing` and rethrows, so the flow `fail()`s with the typo'd `provider close unproven` error rather than the structured `agent_session_owner_exit_unproven` refusal the `{ state: 'live' }` path produced.
- src/main/native-chat/agent-session-wire/structured-agent-session-event-recovery.ts:48 — `recoverAfterSinkFailure` calls `forceCloseSession ?? closeSession`; it is guarded by `.catch(<barrier error>)`, so it cannot leak an unhandled rejection, but the outcome shifts from silent `null` to a user-facing barrier error.
- src/main/native-chat/agent-session-wire/structured-agent-session-adapter.ts:214 — `closeSession` JSDoc documents only `Promise<boolean>`; by contrast `releaseAcquisition` (line 141) explicitly documents the `RootExitObservedError` throw.
## Required outcome
- Every consumer of `closeSession` that is not the eviction owner handles (or documents) the newly raised `RootExitObservedError`/`PreSpawnError`, so a mid-close root exit keeps its intended per-consumer semantics. For the handoff suspend, a `RootExitObservedError` during suspend should map back to a refusal (live/retryable) rather than a hard flow failure.
- The `closeSession` interface contract documents the raises, matching `releaseAcquisition`.
## Suggested approach (optional)
- In `suspendNative`, wrap `closeSession` and translate `AgentSessionAcquisitionRootExitObservedError` / `AgentSessionPreSpawnError` into `{ state: 'live' }` (or a typed refusal), preserving the prior boolean-only contract there. Consider a shared helper so the mapping stays consistent with the eviction owner.
Rendered-Electron QA — head
|
deathEvidence.kind |
settlementRetryRequired |
n | closed? |
|---|---|---|---|
pid-absent |
absent | 7 | 7/7 closed, no toast |
pid-absent |
true |
1 | 0/1 — refused 6× |
So pid-absent alone is no longer the discriminator; on this evidence the surviving dead end is a lease carrying an unsettled restart-eviction settlement. That is a correlation over 8 samples, not a proven mechanism — I did not instrument connection.exitVerdict to confirm which branch of claudeAcquisitionCleanupError the refusing session takes.
Full results
Run 1 — 6 workspaces created via the dialog, all with live provider children:
| workspace | close | toast | deathEvidence.kind |
settlementRetryRequired |
claimStatus |
|---|---|---|---|---|---|
qa19155-a |
closed | none | exit-observed |
absent | released |
qa19155-b (provider child SIGKILLed first, PPID-verified against my own Electron main) |
closed | none | exit-observed |
absent | released |
qa19155-c–f |
not closed in this run; carried through a restart | — | — | — | — |
Run 2 — after a graceful restart on the same profile, c–f reconciled to exit-observed/released. Created g h i j k flatworm focus focus2 (8 live sessions), then force-killed the Electron main and its provider children so the leases were left live with stale pids, and relaunched. On restore, 7 leases reconciled to deathEvidence.kind: "pid-absent", settlementRetryRequired absent (qa19155-k reconciled to exit-observed — "acquisition cleanup proved no provider child remains"). All 12 open tabs then closed cleanly, no toast, no refusal.
| workspace | state at close | close | toast |
|---|---|---|---|
qa19155-g,h,i,j,flatworm,focus,focus2 |
pid-absent, retry absent |
closed | none |
qa19155-k |
exit-observed |
closed | none |
qa19155-c,d,e,f |
exit-observed (dormant) |
closed | none |
Run 3 — 6 fresh workspaces in a single app run, live children, mirroring the shape the previous pass ran:
| workspace | close | toast | deathEvidence.kind |
settlementRetryRequired |
claimStatus |
|---|---|---|---|---|---|
qa19155-r1 |
closed | none | exit-observed |
absent | released |
qa19155-r2 |
closed | none | exit-observed |
absent | released |
qa19155-r3 |
refused, 6 attempts | Could not close this chat session / eviction failed at "stop-provider-child" |
pid-absent |
true |
released |
qa19155-r4 |
closed | none | exit-observed |
absent | released |
qa19155-r5 |
closed | none | exit-observed |
absent | released |
qa19155-r6 |
closed | none | exit-observed |
absent | released |
1 in 6 fresh workspaces, against 1 in 5 in the previous pass.
The two previously-passing behaviours still hold
OBSERVED — structured chat is the sole initial surface, no stray bare terminal. Each of the 6 workspaces from run 1 came up with exactly one tab, a structured-agent-session-claude_* entry; the Resource Manager read 0 terminal sessions.
OBSERVED — navigating away during a launch does not yank focus back. Created qa19155-focus2; 2 s after it became active (structured session still launching — its claude_3037a54f… session and provider child appeared afterwards) I clicked qa19155-k in the sidebar. activeWorktreeId stayed on qa19155-k for the full 30 s poll.
(My first attempt at this test was invalid — the sidebar row I clicked was covered by the "Add a setup script" card, so the navigation never landed. The result above is from the re-run against a verified-clickable row.)
What I did not establish
- Whether this is a regression or a pre-existing hole: I did not build
main, so I cannot say this commit made anything worse. What I can say is that the failure this commit targets still occurs at this head. - Which classifier branch the refusing session takes. The fix raises on
exitVerdict.root === 'processless'(AgentSessionPreSpawnError) and onroot === 'exited' && tree === 'unverifiable'(AgentSessionAcquisitionRootExitObservedError), and keeps everything else a retryablefalse. I did not observeexitVerdictdirectly, so I cannot say whetherqa19155-r3falls into the deliberately-retryableExitUnprovenclass or is being misclassified. - Descendant-bearing sessions. No session in this run ever executed a turn, so none had provider descendants; the
root exited + tree unverifiableshape the new regression test drives was never produced live here.
Follow-up: the latched session is also unwritable, and reveal/attach does not clear the latchSame instance, same head OBSERVED — the latch survives reveal. With the workspace deselected, the lease read {"claimStatus":"released","runtimeFence":2,"ownerProcess":null,
"settlementRetryRequired":true,
"settlementRetryId":"restart-eviction:claude_4d46e8bf_4ebc_48ea_bd19_ac9f6a1ea31c:2"}OBSERVED — the session cannot accept writes either. Sending
Clicking Retry produced the same error; the lease was still So this is worse than an unclosable tab: the workspace's chat is a dead end in both directions. The user can neither use the session nor get rid of it. Against the "attach clears the latch" readingThe seven {"claimStatus":"released","runtimeFence":2,"ownerProcess":null,
"deathEvidence":{"kind":"pid-absent","detail":"recorded pid absent on host","observedAt":1788815299243}}with Could not reproduce the latch on demandThree fresh workspaces ( Not established
|
|
Closing this. It is aimed at the wrong bug, and part of it causes a second one. What was actually reported: creating a worktree with Claude as the default agent produced a bare focused shell instead of a native chat, with the chat arriving ~100 seconds later. Measured from the real incident: the structured session record appeared at t+20.4s and the chat tab at t+99.7s. That no longer reproduces on main. Five runs through the real create-worktree dialog on
The real defect is still live, and this PR does not touch it. And this PR introduced a regression. The lease renewer's native proven-dead eviction added here (absent on main, which handles only Two findings worth carrying forward rather than losing here:
Superseded by a focused PR against the launch-route degrade. Issue #19154 stays open until that lands. |

















ELI5
If a Claude chat's underlying process died at the wrong moment, Orca refused to close its tab — permanently, until you restarted the app. Orca already knew enough to close it safely; it just threw that knowledge away at one boundary. This makes every close path report what it saw, and lets the session owner decide.
What Changed
Every provider close path now reports its verdict. The exit ladder computes a three-valued observation — root
exited/live/processless, and a descendant treeexited/unverifiable/live. The acquisition path already classified it, but the published-session close and the acquisition-cancel path returned a barefalseregardless. Afalseconflates "root still alive" with "root exited, descendants unknowable", so the owner could not tell a retryable refusal from a session it was free to release — and the tab stayed unclosable. Both paths now report through the same classifier. Only the classes the owner can act on are raised; a genuinely unproven exit stays a retryablefalse, which the published-session cleanup contract depends on.Eviction, as the owner, decides. A root proven gone releases the writer even when its descendants are unknowable — the adapter keeps that cleanup — and a session that never spawned has nothing to stop. Exit genuinely unproven, or a descendant proven live, still aborts the eviction.
A dead native owner is reconciled. The periodic lease renewer only handled
runtimeKind: 'tui', so a dead native owner was renewed and refused forever. It now reclaims through the existing fence-checkedevictProvenDeadOwneron positive death evidence, without waiting out the deadline — matching the dead-TUI branch beside it. It never preempts an in-flight handoff: a suspend parks a live owner athandoffStage: 'preparing', so the renewer skips those and the eviction write is a compare-and-swap that raisesagent_session_checkpoint_stalerather than clobbering a handoff.A slow structured launch no longer looks like nothing happening — the creation panel is retained with an agent-specific "Starting Claude chat…" label, activation is skipped if you navigated away mid-launch, and it cannot activate twice.
Recovery copy no longer hardcodes one provider — it resolves through the existing exhaustive
TUI_AGENT_DISPLAY_NAMESmap.Why
The descendant snapshot is armed lazily and latches to
nullwhen the root exits before an admissible walk completes:Once null, the posix gate returns
'unverifiable', the ladder refuses to prove exit, and eviction fails atstop-provider-childon every retry. Nothing self-heals it: the unexpected-exit lifecycle only publishes on a successful tree proof, the lease renewer only handled TUI owners, and in-process reconciliation is gated onunreconciled, which the affected record does not have.The trigger is a race — the child must die before an admissible descendant walk lands. It is not "the child wrote no stderr"; stderr matters only because the first byte arms the walk.
This reuses vocabulary the codebase already has: the verdict type is documented as one that "is never collapsed into either neighbour", the classifier already existed, and the restart adjudicator already returns
evictedfor a pid-absent probe.Linked Issue
Fixes #19154
Visual Proof
Screenshots from rendered-Electron QA are attached in PR comments: structured chat as the sole initial surface, the transient "Starting Claude chat…" pending panel, and tab-close behaviour.
Testing
Red/green by ablation on this base, not merely green — each fix has a test that fails when that fix alone is removed:
closes a published session whose close reports root exit without descendant prooffailsstop-provider-childerrordoes not preempt a native owner handoff after the child stopsfailsreclaims a proven-dead native owner before its lease deadlinefailsstructured-agent-session-expired-claude.test.tsreconstructs the captured production record shape — native live claim,unreconciled: false, null death evidence and processless timestamp, expired deadline, leaf-less handle — against the real Claude adapter and record store, and asserts a live root and a known-live descendant are still rejected.Gates on this head: 137 tests across the directly affected suites,
pnpm tcexit 0, changed-code quality 0 new findings across 17 files,pnpm-lock.yamlunchanged.Live instrumentation — the race, observed
A dev build with temporary logging on the exit ladder showed both branches in a real app; kills within ~139ms of the child appearing latch
unverifiable, and by ~267ms the walk wins and exit proves cleanly.Honest limits. A previous QA pass at
909c747cdareproduced a permanently unclosable tab whosedeathEvidence.kindwaspid-absent; that is the case the close-verdict commit addresses, and a re-run against this head is in progress. Platforms exercised: macOS only.AI Disclosure
Review
The load-bearing judgement is the owner/killer split: the adapter reports what it observed, and eviction decides whether that frees the session. Check that fail-closed genuinely survives for a live root and a proven-live descendant, and that the retryable
falsecontract for a genuinely unproven close is intact — an earlier attempt made every path throw and broke it. Second place to look is the lease-renewer branch: it must not release on expiry alone, and must not preempt a handoff.Scope notes: the stray-terminal half of the original report was fixed separately by #19123 and this branch keeps main's narrower condition. #19122 was checked and does not cover this bug.
Agent skill upstream boundary
N/A — no agent skill or skill-runner behavior changed.