Repository navigation
Conversation
|
Taking a look! |
|
Thanks for the clear diagnosis — I pushed a follow-up that keeps the intended behavior while making the dispatch/task failure transition atomic. Direct-dispatch worker exits now terminally fail the task with the exit reason, while coordinator-owned exits remain retryable and still escalate; I also corrected the lifecycle comment and added database/runtime coverage for both paths. The focused and full orchestration/runtime suites, Node typecheck, formatting, lint, and max-lines ratchet all pass. |
ca1dbf9 to
9197ad5
Compare
📝 WalkthroughWalkthroughDispatch failure handling now accepts an explicit task requeue policy and applies dispatch and task updates transactionally. PTY exit handling retrieves the active coordinator run before failing a dispatch, requeues tasks when appropriate, and escalates coordinator-owned failures. Tests cover worker and coordinator PTY exits and the non-requeue failure path. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/runtime/orchestration/db.ts (1)
834-856: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider using
db.transaction()for robust error propagation.The manual
BEGIN IMMEDIATE/COMMIT/ROLLBACKblock achieves the atomicity goal. However, if an error naturally aborts the SQLite transaction before thecatchblock executes, callingthis.db.exec('ROLLBACK')will throw a new "cannot rollback - no transaction is active" error. This masks the originalcause, making production crashes harder to diagnose.You can safely sidestep this by wrapping the updates in
better-sqlite3's native.transaction()wrapper and invoking it with.immediate(). It handles savepoints, auto-rollbacks, and original error propagation reliably.♻️ Proposed refactor
- // Why: the dispatch and its task are one lifecycle transition; committing - // only one row would leave the ledger contradictory after an interruption. - this.db.exec('BEGIN IMMEDIATE') - try { + // Why: the dispatch and its task are one lifecycle transition; committing + // only one row would leave the ledger contradictory after an interruption. + const updateLedger = this.db.transaction(() => { this.db .prepare( 'UPDATE dispatch_contexts SET status = ?, failure_count = ?, last_failure = ? WHERE id = ?' ) .run(newStatus, newFailureCount, error, ctxId) const shouldRetry = options.requeueTask !== false && newStatus !== 'circuit_broken' if (shouldRetry) { // Why: 'pending' would strand a retry because dependency promotion only // runs when a dependency completes; this task is already unblocked. this.db.prepare("UPDATE tasks SET status = 'ready' WHERE id = ?").run(ctx.task_id) } else { this.updateTaskStatus(ctx.task_id, 'failed', error) } - this.db.exec('COMMIT') - } catch (cause) { - this.db.exec('ROLLBACK') - throw cause - } + }) + + updateLedger.immediate()
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 28cf248d-dac0-43b2-b1bf-18f690bcdf5d
📥 Commits
Reviewing files that changed from the base of the PR and between cf02cc4 and ca1dbf9602232357b66f321f1679f3edb2d2bfdb.
📒 Files selected for processing (4)
src/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/orchestration/db.tssrc/main/runtime/orchestration/dispatch-failure-policy.test.ts
Summary
failedwhen a directly dispatched worker exits and no coordinator run existsreadytaskRoot cause
failDispatchcorrectly returns a task toreadyfor coordinator-managed retries. A directorca orchestration dispatchhas no coordinator loop to consume that retry, so an agent exit could leave work silently stranded inreadyforever.Impact
Coordinator-managed dispatches retain their existing retry and escalation behavior. Directly dispatched tasks now become visible failures that can be deliberately retried by the operator.
Validation
node_modules/.bin/vitest.cmd run --config config/vitest.config.ts src/main/runtime/orca-runtime.test.ts --testNamePattern 'marks a direct dispatch failed'node_modules/.bin/oxfmt.cmd --check src/main/runtime/orca-runtime.ts src/main/runtime/orca-runtime.test.tsnode_modules/.bin/oxlint.cmd src/main/runtime/orca-runtime.ts src/main/runtime/orca-runtime.test.tsThe full runtime test file passed 710 tests; 4 unrelated tests assume a POSIX
/tmppath and fail on this Windows host before exercising this change.Fixes #8984
ELI5
A directly dispatched orchestration worker that crashed left the task looking like it was still ready. Those tasks are now marked failed with the exit reason so work doesn’t sit forever.