Skip to content

feat(orchestration): tell the coordinator when a worker stops without worker_done - #35294

Closed
Jinwoo-H wants to merge 11 commits into
mainfrom
orch-worker-stop-report
Closed

Jinwoo-H wants to merge 11 commits into
mainfrom
orch-worker-stop-report

Conversation

@Jinwoo-H

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

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​297 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​297
Prod 20 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​558 $\color{#cf222e}{\Huge{\mathbf{−}}}$​16 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​542

ELI5

A dispatched worker that stops without sending worker_done (the model was at capacity, it errored, it misread the task, or it just stopped) used to leave its Dispatch at "dispatched". The coordinator heard nothing, sometimes for hours. Now Orca tells the coordinator, once per stop, with the worker's last output. The coordinator then decides what to do: answer it, retry it, or stop it.

What Changed

Before: a worker's turn ends and it sits at its prompt. The Dispatch stays open and no mail arrives.

After: the coordinator's Run gets one escalation ("Worker stopped without reporting", "...stopped on an error...", or "Worker is waiting on a prompt"). The message carries:

  • the worker's last words, or the screen when the turn errored or is stuck at a prompt
  • the commands to answer, read or stop the worker (quoted output is capability-redacted)
  • a payload with stopReason

It wakes the coordinator like other worker mail. The Dispatch is never settled or failed automatically.

When it fires:

  • Signals reused: the turn-end signal Orca already uses for phone alerts and the sidebar. For terminal workers that is TerminalAgentTurnNews over AgentTransitionDetector. For chat workers it is the structured host's turn-completion feed. Only hook-reported finishes, errors and approval prompts count. Silence never does.
  • One per stop: the message id hashes the Dispatch with the stop. The next turn (for example after the coordinator replies) re-arms it.
  • Not during deliberate waits: a worker inside ask or check --wait (a live dispatch:<id> waiter) is skipped, and so is a worker waiting on its own open helper Dispatches.
  • Not for a lead with working children: a new opt-in allClearOnly on TerminalAgentTurnNews waits for the children's all-clear.
  • Dispatch changes: the stop belongs to the Dispatch that was active when it was seen. A follow-up Dispatch that arrives before delivery drops it.
  • Chat failures already escalate through the existing chat-error path. User-stopped turns are not news.

Where:

  • Local and SSH workers: the execution host's runtime observes the pane and calls escalateWorkerFailure, the path terminal-exit escalations already use.
  • Paired-server workers: the execution host relays the escalation to the Run home through enqueueFederationRelay, the way a worker's own send does, under a stable message id. A queued but unacknowledged worker_done suppresses the relay. Older homes import it as an ordinary escalation, and older execution hosts just never send it.
  • Fleet state: while a stop report is newer than the last mail to the worker, worker-list/worker-show project the open attempt as finished_unverified, so requiresAction is true and nextAction is recover (worker-read). Mail to the worker, worker_done, or settling the attempt clears it. No new enum values.
  • Stop keeps output: worker-stop, local and paired-server, archives the worker's output before closing its terminal, bounded at 5 s and best effort. A later release then settles with that archive instead of "unavailable", and worker-retain keeps it for a stopped worker.
  • Guide: one line in the orchestration guide says what the message means and the usual responses.

Testing

  • worker-turn-stops.test.ts covers:
    • an errored stop with screen output, sent once
    • re-arm on a new turn
    • an approval prompt
    • silence for a resumed turn, a settled Dispatch, or an open dispatch: waiter
    • a lead with children
    • a Dispatch replaced during the quiet window
    • chat success vs failure
    • the remote relay: stable id, string payload, and a pending worker_done suppressing it
    • capability redaction
    • fleet projection of a stopped attempt, cleared by coordinator mail
    • stop, optionally retain, then release keeps captured output
  • Real app (dev build, background launch, isolated profile, agents on the dev CLI), Claude worker told to reply "hello" and end its turn:
    • Before (main 40822e2): the turn ended, the Dispatch stayed pending, and check --peek returned 0 messages.
    • After (this branch): one escalation "Worker stopped without reporting" with stopReason: finished. A second turn gave exactly one more. A turn ending in worker_done gave none (worker_done was the only new message).
  • pnpm check:changed --maxWorkers=2: 20 checks passed.

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Walkthrough

The runtime now reports qualifying terminal and chat worker turn stops for local and remote Dispatches. It checks Dispatch and mailbox state before reporting, formats stop details, and routes local reports through failure escalation and remote reports through federation relays. Terminal stop handling validates that the worker and Dispatch remain in the captured state. The orchestration guide documents responses to escalations with a stopReason. The change also updates worker attention and recovery projections and archives worker output before stop operations.

Priority: Normal

Merge Risk: Moderate · up to f353a

Resolve the remote output and worker-recovery visibility issues before merging. Remote workers can also escalate while helpers are active, and a reporting error can go unhandled.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Description check Warning The description follows the repository template. It includes the ELI5, What Changed (before/after, mechanism, and trigger conditions), Why-adjacent rationale, Testing with specific test coverage and a… Add a Linked Issue reference (for example, "Fixes #"); the template requires an actual issue for outside contributors. Fill in Visual Proof with a before/after reference (video or screenshots) or write N/A with a reason, since this …
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title "feat(orchestration): tell the coordinator when a worker stops without worker_done" states the main change. The PR adds an escalation to the coordinator when a dispatched worker's turn ends …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "feat(orchestration): tell the coordinator when a worker stops without worker_done" states the main change. The PR adds an escalation to the coordinator when a dispatched worker's turn ends without sending worker_done. The title is specific and concise, and it follows a conventional commit format. It does not cover the secondary changes (fleet projection, worker-stop archiving, relay), which is acceptable.

Full details: Description check

Explanation

The description follows the repository template. It includes the ELI5, What Changed (before/after, mechanism, and trigger conditions), Why-adjacent rationale, Testing with specific test coverage and a real-app before/after check, and the LoC summary. Gaps: the Linked Issue section is still the empty template ("Fixes #"), which the template says is required for outside contributors. The Visual Proof section is empty even though the change is a behavior change and the template asks for a BEFORE/AFTER. The Testing checkbox for manual testing is not ticked, though the author describes a manual real-app test. The Why section is not separate; rationale for the approach over alternatives is only partly stated. The AI Disclosure, Review, and Agent skill upstream boundary sections are blank. The Checklist items are not ticked.

Resolution

Add a Linked Issue reference (for example, "Fixes #<number>"); the template requires an actual issue for outside contributors. Fill in Visual Proof with a before/after reference (video or screenshots) or write N/A with a reason, since this is a behavior change. Add an explicit Why section that explains why this approach was chosen over alternatives. Tick the manual-testing checkbox if it applies. Complete or mark the Agent skill upstream boundary section. Tick the checklist items that now hold, such as lint, typecheck, test, and build status.

Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 14 functions across 22 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 2
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Nitpick comments: 1
src/main/runtime/orchestration/worker-turn-stops.test.ts: 1

191-219: Trivial · Maintainability & Code Quality · Quick win

Add a chat test for the prompt escalation path.

chatStop maps a prompt event to needs-input. The only chat test sends completion events, so no test reaches this branch. A regression in the prompt branch would not fail the suite.

Add a case to describe('chat worker turn stops') that:

  • Sends a prompt event for a chat session that has a pending approval prompt.
  • Asserts that one escalation is delivered.
  • Asserts that the escalation's stopReason is needs-input.

Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 782aa482-9fc1-4c60-a569-6589cd1eaa5d
Commits

Reviewing files that changed from the base of the PR and between 09bd3b9 and 95b2107.

Files selected for processing: 15
  • skill-guides/orchestration.md
  • src/cli/bundled-skill-guides.ts
  • src/main/runtime/construction/runtime-service-state.ts
  • src/main/runtime/orca-runtime-agent-transitions.ts
  • src/main/runtime/orchestration/chat-worker-error-escalation.ts
  • src/main/runtime/orchestration/chat-worker-turn-stops.ts
  • src/main/runtime/orchestration/db/dispatch-context/dispatch-lookup.ts
  • src/main/runtime/orchestration/db/federation/federation-relay-ack.ts
  • src/main/runtime/orchestration/terminal-worker-turn-stops.ts
  • src/main/runtime/orchestration/worker-turn-stop-report.ts
  • src/main/runtime/orchestration/worker-turn-stops.test.ts
  • src/main/runtime/structured-agent-session-host-assembly.ts
  • src/main/runtime/structured-agent-session-runtime.ts
  • src/main/runtime/terminal-agent-turn-news.ts
  • src/main/runtime/workspaces/workspace-process-listing.ts

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

const resolved = this.resolve(news.paneKey)
return { ...news, dispatchId: resolved && workerTurnStopDispatchId(resolved.target) }
},
deliver: (stop) => void this.report(stop),

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.

