Repository navigation
Conversation
📝 WalkthroughWalkthroughThis PR adds workspace-scoped concurrent orchestration coordinator support. A new 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
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. Comment |
Evidence — #4389 regression proofRoot cause confirmed in the code
After the fix — targeted test runs (actual output)Data-layer scoping + start/stop guard: v5 → v6 migration: Full affected-suite sweep (no regressions): Before vs after (the key behavioral assertion)
Local gateElectron noteEnd-to-end two-worktree visual repro was not run: ports 9333–9336 were occupied by other worktrees' running dev builds, and attaching there risks driving the wrong instance. The regression is a main-process data-layer defect fully proven by the unit tests above; the validation plan marked Electron optional for this bug. |
|
Follow-up pushed in fa84418 (supersedes the c32174f tradeoff note):
Validation:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/main/runtime/orca-runtime.ts (1)
17896-17905: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider routing this inline scoping through
resolveCoordinatorRunForDispatch.The
workspace_key == null ? global : scopeddecision is now duplicated here and inresolveCoordinatorRunForDispatch(Line 7711). Since the workspace-scoping fallback rule is the crux of this PR, keeping two copies risks future divergence (and silent re-introduction of the cross-attribution bug). The only reason this site can't reuse the helper today is that it must honor the locally-resolveddbrather thanthis._orchestrationDb; threading an optionaldbinto the helper would let both sites share one branch.♻️ Optional: share one scoping branch
private resolveCoordinatorRunForDispatch( - workspaceKey: string | null + workspaceKey: string | null, + db = this._orchestrationDb ): ReturnType<OrchestrationDb['getActiveCoordinatorRun']> { - if (!this._orchestrationDb) { + if (!db) { return undefined } if (workspaceKey == null) { - return this._orchestrationDb.getActiveCoordinatorRun() + return db.getActiveCoordinatorRun() } - return this._orchestrationDb.getActiveCoordinatorRunForWorkspace(workspaceKey) + return db.getActiveCoordinatorRunForWorkspace(workspaceKey) }Then at Line 17900:
const activeRun = dispatch.status === 'completed' ? undefined - : dispatch.workspace_key == null - ? db?.getActiveCoordinatorRun?.() - : db?.getActiveCoordinatorRunForWorkspace?.(dispatch.workspace_key) + : db + ? this.resolveCoordinatorRunForDispatch(dispatch.workspace_key, db) + : undefined
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 40cf347e-ea30-4ca6-bb84-d0aa3d324946
📒 Files selected for processing (16)
skills/orchestration/SKILL.mdsrc/cli/handlers/orchestration.tssrc/cli/help.tssrc/cli/index.test.tssrc/cli/specs/orchestration.tssrc/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/orchestration/coordinator.tssrc/main/runtime/orchestration/db.test.tssrc/main/runtime/orchestration/db.tssrc/main/runtime/orchestration/formatter.test.tssrc/main/runtime/orchestration/types.tssrc/main/runtime/rpc/methods/orchestration-gates.test.tssrc/main/runtime/rpc/methods/orchestration-gates.tssrc/main/runtime/rpc/methods/orchestration.tssrc/main/runtime/runtime-rpc.test.ts
| if (resolvedWorktree !== undefined) { | ||
| const response = await client.call<{ handle: string }>('terminal.resolveActive', { | ||
| worktree: resolvedWorktree | ||
| }) | ||
| return response.result.handle | ||
| } | ||
| return await getTerminalHandle(flags, cwd, client) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Don't fall back to getTerminalHandle() after normalizing --worktree all.
Line 482 intentionally clears terminalWorktree for the global coordinator, but Line 147 then re-reads the raw CLI flags through getTerminalHandle(). Because that helper resolves worktree state from flags, orca orchestration run --worktree all can still be treated like a concrete worktree selection instead of the unscoped/global case.
Suggested fix
- if (resolvedWorktree !== undefined) {
+ if (resolvedWorktree !== undefined || getOptionalStringFlag(flags, 'worktree') === 'all') {
const response = await client.call<{ handle: string }>('terminal.resolveActive', {
worktree: resolvedWorktree
})
return response.result.handle
}Also applies to: 481-489
fa84418 to
a583db8
Compare
…ace (#4389) Two orchestrators started in different worktrees of one Orca instance shared a single unscoped orchestration.db, so they blocked each other's start, stopped the wrong coordinator, counted/dispatched each other's tasks, and cross-attributed worker terminals in the agent-status UI. Add a nullable workspace_key column (schema v5 -> v6) to coordinator_runs, tasks, dispatch_contexts, and messages, and thread a per-coordinator workspace key through the writes and run-scoped reads. The start/stop guard now scopes getActiveCoordinatorRun by workspace and keys live coordinators in a Map instead of one module-level singleton, so a run in one workspace can't orphan or stop another's. Runtime helpers attribute a worker terminal to the coordinator that owns its dispatch's workspace. Existing rows keep NULL workspace_key (legacy/global) and every scoped read matches NULL, so single-orchestrator installs are unaffected. Scope resolution goes through the existing worktree-selector resolution, so it is provider-agnostic and works for SSH/remote runtimes. Fixes #4389 Co-authored-by: Orca <help@stably.ai>
Rebase the workspace-scoped coordinator fix onto current main while preserving stale terminal handle validation. Treat every active coordinator prompt as user-owned so push-on-idle cannot auto-submit into an earlier workspace's coordinator when another run is newer, and index the handle lookup used by that path.
a583db8 to
9d3b0b5
Compare
…t-main # Conflicts: # src/main/runtime/orchestration/db.ts
|
Moving this PR to draft because it has been untouched for more than 80 days (latest recorded PR activity or commit timestamp: 2026-07-21T21:28:53Z; checked on 2026-10-27). This keeps the review queue focused on active work while preserving the proposal. Please mark it ready for review when work resumes. |
Description
Fixes #4389. Orca stored orchestration state in one runtime-wide database but did not record which workspace owned each coordinator, task, dispatch, or message. As a result, a coordinator in workspace B could be rejected because A was running, a B-scoped stop could stop A, and concurrent loops could count, dispatch, or attribute each other's work.
This PR:
workspace_keyownership to coordinator runs, tasks, dispatch contexts, and messages through the existing transactional SQLite migration (v5→v6);run-stop --worktree <selector>exact, keeps--worktree allas explicit global mode, and rejects an ambiguous barerun-stop;No UI, keyboard, git-provider, shell, or local-path-specific behavior is introduced.
Evidence of fix
Before, on current
origin/main(c5669cceb5), a productionRpcDispatcherreproduction with two in-memory coordinator fixtures failed both user-visible invariants:The exact reproduction and expected/actual behavior are also recorded on the issue: #4389 (comment).
After, the permanent production-RPC regression proves B can start while A runs and a B stop leaves A active:
Additional verification on the rebased branch:
Reliability proof:
agent-session.coordinator-ownership; a task, dispatch, exit escalation, status row, injected message, and stop request must resolve only to the coordinator owning that workspace.config/reliability-gates.jsoncdoes not exist on currentmain; the intended partial gate isorchestration.workspace-coordinator-isolation, represented by the blocking unit/RPC suites above.(coordinator_handle, status)index, including after migration.ELI5
Two managers were sharing one unlabeled pile of jobs. Manager B could be told “a manager is already working,” even though that was manager A in another workspace; asking B to stop could then stop A. Orca now labels each manager and job with its workspace, so each manager reads, assigns, reports, and stops only its own work.
User-facing trade-offs
run-stopis convenient only when one run is active; with multiple runs, users must identify the workspace (or use--worktree allfor the global run).NULLownership and remain visible as legacy/global data for upgrade compatibility; newly created tasks and runs are isolated.