Skip to content

fix(native-chat): close a structured session whose provider child is gone - #19155

Closed
brennanb2025 wants to merge 4 commits into
mainfrom
brennanb2025/structured-chat-lifecycle
Closed

brennanb2025 wants to merge 4 commits into
mainfrom
brennanb2025/structured-chat-lifecycle

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

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 tree exited/unverifiable/live. 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 — 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-checked evictProvenDeadOwner on 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 at handoffStage: 'preparing', so the renewer skips those and the eviction write is a compare-and-swap that raises agent_session_checkpoint_stale rather 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_NAMES map.

Why

The descendant snapshot is armed lazily and latches to null when the root exits before an admissible walk completes:

if (!rootPid || exited()) { snapshot = exited() ? null : snapshot; return }
const rootExited = exited()
const tree = admissibleTree(captured, platform, rootExited)
if (tree) { snapshot = tree } else if (rootExited) { snapshot = null }

Once null, the posix gate returns 'unverifiable', the ladder refuses to prove exit, and eviction fails at stop-provider-child on 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 on unreconciled, 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 evicted for 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:

  • remove the published-close verdict report → closes a published session whose close reports root exit without descendant proof fails
  • remove the eviction catch → the captured-shape test fails with the reported stop-provider-child error
  • remove the handoff compare-and-swap → does not preempt a native owner handoff after the child stops fails
  • remove the deadline fast-path → reclaims a proven-dead native owner before its lease deadline fails
  • restore the hardcoded provider → 4 parameterized label cases fail

structured-agent-session-expired-claude.test.ts reconstructs 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 tc exit 0, changed-code quality 0 new findings across 17 files, pnpm-lock.yaml unchanged.

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.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Honest limits. A previous QA pass at 909c747cda reproduced a permanently unclosable tab whose deathEvidence.kind was pid-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 false contract 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.

@coderabbitai

coderabbitai Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 908a9afb-6533-4f26-a41e-932fc2d76ef3

📥 Commits

Reviewing files that changed from the base of the PR and between 909c747cdae82bb137e3ed15f34e5b4515154076 and 65f98a1.

📒 Files selected for processing (4)
  • src/main/claude/claude-structured-session-close.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-eviction.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-expired-claude.test.ts
  • src/renderer/src/i18n/locales/en.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/src/i18n/locales/en.json

Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Native 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 65f98

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)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning 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 failur… 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 …
Docstring Coverage ⚠️ Warning 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:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: closing structured native-chat sessions after the provider child exits.
Description check ✅ Passed The description is detailed and covers the change, rationale, linked issue, visual proof, testing, review guidance, and scope boundary. The template checklist is not reproduced, but the key required i…
Out of Scope Changes check ✅ Passed The changes remain related to the linked issue. They cover session eviction, native-owner reconciliation, handoff safety, structured-launch progress, activation behavior, and provider-specific recover…
Full details: Linked Issues check

Explanation

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 Coverage

Explanation

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.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: aa00019b-b2a0-4a96-9076-0e0ed3e01cc4

📥 Commits

Reviewing files that changed from the base of the PR and between 6fd03a7 and cfa85bf.

📒 Files selected for processing (14)
  • src/main/native-chat/agent-session-wire/structured-agent-session-eviction.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-expired-claude.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-lease-renewer.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/lib/pending-worktree-creation.ts
  • src/renderer/src/lib/worktree-activation-structured-commands.test.ts
  • src/renderer/src/lib/worktree-activation-surface-caller-wiring.test.ts
  • src/renderer/src/lib/worktree-creation-chat-setup.test.ts
  • src/renderer/src/lib/worktree-creation-flow-execute.ts
  • src/renderer/src/lib/worktree-creation-structured-recovery.ts
  • src/renderer/src/lib/worktree-creation-structured-session.test.ts
  • src/renderer/src/lib/worktree-creation-structured-session.ts
  • src/renderer/src/lib/worktree-creation-structured-unknown-outcome.test.ts
  • src/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.