Minor · Stability & Availability · Quick win

Catch errors from report; the terminal path can produce an unhandled rejection.

deliver calls void this.report(stop) with no .catch. report calls stillStopped, which calls resolve. That calls getActiveDispatchForTerminal and findActiveRemoteAttachmentForPane. reportWorkerTurnStop also calls hasOpenHelperDispatch and hasPendingFederatedWorkerReport outside any try.

If one of these synchronous database calls throws, for example because the database closed during shutdown, report rejects with no handler. In the Electron main process, an unhandled rejection can surface as a crash dialog.

chatWorkerTurnStopReporter already wraps its body in try/catch and logs a warning. Apply the same guard here.

🛡️ Proposed fix
--- "a/src/main/runtime/orchestration/terminal-worker-turn-stops.ts"
+++ "b/src/main/runtime/orchestration/terminal-worker-turn-stops.ts"
@@ -36,7 +36,11 @@
         const resolved = this.resolve(news.paneKey)
         return { ...news, dispatchId: resolved && workerTurnStopDispatchId(resolved.target) }
       },
-      deliver: (stop) => void this.report(stop),
+      deliver: (stop) => {
+        this.report(stop).catch((error) => {
+          console.warn('[orchestration] terminal worker stop report failed', error)
+        })
+      },
       setTimer: deps.setTimer,
       // A lead waiting on its own children is not stopped; their all-clear is.
       allClearOnly: true
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
deliver: (stop) => void this.report(stop),
deliver: (stop) => {
this.report(stop).catch((error) => {
console.warn('[orchestration] terminal worker stop report failed', error)
})
},

