Skip to content

fix(orchestration): release workers whose exited terminal is gone - #42264

Merged
AmethystLiang merged 12 commits into
mainfrom
brennanb2025/hot-worker-release-19166
Nov 24, 2026
Merged

AmethystLiang merged 12 commits into
mainfrom
brennanb2025/hot-worker-release-19166

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Problem

A finished worker whose terminal is gone (tab closed, Orca restarted, terminal crashed) and whose output had not been recorded could not be released. orca orchestration worker-release answered release_unknown every time, even when Orca could prove the worker's exact process had exited, and startup recovery retried it forever as release_pending (#19166).

The cause: a release request moves the worker's row to "requested", and a requested row could settle only once its output was recorded. Output was recorded only by capturing it from the live terminal, so once the terminal was gone nothing could satisfy that rule.

What this changes for users

  • A worker whose exact process is proven to have exited now releases (state: released, processAction: none) from worker-release, retries, auto-release and startup recovery. This path stops no worker process: it settles the record, and a release from the retained path then closes the worker's bound terminals as a normal release does (those may run other processes).
  • Its output stays findable for local sessions (and WSL sessions saved with their transcript path). Orca records where the worker's conversation lives from the newest session it saved while the worker ran, so worker-read keeps reading the original transcript. When that can't be located safely (no saved session, an SSH host, a WSL session saved without its transcript path), the output is recorded as unavailable.
  • Orca is stricter about what counts as "exited". A missing process is no longer read as exited when local terminals are still starting, when Orca fell back to in-process terminals that never ran the worker, when the worker was recorded with an older identity format, when another daemon generation still lists the same terminal ID, or when a local daemon Orca cannot list might own it: one held for a newer version after a downgrade, or an older one whose pid record names a live process, cannot be read, or is not a whole record naming a positive process ID. The exit check only reads these records. Startup discovery, which cleans them up, used to delete an older record whenever its socket was gone and the pid it could pick out looked dead; it now deletes one only when the record is whole and its process is gone, so doubt survives until the check sees it. In those cases release keeps a stopped or abandoned worker retained, and a follow-up to a finished worker whose terminal is gone is refused with worker_unverifiable instead of reopening it (reopening could run the worker twice). The startup sweep that releases older stopped workers' rows uses the same stricter check.
    • Known trade-off: an older-format worker that worker-release used to settle through the retained path now stays retained. Older-format identities come only from terminals whose provider reported no process incarnation, such as workers started on releases from before about August 2026.
  • A slow terminal-service start can no longer stall release recovery: all exit checks share one bounded wait (the existing 3 s inventory budget) per startup; after it, a missing process stays unproven and recovery retries later.
  • A keep-open, a transfer to a follow-up worker, or a release that lands while Orca is checking the process now wins, and the receipt reports the row as it is afterwards (for example retained with user_kept). Of two releases of the same worker, racing or joined onto one check, only one reports released; the other reports already_released and repeats no completion effects.
  • A release only ever acts on the row its own dispatch owns. If the worker's terminal was kept and handed to a new worker meanwhile, the earlier release (including startup recovery's bookkeeping and the sweep's batched release) reports retained with ownership_transferred and leaves the new owner's row, hold and output record untouched; the two releases never share a check or a receipt.
  • A Keep open that lands while an automatic close is under way keeps the worker: whether the close succeeded, was unconfirmed or failed, the receipt reports retained (user_kept) along with the close already attempted, and no release is announced. If the user then allows auto-close and a new release is requested while that close is still in flight, a transient close failure leaves the new request release_pending for recovery to finish.
  • The startup sweep of older stopped workers records the worker's saved conversation, like worker-release does, when the terminal no longer names one, so worker-read keeps reading it after release. An output record that already exists is kept as is.
  • A database error while recording a terminal exit no longer stops later exit listeners from running; Orca just treats that exit as unproven.

