Skip to content

fix(orchestration): complete null-id worker_done from active dispatch - #7790

Closed
rodboev wants to merge 1 commit into
stablyai:mainfrom
rodboev:pr/orca-7429-worker-done-null-ids
Closed

rodboev wants to merge 1 commit into
stablyai:mainfrom
rodboev:pr/orca-7429-worker-done-null-ids

Conversation

@rodboev

@rodboev rodboev commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Let worker_done recover missing taskId or dispatchId from the sender's active dispatch, then complete through the existing lifecycle checks.
  • Keep completion centralized in updateTaskStatus(taskId, 'completed', result) so task and dispatch state still move through the DB-owned transition path.

Closes #7429.

Screenshots

No visual change

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

Focused validation:

  • pnpm exec vitest run --config config/vitest.config.ts src/main/runtime/orchestration/coordinator.test.ts - passed; covers null-id worker_done completion, missing-active-dispatch rejection, conflict rejection, stale retry preservation, non-owner rejection, and already-completed idempotence.
  • pnpm exec vitest run --config config/vitest.config.ts src/main/runtime/rpc/methods/orchestration.test.ts -t "completes worker_done missing taskId or dispatchId|does not complete worker_done from a terminal that does not own the dispatch|does not complete worker_done for a stale inactive dispatch" - passed; covers the RPC orchestration.check consumer of lifecycle reconciliation.
  • pnpm run typecheck:node - passed.

AI Review Report

  • Reviewed the diff for macOS, Linux, and Windows behavior. The change is runtime-only and does not add platform-specific code paths.
  • Sender ownership still flows through the existing assignee and dispatch checks after id recovery.
  • Stale dispatches, inactive dispatches, and conflicting ids still exit before any completion write.
  • Invalid JSON payloads stay ignored rather than using active-dispatch fallback.
  • No UI, SSH, browser, provider, or subprocess surfaces changed.

Security Audit

  • Missing ids are inferred only from db.getActiveDispatchForTerminal(msg.from_handle), which scopes recovery to the sender's active dispatch.
  • Conflicting supplied taskId or dispatchId values are rejected before any completion state transition.
  • Non-owner terminals, inactive dispatches, and stale retries still fail the existing ownership and liveness checks.
  • No new command execution, path handling, auth, secrets, dependency, IPC, browser, SSH, or filesystem risks were introduced.

Notes

  • No visual change.
  • This keeps the explicit-id path intact and only fills missing ids when the sender owns one active dispatch.

ELI5

A worker finishing without a task/dispatch id could leave orchestration stuck. Missing ids are recovered from the active dispatch so the task completes normally.

@coderabbitai

coderabbitai Bot commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Modified lifecycle reconciliation logic so JSON payload parsing failures return undefined instead of an empty object, causing heartbeat messages with invalid JSON to be ignored. Updated worker_done reconciliation to recover missing taskId/dispatchId values from a terminal's active dispatch context when not present in the payload, validating against conflicts before proceeding with completion logic. Corresponding tests in coordinator and orchestration RPC methods were updated: a test helper now supports optional taskId and explicit payload overrides, new edge-case tests were added for worker_done handling, and an existing RPC test assertion was changed to expect task/dispatch completion rather than no change.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR implements the issue’s core fix by recovering missing ids from the sender’s active dispatch while preserving conflict, stale, and non-owner checks.
Out of Scope Changes check ✅ Passed The changes stay focused on orchestration reconciliation and tests, with no obvious unrelated code added.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly names the main orchestration fix for null-id worker_done messages recovered from the active dispatch.
Description check ✅ Passed The description follows the required template and covers summary, screenshots, testing, AI review, security, and notes.

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.

@brennanb2025

Copy link
Copy Markdown
Contributor

Taking a look!

@brennanb2025
brennanb2025 force-pushed the pr/orca-7429-worker-done-null-ids branch from cec625e to 4e85e2a Compare July 21, 2026 00:06
@brennanb2025

Copy link
Copy Markdown
Contributor

Thanks for the fix! I rebased this onto current main and tightened the fallback so missing or null IDs are inferred only from the sender’s active dispatch using Orca’s stable pane identity, with the legacy handle path retained for older dispatches. This preserves ownership across handle remints without allowing malformed payloads, conflicting partial IDs, stale sends, or foreign panes to complete work; focused coverage now exercises those cases and the RPC path. Verified 199 focused tests, touched-file lint, the max-lines ratchet, and typecheck:node, and pushed the result to the PR branch.

@rodboev

rodboev commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

Current main rejects worker_done messages without both task and dispatch IDs and verifies dispatch ownership before settlement. That authority contract supersedes this null-ID inference change.

@rodboev rodboev closed this Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: worker_done with null taskId/dispatchId silently fails to complete the task

3 participants