Comment on lines +74 to +79
if (
deps.isWaitingForMail(`dispatch:${dispatchId}`) ||
(target.kind === 'local' && db.hasOpenHelperDispatch(dispatchId))
) {
return
}

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.

Minor · Functional Correctness · Quick win

Supported by static analysis

Script executed:

#!/bin/bash
# Check where helper dispatch_contexts rows are written for remote-attached workers.
rg -nP -C4 'creator_dispatch_id|creatorDispatchId' src/main/runtime/orchestration --type=ts -g '!**/*.test.ts' | head -n 150
rg -nP -C3 'remote_dispatch_attachments' src/main/runtime/orchestration --type=ts -g '!**/*.test.ts' | head -n 80

Repository: stablyai/orca

Length of output: 23619


Script executed:

set -eu
printf '%s\n' '--- worker-turn-stop-report.ts ---'
nl -ba src/main/runtime/orchestration/worker-turn-stop-report.ts | sed -n '1,180p'
printf '%s\n' '--- dispatch-row-writer.ts ---'
nl -ba src/main/runtime/orchestration/db/dispatch-row-writer.ts | sed -n '1,180p'
printf '%s\n' '--- remote attachment references and helper creation ---'
rg -n -F --glob '*.ts' -e 'REMOTE_DISPATCH_ATTACHMENT_SQL' -e 'remote_dispatch_attachments' -e 'hasOpenHelperDispatch' -e 'createDispatchContext' -e 'createStartingWorkerDispatch' -e 'creatorDispatchId' src/main/runtime/orchestration src/main/runtime | sed -n '1,260p'
printf '%s\n' '--- remote attachment schema ---'
nl -ba src/main/runtime/orchestration/db/schema/create-graph-tables-sql.ts | sed -n '35,75p'