How it works

  • settleDeadWorkerTerminalRelease settles a proven exit whatever the request state. In the same transaction it rechecks the row the caller saw before its awaited check (owner, host, release state, reason), keeps any output record that exists, and otherwise stores the reference derived from saved state. Only the owning dispatch writes that reference. The release RPC's retained path and release completion's missing-terminal branch both go through settleProvenExitedWorkerTerminal.
  • inspectTerminalProcessIncarnationLiveness (release, follow-up placement, remote attachments, the stopped-worker sweep) reads the local inventory from the provider that owns local terminals after startup, listing every daemon generation under a terminal ID (not only the routed one). A missing process counts as exited only for current identities whose owner can vouch for them; the in-process provider vouches only for exits it observed, held only while the worker still awaits release. If a local daemon outside that inventory may still be running, the check answers unverifiable.

Performance

Assessed from the final diff; the numbers below are operation counts, not measured user-visible latency.

  • Exit proof listing: still one logical inventory per host per sweep (the existing per-sweep cache is kept; a daemon inventory asks each of its adapters), and one per release call otherwise. The listing now includes unrouted daemon generations, which adds only the rows those extra generations already hold.
  • Unlisted-daemon guard: when a daemon provider answers, each local exit-proof listing first reads the daemon runtime directory asynchronously, then per older-protocol pid file present (normally none) reads it asynchronously and runs a small synchronous parse and signal-0 probe. No directory is created or modified. Startup discovery's older-record check moves from a synchronous to an asynchronous read.
  • Startup wait: the startup promise gets one subscription per startup, shared by all checks; once the existing 3 s budget is spent, later checks read a cached verdict (each inventory still has its own listing deadline). In the author's synthetic 100k-call run against a startup that never settles, this made 1 subscription instead of 100,002; that is an operation count, not latency.
  • In-process exit evidence (only when Orca runs in-process terminals): each local terminal exit, worker or not, runs one indexed lookup on process_incarnation, and while proofs are held up to two more lookups to drain stale ones, so up to 3 small indexed queries per exit. Each exit check that consults the evidence adds the same up to 3. Proofs are added only for exits of unreleased local worker rows; a proof whose row was since released stays until the cleanup cursor reaches it (two per exit or check), so the set grows with worker exits, not with all terminal exits. No new polling; one unref'd timer per startup.
  • Sweep: for each candidate proven exited, the same saved-session capture and archive write as before, plus, when the pane names no session, one read of the row's saved session JSON, before the one batched settle.
  • Settlement: the same single BEGIN IMMEDIATE transaction, plus one primary-key read to detect a release another call already made; release state writes gained an owner condition on the primary-key update; the proven-exit path adds at most one archive row insert. The output reference is derived from the row's saved session JSON; no transcript or file I/O.

Not covered

  • An older-daemon pid record that is unreadable or torn keeps local exit proof declined until the record is removed (Orca does not delete a record it cannot read).
  • Workers recorded without a process identity, workers on SSH hosts, and remote/paired attachment releases whose terminal is missing still end release_unknown or retained. This partly resolves [Bug]: worker-release can never reclaim a settled worker whose PTY vanished (retained/identity_unproven on every retry) #19166.
  • A reopened follow-up worker that dies before its own pane reports a session points at its predecessor's conversation (same worker lineage, recorded without a process fence).

Credit

This supersedes the earlier community fix for the same dead end in #24515 by giloh728, whose expected-row check this keeps. Co-authored in the commit trailer.

Part of #19166.

