Skip to content

feat(orchestration): make multi-agent workflows durable - #16904

Merged
Jinwoo-H merged 172 commits into
mainfrom
orchestration-v3
Sep 6, 2026
Merged

Jinwoo-H merged 172 commits into
mainfrom
orchestration-v3

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 225 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​21666 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2820 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​18846
Prod 348 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​17107 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4706 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​12401

ELI5

Orca now treats orchestration like a durable control plane instead of inferring success from terminal keystrokes. Agents can tell whether a prompt was accepted or a turn started, replay an ambiguous request without sending twice, and recover coordinator mail after a crash. Completed workers can be inspected, released, or retained, and their panes no longer auto-resume as if the work were still running.

What changed

  • Run receipts from run-create/use/current/show/list are the row without routing plumbing (home_database, coordinator_pane_key) and without the duplicate binding object.
  • terminal send receipts are honest and idempotent. input_accepted and turn_started are the only stages; --wait-submit observes without resending; --retry-request <uuid> replays the exact request against the same process incarnation. A transport timeout keeps the retry ID; only a different runtime answering strips it. Value-less or non-UUID --retry-request is rejected on the CLI and the SSH shim.
  • Mailbox delivery is committed before wakeup. Pointer writes are staged in the DB before any PTY byte, replayed once after restart, and never emit a naked Enter. The watermark that parks concurrent deliveries is released with the DB reservation. Restart rescans pointer-pending and dispatch: mailboxes.
  • Lifecycle is a guarded transition graph (lifecycle-transition.ts) with a table-driven test over every caller edge. Task reopen/overturn stays in the public contract. A PTY exit during worker-stop is the stop succeeding, not a failure.
  • Worker lifecycle CLI: worker-start (--spec creates Task + attempt in one call), worker-show, worker-read (provider transcript first, bounded terminal fallback with a typed reason, local/WSL/SSH), worker-stop, worker-abandon, worker-release, worker-retain, worker-list (rowid-fenced pagination, fleet liveness, attention, literal nextAction).
  • Release is an explicit ownership table (decideWorkerTerminalRelease): only an owned resource can be settled, the archive is mandatory where reachable, and an owner whose process is proven exited can always get out of retained via archive_status: unavailable. User-taken-over, external, and transferred panes stay retained.
  • Settled-worker resume fence (folds in fix(orchestration): stamp and lift the settled worker resume fence (STA-4577) #17651): a settled dispatch whose pane is still open is fenced at settlement, on stop/abandon/exit, and at startup; lifted on release, retain, takeover, and pane reuse.
  • Liveness is live / unverifiable / exited only, from execution-host evidence. Fleet projection reads the evidence clock, not the relay delivery clock. A host-certified exit outranks the worker's settled state. unverifiable never authorizes stop, abandon, retry, or release, in code or in the guide.
  • Federation: structured reads negotiate by method_not_found so every shipped host keeps transcript-first output; exited remote workers are closed before being reported closed; epoch fencing holds across peer restart, downgrade, and pairing rotation; no per-second forced capability probe.
  • Schema v35: repairs databases stamped v34 by the pre-fix branch (mailbox_handle default, index predicates), drops the write-only lifecycle_transition_receipts ledger and five never-read v31 identity columns.
  • Schema v36: dispatch:<id> mailboxes get a real consumer generation on dispatch_contexts and remote_dispatch_attachments, bumped and fenced in the same transaction on every re-attach (manual inject, worker-start, federated attach). A stale worker whose Dispatch moved to another process now gets consumer_fenced instead of silently acking the new worker's Delivery. Run mailboxes already worked this way.
  • Schema v37: dispatch_contexts records its creator (creator_handle, creator_pane_key), so a coordinator's context-only self-dispatch is bookkeeping rather than a nesting parent; before this, one self-dispatch made every later worker-start from that coordinator fail the depth cap. Pre-v37 rows keep counting (fails closed).
  • Dispatch-mailbox ownership is checked, not inferred. A check from a process whose pane no longer holds the Dispatch, or whose last Attempt was abandoned/failed and moved to another terminal, gets consumer_fenced instead of an empty inbox that reads as "no mail yet". --peek/--all stay readable. A paneless caller still gets stable_pane_required with the rebind recovery.
  • Liveness certification is stricter: a process_exited stage whose termination reason is unknown (a stop that was issued but never observed) projects unverifiable, not exited. Federated worker-show carries the execution host's verdict and host kind instead of a local guess. A live, ready worker with nothing pending has nextAction: none rather than pointing at the worker-show that produced it.
  • Wire: workerShow keeps dispatch.task_id next to taskId for shipped CLIs. ask --json uses the standard {ok, result} envelope like every sibling verb.
  • Migration start-version detection treats the two v32 recovery columns as versioned. Before this, every shipped database stamped below 32 resolved to the v6 floor and replayed the whole chain (the v23 backfill synthesized 68 phantom retained workers on a real v30 profile). Verified on a copy of a real 62 MB v30 profile: starts at 30, no row delta, integrity ok, 11 ms.
  • Skill guide rewritten as a ≤200-line kernel plus seven references, to the outcome-first standard (Result / Done / Safe failure first, conditions not case lists, one done bar, references loaded at the point of use). The canonical loop uses worker-start --spec, names worker-list for completion accounting, documents --retry-request / request-show / --wait-submit, and requires positive evidence before any stall action. The other seven guides get the same treatment in skills: rewrite and trim the seven non-orchestration guides (do not merge without Jinwoo) #18724, split out so this PR stays orchestration-only.
  • rpc/methods/orchestration-* (126 flat files) regrouped into orchestration/{worker,federation,messaging,runs,gates}/.

Why

User reports showed the same boundary failures: false agent_prompt_stalled causing duplicate sends (#15180), coordinators unable to trust screen scrapes, cold-parked terminals receiving a pointer without the submit, settled workers accumulating as live tabs and auto-resuming after restart, and no way to tell a stalled worker from a working one.

Linked issues

Fixes #15180. Fixes #17935 (orchestration skill description is 866 characters; a guard now caps every bundled skill at 1,024). Supersedes #17651 (fence folded in). Advances #16660, #16522, #14907, #13047.

Review record

This PR was reviewed adversarially after revival: eight independent lenses (lifecycle, mailbox, send, worker, federation, transcript, complexity, live ergonomics), each required to prove findings with a failing test. That produced 16 proven blockers, all fixed with red-then-green regression tests, followed by two re-review rounds and a third fix wave that caught 3 regressions introduced by the fixes and 7 fixes that missed their target; all closed. A final pass (five lenses incl. a live built-runtime smoke, then a re-review of the fix wave) found and fixed seven more, chiefly the stale-worker mailbox steal, the self-dispatch depth wedge, and the unproven-exit certification. Three independent Codex (gpt-6-astra) passes followed: the first found nothing new, the second found and fixed 3 defects (task-status reachability, WSL-local host classification, peer-capability epoch), the third found and fixed 6 (production PTY controller never installed settled writes, ambiguous in-flight pointer failures allowed duplicate replay, SSH/relay deadlines cut off a valid --wait-submit, stop-vs-exit race during inspection, and two release-recovery paths for vanished or exited terminals). The full record (findings, proof tests, triage, declines with reasons) is archived outside the repo.

Rework after the live smoke. A first live cross-host run on the shipped adhoc build (this Mac, a paired Windows host on the same build, a paired Mac on 1.4.195, and an SSH host) found a P1: a running local worker read unverifiable/missing_status because the fleet snapshot rows lacked the terminal handle the matcher keyed on. A 59-row failure table over every bug fixed during review showed the same two classes recurring: a fact dropped in transit through optional fields, and two authorities for one fact. Two blind designs (Opus, Codex) converged on the same mechanisms, and the scoped tranches landed here with red-then-green seam tests from the real producer to the real consumer, faults injected only at the transport or hook-ingest boundary:

  • Settlement (data-loss class): one three-valued WriteSettlement (accepted | refused{reason} | unverifiable{reason, bytesHandedToTransport}) from the SSH multiplexer through daemon client, providers, controller, to pointer staging. No boolean, no rejection-as-third-state. The two silent degrades that fabricated a handoff are deleted; a provider that cannot settle refuses before any effect. Pointer text and Enter share the contract; a partial flush is unverifiable, never refused.
  • Evidence identity (false-liveness class): fleet agent-status evidence is a tagged union (binding: worker | pane | unresolved{reason}, clock: observed | delivery) minted once at ingest, so a hook row captured on one process incarnation can never bind to a later dispatch on the same pane. The matcher's !worker.paneKey || defaults are gone. One host-scope parser replaces two.
  • Small pre-merge items: capability_unsupported from an old peer is no longer relabelled host_unavailable; a producer census test asserts every agent-status consumer path projects a pane-only hook row as live.

Two ergonomics defects the second live run surfaced on a real database are fixed here too: a pre-v3 dispatch already marked completed projected as outcome_unknown / requiresAction: true forever (three copies of the outcome ladder disagreed on legacy rows; now one resolver, legacy completed reads succeeded with nothing to act on, legacy failed stays actionable on the failure), and an unscoped worker-list enumerated the entire database (now defaults to the Run bound to the calling terminal, --run overrides, and the receipt's additive scope field says which).

A third live round on the shipped adhoc build of b082443e1f (same four hosts) plus an unscripted run in the user's own prompt style (a plain Claude Code shell, /orchestration, three workers, zero errors, bound-Run default confirmed) found two more branch defects, fixed with red-then-green tests: a worker freshly started on a paired server projected unverifiable/host_indeterminate with requiresAction for ~3 minutes, including after its own worker_done, because the host's federation observation returned missing_liveness_verdict for any PTY the liveness register had not yet swept (the host now reads a connected pane it owns locally as live; disconnected or SSH-scoped panes stay unverifiable); and six pre-v3 completed rows still carried an input category because settling through the task-status path or failDispatch never closed the Dispatch's pending question threads (both paths close them now, and schema v38 closes threads already pending on settled rows). The guide's worker-start examples now show --model sonnet, since an omitted model inherits the launcher's default.

A Codex adversarial pass on the tranche diff found one real design hole (identity minted at read time instead of ingest, now closed) and two daemon settlement paths that threw instead of settling (fixed). Two @ts-nocheck runtime mixins on these paths were extracted into checked modules; the repo-wide @ts-nocheck count is unchanged at 171.

Deletions during review: ~1,900 lines (write-only ledger, unread columns, dead v1 archive path, test harnesses shipped in prod, duplicated liveness and state-machine copies, self-capability checks that were compile-time true).

Testing

  • pnpm typecheck:tsc:node|cli|web clean
  • pnpm run check:code-quality:changed 0 findings; check:react-doctor:changed 0
  • pnpm verify:bundled-skill-guides, verify:skill-bundle-manifest
  • full pnpm test on the integrated head: 72,332 pass / 292 skipped; the only failures were three non-PR files (two zsh live-shell suites hit a node-pty spawn-helper ENOENT while a concurrent native rebuild ran, 44/44 in isolation; release-checkout.unit.test.ts is a known 30 s load timeout that passes in isolation on origin/main too).
  • CI on 70b4811 (rerun, pre-Codex): the only reds are five SSH e2e specs plus terminal-send-agent-prompt-submit:198, each shown failing identically on main (main's E2E workflow is red on its last 40 runs). The terminal-send spec is root-caused and fixed separately in fix(e2e): stop deleting a pre-created agent's setup report #18707. The Windows hook-service flake (test(cursor): widen Windows hook spawn budget to fix ETIMEDOUT flake #17721) and the federation load flake did not recur.
  • Skills: pnpm exec vitest run over the skill gate files plus src/cli, config/scripts, src/main/skills pass; live smoke on the built CLI of skills get orchestration and --full (7 references).
  • live headless runtime (orca-dev serve, isolated profile): canonical loop, stop, release, archive read, retry rejection, stale-handle check, SIGKILL-and-replay all verified with receipts
  • Live cross-host smoke on the shipped adhoc build of 0d465e7931 (this Mac and a paired Windows host on the build, a paired Mac left on 1.4.195, an SSH host): local, paired-new, paired-old and SSH loops all settle; running workers read live on every host and exited after release; the old peer reads capability_unsupported and refuses release honestly. Injected 10 s relay stall with a send in flight: delivered exactly once after recovery, zero duplicates. Every liveness field across 104 receipts is only live / unverifiable / exited.
  • Final live cross-host smoke on the shipped adhoc build of b082443e1f (same hosts): every loop settles; 942 of 948 legacy completed rows read settled with requiresAction: false before the question-thread fix and all of them after; worker-list scope reads bound / flag / all correctly; 122 JSON receipts carry only live / unverifiable / exited. Unscripted prompt-style run: clean.
  • Confirmation smoke on the shipped adhoc build of 2da076d4e9 (this Mac and the paired Windows host, both updated): a freshly started Windows worker reads live on the first fleet poll and on all 20 that follow, with no host_indeterminate at any point, and exited after release; all 948 legacy completed rows read requiresAction: false with nextAction: none after schema v38; every verdict across 60 receipts is live / unverifiable / exited.
  • Not physically exercised: WSL hosts, the renderer notification bell (headless has no renderer), same-session fence via a real pane close (renderer-only state), restart mid-delivery on a real app (covered by e2e only).

Notes

  • Remote-wire additions are optional fields or method_not_found-negotiated methods; one new Electron-only IPC channel (agentStatus:legacyWorkerTerminalResumeFence) never crosses the wire.
  • SSH contact loss remains unverifiable; the execution host stays authoritative.
  • Intentional wire projection change: an SSH host scope with an empty targetId now projects host id ssh instead of an empty string (remote-wire-compatibility rule 3, old clients decode the same field). A fleet pane key without a terminal handle is now unidentifiable rather than matched by pane key alone.
  • Found live but pre-existing on main, filed separately: a relay daemon-start collision during transport loss rewrites the endpoint credential and wedges the surviving relay (host needs a manual kill); terminal create on a reconnecting SSH host reports an opaque No PTY provider for connection; terminal list reports orphaned:false and terminal close reports ptyKilled:true for a pane whose relay is gone (orchestration's own projection reads unverifiable correctly at the same moment).
  • Downgrade after this PR is not a supported path: main opens a v37 database and early-returns (its inserts still work against the v36/v37 defaulted columns), but its one-outstanding-Delivery-per-Run index is a no-op against the branch's mailbox-scoped index of the same name.
  • Known follow-ups (not blockers): worker-list materializes every dispatch row per call; a positive "agent absent" signal distinct from PTY liveness is a product decision left open (a headless fake agent never reaches live, so its nextAction stays inspect); a context-only self-dispatch still lists as role: worker in worker-list; dispatch task-not-found / task-not-ready / inject-rejected still surface as runtime_error; task and inbox receipts still expose raw row columns. Deferred skill product decisions live on skills: rewrite and trim the seven non-orchestration guides (do not merge without Jinwoo) #18724.

@greptile-apps

greptile-apps Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

Too many files changed for review (573 files, 100 file limit).

@coderabbitai

coderabbitai Bot commented Aug 28, 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
📝 Walkthrough

Walkthrough

The change adds durable lifecycle transition receipts and attempt-observation facts to orchestration persistence. It adds lifecycle guards, outcome projection, worker attention, terminal recovery tracking, federated read and release flows, capability negotiation, worker-list pagination, and remote transcript reads. Terminal prompts now support queued delivery, observation, and idempotent retry. Worker-start accepts inline task specifications. Mailbox delivery supports cold-parked terminals. Orchestration guides now bundle conditional reference documents. Tests cover migration, lifecycle atomicity, federation behavior, prompt delivery, projections, recovery, and end-to-end parked-terminal delivery.

Merge Risk: 🟠 High · up to 64dfa

This change introduces durable mailbox delivery, worker recovery, federated observation, and lifecycle management, but the current implementation can still duplicate or strand messages, leave workers or dispatches in incorrect states, and return misleading recovery or fleet results. The PR is not merge-ready until the concrete delivery, lifecycle, replay, release, and observation issues are fixed or explicitly accepted by the owners.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR includes substantial functionality beyond the requirements in [#15180], including federated release and fleet management, worker archive and transcript features, terminal-resource lifecycle man… Split unrelated functionality into separate pull requests, or link the additional issues that define these requirements. Keep this pull request focused on durable dispatch observations, prompt-delivery idempotency, mailbox delivery, and the…
Docstring Coverage ⚠️ Warning Docstring coverage is 6.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 45 functions across 48 files. (196 skipped… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR satisfies the core objective in [#15180] by persisting dispatch attempt observations and lifecycle evidence, distinguishing prompt acceptance from turn-start observation, and adding recovery an…
Title check ✅ Passed The title clearly summarizes the primary change: making multi-agent orchestration workflows durable.
Description check ✅ Passed The description is detailed, relevant, and covers the change, rationale, linked issues, review record, testing, compatibility, and known limitations. Some template sections are absent or not reproduce…
Full details: Out of Scope Changes check

Explanation

The PR includes substantial functionality beyond the requirements in [#15180], including federated release and fleet management, worker archive and transcript features, terminal-resource lifecycle management, pagination, skill-guide rewrites, and broad federation changes.

Resolution

Split unrelated functionality into separate pull requests, or link the additional issues that define these requirements. Keep this pull request focused on durable dispatch observations, prompt-delivery idempotency, mailbox delivery, and the recovery behavior required to support them.

Full details: Docstring Coverage

Explanation

Docstring coverage is 6.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 45 functions across 48 files. (196 skipped: 14 unsupported, 2 too large, 180 over the file limit.)

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

@Jinwoo-H
Jinwoo-H force-pushed the orchestration-v3 branch 3 times, most recently from a9d51da to 9923fef Compare August 28, 2026 00:40

@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: 11

🧹 Nitpick comments (10)
src/main/runtime/rpc/methods/orchestration-local-worker-start.ts (1)

88-88: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Compute the readiness timeout once.

params.timeoutMs ?? 60_000 appears three times. Hoist it into one constant and reuse it for startOptions, waitForTerminal, and the response.

Also applies to: 189-192, 254-254

src/main/runtime/rpc/methods/orchestration-worker-output.ts (1)

47-57: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Derive the remote connection once.

The condition session.connectionId && !isWslHookRelayConnectionId(session.connectionId) is evaluated twice. Bind it once so the provider lookup and the fail-closed guard cannot drift apart.

♻️ Proposed refactor
-  const remoteFilesystemProvider =
-    session.connectionId && !isWslHookRelayConnectionId(session.connectionId)
-      ? getSshFilesystemProvider(session.connectionId)
-      : undefined
-  if (
-    session.connectionId &&
-    !isWslHookRelayConnectionId(session.connectionId) &&
-    !remoteFilesystemProvider
-  ) {
-    return fallbackOrThrow(args, 'remote_capability_unavailable')
-  }
+  const remoteConnectionId =
+    session.connectionId && !isWslHookRelayConnectionId(session.connectionId)
+      ? session.connectionId
+      : null
+  const remoteFilesystemProvider = remoteConnectionId
+    ? getSshFilesystemProvider(remoteConnectionId)
+    : undefined
+  if (remoteConnectionId && !remoteFilesystemProvider) {
+    return fallbackOrThrow(args, 'remote_capability_unavailable')
+  }
src/main/runtime/orchestration/worker-output-archive.test.ts (1)

17-34: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Drop the unused transcript fixture.

Test 1 mocks readWorkerTranscript, and test 2 never reads a file. The tmpdir and session.jsonl created at Lines 24-26 are never used, so directory, transcriptPath, and the rm cleanup can be removed. The describe title also says "WSL routing" while the suite covers SSH routing too.

src/main/runtime/orchestration/db/worker-terminal/worker-terminal-listing.ts (2)

69-84: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract the duplicated terminalState CASE expression.

The same 10-line SQL CASE now exists in listWorkerTerminalResources and countWorkerTerminalResources, and it must stay in lockstep with deriveWorkerTerminalListState. Three copies drift independently, and a listing/count mismatch would produce a wrong total for the same filter. Move the expression to one exported constant in this module and use it in both places.

♻️ Suggested shape
+const TERMINAL_STATE_SQL = `CASE
+  WHEN r.id IS NULL THEN CASE WHEN COALESCE(w.agent_terminal_handle, d.assignee_handle) IS NOT NULL THEN 'retained' ELSE NULL END
+  WHEN r.release_state = 'released' THEN 'released'
+  ...
+END`

Also applies to: 220-234


132-140: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low value

Consider selecting the resource columns in the main query.

The main query already joins worker_terminal_resources r. The second query re-reads the same rows by dispatch id. Selecting r.* (aliased) in the first query removes one round trip and the IN placeholder list. This is optional; keep the two-query form if column-name collisions are the reason.

src/main/runtime/orchestration/db/attempt-observation-types.ts (1)

109-109: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Move the PtyLivenessVerdict import to the top of the file.

The import sits after every declaration. TypeScript hoists it, so behavior is unchanged, but the file reads as if AttemptLivenessObservation on Line 39 has no source.

src/shared/orchestration-fleet-status-index.ts (1)

69-73: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Drop StatusIdentity and the cast.

AgentStatusIpcPayload now declares processIncarnation, endpointId, and endpointIncarnation (src/shared/agent-status-ipc-payload.ts, lines 30-34). The local widening type and the as StatusIdentity cast are redundant, and they will mask a future change to those field types.

♻️ Proposed cleanup
-type StatusIdentity = AgentStatusIpcPayload & {
-  processIncarnation?: string
-  endpointId?: string
-  endpointIncarnation?: string
-}
-
-  const candidate = status as StatusIdentity
+  const candidate = status

Also applies to: 97-97

src/main/runtime/rpc/methods/orchestration-federated-worker-start.ts (1)

35-51: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Share one --deps parser between the local and federated start paths.

Both modules define identical parseTaskDeps implementations for the same contract. Export one parser and import it in both modules to prevent syntax and error-message drift.

src/shared/orchestration-worker-output.ts (1)

50-53: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Consider a named clipping vocabulary instead of string[].

clipping is a wire field with a closed vocabulary. Producers emit message_limit, archive_message_limit, message_limit_or_scan_window, and terminal_fallback. A string[] type allows silent drift between producers and consumers. The file already uses this pattern for ORCHESTRATION_WORKER_READ_FALLBACK_REASONS.

♻️ Proposed typed vocabulary
+export const ORCHESTRATION_WORKER_READ_CLIPPING_REASONS = [
+  'message_limit',
+  'archive_message_limit',
+  'message_limit_or_scan_window',
+  'terminal_fallback'
+] as const
+export type OrchestrationWorkerReadClipping =
+  (typeof ORCHESTRATION_WORKER_READ_CLIPPING_REASONS)[number]
   sourceExact?: boolean
   contentComplete?: boolean
-  clipping?: string[]
+  clipping?: OrchestrationWorkerReadClipping[]

Also applies to: 71-74

src/main/runtime/orchestration/db/lifecycle-transition-boundary.test.ts (1)

8-23: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Scan the directory instead of a hardcoded file list.

The guard only covers eight named files. A new module that writes state or status directly is not scanned, so the boundary regression can reappear unnoticed. Glob the orchestration DB tree and exclude the lifecycle transition module itself. This also removes the need to update the list with every new writer.

Note also that the bounded [\s\S]{0,180}? gap misses an UPDATE statement with a longer clause before SET.

♻️ Proposed directory scan
-    const root = resolve(__dirname)
-    const files = [
-      'worker-dispatch/worker-dispatch-outcome.ts',
-      'worker-dispatch/worker-dispatch-abandon.ts',
-      'worker-dispatch/worker-dispatch-stop.ts',
-      'worker-dispatch/federated-worker-start-reconcile.ts',
-      'dispatch-context/dispatch-completion.ts',
-      'dispatch-context/task-dispatch-reconciliation.ts',
-      'decision-gates/decision-gate-store.ts',
-      '../context-only-dispatch-release.ts'
-    ]
+    const root = resolve(__dirname, '..')
+    const files = globSync('**/*.ts', { cwd: root }).filter(
+      (file) => !file.endsWith('.test.ts') && !file.endsWith('db/lifecycle-transition.ts')
+    )

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d01b7c79-0141-4048-a87e-0712543597bd

📥 Commits

Reviewing files that changed from the base of the PR and between 39ac32f and a9d51da24242e57b8ca34d92b239c553a5f89982.

📒 Files selected for processing (176)
  • config/scripts/generate-bundled-skill-guides.mjs
  • config/scripts/generate-bundled-skill-guides.test.mjs
  • config/scripts/orchestration-skill-guidance.test.mjs
  • resources/skills/current-manifest.json
  • resources/skills/snapshot-registry.json
  • skill-guides/orca-cli.md
  • skill-guides/orchestration.md
  • skill-guides/orchestration/references/coordinator-loop.md
  • skill-guides/orchestration/references/legacy-contract-migration.md
  • skill-guides/orchestration/references/low-level-topology.md
  • skill-guides/orchestration/references/messaging-and-gates.md
  • skill-guides/orchestration/references/placement-and-remote.md
  • skill-guides/orchestration/references/recovery-and-cleanup.md
  • skill-guides/orchestration/references/worker-contract.md
  • skills/orchestration/SKILL.md
  • src/cli/bundled-skill-guides.ts
  • src/cli/handlers/orchestration-worker-cli.test.ts
  • src/cli/handlers/orchestration/worker-launch-handler.ts
  • src/cli/handlers/orchestration/worker-terminal-handlers.ts
  • src/cli/handlers/terminal.test.ts
  • src/cli/handlers/terminal.ts
  • src/cli/index.test.ts
  • src/cli/root-help-text-secondary.ts
  • src/cli/runtime/client.ts
  • src/cli/specs/core.ts
  • src/cli/specs/orchestration-worker-specs.ts
  • src/cli/specs/terminal-send.ts
  • src/cli/terminal-format.ts
  • src/main/runtime/agent-prompt-submission-runtime.test.ts
  • src/main/runtime/agent-prompt-submission-verification.ts
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/orchestration-mailbox-notification-consistency.test.ts
  • src/main/runtime/orchestration/context-only-dispatch-release.ts
  • src/main/runtime/orchestration/coordinator-runtime-contract.ts
  • src/main/runtime/orchestration/coordinator-task-dispatch.ts
  • src/main/runtime/orchestration/db-task-dispatch-invariant.test.ts
  • src/main/runtime/orchestration/db-task-dispatch-lifecycle-guards.test.ts
  • src/main/runtime/orchestration/db-task-dispatch-races.test.ts
  • src/main/runtime/orchestration/db.ts
  • src/main/runtime/orchestration/db/attach-orchestration-db-methods.ts
  • src/main/runtime/orchestration/db/attempt-observation-store.ts
  • src/main/runtime/orchestration/db/attempt-observation-types.ts
  • src/main/runtime/orchestration/db/attempt-outcome-projection.test.ts
  • src/main/runtime/orchestration/db/attempt-outcome-projection.ts
  • src/main/runtime/orchestration/db/contract-constants.ts
  • src/main/runtime/orchestration/db/decision-gate-lifecycle.test.ts
  • src/main/runtime/orchestration/db/decision-gates/decision-gate-store.ts
  • src/main/runtime/orchestration/db/dispatch-context/dispatch-completion.ts
  • src/main/runtime/orchestration/db/dispatch-context/dispatch-context-store.ts
  • src/main/runtime/orchestration/db/dispatch-context/task-dispatch-reconciliation.ts
  • src/main/runtime/orchestration/db/dispatch-context/worker-report-settlement.ts
  • src/main/runtime/orchestration/db/dispatch-depth.ts
  • src/main/runtime/orchestration/db/dispatch-row-writer.ts
  • src/main/runtime/orchestration/db/federation/federated-dispatch-store.ts
  • src/main/runtime/orchestration/db/lifecycle-transition-boundary.test.ts
  • src/main/runtime/orchestration/db/lifecycle-transition.test.ts
  • src/main/runtime/orchestration/db/lifecycle-transition.ts
  • src/main/runtime/orchestration/db/orchestration-db-methods.ts
  • src/main/runtime/orchestration/db/reset/orchestration-reset.ts
  • src/main/runtime/orchestration/db/schema/create-core-tables-sql.ts
  • src/main/runtime/orchestration/db/schema/create-graph-tables-sql.ts
  • src/main/runtime/orchestration/db/schema/migrate-v13-v30.ts
  • src/main/runtime/orchestration/db/tasks/task-status-transition.ts
  • src/main/runtime/orchestration/db/tasks/task-store.ts
  • src/main/runtime/orchestration/db/worker-dispatch/federated-worker-start-reconcile.ts
  • src/main/runtime/orchestration/db/worker-dispatch/worker-dispatch-abandon.ts
  • src/main/runtime/orchestration/db/worker-dispatch/worker-dispatch-authority.ts
  • src/main/runtime/orchestration/db/worker-dispatch/worker-dispatch-outcome.ts
  • src/main/runtime/orchestration/db/worker-dispatch/worker-dispatch-stage.ts
  • src/main/runtime/orchestration/db/worker-dispatch/worker-dispatch-start.ts
  • src/main/runtime/orchestration/db/worker-dispatch/worker-dispatch-stop.ts
  • src/main/runtime/orchestration/db/worker-dispatch/worker-terminal-recovery.ts
  • src/main/runtime/orchestration/db/worker-terminal/worker-terminal-attention-query.ts
  • src/main/runtime/orchestration/db/worker-terminal/worker-terminal-listing.ts
  • src/main/runtime/orchestration/db/worker-terminal/worker-terminal-resource-store.ts
  • src/main/runtime/orchestration/db/worker-terminal/worker-terminal-user-takeover.ts
  • src/main/runtime/orchestration/federation-sync.test.ts
  • src/main/runtime/orchestration/federation-sync.ts
  • src/main/runtime/orchestration/lifecycle-reconciliation.test.ts
  • src/main/runtime/orchestration/lifecycle-reconciliation.ts
  • src/main/runtime/orchestration/mailbox-owner.ts
  • src/main/runtime/orchestration/mailbox-pointer-batch.ts
  • src/main/runtime/orchestration/mailbox-pointer-delivery-contract.ts
  • src/main/runtime/orchestration/mailbox-pointer-delivery.ts
  • src/main/runtime/orchestration/mailbox-pointer-submit.test.ts
  • src/main/runtime/orchestration/mailbox-pointer-submit.ts
  • src/main/runtime/orchestration/orchestration-peer-capability-cache.test.ts
  • src/main/runtime/orchestration/orchestration-peer-capability-cache.ts
  • src/main/runtime/orchestration/orchestration-reset-db.test.ts
  • src/main/runtime/orchestration/orchestration-schema-version-skew.ts
  • src/main/runtime/orchestration/orchestration-version-skew-migration.test.ts
  • src/main/runtime/orchestration/orchestration-worker-dispatch-db.test.ts
  • src/main/runtime/orchestration/preamble.test.ts
  • src/main/runtime/orchestration/r1-identity-migration.test.ts
  • src/main/runtime/orchestration/types.ts
  • src/main/runtime/orchestration/worker-attention-context.ts
  • src/main/runtime/orchestration/worker-output-archive.test.ts
  • src/main/runtime/orchestration/worker-output-archive.ts
  • src/main/runtime/orchestration/worker-provider-session.test.ts
  • src/main/runtime/orchestration/worker-provider-session.ts
  • src/main/runtime/orchestration/worker-report-observation.ts
  • src/main/runtime/orchestration/worker-start-unobserved-prompt-settlement.test.ts
  • src/main/runtime/orchestration/worker-terminal-ownership.ts
  • src/main/runtime/orchestration/worker-transcript-read.ts
  • src/main/runtime/orchestration/worker-transcript-remote-read.test.ts
  • src/main/runtime/orchestration/worker-transcript-remote-read.ts
  • src/main/runtime/rpc/core.ts
  • src/main/runtime/rpc/dispatcher-caller-fingerprint.ts
  • src/main/runtime/rpc/dispatcher.ts
  • src/main/runtime/rpc/methods/orchestration-composed-workers.test.ts
  • src/main/runtime/rpc/methods/orchestration-federated-fleet-snapshot.ts
  • src/main/runtime/rpc/methods/orchestration-federated-worker-read.ts
  • src/main/runtime/rpc/methods/orchestration-federated-worker-release-host.ts
  • src/main/runtime/rpc/methods/orchestration-federated-worker-release.ts
  • src/main/runtime/rpc/methods/orchestration-federated-worker-start-receipts.ts
  • src/main/runtime/rpc/methods/orchestration-federated-worker-start.ts
  • src/main/runtime/rpc/methods/orchestration-federation-control.ts
  • src/main/runtime/rpc/methods/orchestration-federation-liveness-verdict.test.ts
  • src/main/runtime/rpc/methods/orchestration-federation-output.test.ts
  • src/main/runtime/rpc/methods/orchestration-federation.test.ts
  • src/main/runtime/rpc/methods/orchestration-federation.ts
  • src/main/runtime/rpc/methods/orchestration-local-worker-start.ts
  • src/main/runtime/rpc/methods/orchestration-runs.test.ts
  • src/main/runtime/rpc/methods/orchestration-tasks-dispatch.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-archive-read.ts
  • src/main/runtime/rpc/methods/orchestration-worker-control.ts
  • src/main/runtime/rpc/methods/orchestration-worker-launch-preferences.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-legacy-federated-read.ts
  • src/main/runtime/rpc/methods/orchestration-worker-list-cursor.ts
  • src/main/runtime/rpc/methods/orchestration-worker-list-method.ts
  • src/main/runtime/rpc/methods/orchestration-worker-observation.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-observation.ts
  • src/main/runtime/rpc/methods/orchestration-worker-output.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-output.ts
  • src/main/runtime/rpc/methods/orchestration-worker-release-archive.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-release-completion.ts
  • src/main/runtime/rpc/methods/orchestration-worker-release-inventory.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-release-liveness-verdict.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-release-recovery.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-release-schemas.ts
  • src/main/runtime/rpc/methods/orchestration-worker-release-test-harness.ts
  • src/main/runtime/rpc/methods/orchestration-worker-release.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-release.ts
  • src/main/runtime/rpc/methods/orchestration-worker-start-prompt-contract.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-start-schema.ts
  • src/main/runtime/rpc/methods/orchestration-worker-terminal-resource-presentation.ts
  • src/main/runtime/rpc/methods/orchestration-workers-recovery.test.ts
  • src/main/runtime/rpc/methods/orchestration-workers.ts
  • src/main/runtime/rpc/methods/orchestration.ts
  • src/main/runtime/rpc/methods/terminal/terminal-prompt-replay-observation.ts
  • src/main/runtime/rpc/methods/terminal/terminal-send-method.ts
  • src/main/runtime/rpc/methods/terminal/unary-schemas.ts
  • src/main/runtime/rpc/orchestration-commit-notify-characterization.test.ts
  • src/main/runtime/rpc/orchestration-legacy-compatibility-dispatcher.test.ts
  • src/main/runtime/rpc/orchestration-mutation-executor.test.ts
  • src/main/runtime/rpc/orchestration-mutation-executor.ts
  • src/main/runtime/rpc/terminal-prompt-delivery-receipt.test.ts
  • src/main/sqlite/sync-database.test.ts
  • src/main/sqlite/sync-database.ts
  • src/renderer/src/store/slices/agent-status-runtime-orchestration.test.ts
  • src/renderer/src/store/slices/agent-status.ts
  • src/shared/agent-status-ipc-payload.ts
  • src/shared/agent-status-types.ts
  • src/shared/orchestration-fleet-attention.test.ts
  • src/shared/orchestration-fleet-attention.ts
  • src/shared/orchestration-fleet-projection.test.ts
  • src/shared/orchestration-fleet-projection.ts
  • src/shared/orchestration-fleet-status-index.ts
  • src/shared/orchestration-fleet-worker-projection.ts
  • src/shared/orchestration-rpc-contract.ts
  • src/shared/orchestration-worker-output.ts
  • src/shared/protocol-version.ts
  • src/shared/runtime-terminal-contracts.ts
  • src/shared/runtime-types.ts
  • tests/e2e/orchestration-idle-mail-delivery.spec.ts

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

Comment thread src/main/runtime/orchestration/db/dispatch-depth.ts Outdated
Comment thread src/main/runtime/orchestration/worker-attention-context.ts Outdated
Comment thread src/main/runtime/orchestration/worker-transcript-read.ts
Comment on lines +48 to +80
if (observation.status !== 'exited') {
try {
const close = await runtime.closeTerminal(observation.terminal.handle)
if (!close.ptyKilled) {
return {
dispatchId: attachment.dispatch_id,
state: 'release_unknown',
processAction: 'closed_agent_terminal',
lastError: describeUnconfirmedAgentStop(close),
output
}
}
} catch (error) {
return {
dispatchId: attachment.dispatch_id,
state: 'release_unknown',
processAction: 'none',
lastError: error instanceof Error ? error.message : String(error),
output
}
}
}
runtime.getOrchestrationDb().recordRemoteAttachmentStage({
dispatchId: attachment.dispatch_id,
stage: 'released'
})
return {
dispatchId: attachment.dispatch_id,
state: 'released',
processAction:
observation.status === 'exited' ? 'closed_exited_terminal' : 'closed_agent_terminal',
output
}

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

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
# Check how consumers interpret processAction and whether exited terminals are closed elsewhere.
rg -n 'closed_exited_terminal|processAction' --type=ts -C3

Repository: stablyai/orca

Length of output: 151


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- repository conventions ---'
find /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4 -maxdepth 2 -type f -name '*.md' -print
printf '%s\n' '--- reviewed method ---'
cat -n src/main/runtime/rpc/methods/orchestration-federated-worker-release-host.ts
printf '%s\n' '--- direct references ---'
rg -n -C3 'closed_exited_terminal|processAction|releaseRemote|recordRemoteAttachmentStage|closeTerminal' src/main/runtime src --type ts
printf '%s\n' '--- SSH boundary ---'
cat -n docs/reference/ssh-execution-boundary.md

Repository: stablyai/orca

Length of output: 50370


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- convention file list ---'
find /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4 -maxdepth 2 -type f -name '*.md' -print
printf '%s\n' '--- release method ---'
cat -n src/main/runtime/rpc/methods/orchestration-federated-worker-release-host.ts
printf '%s\n' '--- exact action references outside tests ---'
rg -n -C4 --glob '!**/*.test.ts' --glob '!**/*.spec.ts' \
  'closed_exited_terminal|closed_agent_terminal|release_unknown|processAction' src
printf '%s\n' '--- closeTerminal and attachment-stage references near orchestration code ---'
rg -n -C3 --glob '!**/*.test.ts' --glob '!**/*.spec.ts' \
  'closeTerminal|recordRemoteAttachmentStage|observation.status' src/main/runtime/rpc src/main/runtime

Repository: stablyai/orca

Length of output: 50372


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- release caller and related contract ---'
rg -n -C6 --glob '!**/*.test.ts' --glob '!**/*.spec.ts' \
  'releaseRemoteAttachment|orchestration-federated-worker-release-host|Remote.*Release|processAction' src/main
printf '%s\n' '--- bounded runtime-rpc learning ---'
cat /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings/src-main-runtime-rpc.md
printf '%s\n' '--- bounded source convention ---'
cat /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions/src.md

Repository: stablyai/orca

Length of output: 50369


Close exited terminals before marking them released. When observation.status === 'exited', runtime.closeTerminal(...) is skipped, but the method records stage: 'released' and returns processAction: 'closed_exited_terminal'. The federated caller forwards this action in the release receipt. Close the terminal before recording released, or return a non-released state when cleanup is not complete.

Comment thread src/main/runtime/rpc/orchestration-mutation-executor.ts
Comment thread src/shared/orchestration-fleet-projection.ts
Comment on lines +142 to +152
const cursorIndex = args.cursor
? args.workers.findIndex((worker) => worker.dispatchId === args.cursor)
: -1
const start = cursorIndex >= 0 ? cursorIndex + 1 : 0
const rows = args.workers.slice(start, start + limit)
const statusIndex = createFleetStatusIndex(args.statuses, rows)
const now = args.now ?? Date.now()
const workers = rows.map((worker) =>
projectOrchestrationFleetWorker(worker, statusForFleetWorker(worker, statusIndex), now)
)
const hasMore = start + workers.length < args.workers.length

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

An unknown cursor silently restarts pagination at page 1.

findIndex returns -1 when the cursor dispatch id is no longer in workers, for example after that dispatch is released between page requests. start then becomes 0 and the caller receives page 1 again with hasMore: true. A client that pages until hasMore is false can repeat forever. Reject the unknown cursor, or report it in the page metadata.

🐛 Proposed fix
-  const cursorIndex = args.cursor
-    ? args.workers.findIndex((worker) => worker.dispatchId === args.cursor)
-    : -1
-  const start = cursorIndex >= 0 ? cursorIndex + 1 : 0
+  let start = 0
+  if (args.cursor) {
+    const cursorIndex = args.workers.findIndex((worker) => worker.dispatchId === args.cursor)
+    if (cursorIndex < 0) {
+      throw new Error(`Unknown fleet page cursor ${args.cursor}.`)
+    }
+    start = cursorIndex + 1
+  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const cursorIndex = args.cursor
? args.workers.findIndex((worker) => worker.dispatchId === args.cursor)
: -1
const start = cursorIndex >= 0 ? cursorIndex + 1 : 0
const rows = args.workers.slice(start, start + limit)
const statusIndex = createFleetStatusIndex(args.statuses, rows)
const now = args.now ?? Date.now()
const workers = rows.map((worker) =>
projectOrchestrationFleetWorker(worker, statusForFleetWorker(worker, statusIndex), now)
)
const hasMore = start + workers.length < args.workers.length
let start = 0
if (args.cursor) {
const cursorIndex = args.workers.findIndex((worker) => worker.dispatchId === args.cursor)
if (cursorIndex < 0) {
throw new Error(`Unknown fleet page cursor ${args.cursor}.`)
}
start = cursorIndex + 1
}
const rows = args.workers.slice(start, start + limit)
const statusIndex = createFleetStatusIndex(args.statuses, rows)
const now = args.now ?? Date.now()
const workers = rows.map((worker) =>
projectOrchestrationFleetWorker(worker, statusForFleetWorker(worker, statusIndex), now)
)
const hasMore = start + workers.length < args.workers.length

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

🧹 Nitpick comments (7)
src/main/runtime/orchestration/db/attempt-observation-store.ts (1)

175-186: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

The active-sibling predicate is duplicated across two new modules. Both queries decide activeSibling for projectAttemptOutcome with the same status and worker-state lists. If one list changes, the single-dispatch projection and the batched attention projection disagree about taskOutcome.

  • src/main/runtime/orchestration/db/attempt-observation-store.ts#L175-L186: move this predicate into one exported SQL fragment and use it here.
  • src/main/runtime/orchestration/db/worker-terminal/worker-terminal-attention-query.ts#L43-L49: use the same shared fragment in the active_sibling subquery.
src/main/runtime/orchestration/db/worker-terminal/worker-terminal-attention-query.ts (1)

104-116: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use OrchestrationError for the not-found case.

recordAttemptObservation and getAttemptOutcomeProjection throw OrchestrationError('dispatch_not_found', ...) for a missing dispatch. Line 113 throws a plain Error, so callers that branch on the orchestration error code cannot classify it.

src/main/runtime/orchestration/db/worker-terminal/worker-terminal-listing.ts (2)

152-160: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Bind the dispatch ids with json_each instead of one placeholder per row.

params.limit is optional, so rows is unbounded. The placeholder list then grows with the row count and can exceed the SQLite bound-parameter limit. worker-terminal-attention-query.ts already binds the same shape with IN (SELECT value FROM json_each(?)); reuse that pattern here.

♻️ Proposed refactor
-      : (this.db
-          .prepare(
-            `SELECT r.* FROM worker_terminal_resources r
-               WHERE r.owner_dispatch_id IN (${rows.map(() => '?').join(',')})`
-          )
-          .all(...rows.map((row) => row.dispatch_id)) as WorkerTerminalResourceRow[])
+      : (this.db
+          .prepare(
+            `SELECT r.* FROM worker_terminal_resources r
+               WHERE r.owner_dispatch_id IN (SELECT value FROM json_each(?))`
+          )
+          .all(JSON.stringify(rows.map((row) => row.dispatch_id))) as WorkerTerminalResourceRow[])

87-102: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Define the terminal-state CASE expression once and derive its state lists.

The duplicated CASE expression in listWorkerTerminalResources and countWorkerTerminalResources hardcodes the current contents of WORKER_RELEASABLE_STATES and WORKER_SETTLED_STATES. If those constants change, the list, count, and deriveWorkerTerminalListState can diverge. Extract one exported builder that renders the CASE from the shared constants, then call it from both functions.

src/cli/handlers/terminal.ts (1)

114-133: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Localize the new CLI strings. Use intent-named localization IDs with named placeholders for both sites.

  • src/cli/handlers/terminal.ts#L114-L133: replace the new validation and compatibility error text with localized messages.
  • src/cli/help.ts#L111-L112: replace the new --include-remote help text with a localized message.

Based on learnings: “For newly added user-facing strings in stablyai/orca TypeScript and TSX files, follow config/i18n-translation-source.md.”

Source: Learnings

tests/e2e/orchestration-idle-mail-delivery.spec.ts (1)

74-76: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Reuse the helper's option type instead of redeclaring its shape.

tests/e2e/helpers/orchestration-mail-pane-agent.ts already declares MailPaneAgentOptions with the same titleOnStdin field. This spec redeclares that shape twice. Export the helper type and import it so the two definitions cannot drift.

♻️ Proposed refactor

In tests/e2e/helpers/orchestration-mail-pane-agent.ts:

-type MailPaneAgentOptions = {
+export type MailPaneAgentOptions = {
   titleOnStdin?: { needle: string; title: string }
 }

In this spec:

-  openAgentPane: (options?: {
-    titleOnStdin?: { needle: string; title: string }
-  }) => Promise<AgentPane>
+  openAgentPane: (options?: MailPaneAgentOptions) => Promise<AgentPane>
-  const openAgentPane = async (options?: {
-    titleOnStdin?: { needle: string; title: string }
-  }): Promise<AgentPane> => {
+  const openAgentPane = async (options?: MailPaneAgentOptions): Promise<AgentPane> => {

As per coding guidelines: "check whether an existing implementation already does the job (or nearly does). Extend or generalize it instead of building a parallel version".

Also applies to: 133-135

Source: Coding guidelines

src/main/runtime/orca-runtime.ts (1)

20524-20611: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Clarify the correlation cap scope.

AGENT_PROMPT_CORRELATION_LIMIT_PER_PTY is named per PTY, but registerAgentPromptRequest prunes with the prefix ${ptyId}\0${generation}\0. The cap therefore applies per PTY generation. advancePtyLifecycleGeneration clears prior generations, so the practical bound holds. Rename the constant or the prefix to match the intent.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e545dbe9-79dd-4b9e-8216-eebc9a032668

📥 Commits

Reviewing files that changed from the base of the PR and between a9d51da24242e57b8ca34d92b239c553a5f89982 and 04031f5.

📒 Files selected for processing (42)
  • src/cli/args.ts
  • src/cli/handlers/orchestration-worker-cli.test.ts
  • src/cli/handlers/orchestration/worker-terminal-handlers.ts
  • src/cli/handlers/terminal.test.ts
  • src/cli/handlers/terminal.ts
  • src/cli/help.ts
  • src/cli/specs/orchestration-worker-specs.ts
  • src/cli/terminal-format.ts
  • src/main/runtime/agent-prompt-submission-runtime.test.ts
  • src/main/runtime/agent-prompt-submission-verification.test.ts
  • src/main/runtime/agent-prompt-submission-verification.ts
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/orchestration-mailbox-notification-consistency.test.ts
  • src/main/runtime/orchestration/db/attempt-observation-store.ts
  • src/main/runtime/orchestration/db/worker-terminal/worker-terminal-attention-query.ts
  • src/main/runtime/orchestration/db/worker-terminal/worker-terminal-listing.ts
  • src/main/runtime/orchestration/mailbox-pointer-delivery-contract.ts
  • src/main/runtime/orchestration/mailbox-pointer-delivery.ts
  • src/main/runtime/orchestration/mailbox-pointer-submit.test.ts
  • src/main/runtime/orchestration/mailbox-pointer-submit.ts
  • src/main/runtime/orchestration/orchestration-peer-capability-cache.test.ts
  • src/main/runtime/orchestration/orchestration-peer-capability-cache.ts
  • src/main/runtime/orchestration/worker-attention-context.ts
  • src/main/runtime/orchestration/worker-output-archive.ts
  • src/main/runtime/pty-inventory-liveness-verdict.test.ts
  • src/main/runtime/rpc/methods/orchestration-federated-fleet-snapshot.test.ts
  • src/main/runtime/rpc/methods/orchestration-federated-fleet-snapshot.ts
  • src/main/runtime/rpc/methods/orchestration-federated-worker-release-host.ts
  • src/main/runtime/rpc/methods/orchestration-federated-worker-release.ts
  • src/main/runtime/rpc/methods/orchestration-federation-attachment-observation.ts
  • src/main/runtime/rpc/methods/orchestration-federation-control.ts
  • src/main/runtime/rpc/methods/orchestration-federation-liveness-verdict.test.ts
  • src/main/runtime/rpc/methods/orchestration-federation-output.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-archive-read.ts
  • src/main/runtime/rpc/methods/orchestration-worker-list-cursor.ts
  • src/main/runtime/rpc/methods/orchestration-worker-list-method.ts
  • src/main/runtime/rpc/methods/orchestration-worker-list-pagination.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-release-completion.ts
  • src/shared/protocol-version.ts
  • tests/e2e/helpers/orchestration-mail-pane-agent.ts
  • tests/e2e/orchestration-idle-mail-delivery.spec.ts

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

Comment thread src/cli/handlers/terminal.ts Outdated
Comment thread src/main/runtime/orca-runtime.ts Outdated
Comment thread src/main/runtime/orchestration/db/attempt-observation-store.ts
Comment thread src/main/runtime/orchestration/worker-attention-context.ts
Comment thread src/main/runtime/orchestration/worker-output-archive.ts
Comment thread src/main/runtime/rpc/methods/orchestration-worker-archive-read.ts Outdated

@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/orchestration/db/worker-terminal/worker-terminal-listing.ts (1)

95-110: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract the terminal-state CASE expression into one shared constant.

Lines 97-107 and lines 252-262 contain the same 11-line CASE expression. It re-implements deriveWorkerTerminalListState from src/main/runtime/orchestration/worker-terminal-ownership.ts in SQL, including the inlined contents of WORKER_RELEASABLE_STATES and WORKER_SETTLED_STATES. If either constant changes, both SQL copies drift silently. The filter and the count then disagree with the terminalState value that line 185 derives in TypeScript.

Define the expression once in this module and build the state lists from the exported constants so a change in one place propagates.

Reuse of the existing implementation is required by the coding guidelines. As per coding guidelines: "Before writing new logic at any scale ... check whether an existing implementation already does the job (or nearly does). Extend or generalize it instead of building a parallel version".

♻️ Sketch: single source for the SQL expression
+const TERMINAL_STATE_SQL = `CASE
+  WHEN r.id IS NULL THEN CASE WHEN COALESCE(w.agent_terminal_handle, d.assignee_handle) IS NOT NULL THEN 'retained' ELSE NULL END
+  WHEN r.release_state = 'released' THEN 'released'
+  WHEN r.release_state = 'unknown' THEN 'release_unknown'
+  WHEN r.release_state IN ('requested', 'releasing') THEN 'release_pending'
+  WHEN r.ownership_state <> 'owned' OR r.release_state = 'retained' THEN 'retained'
+  WHEN COALESCE(w.state, 'unsupervised') <> 'unsupervised' AND COALESCE(w.state, '') IN (${sqlList(WORKER_RELEASABLE_STATES)}) THEN 'reclaimable'
+  WHEN COALESCE(w.state, 'unsupervised') <> 'unsupervised' AND COALESCE(w.state, '') IN (${sqlList(WORKER_SETTLED_STATES)}) THEN 'retained'
+  WHEN COALESCE(w.state, 'unsupervised') <> 'unsupervised' THEN 'active'
+  ELSE NULL
+END`

Then use TERMINAL_STATE_SQL in both listWorkerTerminalResources and countWorkerTerminalResources.

Also applies to: 251-265

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a718f070-f9a7-4dd4-a2b6-df362b71c5b0

📥 Commits

Reviewing files that changed from the base of the PR and between 04031f5 and e36c235d1e9e842c10d4639007c3f723fc8a256a.

📒 Files selected for processing (14)
  • resources/skills/current-manifest.json
  • resources/skills/snapshot-registry.json
  • skill-stubs/orchestration.md
  • skills/orchestration/SKILL.md
  • src/main/runtime/orchestration/db/worker-terminal/worker-terminal-listing.ts
  • src/main/runtime/orchestration/orchestration-peer-capability-cache.test.ts
  • src/main/runtime/orchestration/orchestration-peer-capability-cache.ts
  • src/main/runtime/rpc/methods/orchestration-federated-worker-release-host.ts
  • src/main/runtime/rpc/methods/orchestration-federation-control.ts
  • src/main/runtime/rpc/methods/orchestration-federation-output.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-list-cursor.ts
  • src/main/runtime/rpc/methods/orchestration-worker-list-method.ts
  • src/main/runtime/rpc/methods/orchestration-worker-list-pagination.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-list-snapshot-store.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • skills/orchestration/SKILL.md

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

@coderabbitai

coderabbitai Bot commented Aug 28, 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.

@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: Pro Plus

Run ID: 79cec803-edf0-4587-8a5a-617f0bff04ca

📥 Commits

Reviewing files that changed from the base of the PR and between 6f3c5cc and 31e3454.

📒 Files selected for processing (188)
  • config/scripts/generate-bundled-skill-guides.mjs
  • config/scripts/generate-bundled-skill-guides.test.mjs
  • config/scripts/orchestration-skill-guidance.test.mjs
  • resources/skills/current-manifest.json
  • resources/skills/snapshot-registry.json
  • skill-guides/orca-cli.md
  • skill-guides/orchestration.md
  • skill-guides/orchestration/references/coordinator-loop.md
  • skill-guides/orchestration/references/legacy-contract-migration.md
  • skill-guides/orchestration/references/low-level-topology.md
  • skill-guides/orchestration/references/messaging-and-gates.md
  • skill-guides/orchestration/references/placement-and-remote.md
  • skill-guides/orchestration/references/recovery-and-cleanup.md
  • skill-guides/orchestration/references/worker-contract.md
  • skill-stubs/orchestration.md
  • skills/orchestration/SKILL.md
  • src/cli/args.ts
  • src/cli/bundled-skill-guides.ts
  • src/cli/handlers/orchestration-worker-cli.test.ts
  • src/cli/handlers/orchestration/worker-launch-handler.ts
  • src/cli/handlers/orchestration/worker-terminal-handlers.ts
  • src/cli/handlers/terminal.test.ts
  • src/cli/handlers/terminal.ts
  • src/cli/help.ts
  • src/cli/index.test.ts
  • src/cli/root-help-text-secondary.ts
  • src/cli/runtime/client.ts
  • src/cli/specs/core.ts
  • src/cli/specs/orchestration-worker-specs.ts
  • src/cli/specs/terminal-send.ts
  • src/cli/terminal-format.test.ts
  • src/cli/terminal-format.ts
  • src/main/runtime/agent-prompt-submission-runtime.test.ts
  • src/main/runtime/agent-prompt-submission-verification.test.ts
  • src/main/runtime/agent-prompt-submission-verification.ts
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/orchestration-mailbox-notification-consistency.test.ts
  • src/main/runtime/orchestration/context-only-dispatch-release.ts
  • src/main/runtime/orchestration/coordinator-runtime-contract.ts
  • src/main/runtime/orchestration/coordinator-task-dispatch.ts
  • src/main/runtime/orchestration/db-task-dispatch-invariant.test.ts
  • src/main/runtime/orchestration/db-task-dispatch-lifecycle-guards.test.ts
  • src/main/runtime/orchestration/db-task-dispatch-races.test.ts
  • src/main/runtime/orchestration/db.ts
  • src/main/runtime/orchestration/db/attach-orchestration-db-methods.ts
  • src/main/runtime/orchestration/db/attempt-observation-store.ts
  • src/main/runtime/orchestration/db/attempt-observation-types.ts
  • src/main/runtime/orchestration/db/attempt-outcome-projection.test.ts
  • src/main/runtime/orchestration/db/attempt-outcome-projection.ts
  • src/main/runtime/orchestration/db/contract-constants.ts
  • src/main/runtime/orchestration/db/decision-gate-lifecycle.test.ts
  • src/main/runtime/orchestration/db/decision-gates/decision-gate-store.ts
  • src/main/runtime/orchestration/db/dispatch-context/dispatch-completion.ts
  • src/main/runtime/orchestration/db/dispatch-context/dispatch-context-store.ts
  • src/main/runtime/orchestration/db/dispatch-context/task-dispatch-reconciliation.ts
  • src/main/runtime/orchestration/db/dispatch-context/worker-report-settlement.ts
  • src/main/runtime/orchestration/db/dispatch-depth.ts
  • src/main/runtime/orchestration/db/dispatch-row-writer.ts
  • src/main/runtime/orchestration/db/federation/federated-dispatch-store.ts
  • src/main/runtime/orchestration/db/lifecycle-transition-boundary.test.ts
  • src/main/runtime/orchestration/db/lifecycle-transition.test.ts
  • src/main/runtime/orchestration/db/lifecycle-transition.ts
  • src/main/runtime/orchestration/db/orchestration-db-methods.ts
  • src/main/runtime/orchestration/db/reset/orchestration-reset.ts
  • src/main/runtime/orchestration/db/schema/create-core-tables-sql.ts
  • src/main/runtime/orchestration/db/schema/create-graph-tables-sql.ts
  • src/main/runtime/orchestration/db/schema/migrate-v13-v30.ts
  • src/main/runtime/orchestration/db/tasks/task-status-transition.ts
  • src/main/runtime/orchestration/db/tasks/task-store.ts
  • src/main/runtime/orchestration/db/worker-dispatch/federated-worker-start-reconcile.ts
  • src/main/runtime/orchestration/db/worker-dispatch/worker-dispatch-abandon.ts
  • src/main/runtime/orchestration/db/worker-dispatch/worker-dispatch-authority.ts
  • src/main/runtime/orchestration/db/worker-dispatch/worker-dispatch-outcome.ts
  • src/main/runtime/orchestration/db/worker-dispatch/worker-dispatch-stage.ts
  • src/main/runtime/orchestration/db/worker-dispatch/worker-dispatch-start.ts
  • src/main/runtime/orchestration/db/worker-dispatch/worker-dispatch-stop.ts
  • src/main/runtime/orchestration/db/worker-dispatch/worker-terminal-recovery.ts
  • src/main/runtime/orchestration/db/worker-terminal/worker-terminal-attention-query.ts
  • src/main/runtime/orchestration/db/worker-terminal/worker-terminal-listing.ts
  • src/main/runtime/orchestration/db/worker-terminal/worker-terminal-resource-store.ts
  • src/main/runtime/orchestration/db/worker-terminal/worker-terminal-user-takeover.ts
  • src/main/runtime/orchestration/federation-sync.test.ts
  • src/main/runtime/orchestration/federation-sync.ts
  • src/main/runtime/orchestration/lifecycle-reconciliation.test.ts
  • src/main/runtime/orchestration/lifecycle-reconciliation.ts
  • src/main/runtime/orchestration/mailbox-owner.ts
  • src/main/runtime/orchestration/mailbox-pointer-batch.ts
  • src/main/runtime/orchestration/mailbox-pointer-delivery-contract.ts
  • src/main/runtime/orchestration/mailbox-pointer-delivery.ts
  • src/main/runtime/orchestration/mailbox-pointer-submit.test.ts
  • src/main/runtime/orchestration/mailbox-pointer-submit.ts
  • src/main/runtime/orchestration/orchestration-peer-capability-cache.test.ts
  • src/main/runtime/orchestration/orchestration-peer-capability-cache.ts
  • src/main/runtime/orchestration/orchestration-reset-db.test.ts
  • src/main/runtime/orchestration/orchestration-schema-version-skew.ts
  • src/main/runtime/orchestration/orchestration-version-skew-migration.test.ts
  • src/main/runtime/orchestration/orchestration-worker-dispatch-db.test.ts
  • src/main/runtime/orchestration/preamble.test.ts
  • src/main/runtime/orchestration/r1-identity-migration.test.ts
  • src/main/runtime/orchestration/types.ts
  • src/main/runtime/orchestration/worker-attention-context.ts
  • src/main/runtime/orchestration/worker-output-archive.test.ts
  • src/main/runtime/orchestration/worker-output-archive.ts
  • src/main/runtime/orchestration/worker-provider-session.test.ts
  • src/main/runtime/orchestration/worker-provider-session.ts
  • src/main/runtime/orchestration/worker-report-observation.ts
  • src/main/runtime/orchestration/worker-start-unobserved-prompt-settlement.test.ts
  • src/main/runtime/orchestration/worker-terminal-ownership.ts
  • src/main/runtime/orchestration/worker-transcript-read.ts
  • src/main/runtime/orchestration/worker-transcript-remote-read.test.ts
  • src/main/runtime/orchestration/worker-transcript-remote-read.ts
  • src/main/runtime/pty-inventory-liveness-verdict.test.ts
  • src/main/runtime/rpc/core.ts
  • src/main/runtime/rpc/dispatcher-caller-fingerprint.ts
  • src/main/runtime/rpc/dispatcher.ts
  • src/main/runtime/rpc/methods/orchestration-composed-workers.test.ts
  • src/main/runtime/rpc/methods/orchestration-federated-fleet-snapshot.test.ts
  • src/main/runtime/rpc/methods/orchestration-federated-fleet-snapshot.ts
  • src/main/runtime/rpc/methods/orchestration-federated-worker-read.ts
  • src/main/runtime/rpc/methods/orchestration-federated-worker-release-host.ts
  • src/main/runtime/rpc/methods/orchestration-federated-worker-release.ts
  • src/main/runtime/rpc/methods/orchestration-federated-worker-start-receipts.ts
  • src/main/runtime/rpc/methods/orchestration-federated-worker-start.ts
  • src/main/runtime/rpc/methods/orchestration-federation-attachment-observation.ts
  • src/main/runtime/rpc/methods/orchestration-federation-control.ts
  • src/main/runtime/rpc/methods/orchestration-federation-liveness-verdict.test.ts
  • src/main/runtime/rpc/methods/orchestration-federation-output.test.ts
  • src/main/runtime/rpc/methods/orchestration-federation-release-recovery-scenarios.ts
  • src/main/runtime/rpc/methods/orchestration-federation.test.ts
  • src/main/runtime/rpc/methods/orchestration-federation.ts
  • src/main/runtime/rpc/methods/orchestration-local-worker-start.ts
  • src/main/runtime/rpc/methods/orchestration-runs.test.ts
  • src/main/runtime/rpc/methods/orchestration-tasks-dispatch.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-archive-read.ts
  • src/main/runtime/rpc/methods/orchestration-worker-control.ts
  • src/main/runtime/rpc/methods/orchestration-worker-launch-preferences.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-legacy-federated-read.ts
  • src/main/runtime/rpc/methods/orchestration-worker-list-cursor.ts
  • src/main/runtime/rpc/methods/orchestration-worker-list-method.ts
  • src/main/runtime/rpc/methods/orchestration-worker-list-pagination.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-list-snapshot-store.ts
  • src/main/runtime/rpc/methods/orchestration-worker-observation.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-observation.ts
  • src/main/runtime/rpc/methods/orchestration-worker-output.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-output.ts
  • src/main/runtime/rpc/methods/orchestration-worker-release-archive.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-release-completion.ts
  • src/main/runtime/rpc/methods/orchestration-worker-release-inventory.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-release-liveness-verdict.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-release-recovery.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-release-schemas.ts
  • src/main/runtime/rpc/methods/orchestration-worker-release-test-harness.ts
  • src/main/runtime/rpc/methods/orchestration-worker-release.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-release.ts
  • src/main/runtime/rpc/methods/orchestration-worker-start-prompt-contract.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-start-schema.ts
  • src/main/runtime/rpc/methods/orchestration-worker-terminal-resource-presentation.ts
  • src/main/runtime/rpc/methods/orchestration-workers-recovery.test.ts
  • src/main/runtime/rpc/methods/orchestration-workers.ts
  • src/main/runtime/rpc/methods/orchestration.ts
  • src/main/runtime/rpc/methods/terminal/terminal-prompt-replay-observation.ts
  • src/main/runtime/rpc/methods/terminal/terminal-send-method.ts
  • src/main/runtime/rpc/methods/terminal/unary-schemas.ts
  • src/main/runtime/rpc/orchestration-commit-notify-characterization.test.ts
  • src/main/runtime/rpc/orchestration-legacy-compatibility-dispatcher.test.ts
  • src/main/runtime/rpc/orchestration-mutation-executor.test.ts
  • src/main/runtime/rpc/orchestration-mutation-executor.ts
  • src/main/runtime/rpc/terminal-prompt-delivery-receipt.test.ts
  • src/main/sqlite/sync-database.test.ts
  • src/main/sqlite/sync-database.ts
  • src/renderer/src/store/slices/agent-status-runtime-orchestration.test.ts
  • src/renderer/src/store/slices/agent-status.ts
  • src/shared/agent-status-ipc-payload.ts
  • src/shared/agent-status-types.ts
  • src/shared/orchestration-fleet-attention.test.ts
  • src/shared/orchestration-fleet-attention.ts
  • src/shared/orchestration-fleet-projection.test.ts
  • src/shared/orchestration-fleet-projection.ts
  • src/shared/orchestration-fleet-status-index.ts
  • src/shared/orchestration-fleet-worker-projection.ts
  • src/shared/orchestration-rpc-contract.ts
  • src/shared/orchestration-worker-output.ts
  • src/shared/protocol-version.ts
  • src/shared/runtime-terminal-contracts.ts
  • src/shared/runtime-types.ts
  • tests/e2e/helpers/orchestration-mail-pane-agent.ts
  • tests/e2e/orchestration-idle-mail-delivery.spec.ts
🚧 Files skipped from review as they are similar to previous changes (167)
  • src/main/runtime/agent-prompt-submission-verification.ts
  • src/main/runtime/orchestration/orchestration-reset-db.test.ts
  • src/main/runtime/orchestration/types.ts
  • src/cli/specs/orchestration-worker-specs.ts
  • src/main/runtime/orchestration/db-task-dispatch-races.test.ts
  • src/main/runtime/orchestration/db/reset/orchestration-reset.ts
  • src/main/runtime/rpc/methods/orchestration-workers-recovery.test.ts
  • src/cli/help.ts
  • src/main/runtime/rpc/methods/orchestration-runs.test.ts
  • skill-stubs/orchestration.md
  • src/main/runtime/orchestration/db.ts
  • src/main/sqlite/sync-database.ts
  • skill-guides/orchestration/references/placement-and-remote.md
  • src/main/runtime/rpc/dispatcher-caller-fingerprint.ts
  • src/main/runtime/orchestration/coordinator-runtime-contract.ts
  • src/shared/agent-status-ipc-payload.ts
  • src/cli/args.ts
  • src/main/runtime/rpc/methods/terminal/unary-schemas.ts
  • src/shared/orchestration-fleet-status-index.ts
  • src/main/runtime/orchestration/lifecycle-reconciliation.ts
  • src/main/runtime/rpc/core.ts
  • config/scripts/generate-bundled-skill-guides.test.mjs
  • src/cli/runtime/client.ts
  • src/main/runtime/orchestration/db/schema/create-graph-tables-sql.ts
  • src/main/runtime/rpc/methods/terminal/terminal-prompt-replay-observation.ts
  • src/renderer/src/store/slices/agent-status-runtime-orchestration.test.ts
  • src/shared/orchestration-fleet-attention.test.ts
  • skill-guides/orchestration/references/low-level-topology.md
  • src/cli/specs/terminal-send.ts
  • src/main/runtime/rpc/methods/orchestration-worker-legacy-federated-read.ts
  • src/cli/handlers/terminal.test.ts
  • src/main/runtime/orchestration/context-only-dispatch-release.ts
  • src/main/runtime/orchestration/db/lifecycle-transition.test.ts
  • src/main/runtime/agent-prompt-submission-verification.test.ts
  • src/main/runtime/orchestration/db/worker-terminal/worker-terminal-attention-query.ts
  • src/main/runtime/orchestration/db-task-dispatch-invariant.test.ts
  • src/main/runtime/orchestration/db-task-dispatch-lifecycle-guards.test.ts
  • src/main/runtime/orchestration/db/lifecycle-transition-boundary.test.ts
  • tests/e2e/helpers/orchestration-mail-pane-agent.ts
  • src/main/runtime/rpc/methods/orchestration-worker-terminal-resource-presentation.ts
  • src/main/runtime/orchestration/db/decision-gates/decision-gate-store.ts
  • src/shared/agent-status-types.ts
  • src/main/runtime/orchestration/db/dispatch-context/task-dispatch-reconciliation.ts
  • src/main/runtime/orchestration/db/worker-dispatch/worker-dispatch-stage.ts
  • src/main/runtime/rpc/methods/orchestration-worker-release-schemas.ts
  • resources/skills/snapshot-registry.json
  • src/main/runtime/orchestration/db/decision-gate-lifecycle.test.ts
  • src/cli/root-help-text-secondary.ts
  • src/main/runtime/rpc/orchestration-mutation-executor.test.ts
  • skill-guides/orca-cli.md
  • src/main/runtime/rpc/orchestration-legacy-compatibility-dispatcher.test.ts
  • src/main/runtime/orchestration/db/dispatch-depth.ts
  • src/main/runtime/rpc/methods/orchestration-worker-release-liveness-verdict.test.ts
  • src/main/runtime/orchestration/db/schema/create-core-tables-sql.ts
  • skills/orchestration/SKILL.md
  • src/main/runtime/rpc/methods/orchestration-worker-observation.test.ts
  • src/shared/runtime-types.ts
  • src/cli/specs/core.ts
  • src/main/runtime/pty-inventory-liveness-verdict.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-start-schema.ts
  • src/main/runtime/orchestration/db/worker-dispatch/worker-dispatch-outcome.ts
  • src/main/runtime/orchestration/db/worker-dispatch/worker-dispatch-abandon.ts
  • src/main/runtime/orchestration/lifecycle-reconciliation.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-launch-preferences.test.ts
  • src/main/runtime/orchestration/worker-provider-session.test.ts
  • src/main/runtime/orchestration/db/orchestration-db-methods.ts
  • src/main/runtime/orchestration/worker-report-observation.ts
  • src/main/runtime/orchestration/worker-transcript-read.ts
  • src/main/runtime/orchestration/db/worker-dispatch/worker-dispatch-authority.ts
  • src/main/runtime/orchestration/db/dispatch-row-writer.ts
  • src/shared/orchestration-rpc-contract.ts
  • src/main/runtime/orchestration/db/contract-constants.ts
  • src/main/runtime/orchestration/db/tasks/task-status-transition.ts
  • src/main/runtime/rpc/methods/orchestration-worker-release-inventory.test.ts
  • src/main/runtime/orchestration/db/worker-terminal/worker-terminal-user-takeover.ts
  • src/main/runtime/rpc/methods/orchestration-tasks-dispatch.test.ts
  • src/main/sqlite/sync-database.test.ts
  • src/shared/orchestration-fleet-projection.ts
  • src/main/runtime/rpc/methods/orchestration-federation.ts
  • src/main/runtime/orchestration/mailbox-pointer-delivery-contract.ts
  • src/main/runtime/orchestration/db/dispatch-context/dispatch-context-store.ts
  • src/main/runtime/orchestration/db/attempt-observation-store.ts
  • src/main/runtime/rpc/methods/orchestration-worker-release.ts
  • src/main/runtime/rpc/methods/orchestration-federated-worker-release.ts
  • src/main/runtime/rpc/methods/orchestration-federated-worker-start.ts
  • src/main/runtime/orchestration/mailbox-pointer-batch.ts
  • src/cli/handlers/orchestration/worker-launch-handler.ts
  • src/main/runtime/orchestration/db/lifecycle-transition.ts
  • src/main/runtime/orchestration/worker-attention-context.ts
  • src/main/runtime/rpc/dispatcher.ts
  • src/main/runtime/orchestration/db/tasks/task-store.ts
  • src/main/runtime/rpc/methods/orchestration-federation-attachment-observation.ts
  • src/cli/terminal-format.ts
  • src/main/runtime/orchestration/federation-sync.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-release.test.ts
  • src/main/runtime/orchestration/coordinator-task-dispatch.ts
  • src/shared/orchestration-fleet-worker-projection.ts
  • src/main/runtime/rpc/methods/orchestration-federated-worker-start-receipts.ts
  • src/main/runtime/rpc/orchestration-commit-notify-characterization.test.ts
  • src/main/runtime/orchestration/worker-provider-session.ts
  • src/main/runtime/rpc/methods/orchestration-composed-workers.test.ts
  • resources/skills/current-manifest.json
  • src/main/runtime/orchestration/db/worker-terminal/worker-terminal-resource-store.ts
  • src/main/runtime/orchestration/orchestration-worker-dispatch-db.test.ts
  • src/main/runtime/orchestration/db/worker-dispatch/worker-terminal-recovery.ts
  • src/cli/handlers/orchestration/worker-terminal-handlers.ts
  • src/main/runtime/orchestration/orchestration-version-skew-migration.test.ts
  • src/cli/handlers/orchestration-worker-cli.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-list-cursor.ts
  • src/cli/handlers/terminal.ts
  • src/main/runtime/orchestration/worker-transcript-remote-read.ts
  • src/main/runtime/orchestration/db/worker-terminal/worker-terminal-listing.ts
  • skill-guides/orchestration.md
  • src/main/runtime/rpc/methods/orchestration-federation.test.ts
  • src/cli/index.test.ts
  • skill-guides/orchestration/references/legacy-contract-migration.md
  • src/main/runtime/orchestration/db/worker-dispatch/worker-dispatch-stop.ts
  • src/main/runtime/orchestration/worker-transcript-remote-read.test.ts
  • src/main/runtime/rpc/orchestration-mutation-executor.ts
  • src/main/runtime/orchestration/federation-sync.ts
  • skill-guides/orchestration/references/recovery-and-cleanup.md
  • src/main/runtime/orchestration/worker-start-unobserved-prompt-settlement.test.ts
  • src/main/runtime/orchestration/worker-terminal-ownership.ts
  • config/scripts/generate-bundled-skill-guides.mjs
  • src/main/runtime/rpc/terminal-prompt-delivery-receipt.test.ts
  • src/main/runtime/orchestration/worker-output-archive.ts
  • src/shared/runtime-terminal-contracts.ts
  • src/main/runtime/rpc/methods/orchestration-local-worker-start.ts
  • src/main/runtime/rpc/methods/orchestration-federated-worker-read.ts
  • src/main/runtime/rpc/methods/orchestration-worker-control.ts
  • src/main/runtime/rpc/methods/orchestration-worker-archive-read.ts
  • src/main/runtime/orchestration/db/attempt-outcome-projection.ts
  • src/main/runtime/orchestration/db/attach-orchestration-db-methods.ts
  • src/main/runtime/rpc/methods/orchestration-federated-fleet-snapshot.ts
  • src/main/runtime/rpc/methods/orchestration-worker-output.test.ts
  • src/main/runtime/agent-prompt-submission-runtime.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-release-recovery.test.ts
  • src/renderer/src/store/slices/agent-status.ts
  • src/main/runtime/orchestration/db/federation/federated-dispatch-store.ts
  • src/main/runtime/rpc/methods/terminal/terminal-send-method.ts
  • src/main/runtime/rpc/methods/orchestration-federated-fleet-snapshot.test.ts
  • src/main/runtime/orchestration/db/dispatch-context/worker-report-settlement.ts
  • src/main/runtime/orchestration/db/attempt-outcome-projection.test.ts
  • src/main/runtime/orchestration/mailbox-owner.ts
  • src/main/runtime/orchestration/db/worker-dispatch/worker-dispatch-start.ts
  • src/main/runtime/orchestration/db/attempt-observation-types.ts
  • src/main/runtime/rpc/methods/orchestration-federated-worker-release-host.ts
  • src/shared/orchestration-fleet-attention.ts
  • src/main/runtime/rpc/methods/orchestration-worker-output.ts
  • config/scripts/orchestration-skill-guidance.test.mjs
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/rpc/methods/orchestration-workers.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/orchestration-worker-observation.ts
  • src/main/runtime/rpc/methods/orchestration-worker-start-prompt-contract.test.ts
  • src/main/runtime/orchestration/mailbox-pointer-submit.ts
  • src/main/runtime/orchestration/db/worker-dispatch/federated-worker-start-reconcile.ts
  • src/main/runtime/orchestration/orchestration-peer-capability-cache.test.ts
  • src/main/runtime/orchestration/mailbox-pointer-delivery.ts
  • src/main/runtime/orchestration/mailbox-pointer-submit.test.ts
  • src/main/runtime/orchestration-mailbox-notification-consistency.test.ts
  • src/main/runtime/rpc/methods/orchestration-federation-liveness-verdict.test.ts
  • src/main/runtime/rpc/methods/orchestration.ts
  • src/main/runtime/rpc/methods/orchestration-worker-release-completion.ts
  • src/main/runtime/orchestration/orchestration-peer-capability-cache.ts
  • tests/e2e/orchestration-idle-mail-delivery.spec.ts
  • src/main/runtime/rpc/methods/orchestration-federation-output.test.ts

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

Comment on lines +279 to +283
const count = db.countWorkerTerminalResources({
runId: params.run,
snapshot: args.snapshot,
terminalState: state
})

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.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Keep counts bound to the version-3 snapshot. args.snapshot is undefined for version-3 cursors, so page.total is frozen but counts changes with current inventory; count the retained filteredSnapshot.dispatchIds instead.

@coderabbitai

coderabbitai Bot commented Aug 28, 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.

@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: 9

♻️ Duplicate comments (2)
src/cli/handlers/terminal.ts (1)

111-126: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Reject value-less --retry-request and --wait-submit.

parseArgs stores true when a value token is absent (src/cli/args.ts:89-133). getOptionalStringFlag and getOptionalPositiveIntegerFlag both discard that boolean (src/cli/flags.ts:23-29, 56-68). orca terminal send --text x --enter --retry-request therefore sends a prompt with no retry identity, which is the non-idempotent send this flag exists to prevent. --wait-submit without a value is dropped in the same way.

🐛 Proposed fix
     const promptCandidate = !!text && enter && !interrupt
+    if (flags.get('retry-request') === true || flags.get('wait-submit') === true) {
+      throw new RuntimeClientError(
+        'invalid_argument',
+        '--retry-request and --wait-submit require a value; no input was sent.'
+      )
+    }
     const retryRequest = getOptionalStringFlag(flags, 'retry-request')
src/main/runtime/orca-runtime.ts (1)

36508-36511: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Guard makePaneKey for non-UUID leaf ids in the parked branch.

Line 36511 passes stagedLeaf.leafId straight to makePaneKey. makePaneKey throws for a legacy numeric leaf id, and every other call site in this file guards with isTerminalLeafId first (for example lines 9063, 11518, 14761, and 34570). A throw here escapes resolveSubmitTarget, so the pointer submit fails and the messages are redriven without delivery. Guard the pane-key comparison instead of throwing.

🛠️ Proposed guard
     const pty = this.ptysById.get(ptyId)
     const leaf = parked
       ? pty?.connected &&
         pty.tabId === stagedLeaf.tabId &&
-        pty.paneKey === makePaneKey(stagedLeaf.tabId, stagedLeaf.leafId)
+        isTerminalLeafId(stagedLeaf.leafId) &&
+        pty.paneKey === makePaneKey(stagedLeaf.tabId, stagedLeaf.leafId)
🧹 Nitpick comments (2)
src/main/runtime/orchestration/db/federation/remote-dispatch-attachment-release.ts (1)

20-20: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Use runLifecycleWriteTransaction for this lifecycle write.

The current direct callers do not show an existing transaction, but this method can be called from one. Raw BEGIN IMMEDIATE then fails, and ROLLBACK can undo the caller's transaction. Use the helper and remove the per-branch COMMIT calls so nested calls use savepoints.

src/main/runtime/orchestration/mailbox-pointer-resume.ts (1)

17-27: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Trim the unused parameters from the resume signature.

The body uses only deps, leaf, and messages. state, mailboxHandle, enterDelayMs, leafKey, settle, and redrive are never read. The signature suggests that this function can settle flights and redrive mailboxes, which it does not do.

♻️ Proposed signature reduction
 export function resumePendingOrchestrationMailboxPointer<
   TWaiter extends OrchestrationMessageWaiter
 >(args: {
   deps: PointerDeliveryDependencies<TWaiter>
-  state: OrchestrationMailboxPointerState
   leaf: OrchestrationMailboxLeaf
-  mailboxHandle: string
   messages: readonly OrchestrationMailboxPointerMessage[]
-  enterDelayMs: number
-  leafKey: string
-  settle: (ptyId: string, flight: OrchestrationMailboxDeliveryFlight) => void
-  redrive: (mailboxHandle: string, force?: boolean) => void
 }): boolean {

Then drop the matching arguments in src/main/runtime/orchestration/mailbox-pointer-delivery.ts lines 91-101 and remove the now-unused mailbox-pointer-state type import.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a9da1afd-2ecb-407f-a510-fde7224681c1

📥 Commits

Reviewing files that changed from the base of the PR and between 65dd06a and 64dfab2.

📒 Files selected for processing (245)
  • config/reliability-gates.jsonc
  • config/scripts/generate-bundled-skill-guides.mjs
  • config/scripts/generate-bundled-skill-guides.test.mjs
  • config/scripts/orchestration-skill-guidance.test.mjs
  • resources/skills/current-manifest.json
  • resources/skills/snapshot-registry.json
  • skill-guides/orca-cli.md
  • skill-guides/orchestration.md
  • skill-guides/orchestration/references/coordinator-loop.md
  • skill-guides/orchestration/references/legacy-contract-migration.md
  • skill-guides/orchestration/references/low-level-topology.md
  • skill-guides/orchestration/references/messaging-and-gates.md
  • skill-guides/orchestration/references/placement-and-remote.md
  • skill-guides/orchestration/references/recovery-and-cleanup.md
  • skill-guides/orchestration/references/worker-contract.md
  • skill-stubs/orchestration.md
  • skills/orchestration/SKILL.md
  • src/cli/args.ts
  • src/cli/bundled-skill-guides.ts
  • src/cli/handlers/orchestration-module-boundaries.test.ts
  • src/cli/handlers/orchestration-worker-cli.test.ts
  • src/cli/handlers/orchestration/worker-launch-handler.ts
  • src/cli/handlers/orchestration/worker-output.test.ts
  • src/cli/handlers/orchestration/worker-output.ts
  • src/cli/handlers/orchestration/worker-terminal-handlers.ts
  • src/cli/handlers/terminal.test.ts
  • src/cli/handlers/terminal.ts
  • src/cli/help.ts
  • src/cli/index.test.ts
  • src/cli/root-help-text-secondary.ts
  • src/cli/runtime/client-recovery.test.ts
  • src/cli/runtime/client.ts
  • src/cli/runtime/terminal-prompt-mutation-recovery.ts
  • src/cli/specs/core.ts
  • src/cli/specs/orchestration-worker-specs.ts
  • src/cli/specs/terminal-send.ts
  • src/cli/terminal-format.test.ts
  • src/cli/terminal-format.ts
  • src/main/index.ts
  • src/main/native-chat/host-readable-transcript-path.test.ts
  • src/main/native-chat/host-readable-transcript-path.ts
  • src/main/native-chat/session-file-resolver-wsl.test.ts
  • src/main/native-chat/session-file-resolver.ts
  • src/main/runtime/agent-prompt-receipt-correlation.test.ts
  • src/main/runtime/agent-prompt-submission-runtime.test.ts
  • src/main/runtime/agent-prompt-submission-verification.test.ts
  • src/main/runtime/agent-prompt-submission-verification.ts
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/orchestration-mailbox-cold-park-idle.test.ts
  • src/main/runtime/orchestration-mailbox-crash-recovery.test.ts
  • src/main/runtime/orchestration-mailbox-notification-consistency.test.ts
  • src/main/runtime/orchestration-mailbox-notification-test-harness.ts
  • src/main/runtime/orchestration-mailbox-pointer-cli-command.test.ts
  • src/main/runtime/orchestration-mailbox-transport-settlement.test.ts
  • src/main/runtime/orchestration-message-delivery-identity.test.ts
  • src/main/runtime/orchestration/cli-command.test.ts
  • src/main/runtime/orchestration/cli-command.ts
  • src/main/runtime/orchestration/context-only-dispatch-release.ts
  • src/main/runtime/orchestration/coordinator-runtime-contract.ts
  • src/main/runtime/orchestration/coordinator-task-dispatch.ts
  • src/main/runtime/orchestration/db-task-dispatch-invariant.test.ts
  • src/main/runtime/orchestration/db-task-dispatch-lifecycle-guards.test.ts
  • src/main/runtime/orchestration/db-task-dispatch-races.test.ts
  • src/main/runtime/orchestration/db-undelivered-mailboxes.test.ts
  • src/main/runtime/orchestration/db.ts
  • src/main/runtime/orchestration/db/attach-orchestration-db-methods.ts
  • src/main/runtime/orchestration/db/attempt-observation-store.ts
  • src/main/runtime/orchestration/db/attempt-observation-types.ts
  • src/main/runtime/orchestration/db/attempt-outcome-projection.test.ts
  • src/main/runtime/orchestration/db/attempt-outcome-projection.ts
  • src/main/runtime/orchestration/db/contract-constants.ts
  • src/main/runtime/orchestration/db/decision-gate-lifecycle.test.ts
  • src/main/runtime/orchestration/db/decision-gates/decision-gate-store.ts
  • src/main/runtime/orchestration/db/dispatch-context/dispatch-completion.ts
  • src/main/runtime/orchestration/db/dispatch-context/dispatch-context-store.ts
  • src/main/runtime/orchestration/db/dispatch-context/task-dispatch-reconciliation.ts
  • src/main/runtime/orchestration/db/dispatch-context/worker-report-settlement.ts
  • src/main/runtime/orchestration/db/dispatch-depth.ts
  • src/main/runtime/orchestration/db/dispatch-row-writer.ts
  • src/main/runtime/orchestration/db/federation/federated-dispatch-store.ts
  • src/main/runtime/orchestration/db/federation/remote-dispatch-attachment-authority.ts
  • src/main/runtime/orchestration/db/federation/remote-dispatch-attachment-release.ts
  • src/main/runtime/orchestration/db/lifecycle-transition-boundary.test.ts
  • src/main/runtime/orchestration/db/lifecycle-transition.test.ts
  • src/main/runtime/orchestration/db/lifecycle-transition.ts
  • src/main/runtime/orchestration/db/lifecycle-write-transaction-runner.ts
  • src/main/runtime/orchestration/db/messages/mailbox-pointer-enter-state.ts
  • src/main/runtime/orchestration/db/messages/message-inbox.ts
  • src/main/runtime/orchestration/db/messages/message-insert.ts
  • src/main/runtime/orchestration/db/mutation-receipts/mutation-receipt-store.ts
  • src/main/runtime/orchestration/db/orchestration-db-methods.ts
  • src/main/runtime/orchestration/db/reset/orchestration-reset.ts
  • src/main/runtime/orchestration/db/schema/create-core-tables-sql.ts
  • src/main/runtime/orchestration/db/schema/create-graph-tables-sql.ts
  • src/main/runtime/orchestration/db/schema/migrate-mailbox-pointer-enter-v33.ts
  • src/main/runtime/orchestration/db/schema/migrate-v13-v30.ts
  • src/main/runtime/orchestration/db/schema/migrate.ts
  • src/main/runtime/orchestration/db/schema/schema-column-probes.ts
  • src/main/runtime/orchestration/db/tasks/task-status-transition.ts
  • src/main/runtime/orchestration/db/tasks/task-store.ts
  • src/main/runtime/orchestration/db/worker-dispatch/federated-worker-start-reconcile.ts
  • src/main/runtime/orchestration/db/worker-dispatch/worker-dispatch-abandon.ts
  • src/main/runtime/orchestration/db/worker-dispatch/worker-dispatch-authority.ts
  • src/main/runtime/orchestration/db/worker-dispatch/worker-dispatch-outcome.ts
  • src/main/runtime/orchestration/db/worker-dispatch/worker-dispatch-stage.ts
  • src/main/runtime/orchestration/db/worker-dispatch/worker-dispatch-start.ts
  • src/main/runtime/orchestration/db/worker-dispatch/worker-dispatch-stop.ts
  • src/main/runtime/orchestration/db/worker-dispatch/worker-terminal-recovery.ts
  • src/main/runtime/orchestration/db/worker-terminal/worker-terminal-attention-query.ts
  • src/main/runtime/orchestration/db/worker-terminal/worker-terminal-inventory-counts.ts
  • src/main/runtime/orchestration/db/worker-terminal/worker-terminal-listing.ts
  • src/main/runtime/orchestration/db/worker-terminal/worker-terminal-resource-store.ts
  • src/main/runtime/orchestration/db/worker-terminal/worker-terminal-transfer.ts
  • src/main/runtime/orchestration/db/worker-terminal/worker-terminal-user-takeover.ts
  • src/main/runtime/orchestration/environment-transport.ts
  • src/main/runtime/orchestration/federation-sync.test.ts
  • src/main/runtime/orchestration/federation-sync.ts
  • src/main/runtime/orchestration/formatter.test.ts
  • src/main/runtime/orchestration/formatter.ts
  • src/main/runtime/orchestration/lifecycle-reconciliation.test.ts
  • src/main/runtime/orchestration/lifecycle-reconciliation.ts
  • src/main/runtime/orchestration/mailbox-owner.ts
  • src/main/runtime/orchestration/mailbox-pointer-batch.ts
  • src/main/runtime/orchestration/mailbox-pointer-delivery-contract.ts
  • src/main/runtime/orchestration/mailbox-pointer-delivery.ts
  • src/main/runtime/orchestration/mailbox-pointer-resume.ts
  • src/main/runtime/orchestration/mailbox-pointer-stage.ts
  • src/main/runtime/orchestration/mailbox-pointer-state.ts
  • src/main/runtime/orchestration/mailbox-pointer-submit.test.ts
  • src/main/runtime/orchestration/mailbox-pointer-submit.ts
  • src/main/runtime/orchestration/message-batch-atomicity.test.ts
  • src/main/runtime/orchestration/orchestration-peer-capability-cache.test.ts
  • src/main/runtime/orchestration/orchestration-peer-capability-cache.ts
  • src/main/runtime/orchestration/orchestration-reset-db.test.ts
  • src/main/runtime/orchestration/orchestration-schema-version-skew.ts
  • src/main/runtime/orchestration/orchestration-version-skew-migration.test.ts
  • src/main/runtime/orchestration/orchestration-worker-dispatch-db.test.ts
  • src/main/runtime/orchestration/preamble.test.ts
  • src/main/runtime/orchestration/r1-identity-migration.test.ts
  • src/main/runtime/orchestration/types.ts
  • src/main/runtime/orchestration/worker-attention-context.ts
  • src/main/runtime/orchestration/worker-output-archive.test.ts
  • src/main/runtime/orchestration/worker-output-archive.ts
  • src/main/runtime/orchestration/worker-provider-session.test.ts
  • src/main/runtime/orchestration/worker-provider-session.ts
  • src/main/runtime/orchestration/worker-report-observation.ts
  • src/main/runtime/orchestration/worker-start-unobserved-prompt-settlement.test.ts
  • src/main/runtime/orchestration/worker-terminal-ownership.ts
  • src/main/runtime/orchestration/worker-terminal-release-reconciliation.ts
  • src/main/runtime/orchestration/worker-transcript-payload.test.ts
  • src/main/runtime/orchestration/worker-transcript-payload.ts
  • src/main/runtime/orchestration/worker-transcript-read.ts
  • src/main/runtime/orchestration/worker-transcript-remote-read.test.ts
  • src/main/runtime/orchestration/worker-transcript-remote-read.ts
  • src/main/runtime/pty-inventory-liveness-verdict.test.ts
  • src/main/runtime/rpc/core.ts
  • src/main/runtime/rpc/dispatcher-caller-fingerprint.ts
  • src/main/runtime/rpc/dispatcher-unary-method-invocation.ts
  • src/main/runtime/rpc/dispatcher.ts
  • src/main/runtime/rpc/methods/orchestration-composed-workers.test.ts
  • src/main/runtime/rpc/methods/orchestration-federated-fleet-snapshot.test.ts
  • src/main/runtime/rpc/methods/orchestration-federated-fleet-snapshot.ts
  • src/main/runtime/rpc/methods/orchestration-federated-release-safety.test.ts
  • src/main/runtime/rpc/methods/orchestration-federated-transport-safety.test.ts
  • src/main/runtime/rpc/methods/orchestration-federated-worker-read.ts
  • src/main/runtime/rpc/methods/orchestration-federated-worker-release-host.ts
  • src/main/runtime/rpc/methods/orchestration-federated-worker-release.ts
  • src/main/runtime/rpc/methods/orchestration-federated-worker-start-receipt.test.ts
  • src/main/runtime/rpc/methods/orchestration-federated-worker-start-receipts.ts
  • src/main/runtime/rpc/methods/orchestration-federated-worker-start.ts
  • src/main/runtime/rpc/methods/orchestration-federation-attachment-observation.ts
  • src/main/runtime/rpc/methods/orchestration-federation-control.ts
  • src/main/runtime/rpc/methods/orchestration-federation-liveness-verdict.test.ts
  • src/main/runtime/rpc/methods/orchestration-federation-output.test.ts
  • src/main/runtime/rpc/methods/orchestration-federation-release-recovery-scenarios.ts
  • src/main/runtime/rpc/methods/orchestration-federation.test.ts
  • src/main/runtime/rpc/methods/orchestration-federation.ts
  • src/main/runtime/rpc/methods/orchestration-local-worker-start.ts
  • src/main/runtime/rpc/methods/orchestration-runs.test.ts
  • src/main/runtime/rpc/methods/orchestration-tasks-dispatch.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-archive-read.ts
  • src/main/runtime/rpc/methods/orchestration-worker-control.ts
  • src/main/runtime/rpc/methods/orchestration-worker-launch-preferences.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-legacy-federated-read.ts
  • src/main/runtime/rpc/methods/orchestration-worker-list-cursor.ts
  • src/main/runtime/rpc/methods/orchestration-worker-list-method.ts
  • src/main/runtime/rpc/methods/orchestration-worker-list-pagination.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-list-projection.ts
  • src/main/runtime/rpc/methods/orchestration-worker-list-snapshot-store.ts
  • src/main/runtime/rpc/methods/orchestration-worker-observation.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-observation.ts
  • src/main/runtime/rpc/methods/orchestration-worker-output.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-output.ts
  • src/main/runtime/rpc/methods/orchestration-worker-release-archive.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-release-completion.ts
  • src/main/runtime/rpc/methods/orchestration-worker-release-inventory.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-release-liveness-verdict.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-release-recovery.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-release-schemas.ts
  • src/main/runtime/rpc/methods/orchestration-worker-release-test-harness.ts
  • src/main/runtime/rpc/methods/orchestration-worker-release.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-release.ts
  • src/main/runtime/rpc/methods/orchestration-worker-start-prompt-contract.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-start-schema.ts
  • src/main/runtime/rpc/methods/orchestration-worker-stop.ts
  • src/main/runtime/rpc/methods/orchestration-worker-terminal-resource-presentation.ts
  • src/main/runtime/rpc/methods/orchestration-workers-recovery.test.ts
  • src/main/runtime/rpc/methods/orchestration-workers.ts
  • src/main/runtime/rpc/methods/orchestration.ts
  • src/main/runtime/rpc/methods/terminal/terminal-prompt-replay-observation.ts
  • src/main/runtime/rpc/methods/terminal/terminal-send-method.ts
  • src/main/runtime/rpc/methods/terminal/unary-schemas.ts
  • src/main/runtime/rpc/orchestration-commit-notify-characterization.test.ts
  • src/main/runtime/rpc/orchestration-legacy-compatibility-dispatcher.test.ts
  • src/main/runtime/rpc/orchestration-mutation-executor.test.ts
  • src/main/runtime/rpc/orchestration-mutation-executor.ts
  • src/main/runtime/rpc/orchestration-mutation-receipt.ts
  • src/main/runtime/rpc/terminal-prompt-delivery-receipt.test.ts
  • src/main/runtime/terminal-send-stale-leaf-liveness.test.ts
  • src/main/sqlite/sync-database.test.ts
  • src/main/sqlite/sync-database.ts
  • src/renderer/src/store/slices/agent-status-runtime-orchestration.test.ts
  • src/renderer/src/store/slices/agent-status.ts
  • src/shared/agent-status-ipc-payload.ts
  • src/shared/agent-status-types.ts
  • src/shared/orchestration-fleet-attention.test.ts
  • src/shared/orchestration-fleet-attention.ts
  • src/shared/orchestration-fleet-projection.test.ts
  • src/shared/orchestration-fleet-projection.ts
  • src/shared/orchestration-fleet-status-index.ts
  • src/shared/orchestration-fleet-worker-projection.ts
  • src/shared/orchestration-rpc-contract.ts
  • src/shared/orchestration-worker-output.ts
  • src/shared/pane-agent-identity-inventory.test.ts
  • src/shared/protocol-version.ts
  • src/shared/runtime-terminal-contracts.ts
  • src/shared/runtime-types.ts
  • tests/e2e/helpers/orchestration-mail-pane-agent.ts
  • tests/e2e/helpers/orchestration-mail-store.ts
  • tests/e2e/orchestration-idle-mail-delivery.spec.ts
  • tests/e2e/orchestration-idle-mail-restore.spec.ts
  • tests/e2e/orchestration-worker-terminal-visibility.spec.ts
  • tests/e2e/terminal-send-agent-prompt-submit.spec.ts
  • tests/tools/repro-terminal-send-submit.mjs
🚧 Files skipped from review as they are similar to previous changes (133)
  • src/main/runtime/rpc/methods/orchestration-worker-launch-preferences.test.ts
  • src/shared/orchestration-rpc-contract.ts
  • src/main/sqlite/sync-database.ts
  • resources/skills/current-manifest.json
  • src/main/runtime/rpc/methods/terminal/unary-schemas.ts
  • src/main/runtime/rpc/methods/terminal/terminal-prompt-replay-observation.ts
  • src/main/runtime/rpc/methods/orchestration-worker-release-liveness-verdict.test.ts
  • src/renderer/src/store/slices/agent-status-runtime-orchestration.test.ts
  • src/main/runtime/orchestration/db/dispatch-depth.ts
  • skill-guides/orca-cli.md
  • src/shared/runtime-types.ts
  • src/main/runtime/rpc/methods/orchestration-worker-list-cursor.ts
  • src/main/runtime/rpc/methods/orchestration-workers-recovery.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-start-schema.ts
  • src/main/runtime/rpc/dispatcher-caller-fingerprint.ts
  • src/shared/agent-status-ipc-payload.ts
  • src/cli/root-help-text-secondary.ts
  • src/main/runtime/rpc/methods/orchestration-federated-worker-read.ts
  • src/renderer/src/store/slices/agent-status.ts
  • src/main/runtime/orchestration/db/worker-terminal/worker-terminal-user-takeover.ts
  • src/main/runtime/orchestration/db/worker-dispatch/worker-dispatch-abandon.ts
  • src/main/runtime/rpc/orchestration-legacy-compatibility-dispatcher.test.ts
  • src/main/runtime/rpc/methods/orchestration-federation-attachment-observation.ts
  • src/main/runtime/orchestration/mailbox-pointer-delivery-contract.ts
  • src/main/runtime/orchestration/worker-attention-context.ts
  • src/shared/orchestration-fleet-attention.test.ts
  • src/main/runtime/orchestration/db/decision-gate-lifecycle.test.ts
  • src/shared/agent-status-types.ts
  • src/main/runtime/rpc/methods/orchestration-worker-release-schemas.ts
  • src/main/runtime/orchestration/mailbox-pointer-batch.ts
  • src/main/runtime/orchestration/db/worker-terminal/worker-terminal-attention-query.ts
  • src/shared/runtime-terminal-contracts.ts
  • src/main/runtime/rpc/methods/orchestration-runs.test.ts
  • src/main/runtime/orchestration/db/schema/create-graph-tables-sql.ts
  • src/main/runtime/orchestration/db/federation/federated-dispatch-store.ts
  • src/main/runtime/orchestration/db/lifecycle-transition-boundary.test.ts
  • src/main/runtime/orchestration/db/dispatch-context/task-dispatch-reconciliation.ts
  • src/main/runtime/orchestration/worker-start-unobserved-prompt-settlement.test.ts
  • src/main/runtime/orchestration/db/worker-dispatch/federated-worker-start-reconcile.ts
  • src/cli/specs/orchestration-worker-specs.ts
  • skill-guides/orchestration/references/placement-and-remote.md
  • src/main/runtime/rpc/methods/terminal/terminal-send-method.ts
  • config/scripts/orchestration-skill-guidance.test.mjs
  • src/main/runtime/orchestration/orchestration-version-skew-migration.test.ts
  • skill-guides/orchestration/references/recovery-and-cleanup.md
  • src/main/runtime/rpc/methods/orchestration-worker-release-inventory.test.ts
  • skill-guides/orchestration/references/low-level-topology.md
  • src/main/runtime/rpc/methods/orchestration-composed-workers.test.ts
  • src/main/runtime/orchestration/orchestration-peer-capability-cache.test.ts
  • src/shared/orchestration-fleet-worker-projection.ts
  • src/main/runtime/orchestration/worker-terminal-ownership.ts
  • src/cli/args.ts
  • src/main/runtime/orchestration/orchestration-worker-dispatch-db.test.ts
  • src/main/runtime/orchestration/worker-provider-session.test.ts
  • src/main/sqlite/sync-database.test.ts
  • src/main/runtime/orchestration/coordinator-runtime-contract.ts
  • src/main/runtime/orchestration/db/reset/orchestration-reset.ts
  • src/main/runtime/rpc/methods/orchestration-worker-list-method.ts
  • src/cli/handlers/orchestration/worker-launch-handler.ts
  • resources/skills/snapshot-registry.json
  • src/main/runtime/rpc/methods/orchestration-tasks-dispatch.test.ts
  • src/shared/orchestration-fleet-projection.ts
  • src/main/runtime/orchestration/db/dispatch-row-writer.ts
  • src/main/runtime/orchestration/db.ts
  • src/main/runtime/orchestration/federation-sync.test.ts
  • src/main/runtime/orchestration/coordinator-task-dispatch.ts
  • src/main/runtime/rpc/methods/orchestration-worker-output.ts
  • src/main/runtime/orchestration/db/dispatch-context/dispatch-context-store.ts
  • src/cli/specs/terminal-send.ts
  • src/main/runtime/orchestration/db/worker-dispatch/worker-dispatch-authority.ts
  • src/main/runtime/orchestration/lifecycle-reconciliation.test.ts
  • src/main/runtime/orchestration/db/tasks/task-store.ts
  • src/main/runtime/rpc/methods/orchestration-worker-control.ts
  • skill-guides/orchestration/references/legacy-contract-migration.md
  • src/main/runtime/orchestration/db/worker-dispatch/worker-dispatch-outcome.ts
  • src/main/runtime/orchestration/db/worker-terminal/worker-terminal-resource-store.ts
  • src/main/runtime/rpc/methods/orchestration-federated-worker-start-receipts.ts
  • src/main/runtime/rpc/methods/orchestration-worker-archive-read.ts
  • src/main/runtime/orchestration/worker-report-observation.ts
  • src/main/runtime/rpc/methods/orchestration-local-worker-start.ts
  • src/cli/specs/core.ts
  • src/shared/orchestration-fleet-attention.ts
  • tests/e2e/helpers/orchestration-mail-pane-agent.ts
  • skill-guides/orchestration.md
  • src/main/runtime/orchestration/db/decision-gates/decision-gate-store.ts
  • src/main/runtime/orchestration/db/lifecycle-transition.test.ts
  • src/main/runtime/orchestration/worker-transcript-remote-read.ts
  • src/main/runtime/rpc/methods/orchestration-worker-list-snapshot-store.ts
  • src/shared/orchestration-fleet-status-index.ts
  • src/main/runtime/orchestration/mailbox-owner.ts
  • src/main/runtime/orchestration/db/worker-dispatch/worker-dispatch-stop.ts
  • skill-stubs/orchestration.md
  • src/cli/terminal-format.ts
  • src/main/runtime/orchestration/db-task-dispatch-invariant.test.ts
  • src/main/runtime/orchestration/db/attempt-observation-types.ts
  • src/main/runtime/orchestration/db/worker-dispatch/worker-dispatch-stage.ts
  • src/main/runtime/rpc/methods/orchestration-workers.ts
  • src/main/runtime/orchestration/db/worker-dispatch/worker-dispatch-start.ts
  • src/main/runtime/orchestration/lifecycle-reconciliation.ts
  • config/scripts/generate-bundled-skill-guides.test.mjs
  • src/main/runtime/orchestration/worker-output-archive.test.ts
  • src/main/runtime/orchestration/db/worker-dispatch/worker-terminal-recovery.ts
  • src/main/runtime/rpc/terminal-prompt-delivery-receipt.test.ts
  • src/main/runtime/orchestration/worker-provider-session.ts
  • config/scripts/generate-bundled-skill-guides.mjs
  • src/main/runtime/rpc/methods/orchestration-federation.test.ts
  • src/main/runtime/orchestration/orchestration-peer-capability-cache.ts
  • src/main/runtime/orchestration/db/attempt-outcome-projection.ts
  • src/main/runtime/orchestration/db/attempt-outcome-projection.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-release.ts
  • skills/orchestration/SKILL.md
  • src/main/runtime/rpc/methods/orchestration-worker-release-test-harness.ts
  • src/main/runtime/orchestration/db-task-dispatch-lifecycle-guards.test.ts
  • src/cli/terminal-format.test.ts
  • src/main/runtime/orchestration/db/tasks/task-status-transition.ts
  • src/main/runtime/agent-prompt-submission-verification.ts
  • src/main/runtime/rpc/methods/orchestration-federation-control.ts
  • src/main/runtime/orchestration/db/attempt-observation-store.ts
  • src/shared/protocol-version.ts
  • src/main/runtime/rpc/methods/orchestration-federated-worker-release.ts
  • src/main/runtime/orchestration/context-only-dispatch-release.ts
  • src/main/runtime/rpc/methods/orchestration-worker-release-completion.ts
  • src/main/runtime/rpc/methods/orchestration-worker-start-prompt-contract.test.ts
  • src/main/runtime/rpc/methods/orchestration-federated-fleet-snapshot.ts
  • src/main/runtime/rpc/methods/orchestration-federation-output.test.ts
  • src/main/runtime/orchestration/db/dispatch-context/worker-report-settlement.ts
  • src/main/runtime/orchestration/db/dispatch-context/dispatch-completion.ts
  • src/main/runtime/orchestration/orchestration-schema-version-skew.ts
  • src/main/runtime/rpc/methods/orchestration-worker-observation.test.ts
  • tests/e2e/orchestration-idle-mail-delivery.spec.ts
  • src/main/runtime/rpc/orchestration-mutation-executor.ts
  • src/main/runtime/orchestration/orchestration-reset-db.test.ts
  • src/shared/orchestration-fleet-projection.test.ts

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

Comment thread src/cli/handlers/orchestration/worker-terminal-handlers.ts Outdated
Comment thread src/main/runtime/agent-prompt-receipt-correlation.test.ts Outdated
Comment thread src/main/runtime/orca-runtime.test.ts Outdated
Comment on lines +1242 to +1252
const stagedIds = new Set(ids)
let changed = 0
for (const message of this.messages) {
if (stagedIds.has(message.id) && message.read === 0) {
message.pointer_enter_pending = 1
message.pointer_pty_id = target.ptyId
message.pointer_process_incarnation = target.processIncarnation
changed += 1
}
}
return changed === ids.length

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

Preserve an existing pointer reservation.

Line 1245 overwrites an unread message that is already pointer-pending. A second target can replace the original ptyId and processIncarnation, so its later release cannot match or clear the reservation. Require pointer_enter_pending === 0 before staging.

Comment thread src/main/runtime/orchestration/db/messages/mailbox-pointer-enter-state.ts Outdated
Comment thread src/main/runtime/orchestration/mailbox-pointer-delivery.ts
Comment thread src/main/runtime/orchestration/mailbox-pointer-resume.ts
Comment thread src/main/runtime/orchestration/mailbox-pointer-stage.ts Outdated
Comment thread src/main/runtime/pty-inventory-liveness-verdict.test.ts Outdated
@Tauri-EPO

Tauri-EPO commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

From the #15190 map: what this PR closes, and a Windows QA offer

I really like the direction here — durable receipts instead of keystroke inference is the right foundation. I've been tracking every stage of the orchestration loop in #15190, and this single PR moves more of that map than everything else combined since it was opened. Measured against the reports filed from my sessions:

  • #15180 — closed as declared: the receipt ladder (input_accepted → queued_pending_turn → submission_observed → turn_started) with durable mutation_receipts and replay-without-resend is the verdict that issue asked for.
  • #15976 — the false-stall half is resolved at the source: an answered prompt that never starts a turn returns an honest receipt instead of agent_prompt_stalled, and --retry-request never re-pastes, so the retry-corruption mode dies.
  • #16377 / #16902 family — retainCapability on a stalled start plus the self-correcting worker_done (unobserved_prompt_report) cuts the stalled → revoked → unreportable chain that stranded three of my lanes in one night.
  • #16529 — --retry-of documented in recovery-and-cleanup.md where recovery actually happens, and a rejected worker_done now wakes the waiting coordinator instead of leaving it in check --wait forever.
  • #14907 / #15951 / #15186 — advanced: the paginated fleet projection with liveness / attention / nextAction is the first real answer to "which lane went quiet?" without one call per worker.
  • #14832 / #14840 — partially: the busy-agent Enter deferral and incarnation-fenced submit harden the pointer path, and the worktree-placement rule now opens placement-and-remote.md.

If a Windows QA pass would help, this machine reproduced most of the failures above (Windows 11, multi-orchestrator, Claude + Codex + Grok lanes) and I'd be glad to rerun those measured scenarios on this branch — just say the word and whether to wait for the rebase.

Three notes from reading the diff, none overlapping the existing review threads:

1. A worker whose prompt never started a turn now looks healthy in the fleet. With agent_prompt_stalled converted to a queued receipt (and retainCapability keeping the dispatch alive — both good calls), the only trace of "accepted but no turn started" lives in the prompt receipt's stages. Nothing projects those stages into worker-list/attention (orchestration-fleet-projection.ts and worker-terminal-attention-query.ts have no consumer for queued_pending_turn/turn_started), so the case this PR downgrades from a false failure becomes an invisible non-start: state: ready, stage: input_accepted, no attention category. An input-style attention entry for "accepted, no turn observed after N s" would close the loop the receipt ladder opens. (This is the surviving sliver of #15180 — no objection to that issue closing with this PR; if the projection gap remains after landing, I'll re-file it narrowly.)

2. The coordinator inject drops the receipt the PR standardizes. coordinator-task-dispatch.ts:139-143 awaits sendTerminalAgentPrompt(...acceptQueued...) without capturing the result, so the delivery stages for a coordinator-driven dispatch are recorded nowhere — the one send surface where no caller can ever re-observe them. The Why (#16095) comment explains not failing here; persisting or logging the returned stages seems consistent with the rest of the design.

3. The v33 partial index can't be used by its own queries. migrate-mailbox-pointer-enter-v33.ts:18-20 creates idx_messages_pending_pointer_enter ... WHERE read = 0 AND pointer_enter_pending = 1, but the scans filter pointer_enter_pending > 0 (mailbox-pointer-enter-state.ts:22,34,153), which SQLite won't match against the = 1 predicate. > 0 in the index predicate (or IN (1,2,3)) would make it live.

brennanb2025 added a commit that referenced this pull request Aug 29, 2026
`native-smoke (windows-latest)` fails ~4.5% of runs on
`preserves a multiline argument through the compiled remote launcher`
with "Test timed out in 15000ms" — on unrelated PRs, for reasons that
have nothing to do with them. Across 176 sampled attempts it is the only
red that job produced, and it hit seven different PRs in two days:
#16900, #16904, #16915, #16955 (twice), #16979, #17014, #17085.

The test is six process creations: powershell.exe forks csc.exe, then
the freshly compiled orca.exe forks node.exe, twice. Hosted Windows
runners periodically slow process creation down, and this test amplifies
that far harder than anything else in the job. Comparing the 80 attempts
where it ran under 3s against the 12 where it ran over 12s, its own
median goes 2198ms -> 15917ms (7.2x) while the same file's
powershell-only test moves 556 -> 686ms (1.2x), the cmd.exe and Git Bash
process tests in the neighbouring file move 1.4x, and the other 35 files
put together move 1.5x.

Measured across those 176 attempts: 1881ms to 35438ms, p50 4264ms,
correlation +0.881 with the job's total Vitest duration. 8 of 176 (4.5%)
exceeded the 15s cap; 2 of 176 (1.1%) also exceeded the shared 30s
testTimeout, so deleting the override and inheriting the config is not
enough on its own. 60s clears all 176 with 1.7x headroom on the worst.

This is slow, not hung. Every body here is synchronous spawnSync, so
Vitest cannot interrupt one — the timer fires only after the body
returns and the reported duration is real elapsed time. That is why a
failure reads `× ... 22464ms` under `Test timed out in 15000ms`. The
work finished; the stopwatch was short. Seven reruns at one identical
head measured 2053 / 4680 / 5551 / 8732 / 13506 / 14868 / 21937ms — the
last of those would have been red on code that had not changed.

The 15s came from #8897, which raised this test off Vitest's built-in 5s
default because the job then ran bare `pnpm vitest run`. #8909 landed
3h27m later and pointed the job at config/vitest.config.ts, which is the
real fix for that. The constant stayed behind and has been the binding
budget ever since.
@Jinwoo-H
Jinwoo-H force-pushed the orchestration-v3 branch 3 times, most recently from 34ada8d to 4a32d07 Compare August 29, 2026 08:10
brennanb2025 added a commit that referenced this pull request Aug 30, 2026
`native-smoke (windows-latest)` fails ~4.5% of runs on
`preserves a multiline argument through the compiled remote launcher`
with "Test timed out in 15000ms" — on unrelated PRs, for reasons that
have nothing to do with them. Across 176 sampled attempts it is the only
red that job produced, and it hit seven different PRs in two days:
#16900, #16904, #16915, #16955 (twice), #16979, #17014, #17085.

The test is six process creations: powershell.exe forks csc.exe, then
the freshly compiled orca.exe forks node.exe, twice. Hosted Windows
runners periodically slow process creation down, and this test amplifies
that far harder than anything else in the job. Comparing the 80 attempts
where it ran under 3s against the 12 where it ran over 12s, its own
median goes 2198ms -> 15917ms (7.2x) while the same file's
powershell-only test moves 556 -> 686ms (1.2x), the cmd.exe and Git Bash
process tests in the neighbouring file move 1.4x, and the other 35 files
put together move 1.5x.

Measured across those 176 attempts: 1881ms to 35438ms, p50 4264ms,
correlation +0.881 with the job's total Vitest duration. 8 of 176 (4.5%)
exceeded the 15s cap; 2 of 176 (1.1%) also exceeded the shared 30s
testTimeout, so deleting the override and inheriting the config is not
enough on its own. 60s clears all 176 with 1.7x headroom on the worst.

This is slow, not hung. Every body here is synchronous spawnSync, so
Vitest cannot interrupt one — the timer fires only after the body
returns and the reported duration is real elapsed time. That is why a
failure reads `× ... 22464ms` under `Test timed out in 15000ms`. The
work finished; the stopwatch was short. Seven reruns at one identical
head measured 2053 / 4680 / 5551 / 8732 / 13506 / 14868 / 21937ms — the
last of those would have been red on code that had not changed.

The 15s came from #8897, which raised this test off Vitest's built-in 5s
default because the job then ran bare `pnpm vitest run`. #8909 landed
3h27m later and pointed the job at config/vitest.config.ts, which is the
real fix for that. The constant stayed behind and has been the binding
budget ever since.
@Jinwoo-H

Copy link
Copy Markdown
Contributor Author

Review audit against head bae6453813:

Fixed concrete findings:

  • Mailbox pointer reservations are now compare-and-set (pointer_enter_pending = 0) with all-or-nothing staging/phase transitions, so concurrent flights cannot steal or partially claim a batch.
  • Mixed-target pending reservations are released per target, and a competing mailbox is parked before a deferred Enter is consumed.
  • Remote transcript reads report transcript_missing when no attested path exists.
  • Federation structured-read fallback observes and stores the runtime epoch returned by the legacy read.
  • Observation payload canonicalization always writes valid JSON when optional fields are explicitly undefined.
  • Abandoning an already failed/stopped worker is an idempotent stale result instead of an illegal lifecycle transition.
  • Legacy pane IDs are guarded before makePaneKey.
  • Non-exact federated fleet observations are normalized to unverifiable.
  • Replay-only mutation observation failures return the already durable receipt and never create a resend opportunity.
  • Worker attention uses the DB-derived root flag; the CLI omits empty cursor hints.
  • Fixed the Map cardinality assertions and the tautological prompt-write assertion.
  • Updated the v33 mailbox pointer index predicate to match the > 0 queries.
  • Added focused regression coverage; 90 relevant tests pass, pnpm tc:node passes, and changed-code quality is clean.

Intentionally not changed:

  • The optional CodeRabbit refactors (hoisted constants, duplicated SQL extraction, parser deduplication, selecting extra columns, import placement, docstring coverage) do not change behavior and would expand this already-large PR.
  • The “close exited terminal” suggestion is not applicable: an execution-host exited verdict is already the cleanup evidence; attempting another close would be redundant. The existing closed_exited_terminal action is retained for wire compatibility.
  • The shared projection’s unknown-cursor fallback is not reachable from the worker-list API, which rejects unknown encoded/legacy cursors before projection; changing the shared helper would add an API contract without a current caller.
  • The outdated archive/count comments and the coordinator receipt-plumbing suggestion were not acted on because they are superseded or observational-only rather than user-visible correctness issues.

All changes are pushed to the PR branch.

@Jinwoo-H

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (cc6b600e21) to clear merge conflicts. New head: d4e6fb412e. Local verification remains green: pnpm tc:node and 90 focused orchestration/review regression tests. GitHub now reports the PR as MERGEABLE / CLEAN; fresh CI is queued for the rebased head.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants