Repository navigation
fix(orchestration): release dispatch lock when worker_done is sent via orchestration.send - #6317
Conversation
…a orchestration.send (stablyai#6090)
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthrough
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
Co-authored-by: Orca <[email protected]>
Jinwoo-H
left a comment
There was a problem hiding this comment.
Thanks for the focused fix. I verified the send-path lifecycle ordering and added a small follow-up so coordinator accounting remains correct when send reconciles before the coordinator reads the message.
- worker_done via orchestration.send releases the dispatch lock before delivery.
- Heartbeats sent via send now have regression coverage.
- Coordinator completedTasks remains correct and de-duped for already-reconciled lifecycle messages.
Validated with focused orchestration tests, typecheck, lint, and a live Electron/CLI lifecycle probe.
…a orchestration.send (stablyai#6317) * fix(orchestration): release dispatch lock when worker_done is sent via orchestration.send (stablyai#6090) * fix: preserve coordinator lifecycle accounting Co-authored-by: Orca <[email protected]> --------- Co-authored-by: Jinwoo-H <[email protected]> Co-authored-by: Orca <[email protected]>
Summary
orchestration.sendinserted messages and delivered them to the PTY but never calledreconcileLifecycleMessage. When a manual coordinator sentworker_doneviasend(instead of letting the recipient callcheck), the dispatch context for that terminal stayed in'dispatched'status permanently. Every subsequentsendto the same terminal threw"Terminal X already has an active dispatch".reconcileLifecycleMessagecall inorchestration.sendforworker_doneandheartbeatmessages, placed beforedeliverPendingMessagesForHandleso the lock releases before waking recipients who may immediately dispatch new work.orchestration.checkalready reconciled on every unread read. Both send and check paths now release the dispatch lock equivalently regardless of how the coordinator drives the lifecycle.Closes #6090.
Screenshots
No visual change.
Testing
pnpm lintpnpm typecheckpnpm testpnpm buildFocused validation run in this session:
pnpm exec vitest run --config config/vitest.config.ts src/main/runtime/rpc/methods/orchestration.test.ts— 97 tests passed (0 failed), 6.12spnpm run typecheck:node— clean, no errorsAI Review Report
Reviewed
orchestration.tschange on macOS, Linux, and Windows. The fix inserts one conditional call in the point-to-point send path.reconcileLifecycleMessageis already imported at line 8 of the file and used byorchestration.check— no new dependency. The call is gated onmsg.type === 'worker_done' || msg.type === 'heartbeat'; all other message types pass through unchanged. Group-address sends already rejectworker_doneandheartbeatvia ZodsuperRefinebefore insertion, so the group path is unaffected. Ordering: reconcile runs afterdb.insertMessage(required — reconcile operates on the persisted row) and beforedeliverPendingMessagesForHandle(required — recipients must see the lock already released). Invalid or staleworker_donemessages with mismatcheddispatchIdreturn{ action: 'ignored' }fromreconcileWorkerDoneMessage— lock stays held, which is correct. No SSH, terminal, browser, mobile, or UI surface touched. Provider-neutral main-process logic.Security Audit
No filesystem access, subprocess execution, auth, secrets, or external IPC touched. The change affects only the DB lock lifecycle in the orchestration layer.
reconcileLifecycleMessagevalidatestaskId,dispatchId, and dispatch ownership before releasing any lock — no privilege escalation possible.Notes
heartbeatmessages are included in the guard for symmetry withorchestration.check's existing reconciliation. In practice, heartbeats do not carrytaskId/dispatchIdand reconcile to a no-op, but including them here keeps both paths consistent and future-proof. Group-address path unchanged.