Files Added Deleted Net
Test 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1718 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1718
Prod 27 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1091 $\color{#cf222e}{\Huge{\mathbf{−}}}$​179 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​912

@brennanb2025
brennanb2025 marked this pull request as ready for review November 14, 2026 03:25
@coderabbitai

coderabbitai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

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
Walkthrough

The runtime now records local PTY exits and exposes local process inventories with provider-ownership information. Worker terminal liveness checks use that information and recorded exit evidence to decide whether an absent process is proven exited. Release handlers use shared settlement helpers, preserve current retained or transferred state when proof does not release the resource, and record archive metadata when settlement succeeds. Tests cover inventory startup, liveness, archive derivation, and release state changes.

Severity of issue fixed: Medium

Merge Risk: Moderate · previous review 0f929

Releasing a worker after its terminal disappears can wrongly treat a live terminal as exited when a legacy daemon's pid file cannot be read. Make unreadable or invalid pid records count as possibly alive before merging. Other release paths retain the worker when proof is missing.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Linked Issues check Inconclusive [#19166] Implementation evidence at the reviewed head supports the core objectives. In the release path, settleProvenExitedWorkerTerminal (worker-release-proven-exit.ts) settles a row only when the … Provide the remainder of src/main/runtime/rpc/methods/orchestration/worker/release/worker-release-exit-proof.test.ts (or the test file that contains it) and confirm that a regression test exists. The test must set dispatch authority to null…
Passed Passed checks: 3 passed

Check name Status Explanation
Title check Passed The title "fix(orchestration): release workers whose exited terminal is gone" matches the main change. The PR lets release settle a worker whose exact process is proven exited when its terminal is gon…
Out of Scope Changes check Passed Each changed area supports the exit-proof release path described in #19166. The changes cover: the in-process exit observer and its evidence store; the local inventory API used for exit proof, with it…
Description check Passed The description is thorough and follows the template's main sections. It explains the problem, what changes for users, the mechanism, and performance, and it gives a risk-relevant trade-off. It also l…
Full details: Title check

Explanation

The title "fix(orchestration): release workers whose exited terminal is gone" matches the main change. The PR lets release settle a worker whose exact process is proven exited when its terminal is gone and no output was recorded. The changeset covers the release settlement path, exit proof, and output-reference derivation that support this. The title is specific and readable.

Full details: Out of Scope Changes check

Explanation

Each changed area supports the exit-proof release path described in #19166. The changes cover: the in-process exit observer and its evidence store; the local inventory API used for exit proof, with its bounded startup wait; liveness classification that takes absenceProvesExit; release settlement and retained-state rereads; output-reference derivation from saved session state (needed to record output when the terminal is gone); the worker_unverifiable follow-up message; the daemon unlisted-session check used by inventory proof; the includeUnrouted contract documentation; and the stopped-worker sweep that uses the same stricter check. The PR description and the raw summary link each of these to the same exit-proof behavior. No change was found that is unrelated to the linked issue.

Full details: Description check

Explanation

The description is thorough and follows the template's main sections. It explains the problem, what changes for users, the mechanism, and performance, and it gives a risk-relevant trade-off. It also lists known gaps and credits a prior fix. Several template items are missing or not filled in. The ELI5 section is absent. The Linked Issue section says "Fixes #" with no number, though the body references #19166 as a partial fix. The Visual Proof section has no content or N/A reason, even though the change affects user-visible receipts and error text. The Testing section has no checkboxes ticked and no description of manual or platform testing. The Risk section has no Level value and no revert guidance. The Review and Notes sections are empty, and the Checklist is not ticked. The description does explain what changed and why, and it covers the mechanism and performance in detail. Because most critical content is present, the check passes overall, but the gaps below should be fixed before merge.

Full details: Linked Issues check

Explanation

[#19166] Implementation evidence at the reviewed head supports the core objectives. In the release path, settleProvenExitedWorkerTerminal (worker-release-proven-exit.ts) settles a row only when the recorded process incarnation is proven exited. It writes released with processAction: none and does not close a process. Live and unverifiable cases stay retained. Reconciliation and worker-release tests in worker-release-exit-proof.test.ts cover these paths. The issue also requires a regression test for the runtime condition where dispatch authority is null while terminal inspection fails. In the visible part of worker-release-exit-proof.test.ts, getOrchestrationDispatchAuthority returns a non-null authority for term_worker in setup(), and the reviewed portion does not show a null-authority case. The test file was truncated at 16000 bytes, so later tests are unknown. The null-authority regression test therefore cannot be confirmed. The PR description also states that workers without process identity, SSH workers, and remote/paired attachments remain unresolved. That matches the issue's stated scope caveats and is not counted as a gap for this assessment.

Resolution

Provide the remainder of src/main/runtime/rpc/methods/orchestration/worker/release/worker-release-exit-proof.test.ts (or the test file that contains it) and confirm that a regression test exists. The test must set dispatch authority to null while terminal inspection fails, and must assert that a proven-exited worker releases with processAction none and that a live or unverifiable worker stays retained. If no such test exists, add it.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@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

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 67bdee43-cc50-4ea9-ae32-3dba4649f52c
Commits

Reviewing files that changed from the base of the PR and between 4d005cf and 3f58497.

Files selected for processing: 21

  • src/main/ipc/pty/runtime/controller.ts
  • src/main/ipc/pty/runtime/in-process-exit-observer.ts
  • src/main/ipc/pty/runtime/inventory-operations.test.ts
  • src/main/ipc/pty/runtime/inventory-operations.ts
  • src/main/providers/local-pty/local-pty-provider-shutdown.test.ts
  • src/main/runtime/orchestration/db/worker-terminal/worker-terminal-release.ts
  • src/main/runtime/orchestration/terminal-authority/release/in-process-worker-exit-evidence.test.ts
  • src/main/runtime/orchestration/terminal-authority/release/in-process-worker-exit-evidence.ts
  • src/main/runtime/orchestration/terminal-authority/release/worker-terminal-process-liveness.test.ts
  • src/main/runtime/orchestration/terminal-authority/release/worker-terminal-process-liveness.ts
  • src/main/runtime/orchestration/terminal-authority/structured-sessions/structured-worker-at-rest.test.ts
  • src/main/runtime/orchestration/workers/archives/worker-output-archive.test.ts
  • src/main/runtime/orchestration/workers/archives/worker-output-archive.ts
  • src/main/runtime/rpc/methods/orchestration/worker/follow-up/worker-follow-up-choice.ts
  • src/main/runtime/rpc/methods/orchestration/worker/release/worker-release-completion.ts
  • src/main/runtime/rpc/methods/orchestration/worker/release/worker-release-proven-exit.ts
  • src/main/runtime/rpc/methods/orchestration/worker/release/worker-release-recovery.test.ts
  • src/main/runtime/rpc/methods/orchestration/worker/worker-release.ts
  • src/main/runtime/terminal/layout/terminal-resize-listeners.ts
  • src/main/runtime/terminal/lifecycle/runtime-pty-controller-contract.ts
  • tests/e2e/orchestration-worker-settlement-release-cli.spec.ts

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

@AmethystLiang
AmethystLiang force-pushed the brennanb2025/hot-worker-release-19166 branch from 06d4f7f to fe1aae6 Compare November 15, 2026 03:19

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

Nitpick comments: 1

src/main/runtime/rpc/methods/orchestration/worker/release/worker-release-recovery.test.ts: 1

210-212: Trivial · Maintainability & Code Quality · Quick win

Cover the null-authority case in the proven-exit release tests.

goneAfterSettle() makes showTerminal reject, but it does not change the dispatch-authority stub that setup() installs. As a result, the five proven-exit tests that call it still run with non-null authority for term_worker. The null-authority combination appears only in the reconciliation test at lines 173-196, not on the orchestration.workerRelease proven-exit path. The linked issue requests coverage for that combination.

Add a dedicated proven-exit test that makes getOrchestrationDispatchAuthority return null for term_worker while showTerminal rejects. Assert that the release reaches state: 'released' with processAction: 'none'. Scope the null override to that test. Setting it inside the shared goneAfterSettle() helper would change the premise of all five tests that use it.

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f4c93c23-a1a5-4c83-a217-f8dbe11beb5b
Commits

Reviewing files that changed from the base of the PR and between 06d4f7f and fe1aae6.

Files selected for processing: 4

  • src/main/ipc/pty/runtime/inventory-operations.test.ts
  • src/main/ipc/pty/runtime/inventory-operations.ts
  • src/main/runtime/rpc/methods/orchestration/worker/release/worker-release-completion.ts
  • src/main/runtime/rpc/methods/orchestration/worker/release/worker-release-recovery.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

@AmethystLiang
AmethystLiang force-pushed the brennanb2025/hot-worker-release-19166 branch 2 times, most recently from 6f5b50f to 0f92997 Compare November 24, 2026 02:20

@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

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 019ba076-dbe6-4fc6-b1c1-458afaa9ce47
Commits

Reviewing files that changed from the base of the PR and between 6f5b50f and 0f92997.

Files selected for processing: 10

  • src/main/daemon/providers/routing/daemon-unlisted-session.test.ts
  • src/main/daemon/providers/routing/daemon-unlisted-session.ts
  • src/main/ipc/pty/runtime/in-process-exit-observer.ts
  • src/main/ipc/pty/runtime/inventory-operations.ts
  • src/main/providers/pty/provider-contract.ts
  • src/main/runtime/orchestration/db/worker-terminal/worker-terminal-release.ts
  • src/main/runtime/orchestration/terminal-authority/release/in-process-worker-exit-evidence.test.ts
  • src/main/runtime/orchestration/terminal-authority/release/in-process-worker-exit-evidence.ts
  • src/main/runtime/rpc/methods/orchestration/worker/release/worker-release-completion.ts
  • src/main/runtime/rpc/methods/orchestration/worker/release/worker-release-exit-proof.test.ts

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

AmethystLiang and others added 12 commits November 24, 2026 10:09
A finished worker whose terminal was closed or lost could never be
released: the release request demanded an output record that only the
live terminal could provide, so worker-release answered release_unknown
and startup recovery retried forever, even after Orca proved the exact
process had exited.

A proven exit now settles the release whatever its request state,
rechecking the row the caller saw and recording where the worker's
output lives from what Orca saved while it ran. The exit check now waits
for local terminal startup, trusts only the provider that owns local
terminals, and no longer reads an older identity format or an
unobserved in-process absence as an exit.

Co-authored-by: giloh <[email protected]>
…ceipt current

A startup that never settles no longer collects one reaction per exit
proof: the startup promise gets one subscription per startup, and once
its shared budget is spent later proofs read the cached verdict.

A retained worker-release whose exit proof awaited now reports the row as
it is afterwards, so a keep-open, transfer or release that landed during
the proof is what the receipt says.
The routed daemon listing shows one generation per PTY id, so a worker
still running in another generation under the same id read as exited.
Exit proof now lists every generation and still refuses an incomplete
inventory.
…nd settle once

A local daemon held for a newer protocol, or an older one still alive
that no adapter reaches, lists nothing Orca can read; exit proof now
reads that as unverifiable. Of two racing releases only the one that
makes the transition reports released; the other reports already
released and repeats no completion effects. Recording an in-process
exit no longer throws into the provider's listener loop, and an
unreadable database vouches for nothing.
…hread

The exit-proof guard for daemons outside the inventory runs on Electron
main for every local exit check, so it now lists the runtime directory
and reads older pid files with node:fs/promises.
… that may still run

Exit proof reads "no older daemon" as absence, so only a missing pid
file or a missing process may say the daemon is gone; an unparsable
record or any other read error now keeps the proof declined. Legacy
discovery keeps the lenient check it uses to delete corrupt records.
…der-daemon doubt

Startup discovery deletes an older daemon's pid record only when the
daemon is provably gone, and a record naming no positive pid counts as
a daemon that may still run, so exit proof keeps declining. The
stopped-worker sweep records the saved conversation when the pane names
none. Joined releases share one check but only one reports released.
A release is keyed and fenced to its own dispatch's custody: after a
transfer it reports ownership_transferred, never the new owner's state,
and a former owner can no longer settle its successor's row.
…rminal

In the runtime a terminal that no longer resolves has no dispatch
authority either; the release fixtures kept it alive, the pairing that
hid #19166. Every gone-terminal case now runs with both gone.
…write landed

An older daemon's pid record proves its daemon gone only when whole: a
torn record's integer prefix no longer turns another process's absence
into proof. After its awaited observation a requested release goes on
only while its dispatch still owns the row, and reports success, failure
or a Keep open from whether its own write applied, not from the row it
reads back. Recovery charges its attempt to the initiating custody only,
and the sweep's batched release settles an item only for the dispatch
that owns the row now.
… and on losing receipts

The crew notification wrapper over settleWorkerTerminalRelease dropped
the owner argument, so the fence never reached SQL; it now forwards
it. A release that loses its row during a close reports the winner from
the row, whether the close failed transiently, was unconfirmed or threw,
and an owner-fenced unknown write counts only when it landed on this
dispatch's row. A stopped worker that loses custody during its own exit
proof no longer reports the successor's output summary; a lookup by a
former owner keeps its lineage summary. A bare pid record proves a pid
only as plain digits.
… joined fails transiently

After Keep open and Allow Auto-Close, a new release request can join an
automatic close still in flight. A transient close failure then left
that request's intent in place but answered it as retained; it now
answers release_pending, and recovery finishes it.
… the one it captured

When Keep open drops the output record during a held automatic close
and a fresh release joins it, a failed or unreachable close reported
the record captured before the close. Its pending and unknown receipts
now read the record from the row as it is.
@AmethystLiang
AmethystLiang force-pushed the brennanb2025/hot-worker-release-19166 branch from afde47c to 3d8eb0d Compare November 24, 2026 19:16
@AmethystLiang
AmethystLiang merged commit 36f75ce into main Nov 24, 2026
69 checks passed
Jinwoo-H pushed a commit that referenced this pull request Nov 24, 2026
…2264)

* fix(orchestration): release workers whose exited terminal is gone

A finished worker whose terminal was closed or lost could never be
released: the release request demanded an output record that only the
live terminal could provide, so worker-release answered release_unknown
and startup recovery retried forever, even after Orca proved the exact
process had exited.

A proven exit now settles the release whatever its request state,
rechecking the row the caller saw and recording where the worker's
output lives from what Orca saved while it ran. The exit check now waits
for local terminal startup, trusts only the provider that owns local
terminals, and no longer reads an older identity format or an
unobserved in-process absence as an exit.

Co-authored-by: giloh <[email protected]>

* fix(orchestration): keep the startup wait bounded and the retained receipt current

A startup that never settles no longer collects one reaction per exit
proof: the startup promise gets one subscription per startup, and once
its shared budget is spent later proofs read the cached verdict.

A retained worker-release whose exit proof awaited now reports the row as
it is afterwards, so a keep-open, transfer or release that landed during
the proof is what the receipt says.

* fix(orchestration): prove a local exit against every daemon generation

The routed daemon listing shows one generation per PTY id, so a worker
still running in another generation under the same id read as exited.
Exit proof now lists every generation and still refuses an incomplete
inventory.

* fix(orchestration): refuse exit proof a held daemon could disprove, and settle once

A local daemon held for a newer protocol, or an older one still alive
that no adapter reaches, lists nothing Orca can read; exit proof now
reads that as unverifiable. Of two racing releases only the one that
makes the transition reports released; the other reports already
released and repeats no completion effects. Recording an in-process
exit no longer throws into the provider's listener loop, and an
unreadable database vouches for nothing.

* fix(orchestration): read daemon pid files without blocking the main thread

The exit-proof guard for daemons outside the inventory runs on Electron
main for every local exit check, so it now lists the runtime directory
and reads older pid files with node:fs/promises.

* fix(orchestration): count an unreadable daemon pid record as a daemon that may still run

Exit proof reads "no older daemon" as absence, so only a missing pid
file or a missing process may say the daemon is gone; an unparsable
record or any other read error now keeps the proof declined. Legacy
discovery keeps the lenient check it uses to delete corrupt records.

* fix(orchestration): keep worker release within its own custody and older-daemon doubt

Startup discovery deletes an older daemon's pid record only when the
daemon is provably gone, and a record naming no positive pid counts as
a daemon that may still run, so exit proof keeps declining. The
stopped-worker sweep records the saved conversation when the pane names
none. Joined releases share one check but only one reports released.
A release is keyed and fenced to its own dispatch's custody: after a
transfer it reports ownership_transferred, never the new owner's state,
and a former owner can no longer settle its successor's row.

* test(orchestration): drop the worker's dispatch authority with its terminal

In the runtime a terminal that no longer resolves has no dispatch
authority either; the release fixtures kept it alive, the pairing that
hid #19166. Every gone-terminal case now runs with both gone.

* fix(orchestration): act on release outcomes only when this custody's write landed

An older daemon's pid record proves its daemon gone only when whole: a
torn record's integer prefix no longer turns another process's absence
into proof. After its awaited observation a requested release goes on
only while its dispatch still owns the row, and reports success, failure
or a Keep open from whether its own write applied, not from the row it
reads back. Recovery charges its attempt to the initiating custody only,
and the sweep's batched release settles an item only for the dispatch
that owns the row now.

* fix(orchestration): keep the owner fence through the installed settle and on losing receipts

The crew notification wrapper over settleWorkerTerminalRelease dropped
the owner argument, so the fence never reached SQL; it now forwards
it. A release that loses its row during a close reports the winner from
the row, whether the close failed transiently, was unconfirmed or threw,
and an owner-fenced unknown write counts only when it landed on this
dispatch's row. A stopped worker that loses custody during its own exit
proof no longer reports the successor's output summary; a lookup by a
former owner keeps its lineage summary. A bare pid record proves a pid
only as plain digits.

* fix(orchestration): keep a fresh release pending when a held close it joined fails transiently

After Keep open and Allow Auto-Close, a new release request can join an
automatic close still in flight. A transient close failure then left
that request's intent in place but answered it as retained; it now
answers release_pending, and recovery finishes it.

* fix(orchestration): name the output record a failed close leaves, not the one it captured

When Keep open drops the output record during a held automatic close
and a fresh release joins it, a failed or unreachable close reported
the record captured before the close. Its pending and unknown receipts
now read the record from the row as it is.

---------

Co-authored-by: Jinjing <[email protected]>
Co-authored-by: giloh <[email protected]>
DoozyX added a commit to DoozyX/orca that referenced this pull request Nov 25, 2026
Merges stablyai/orca 752c757 (277 commits).

Conflicts resolved by hand (independently reviewed, no defects):
- Gemini CLI removal (stablyai#48447) vs fork omp usage provider: StatusBarItem moved to
  client-ui-status-bar-params with omp kept; fork-retained status-bar tests
  repointed from gemini to kimi.
- Worker release custody (stablyai#42264) vs fork #67 ownership-transferred receipt
  fields: fields now spread on upstream's former-owner branch; retainedReason
  imported from its new presentation module.
- Source Control scope menu (stablyai#44229) vs fork Git Graph ref rail, Branches & Tags
  and redesigned commit pane: upstream panel-content taken, Branches & Tags dock
  moved to panel-ready, fork use-git-graph-support replaced by upstream's hook,
  git-history-panel deleted with upstream.
- Structured worker setup wait (stablyai#48202), agent row model chip (stablyai#48489), project
  badges (stablyai#48565/stablyai#48572) vs fork host badge, usage docs.
- Open diff button extracted and mobile page package aliases moved into
  mobile-web-app-aliased-packages to stay under max-lines after the merge.
- React Compiler baseline pruned.

Claude-Session: https://claude.ai/code/session_01BPjp5xBHHzDpEqwBtKH8Ac
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.

[Bug]: worker-release can never reclaim a settled worker whose PTY vanished (retained/identity_unproven on every retry)

2 participants