You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Multiple orchestrators in a single workspace kill each other #4389
Reproduced on current main source (1.4.132, commit 6f895eff0a) on macOS arm64 with two safe in-memory coordinator fixtures and no real terminals/processes.
Steps:
Start coordinator A with worktree selector worktree:wt-a.
While A is active, start coordinator B with selector worktree:wt-b.
Separately, with A active, issue orchestration.runStop scoped to worktree:wt-b.
Expected: A and B have independent coordinator ownership; B can start, and a B stop cannot target A.
Actual:
B start returns runtime_error: Coordinator already running: <A run id>, despite a distinct worktree selector.
The stop request from B returns { stopped: true, runId: <A run id> }, so B targets A’s module-global coordinator rather than its own scope.
Repeatability: deterministic 1/1 for each targeted case. The tests used an in-memory orchestration DB with no available worker terminals, were removed after capture, and left no tracked changes; no attachment or reporter-provided code was opened or run.
Root cause: orchestrator (coordinator) ownership is tracked at module/process scope, not per worktree. orchestration.run gates on db.getActiveCoordinatorRun() (orchestration-gates.ts:50-53), whose SQL has no worktree predicate (db.ts:1010-1016: SELECT ... WHERE status='running' ... LIMIT 1). The worktree selector is handed to the Coordinator but never persisted on the run nor used in the gate, so a coordinator for wt-b collides with a running wt-a run and throws Coordinator already running: <A>. Compounding it, the active coordinator is a single module-global activeCoordinator (:10) and orchestration.runStop uses an empty params schema z.object({}) (:18) that resolves the same unscoped run — so a stop from B halts A's run and its workers.
The repro test imports the real gate handlers + real OrchestrationDb (only the Coordinator's background loop is stubbed to avoid a self-completing race) and pins both defects.
Re-run:
pnpm exec vitest run --config config/vitest.config.ts src/main/runtime/rpc/methods/repro-4389-coordinator-global-ownership.test.ts
Fix direction: add a worktree column to coordinator_runs, persist + filter by it in getActiveCoordinatorRun, replace the module-global activeCoordinator with a per-worktree map, and give runStop a worktree param.
Automated bug-reproduction pass. Repro artifact committed on branch nwparker/bug-repro-pass2; check it out to run the command above. Writeup: docs/bug-reproductions/4389.md.
Activity
fix(orchestration): per-run isolation of the orchestration DB (#12)
nwparker commentedon Jul 10, 2026
Reproduced on current
mainsource (1.4.132, commit6f895eff0a) on macOS arm64 with two safe in-memory coordinator fixtures and no real terminals/processes.Steps:
worktree:wt-a.worktree:wt-b.orchestration.runStopscoped toworktree:wt-b.Expected: A and B have independent coordinator ownership; B can start, and a B stop cannot target A.
Actual:
runtime_error: Coordinator already running: <A run id>, despite a distinct worktree selector.{ stopped: true, runId: <A run id> }, so B targets A’s module-global coordinator rather than its own scope.Repeatability: deterministic 1/1 for each targeted case. The tests used an in-memory orchestration DB with no available worker terminals, were removed after capture, and left no tracked changes; no attachment or reporter-provided code was opened or run.
fix(orchestration): scope coordinator runs/tasks/dispatches by worksp…
nwparker commentedon Jul 18, 2026
Status: REPRODUCED on current
mainvia unit test.Root cause: orchestrator (coordinator) ownership is tracked at module/process scope, not per worktree.
orchestration.rungates ondb.getActiveCoordinatorRun()(orchestration-gates.ts:50-53), whose SQL has no worktree predicate (db.ts:1010-1016:SELECT ... WHERE status='running' ... LIMIT 1). Theworktreeselector is handed to theCoordinatorbut never persisted on the run nor used in the gate, so a coordinator forwt-bcollides with a runningwt-arun and throwsCoordinator already running: <A>. Compounding it, the active coordinator is a single module-globalactiveCoordinator(:10) andorchestration.runStopuses an empty params schemaz.object({})(:18) that resolves the same unscoped run — so a stop from B halts A's run and its workers.The repro test imports the real gate handlers + real
OrchestrationDb(only the Coordinator's background loop is stubbed to avoid a self-completing race) and pins both defects.Re-run:
Key files:
src/main/runtime/rpc/methods/orchestration-gates.ts,src/main/runtime/orchestration/db.ts,src/main/runtime/orchestration/coordinator.ts. Writeup:docs/bug-reproductions/4389.md.Fix direction: add a
worktreecolumn tocoordinator_runs, persist + filter by it ingetActiveCoordinatorRun, replace the module-globalactiveCoordinatorwith a per-worktree map, and giverunStopaworktreeparam.Automated bug-reproduction pass. Repro artifact committed on branch
nwparker/bug-repro-pass2; check it out to run the command above. Writeup:docs/bug-reproductions/4389.md.fix(orchestration): scope coordinator runs/tasks/dispatches by worksp…