Repository: stablyai/orca

Length of output: 41218


Script executed:

set -eu
printf '%s\n' '--- helper lookup ---'
nl -ba src/main/runtime/orchestration/db/dispatch-context/dispatch-lookup.ts | sed -n '145,180p'
printf '%s\n' '--- remote attachment creation ---'
nl -ba src/main/runtime/orchestration/db/federation/remote-dispatch-attachment-create.ts | sed -n '1,230p'
printf '%s\n' '--- worker dispatch start creator handling ---'
nl -ba src/main/runtime/orchestration/db/worker-dispatch/worker-dispatch-start.ts | sed -n '110,190p'
printf '%s\n' '--- helper/child creation call sites excluding tests ---'
rg -n -F --glob '*.ts' -g '!**/*.test.ts' -e 'creator:' -e 'createDispatchContext({' -e 'createStartingWorkerDispatch({' -e 'insertRemoteDispatchAttachmentRow' src/main/runtime/orchestration | sed -n '1,240p'

Repository: stablyai/orca

Length of output: 16062


Script executed:

set -eu
printf '%s\n' '--- DispatchCreator and resolution ---'
rg -n -F --glob '*.ts' -e 'export type DispatchCreator' -e 'type DispatchCreator' -e 'resolveCreatorDispatchId' -e 'DispatchCreator' src/main/runtime/orchestration | sed -n '1,220p'
nl -ba src/main/runtime/orchestration/db/dispatch-depth.ts | sed -n '1,210p'
printf '%s\n' '--- remote dispatch command/creator references ---'
rg -n -F --glob '*.ts' -g '!**/*.test.ts' -e 'remoteDispatch' -e 'remote_dispatch' -e 'creatorDispatchId' -e 'requiredCreatorDispatchId' src/main/runtime | sed -n '1,280p'

Repository: stablyai/orca

Length of output: 20761


Script executed:

set -eu
printf '%s\n' '--- local worker start helper binding ---'
nl -ba src/main/runtime/rpc/methods/orchestration/worker/local-worker-start.ts | sed -n '110,185p'
printf '%s\n' '--- remote worker target wiring ---'
rg -n -F --glob '*.ts' -g '!**/*.test.ts' -e 'kind: .remote.' -e 'reportWorkerTurnStop' -e 'helperCreator' -e 'remoteAttachment' src/main/runtime/rpc src/main/runtime/orchestration | sed -n '1,260p'

Repository: stablyai/orca

Length of output: 10663


Apply the open-helper check to remote Dispatches.

A remote worker can start a helper whose creator_dispatch_id is the remote attachment's dispatch_id. The current guard skips that check for remote targets, so the worker can emit an escalation while its helper remains open.

🐛 Suggested fix
-    (target.kind === 'local' && db.hasOpenHelperDispatch(dispatchId))
+    db.hasOpenHelperDispatch(dispatchId)
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
if (
deps.isWaitingForMail(`dispatch:${dispatchId}`) ||
(target.kind === 'local' && db.hasOpenHelperDispatch(dispatchId))
) {
return
}
if (
deps.isWaitingForMail(`dispatch:${dispatchId}`) ||
db.hasOpenHelperDispatch(dispatchId)
) {
return
}

Jinwoo-H added a commit that referenced this pull request Oct 28, 2026
…and stop keeps its output

worker-list projected a stop-reported attempt as live, in_progress, no action. It now
projects finished_unverified with a worker-read recovery until mail reaches the worker.
worker-stop closed the terminal before anything archived it, so release reported the
archive unavailable; stop now archives the output first.
@greptile-apps

greptile-apps Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The changes affect worker-stop reporting and recovery across Orca's orchestration workflows.