Comment on lines +174 to +175
if (entry.startingChatAgent) {
return `Starting ${TUI_AGENT_DISPLAY_NAMES[entry.startingChatAgent] ?? entry.startingChatAgent} chat…`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Eviction accepts root-exit proof with unverifiable descendants — stop-provider-child now catches AgentSessionAcquisitionRootExitObservedError and 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 returns false (abort) and a known-live descendant yields AgentSessionAcquisitionExitUnprovenError (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 uncertain exits entry.
  • Lease renewer reconciles expired native owners — the new native branch gates eviction on leaseDeadlineAt <= now AND isProvenDeadProbe(probe), routing through the fence-checked evictProvenDeadOwner. Expiry alone, indeterminate, and identity-matched probes still fail closed (verified against isProvenDeadProbe/isProvenAliveProbe and the adjudicateAgentSessionRestart dispositions).
  • 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 through TUI_AGENT_DISPLAY_NAMES instead of hardcoding Codex.
  • Activation no longer yanks the user back — launchStructuredWorktreeSession disables activation on selection change and guards against double activation with if (!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.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Electron QA evidence (PR #19155 / #19154)

Isolated background instance (ORCA_BACKGROUND_LAUNCH=1, CDP 9334, renderer 5174, unique user-data). Identity: window.api.app.getIdentity() → Orca: brennanb2025/structured-chat-lifecycle, branch brennanb2025/structured-chat-lifecycle, repo root /Users/brennanbenson/orca/workspaces/orca/structured-chat-lifecycle.

Pending launch label (full-window, surrounding Orca chrome)

Starting Claude chat… — pending creation surface in the content panel and sidebar row:

starting-claude-chat.png

Starting Codex chat… — same surface, agent-specific copy:

starting-codex-chat.png

Navigate away during in-flight pending launch

Clicked the existing main workspace while the pending row still showed Starting Codex chat…. Content switched to main / Terminal 1; the pending sidebar row stayed. Store: activePendingCreationId=null, pending entry still status: creating.

navigated-away-during-pending.png

Real composer → structured native chat

New Workspace composer (Agent = Claude) with Chat UI + structured native chat enabled. Request agentLaunchRoute: structured-native-chat. Store spy: startingChatAgent: claude then ~1.16s later setActiveWorktree + removePending because we stayed on the pending surface. Landed on structured Claude Chat (Start a chat with Claude), not a TUI tab.

composer-claude-create.png

after-structured-create.png

Without those experimental flags, the same composer launched a Claude TUI (claude '--dangerously-skip-permissions'), which is the isolated-profile default:

after-real-claude-create.png

Console / runtime

No renderer errors from the pending-label or structured-launch path. Isolated-profile noise only: Linear CredentialDecryptionError (keychain), Chromium keychain userCanceledErr, Tooltip controlled/uncontrolled, xterm deadline warning, React Grab outdated, MaxListenersExceededWarning on BrowserWindow.

Gaps (not claimed verified)

  • Did not click away during the ~1.16s real startingChatAgent window, so “completion does not steal focus” is proven for staying on the pending surface (activation expected) and for navigating away from an injected pending panel (content stayed on main), but not for a real structured launch that completes after the user has already left.
  • Dead-session close after provider-root exit with unverifiable descendants was not exercised in the UI (backend lifecycle).
  • Real Codex structured launch not driven (Codex label was the shared pending panel).

QA worktrees qa-real-claude / qa-structured-claude were force-removed. Isolated instance PIDs stopped. Product worktree was not modified.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status: PASS

Recommendation: land, with the residual QA gaps below kept explicit.

  • HEAD cfa85bfc0fd634cb43367890595918bf41742406 matches the PR branch and the worktree is clean; pnpm-lock.yaml is unchanged.
  • A same-model xhigh review completed two full review rounds with no proven in-scope findings and no code changes required. Initial and final readiness passes both found P0: 0, P1: 0, P2: 0.
  • Verification passed across 11 exact Vitest files: 43 changed-test cases plus 90 adjacent-test cases. pnpm tc, changed-code quality, and git diff --check passed.
  • GitHub reports the PR mergeable/clean with 19 successful checks, 0 failed, and 0 pending.
  • Electron QA used an isolated background instance of the exact PR worktree. It visibly verified the agent-specific pending labels, a real Claude structured-chat create landing in Claude Chat, and click-away behavior on the pending surface. Screenshots and detailed evidence.

Residual risk, not a proven blocker:

  • The real Claude launch completed in about 1.16 seconds, so QA did not click away during that exact live window.
  • The dead-session close was covered by regression tests but was not reproduced end-to-end after killing a real provider root.
  • A real Codex structured launch was not driven; its agent-specific pending label was rendered through the shared pending surface.
  • Rendered QA was macOS-only; the diff does not change platform-specific, wire, mobile, dependency, or persisted-schema contracts.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Follow-up commit 3f51510d7a, pushed after the review pass on cfa85bfc0f. Added rather than amended so the earlier verdict stays traceable to the SHA it was made against.

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: isProvenDeadProbe still requires exit-observed, pid-absent, or identity-mismatch, and an indeterminate or identity-matched probe continues to renew the lease rather than release it.

Verification: new test reclaims a proven-dead native owner before its lease deadline, red/green confirmed by ablation — restoring the deadline condition fails it. Suite is 7 tests, up from 6. Gates on 3f51510d7a: 4 files / 30 tests passing, pnpm tc exit 0, changed-code quality 0 new findings across 13 files, pnpm-lock.yaml unchanged.

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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Native eviction no longer waits for lease expiry — structured-agent-session-lease-renewer.ts drops the leaseDeadlineAt <= now gate from the native branch, so a proven-dead native owner (exit-observed / pid-absent / identity-mismatch) is evicted immediately through the fence-checked evictProvenDeadOwner, matching the existing dead-TUI-owner branch.
  • Added a red/green test for pre-expiry reclamation — structured-agent-session-expired-claude.test.ts proves a pid-absent owner is released before its deadline; the claimStatus: '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.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@brennanb2025
brennanb2025 force-pushed the brennanb2025/structured-chat-lifecycle branch from 3f51510 to a1d3371 Compare September 7, 2026 18:15
@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

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.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (89 commits) and force-pushed once: 3f51510d7a → a1d337145f. Both commits replayed cleanly with no conflicts; gates re-run on the new base (4 files / 30 tests, pnpm tc exit 0, changed-code quality 0 new findings, lockfile unchanged).

The force-push was deliberate and batched — an earlier review pass approved cfa85bfc0f, and rewriting that lineage costs traceability, so I did it once rather than pushing a rebase and then a body fix separately.

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:

  • fix(native-chat): settle structured chat turns stranded by a restart #19122 does not cover this. It adds a settlement-pending disposition for restart adjudication of journal settlement latches. It does not touch eviction, the exit-proof ladder, acquisition release, or the lease renewer. This fix is not redundant.
  • The stuck end state still has not been reproduced live, and the body now says so plainly with the manual-testing box left unchecked. Live attempts all killed the child during or just after acquisition, where acquisition-failure settlement releases the lease cleanly. The reported incident died after full acquisition — a path the rig never exercised. Mechanism proven live; end state proven at test level only.

CI is re-running against the new head.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

New commit 909c747cda — a real defect the re-review found in the preceding commit, plus its fix.

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 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 deadline had been masking that window; removing it made the race immediate.

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 agent_session_checkpoint_stale instead of clobbering the handoff.

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 handoffStage === null check leaves the regression test green (the CAS still catches it), while removing the CAS fails it. Both are kept deliberately — the renewer check avoids a pointless mutation attempt, the CAS closes the TOCTOU gap between scan and write.

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 max-lines gate — the store was exactly at the cap — and no disable was added.

Gates on this head: 5 files / 98 tests passing, pnpm tc exit 0, changed-code quality 0 new findings across 16 files, pnpm-lock.yaml unchanged. PR Checks was green on the parent commit a1d337145f, confirming the earlier TS1117 failure was a merge-ref artifact from main and not this branch.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 — evictAgentSessionOwner accepts an optional expectedHandoffStage and throws agent_session_checkpoint_stale when the stage has drifted since the scan; evictProvenDeadOwner threads it through, checked against the freshly-read record inside the serialized transact.
  • Red/green coverage for the race — the new renewer test starts a handoff mid-probe (transitionHandoff to preparing) and asserts the eviction is refused and the handoff completes cleanly via stopStoredAgentSessionOwnerForHandoff.

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.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Rendered-Electron manual QA — head 909c747cda

Rig: isolated dev instance from this worktree (own ORCA_DEV_USER_DATA_PATH, own renderer port 5191, own CDP port 9361, --use-mock-keychain), driven only through CDP/Playwright against the real UI. Renderer ownership proven before capture (/@fs returns 200 for this worktree and 403 for a peer worktree, and the 200 body contains this branch's new startingChatAgent symbol). Flags on: experimentalNativeChat, openAgentTabsInChatByDefault, experimentalStructuredNativeChat. Scratch git repo, five workspaces created with Claude as the agent through the real "Create worktree" dialog.

Everything below labelled Observed was seen on screen or read out of the live store. Nothing here is inferred.


1. Structured Claude chat is the initial surface, no stray bare terminal — Observed ✅

Creating a workspace with Claude opens a single Claude Chat tab. The active worktree's tab list held exactly one tab (structured-agent-session-claude_…) and the rendered page contained no Terminal 1. Same result on all five workspaces I created (a–e).

initial surface

2. Pending panel retained with the agent-specific label — Observed ✅

Caught live during the launch. Both the sidebar row and the pending panel read "Starting Claude chat…", and the pending entry carried startingChatAgent: "claude" with phase: "creating". The label was present from ~430 ms to ~2.3 s after clicking Create.

starting claude chat

3. Navigating away mid-flight does not yank you back — Observed ✅

With "Starting Claude chat…" on screen (structured launch in flight), I clicked the main workspace row. Polled activeWorktreeId every 400 ms for 20 s, through the pending entry clearing and the new workspace's structured tab being created: it stayed on main for the entire window — zero switches to qa19155-claude-d. The new workspace still got its structured tab, just without stealing focus.

no yank

Scope note on this one: I deliberately tested the window after the structured launch begins, which is what the new initialSelection guard covers. Navigating to another workspace before the launch starts still activates on completion — that is the pre-existing shouldActivateOnCompletion behaviour documented in worktree-creation-flow-execute.ts ("selecting another workspace means the user still expects this task-launch handoff"), not something this PR changes.

4. Closing a structured chat tab — Observed ✅ on the normal path, with one reproducible failure ⚠️

Normal path works. Fresh workspace qa19155-claude-e: single Claude Chat tab, clicked the tab's ✕, tab gone in 1.2 s, no error toast, tab list went 1 → 0. Workspace qa19155-claude-b closed the same way in 1.5 s.

before close after close
open closed

But one workspace could never be closed. qa19155-claude-a refuses every close attempt with a toast, and the tab stays:

Could not close this chat session
agent session eviction failed at step "stop-provider-child" for claude_83f95274_5ebf_4e55_974a_f84155e91270

close failure

Tried 3 times, including ~3 minutes after lease.leaseDeadlineAt had passed. Every attempt failed identically and the tab count stayed at 1. No live claude child existed for that workspace at the time (checked by PPID against my dev Electron main — only the still-open workspaces c and d had live children).

Diffing the two session records in agent-sessions.json gives a clean discriminator between the workspace that closes and the one that will not:

field a (close refused) b (closed fine)
lease.deathEvidence.kind pid-absent exit-observed
lease.deathEvidence.detail "recorded pid absent on host" "the last surface holding this session…"
lease.settlementRetryRequired true absent
lease.settlementRetryId restart-eviction:claude_83f95274_… absent

So the tab is closable when the child's death is exit-observed, and permanently stuck when the only evidence is pid-absent. That is adjacent to what this PR does — the new catch in structured-agent-session-eviction.ts accepts AgentSessionAcquisitionRootExitObservedError, i.e. root-exit-observed proof — but this case arrives with pid-absent evidence and is not accepted, so stop-provider-child throws "provider child exit was not proven" forever and the user has no way to close the tab.

I did not establish whether this predates the PR. I only exercised this head; I did not build and re-run the same flow on main, so I am not claiming it is a regression. Flagging it because it lands squarely in this PR's subject area and is a user-visible dead end.

Not covered

  • The PR's core eviction end state (root-exit-observed acceptance when a provider child died and descendants can't be verified) — not reproduced, per the agreed scope limit. I did not try to manufacture it and did not touch product code.
  • "Starting Codex chat…" — not tested; I only exercised the Claude agent.
  • Nothing was committed, pushed, or rebased; the branch is untouched.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

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 909c747cda, four closed normally in ~1.2–1.5s with no toast. One did not — three attempts, including past the lease deadline, all produced:

Could not close this chat session
agent session eviction failed at step "stop-provider-child"
for claude_83f95274_5ebf_4e55_974a_f84155e91270

The build genuinely contained the fix. Verified from the compiled bundle rather than assumed — the eviction step reads try{ n = await t.call(...) } catch(e){ if(!(e instanceof u7)) throw e; n = !0 }, u7 being the minified AgentSessionAcquisitionRootExitObservedError, and out/main was built after both commits.

Why it still failed. The fix only handles the adapter throwing that error. claude-structured-session-close.ts has two paths that return false instead of throwing:

  • :77 — if ((await session.connection.close()) !== true) return false (live-session path)
  • :242 — if (!(await cancelClaudeAcquisitionAttempt(attempt))) return false

A false return falls through to if (n !== true) throw Error('provider child exit was not proven') — the same user-visible failure by a different branch.

Two independent discriminators point at the same place. The QA's: failing session has lease.deathEvidence.kind = 'pid-absent' plus settlementRetryRequired: true, while every session that closed has 'exit-observed'. Mine: the failing record carries a leaf-less handle (-empty, never produced a turn).

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, finalizeClaudePublishedSession should throw AgentSessionAcquisitionRootExitObservedError — exactly as releaseClaudeAcquisition already does — rather than returning false. One boundary then covers both paths, and a genuinely unproven exit still returns false and still fails closed.

Blanket-accepting false at the eviction step would be wrong: false also means legitimately-unproven exit, which must keep failing closed.

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.

Merge Sim added 4 commits September 7, 2026 13:44
…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.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/structured-chat-lifecycle branch from 909c747 to 65f98a1 Compare September 7, 2026 20:46

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 a false close through claudeAcquisitionCleanupError, raising AgentSessionAcquisitionRootExitObservedError / AgentSessionPreSpawnError so the owner can decide, while keeping a genuinely unproven exit a retryable false.
  • structured-agent-session-eviction.ts — stop-provider-child additionally catches AgentSessionPreSpawnError (processless root = nothing to stop) alongside the existing RootExitObservedError catch.
  • structured-agent-session-expired-claude.test.ts — new regression test drives the published-session close() === false path with exitVerdict { root: 'exited', tree: 'unverifiable' } and asserts eviction succeeds; it would fail against the prior bare-false code.

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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

new Error('provider close unproven')
)
if (!(reported instanceof AgentSessionAcquisitionExitUnprovenError)) {
throw reported

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Rendered-Electron QA — head 65f98a1e59 — FAIL: the permanently-unclosable case still reproduces

Isolated dev instance built from brennanb2025/structured-chat-lifecycle @ 65f98a1e59, own ORCA_DEV_USER_DATA_PATH, own renderer port (5191) and CDP port, experimentalNativeChat + openAgentTabsInChatByDefault + experimentalStructuredNativeChat on. Renderer ownership proven before every capture (an untracked marker file under /@fs returns 200 with real content from this worktree vs 403 for a peer worktree; app.getIdentity().devRepoRoot = this worktree; single listener on 5191; CDP port owner is this worktree's out/electron-dev bundle). The running out/main/index.js contains this commit's new strings (provider close unproven, acquisition cancel unproven, AgentSessionPreSpawnError), so the build under test is the fix.

20 structured Claude workspaces created through the real Create worktree dialog across three app runs; every close driven through the real Close tab Claude Chat button.

Headline

OBSERVED — one workspace is still permanently unclosable at this head, with the identical failure the previous pass reported. qa19155-r3, created in an ordinary run of six fresh workspaces, refused 6 close attempts (including ~9 minutes past lease.leaseDeadlineAt) with:

Could not close this chat session
agent session eviction failed at step "stop-provider-child" for claude_4d46e8bf_4ebc_48ea_bd19_ac9f6a1ea31c

06-r3-final-refusal.png

Its lease at the time of every refusal (from this instance's agent-sessions/agent-sessions.json):

"deathEvidence": { "kind": "pid-absent", "detail": "recorded pid absent on host", "observedAt": 1788815722837 },
"settlementRetryRequired": true,
"settlementRetryId": "restart-eviction:claude_4d46e8bf_4ebc_48ea_bd19_ac9f6a1ea31c:2",
"claimStatus": "released", "runtimeFence": 2, "ownerProcess": null, "unreconciled": false

As in the previous pass, logs/main.trace.ndjson contains zero evict / stop-provider-child lines — the lease record is the only evidence.

The pid-absent case is only partly fixed

I did produce pid-absent sessions naturally, seven of them, and all seven closed cleanly. But the one that refuses also carries settlementRetryRequired: true. Across the 8 pid-absent samples the split is exact:

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.

01-six-workspaces-structured-chat.png

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.

02-focus-not-yanked.png

(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 on root === 'exited' && tree === 'unverifiable' (AgentSessionAcquisitionRootExitObservedError), and keeps everything else a retryable false. I did not observe exitVerdict directly, so I cannot say whether qa19155-r3 falls into the deliberately-retryable ExitUnproven class 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 unverifiable shape the new regression test drives was never produced live here.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Follow-up: the latched session is also unwritable, and reveal/attach does not clear the latch

Same instance, same head 65f98a1e59, same session claude_4d46e8bf_4ebc_48ea_bd19_ac9f6a1ea31c (qa19155-r3). Testing whether lease.settlementRetryRequired is the actual blocker and whether attaching clears it.

OBSERVED — the latch survives reveal. With the workspace deselected, the lease read settlementRetryRequired: true. I then selected the workspace so its Claude Chat pane mounted (composer rendered) and re-read the record at +5 s, +15 s and +30 s. Unchanged every time:

{"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 say ok through the real composer produced a rendered failure and spawned no provider child (no stream-json child of this dev Electron main appeared at any point):

Message was not sent.
The session has no live owner to accept writes. [Retry]

07-r3-send-attempt.png

Clicking Retry produced the same error; the lease was still settlementRetryRequired: true at fence 2 afterwards. A close attempt after all of that failed again with the same stop-provider-child toast — 7 refusals total now.

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" reading

The seven pid-absent sessions that closed cleanly were not sessions whose latch got cleared — they never carried the latch. Read straight after the crash-restart, before I touched any of them, all seven were identical:

{"claimStatus":"released","runtimeFence":2,"ownerProcess":null,
 "deathEvidence":{"kind":"pid-absent","detail":"recorded pid absent on host","observedAt":1788815299243}}

with settlementRetryRequired absent. Each was then selected (mounting its chat pane) and closed — same interaction sequence I applied to qa19155-r3, which stayed latched throughout. On this evidence, reveal is not what separates the two groups; carrying the latch is.

Could not reproduce the latch on demand

Three fresh workspaces (qa19155-x1/x2/x3) created through the real dialog, each with its provider child SIGKILLed the instant it appeared (PPID-verified against my own dev Electron main). All three settled to deathEvidence.kind: "exit-observed", settlementRetryRequired absent, and their tabs went away on their own. Killing the child at spawn does not produce the latch, so I have no on-demand recipe — the only latched session I have is the one that arose naturally, 1 in 6 in an ordinary creation burst, with no app restart between its creation and its first refused close.

Not established

  • I did not read connection.exitVerdict, and I did not instrument evictAgentSessionOwner, so I cannot confirm from the running app which throw the eviction actually takes. The correlation is clean across 8 pid-absent samples (7 unlatched → close; 1 latched → 7 refusals), but this is observed behaviour, not a traced mechanism.
  • I did not test closing a restored tab without opening it first, because the premise did not survive: opening qa19155-r3 repeatedly never cleared its latch.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

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 aac38d698f, with the reporter's exact settings and a repo carrying a setup script:

reported incident main today
structured record exists 20,400 ms 303–483 ms
chat tab focused 99,700 ms 1,037–1,255 ms
initial surface focused bare shell Claude Chat focused, Setup beside it, no bare shell

agentLaunchRoute was captured as structured-native-chat. #19123 and #19753 closed the warm path.

The real defect is still live, and this PR does not touch it. readLocalRuntimeCapabilitiesOrUnknown() returns null until the renderer hydrates, and structured-native-chat-launch-route.ts treats null capabilities as runtime-capability-unknown and degrades the route to legacy-native-chat. A worktree created in that window — immediately after app launch — activates with the setup payload and no surface-ownership flag, seeding a focused bare terminal while the chat arrives later from a retry. That matches the reported incident precisely, and it is what a fix should target.

And this PR introduced a regression. The lease renewer's native proven-dead eviction added here (absent on main, which handles only runtimeKind: 'tui') is store-only: it updates the lease record without informing the wire layer, so the in-memory session keeps hasProviderChild: true for a child that is gone. Close then fails at stop-provider-child, and reveal, resume and sends are all short-circuited by the stale flag. A baseline run on plain main was 8/8 clean; this branch produced a permanently unclosable tab. Forensics on the stuck session's journal showed a single session_created row and zero settlement rows, proving the settlement retry was never invoked rather than failing.

Two findings worth carrying forward rather than losing here:

  • Reference implementations settle transcript history at read, not at teardown — an unpaired tool call becomes aborted/interrupted when the next reader loads history. None of them blocks a user-visible close on a durable "ended" write. Orca's teardown-time coupling is the inverse, and is worth revisiting separately.
  • The close path not settling a pending journal obligation (while attach, reveal and handoff all do) is a real inconsistency, but on its own it does not unblock the tab.

Superseded by a focused PR against the launch-route degrade. Issue #19154 stays open until that lands.

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.

Structured Claude chat session can never be closed: eviction fails at stop-provider-child

1 participant