fix: skip batch tasks in Phase 0.6 reconcile-queue to prevent premature cancellation#2844
Conversation
…re cancellation Phase 0.6 (reconcile-queue) cancelled newly-added batch tasks before Phase 0.9 could tag them with #auto-dispatch. Tasks added via supervisor-helper.sh add and associated with a batch were immediately cancelled as 'phantom queue entries' on the first pulse. Now Phase 0.6 checks batch_tasks + batches tables before cancelling. Tasks belonging to an active or paused batch are skipped — batch membership is explicit dispatch intent. Closes #2836
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Wed Mar 4 17:45:04 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a race condition where batch tasks were being prematurely cancelled by Phase 0.6 of the supervisor reconciliation process. The fix introduces a crucial check to identify tasks that are part of active or paused batches, ensuring they are not mistakenly marked as 'phantom queue entries' and cancelled before subsequent phases can properly process them. This prevents unintended task cancellations and improves the robustness of batch task management. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
There was a problem hiding this comment.
Code Review
This pull request effectively addresses a race condition that caused premature cancellation of batch tasks. The fix, which involves checking for active batch membership before cancelling a task, is logical and well-implemented. My primary feedback concerns the error handling in the new database query, where suppressing stderr could hide important diagnostic information, which goes against repository guidelines. Improving this will make the script more robust and easier to debug.
Note: Security Review did not run due to the size of the PR.
| active_batch_id=$(db "$SUPERVISOR_DB" " | ||
| SELECT bt.batch_id FROM batch_tasks bt | ||
| JOIN batches b ON b.id = bt.batch_id | ||
| WHERE bt.task_id = '$(sql_escape "$tid")' | ||
| AND b.status IN ('active','paused') | ||
| LIMIT 1; | ||
| " 2>/dev/null || echo "") |
There was a problem hiding this comment.
While the || echo "" correctly prevents the script from exiting on failure (if set -e is active), suppressing stderr with 2>/dev/null can hide important database or SQL syntax errors, making debugging difficult. It's better to allow errors to be visible on stderr for diagnostics. This aligns with the repository's guidelines against blanket suppression of errors, especially when set -e is active, to ensure that syntax or system errors remain visible.
| active_batch_id=$(db "$SUPERVISOR_DB" " | |
| SELECT bt.batch_id FROM batch_tasks bt | |
| JOIN batches b ON b.id = bt.batch_id | |
| WHERE bt.task_id = '$(sql_escape "$tid")' | |
| AND b.status IN ('active','paused') | |
| LIMIT 1; | |
| " 2>/dev/null || echo "") | |
| active_batch_id=$(db "$SUPERVISOR_DB" " | |
| SELECT bt.batch_id FROM batch_tasks bt | |
| JOIN batches b ON b.id = bt.batch_id | |
| WHERE bt.task_id = '$(sql_escape "$tid")' | |
| AND b.status IN ('active','paused') | |
| LIMIT 1; | |
| " || echo "") |
References
- Avoid blanket suppression of errors with '2>/dev/null'. For commands that might fail but shouldn't exit the script, use '|| true' or a similar construct, but allow stderr to be printed for debugging purposes.
- In shell scripts with 'set -e' enabled, use '|| true' to prevent the script from exiting when a command like 'jq' fails on an optional lookup. Do not suppress stderr with '2>/dev/null' so that actual syntax or system errors remain visible for debugging.
- Avoid using '2>/dev/null' for blanket suppression of command errors in shell scripts to ensure that authentication, syntax, or system issues remain visible for debugging.



Summary
cmd_reconcile_queue_dispatchability) cancelled newly-added batch tasks before Phase 0.9 could tag them with#auto-dispatch, causing all tasks in a batch to be immediately cancelled on the first pulsebatch_tasks+batchestables to see if the task belongs to an active/paused batchRoot Cause
Phase ordering race condition:
supervisor-helper.sh addputs tasks in DB asqueuedbut does NOT modify TODO.md#auto-dispatchtag — not found → cancels as phantomFix
Option 2 from the issue: Phase 0.6 checks
batch_tasks JOIN batchesfor active/paused batch membership before the phantom cancellation decision. This is the cleanest approach because batch membership is an explicit, queryable signal of dispatch intent.Changed Files
.agents/scripts/supervisor-archived/todo-sync.sh—cmd_reconcile_queue_dispatchability()(lines 1967-1981): added batch membership check before phantom cancellationVerification
Closes #2836