Fix the saved-output behavior after failed stops before merging.

Findings

  1. P1 Failed stops freeze saved output ▶

Summary

Adds coordinator mail when a worker ends a turn or needs input without sending worker_done.

  • Orca alerts the coordinator when a worker stops without reporting.
  • Worker views flag unreported stops and point recovery to worker-read.
  • Stopped workers keep their captured output for later release.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Worker ends turn or needs input] --> B{Dispatch still open?}
  B -->|No| C[Do not report]
  B -->|Yes| D{Deliberate wait?}
  D -->|Yes| C
  D -->|No| E{Worker location}
  E -->|Local| F[Insert escalation]
  E -->|Paired server| G[Relay to Run home]
  G --> F
  F --> H[Wake coordinator]
  H --> I[Dispatch stays open]
Loading

Reviews (1) · Last reviewed commit: "fix(orchestration): a failed pre-stop ar..." · Reviewed by Greptile

Comment on lines +44 to +50
db.storeWorkerTerminalArchiveBeforeStop({
dispatchId,
resourceId: resource.id,
kind: captured.kind,
content: JSON.stringify(captured.content),
archiveSource: captured.kind === 'terminal_tail' ? 'terminal' : 'transcript',
archiveStatus: captured.status

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Failed stops freeze saved output

archiveWorkerOutputBeforeStop saves output before closeTerminal runs. If closing fails and the worker keeps running, the saved copy remains. When the process later exits, release can treat that old copy as final and report it as captured, losing everything written after the failed stop.

Keep the copy provisional until stop succeeds, or refresh it while the worker is still reachable.

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


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0cca21cb-e411-4335-bf3c-8b1d32901284
Commits

Reviewing files that changed from the base of the PR and between 95b2107 and f353a2a.

Files selected for processing: 9
  • src/main/runtime/orchestration/db/worker-terminal/worker-terminal-archive.ts
  • src/main/runtime/orchestration/db/worker-terminal/worker-terminal-attention-query.ts
  • src/main/runtime/orchestration/worker-turn-stops.test.ts
  • src/main/runtime/rpc/methods/orchestration/federation/federation-control.ts
  • src/main/runtime/rpc/methods/orchestration/worker/worker-release.test.ts
  • src/main/runtime/rpc/methods/orchestration/worker/worker-stop-archive.ts
  • src/main/runtime/rpc/methods/orchestration/worker/worker-stop.ts
  • src/shared/orchestration-fleet-projection.test.ts
  • src/shared/orchestration-fleet-worker-projection.ts

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

Comment on lines +17 to +18
AND m.rowid > COALESCE(
(SELECT MAX(r.rowid) FROM messages r WHERE r.to_handle = 'dispatch:' || d.id), 0)`

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.

Minor · Functional Correctness · Quick win

Compare mail with the stop time, not report insertion.

If guidance arrives while the terminal stop report is waiting for delivery, the report can be inserted after the guidance. The worker can still be at rest while its wake is pending, so TerminalWorkerTurnStops can deliver that report. The query then marks the worker finished_unverified until another message or settlement clears it. Capture a mailbox watermark when the stop is observed and use it to reject or project stale reports. (raw.githubusercontent.com)

Comment on lines +116 to +123
// Orca saw the turn end without worker_done, and no mail has reached the worker since.
const stopped =
row.stopped_without_report === 1 &&
(projected === 'in_progress' || projected === 'outcome_unknown')
return [
row.dispatch_id,
{
outcome: projected,
outcome: stopped ? 'finished_unverified' : projected,

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.

Minor · Functional Correctness · Quick win

Supported by static analysis

Script executed:

sed -n '42,105p' src/shared/orchestration-fleet-worker-projection.ts
sed -n '230,275p' src/shared/orchestration-fleet-worker-projection.ts
sed -n '20,85p' src/main/runtime/orchestration/worker-attention-context.ts
rg -n 'function resolveFleetWorkerOutcome|const resolveFleetWorkerOutcome' src

Repository: stablyai/orca

Length of output: 5516


Script executed:

set -o pipefail
printf '%s\n' '--- outcome resolver ---'
sed -n '1,130p' src/shared/orchestration-fleet-outcome-resolution.ts
printf '%s\n' '--- attention projection ---'
sed -n '1,125p' src/shared/orchestration-fleet-attention.ts
printf '%s\n' '--- changed query and stop SQL ---'
sed -n '1,145p' src/main/runtime/orchestration/db/worker-terminal/worker-terminal-attention-query.ts
printf '%s\n' '--- stop-report SQL definition and references ---'
rg -n -F --glob '*.ts' -e 'STOP_REPORT_SINCE_LAST_MAIL_SQL' -e 'stopped_without_report' src/main/runtime/orchestration
printf '%s\n' '--- relevant projection callers ---'
rg -n -F --glob '*.ts' -e 'projectWorkerAttentionContext' -e 'getWorkerAttentionFactsForDispatches' -e 'projectOrchestrationFleet(' src/main src/shared
printf '%s\n' '--- relevant tests ---'
sed -n '430,510p' src/shared/orchestration-fleet-projection.test.ts
sed -n '1,90p' src/shared/orchestration-fleet-attention.test.ts

Repository: stablyai/orca

Length of output: 23871


Script executed:

set -o pipefail
printf '%s\n' '--- shared fleet projection ---'
sed -n '115,180p' src/shared/orchestration-fleet-projection.ts
printf '%s\n' '--- worker-list projection ---'
sed -n '1,105p' src/main/runtime/rpc/methods/orchestration/worker/worker-list-projection.ts
printf '%s\n' '--- runtime projection ---'
sed -n '35,115p' src/main/runtime/runtime-agent-orchestration-projection.ts
printf '%s\n' '--- worker attention query wrapper ---'
sed -n '135,175p' src/main/runtime/orchestration/db/worker-terminal/worker-terminal-attention-query.ts
printf '%s\n' '--- next action and attention exact lines ---'
nl -ba src/shared/orchestration-fleet-worker-projection.ts | sed -n '145,175p'
nl -ba src/shared/orchestration-fleet-attention.ts | sed -n '60,90p'

Repository: stablyai/orca

Length of output: 12061


Keep stop-reported exits actionable.

When an unsettled worker has a matching stop report and a certified exit, the outcome remains finished_unverified. projectFleetNextAction returns recover, but projectOrchestrationFleetAttention suppresses unverifiable for exited workers. With no other pending condition, callers receive requiresAction: false and can miss the recovery signal.

Suggested fix
-  // Proven exit must not also report absence and tell callers to keep waiting.
+  // Stop-reported workers remain actionable even when exit is proven.
   if (
-    facts.liveness.verdict !== 'exited' &&
-    (facts.outcome === 'outcome_unknown' || facts.outcome === 'finished_unverified')
+    facts.outcome === 'finished_unverified' ||
+    (facts.liveness.verdict !== 'exited' && facts.outcome === 'outcome_unknown')
   ) {

Comment on lines +44 to +51
db.storeWorkerTerminalArchiveBeforeStop({
dispatchId,
resourceId: resource.id,
kind: captured.kind,
content: JSON.stringify(captured.content),
archiveSource: captured.kind === 'terminal_tail' ? 'terminal' : 'transcript',
archiveStatus: captured.status
})

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.

Major · Data Integrity & Integration · Quick win

Do not serve a pre-stop archive as final output after an unproven stop.

If remote closeTerminal fails or cannot prove the process stopped, federationStop records an unknown outcome. The archive stored here remains. federationReadOutput then selects that archive before a live read, so later worker output is absent from output reads. When the stop is unproven, invalidate the snapshot or prefer live output until the process is proven stopped. (raw.githubusercontent.com)

@Jinwoo-H

Copy link
Copy Markdown
Contributor Author

Superseded by #36137, which combines the orchestration v3 changes into one PR.

@Jinwoo-H Jinwoo-H closed this Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant