Skip to content

fix: skip batch tasks in Phase 0.6 reconcile-queue to prevent premature cancellation#2844

Merged
alex-solovyev merged 1 commit intomainfrom
bugfix/phase06-batch-skip
Mar 4, 2026
Merged

fix: skip batch tasks in Phase 0.6 reconcile-queue to prevent premature cancellation#2844
alex-solovyev merged 1 commit intomainfrom
bugfix/phase06-batch-skip

Conversation

@alex-solovyev
Copy link
Collaborator

Summary

  • Phase 0.6 (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 pulse
  • Added a batch membership check: before cancelling a task as a "phantom queue entry", Phase 0.6 now queries batch_tasks + batches tables to see if the task belongs to an active/paused batch
  • Tasks in active batches are skipped — batch membership is explicit dispatch intent

Root Cause

Phase ordering race condition:

  1. supervisor-helper.sh add puts tasks in DB as queued but does NOT modify TODO.md
  2. Phase 0.6 checks TODO.md for #auto-dispatch tag — not found → cancels as phantom
  3. Phase 0.9 (sanity check) would have auto-tagged, but only runs when queue is empty — which it now is because Phase 0.6 cancelled everything

Fix

Option 2 from the issue: Phase 0.6 checks batch_tasks JOIN batches for 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.shcmd_reconcile_queue_dispatchability() (lines 1967-1981): added batch membership check before phantom cancellation

Verification

  • ShellCheck: zero violations
  • The fix is a pure additive guard — existing phantom detection for non-batch tasks is unchanged

Closes #2836

…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
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 4, 2026

Warning

Rate limit exceeded

@alex-solovyev has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 29 minutes and 16 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 83fd3749-2cd1-4a0e-a8c8-ed8e0e4cf232

📥 Commits

Reviewing files that changed from the base of the PR and between 55b249c and ea86831.

📒 Files selected for processing (1)
  • .agents/scripts/supervisor-archived/todo-sync.sh
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bugfix/phase06-batch-skip

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added the bug Auto-created from TODO.md tag label Mar 4, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 107 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Wed Mar 4 17:45:01 UTC 2026: Code review monitoring started
Wed Mar 4 17:45:01 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 107

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 107
  • VULNERABILITIES: 0

Generated on: Wed Mar 4 17:45:04 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@gemini-code-assist
Copy link

Summary of Changes

Hello, 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

  • Prevented premature batch task cancellation: Phase 0.6 was prematurely cancelling newly-added batch tasks before they could be properly tagged, leading to immediate cancellation of all tasks in a batch.
  • Implemented batch membership check: A check was added to cmd_reconcile_queue_dispatchability in Phase 0.6 to query batch_tasks and batches tables, determining if a task belongs to an active or paused batch.
  • Skipped tasks in active batches: Tasks identified as belonging to active or paused batches are now explicitly skipped from the phantom queue entry cancellation logic, as their batch membership signifies dispatch intent.
Changelog
  • .agents/scripts/supervisor-archived/todo-sync.sh
    • Added a database query to check if a task belongs to an active or paused batch within the cmd_reconcile_queue_dispatchability function.
    • Modified the conditional logic for identifying and cancelling 'phantom queue entries' to exclude tasks that are part of an active batch.
    • Updated the verbose logging message to include the in_active_batch status for dispatchable tasks.
Activity
  • The pull request was created by alex-solovyev to fix an issue where batch tasks were being prematurely cancelled.
  • The author provided a detailed summary, root cause analysis, and verification steps for the proposed fix.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 4, 2026

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +1972 to +1978
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 "")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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.

Suggested change
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
  1. 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.
  2. 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.
  3. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Auto-created from TODO.md tag

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Phase 0.6 reconcile-queue cancels newly-added batch tasks before Phase 0.9 tags them

1 participant