Skip to content

fix(orchestration): release context-only dispatches - #13376

Merged
Jinwoo-H merged 2 commits into
mainfrom
bug-worker-abandon-worker-stop-return-dispatch_n
Aug 9, 2026
Merged

Jinwoo-H merged 2 commits into
mainfrom
bug-worker-abandon-worker-stop-return-dispatch_n

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Low-level orca orchestration dispatch creates a live Dispatch without a supervised worker record. worker-stop and worker-abandon previously looked only for the worker record, returned dispatch_not_found, and left the terminal permanently occupied.

This change gives those context-only Dispatches a real release path:

  • atomically record stopped or abandoned, revoke lifecycle authority, close pending questions, and release the exact assignee identity
  • block the Task only when the released Dispatch is still its current owner; preserve newer/superseding Dispatches
  • retain the unmanaged terminal process and report that explicitly in CLI output
  • leave supervised and federated worker behavior unchanged

Fixes #13005.

Supersedes #13250 with a transaction-scoped release path that does not create synthetic worker rows.

Screenshots

No visual change.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test — 48,603 tests passed; five unrelated failures passed immediately in isolation (updater, transcript watcher, relay environment, and daemon cwd coverage)
  • pnpm build
  • Added high-quality regression coverage

Focused validation on the final rebased commit:

  • 213 focused/broad orchestration tests passed
  • Electron/PTY E2E passed for both release verbs, exact PTY/incarnation preservation, and same-pane redispatch
  • reliability gates and max-lines checks passed
  • federation, orchestration CLI, and CLI index regression suites passed

The reliability gate orchestration.context-only-dispatch-release includes red/green evidence: the Electron oracle reproduced dispatch_not_found on the pre-fix main commit and passed with this implementation.

AI Review Report

Two review/fix rounds were completed. The first found that text-mode worker-stop omitted the new retained-process warning; the CLI output, help, and regression coverage were updated. Two independent reviewers then returned clean after checking root cause, atomicity, stale/current Dispatch races, first-outcome idempotency, terminal identity safety, supervised/federated isolation, RPC compatibility, and test reliability.

The implementation was also compared with synthetic worker rows and a separate release verb. Releasing the existing Dispatch in one database transaction is the smaller ownership-correct design and avoids manufacturing lifecycle/process state that does not exist.

Cross-platform review found no new shortcuts, path handling, shell commands, native modules, filesystem assumptions, or platform branches. The control path is provider-neutral. macOS local runtime behavior is proven; physical Linux, Windows, WSL, SSH, and paired remote-runtime journeys remain explicit evidence gaps.

Performance review found no hot-path regression: release is an explicit control action using indexed lookups and bounded updates, with no polling, subprocesses, process inspection, renderer work, terminal I/O, caches, listeners, or unbounded state.

Security Audit

No dependencies, command execution, path handling, auth flow, secrets, or external network behavior changed. Dispatch IDs continue through the existing validated RPC schema and parameterized database operations. Capability revocation and pending-question closure are part of the same transaction as assignment release. The context-only path deliberately cannot close a terminal process it does not supervise.

Notes

  • Remote wire compatibility: the only response addition is an optional warning; older clients can ignore it. No new stream opcode or required request field was added.
  • Mobile-facing protocols and persisted mobile state are unchanged.
  • Folder workspaces and SSH/remote providers share this database transition and receive no local filesystem/process assumptions, but live remote and non-macOS journeys have not yet been attached.
  • The reliability gate remains experimental until it accumulates CI/soak and cross-platform evidence.

@Jinwoo-H

Jinwoo-H commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Already reviewed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e44d80ef-f9d0-499b-8771-e4aa6c3a7a18

📥 Commits

Reviewing files that changed from the base of the PR and between 45d9699 and 0f462ee.

📒 Files selected for processing (1)
  • tests/e2e/orchestration-low-level-dispatch-release.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/e2e/orchestration-low-level-dispatch-release.spec.ts

📝 Walkthrough

Walkthrough

Added context-only Dispatch release handling for worker-abandon and worker-stop. The runtime now records release state without closing unsupervised terminals. RPC responses report settlement state, warnings, and non-terminal process actions. CLI output, help, and specifications describe the behavior. Unit, CLI, and end-to-end tests cover state transitions, idempotence, terminal preservation, supervised-worker isolation, and terminal reuse. A reliability gate records verification evidence and promotion criteria.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 6.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: releasing context-only dispatches.
Description check ✅ Passed The description includes all required sections and provides detailed testing, review, security, and platform information.
Linked Issues check ✅ Passed The implementation addresses issue #13005 by releasing context-only dispatches while preserving task ownership and terminal state.
Out of Scope Changes check ✅ Passed The changes, tests, documentation, and reliability evidence support the linked issue objectives without unrelated scope.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tests/e2e/orchestration-low-level-dispatch-release.spec.ts (1)

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

Give the incarnation poll an explicit timeout to match the sibling wait.

Line 18 uses waitForActivePanePtyId(orcaPage), which the helper documentation shows uses a 15-second timeoutMs. Line 27 polls for incarnationId with no options, so it falls back to Playwright's built-in 5-second expect.poll default. Both waits depend on the same PTY process publishing state after startup. A shorter default on the second wait can make this test flakier under CI load than the first wait, for no functional reason.

Pass an explicit timeout to expect.poll to match the surrounding pattern.

🕐 Proposed timeout alignment
   await expect
     .poll(async () => (await findTerminal(client, terminalHandle)).incarnationId)
+    .toBeTruthy()
-    .toBeTruthy()

Use expect.poll(fn, { timeout: 15_000 }) instead of expect.poll(fn) to align with the 15-second budget used one line earlier for a comparable PTY startup wait.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 434aa06e-bf56-401f-a12e-82f525ce3f55

📥 Commits

Reviewing files that changed from the base of the PR and between 6858e07 and 45d9699.

📒 Files selected for processing (11)
  • config/reliability-gates.jsonc
  • src/cli/handlers/orchestration-worker-cli.test.ts
  • src/cli/handlers/orchestration.ts
  • src/cli/help.ts
  • src/cli/specs/orchestration-worker-specs.ts
  • src/main/runtime/orchestration/context-only-dispatch-release.ts
  • src/main/runtime/orchestration/db.ts
  • src/main/runtime/rpc/methods/orchestration-manual-dispatch-release.test.ts
  • src/main/runtime/rpc/methods/orchestration-worker-control.ts
  • src/main/runtime/rpc/methods/orchestration-worker-stop.ts
  • tests/e2e/orchestration-low-level-dispatch-release.spec.ts

@Jinwoo-H
Jinwoo-H merged commit 45c1cb9 into main Aug 9, 2026
53 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* fix(orchestration): release context-only dispatches

Refs stablyai#13005

* test(orchestration): align PTY readiness timeout

---------

Co-authored-by: Jinwoo-H <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: worker-abandon/worker-stop return dispatch_not_found for a live dispatch dispatch-show returns (1.4.175)

1 participant