Skip to content

t296: Auto-create batches on auto-pickup#1162

Merged
marcusquinn merged 1 commit intomainfrom
feature/t296-auto-batch-pickup
Feb 11, 2026
Merged

t296: Auto-create batches on auto-pickup#1162
marcusquinn merged 1 commit intomainfrom
feature/t296-auto-batch-pickup

Conversation

@marcusquinn
Copy link
Owner

@marcusquinn marcusquinn commented Feb 11, 2026

Summary

  • When cmd_auto_pickup picks up #auto-dispatch tasks, they are now automatically assigned to a batch
  • If an active batch exists (has non-terminal tasks), new tasks are added to it
  • If no active batch exists, creates a new auto-YYYYMMDD-HHMMSS batch with concurrency 3
  • Previously, auto-picked tasks were unbatched — dispatched globally without batch-level concurrency control, completion tracking, or auto-release

Problem

The cron pulse runs auto-pickup every 2 minutes, which scans TODO.md for #auto-dispatch tasks and adds them to the supervisor DB. But cmd_add doesn't assign tasks to any batch. Phase 2 of the pulse dispatches unbatched tasks globally, bypassing batch concurrency limits and losing batch-level features (completion tracking, retrospectives, auto-release).

Solution

Added auto-batching logic at the end of cmd_auto_pickup:

  1. After picking up tasks, find unbatched queued tasks
  2. Check for an active batch (any batch with non-terminal tasks)
  3. If active batch exists → add tasks to it (appends at next position)
  4. If no active batch → create auto-YYYYMMDD-HHMMSS with concurrency 3

Testing

  • Bash syntax check: pass
  • ShellCheck (warning level): zero new violations (only pre-existing SC2034)
  • Logic review: handles edge cases (empty pickup, existing batch, no batch)

Files Changed

  • .agents/scripts/supervisor-helper.sh — auto-batch logic in cmd_auto_pickup, updated help text
  • .agents/AGENTS.md — updated auto-dispatch documentation

Ref #1155

Summary by CodeRabbit

Release Notes

  • New Features
    • Auto-dispatch system now automatically creates batches (auto-YYYYMMDD-HHMMSS format with concurrency 3) when no active batch exists.
    • Auto-pickup process automatically batches unbatched tasks to existing active batches or creates new batches as needed.
    • Enhanced logging for batch creation and task batching operations.
    • Updated documentation for auto-pickup behavior.

When cmd_auto_pickup picks up #auto-dispatch tasks from TODO.md, they
were added to the supervisor DB unbatched. This meant no batch-level
concurrency control, completion tracking, or auto-release.

Now after picking up tasks:
- If an active batch exists, new tasks are added to it
- If no active batch exists, creates 'auto-YYYYMMDD-HHMMSS' batch
  with concurrency 3

This closes the loop: add #auto-dispatch to TODO.md -> cron pulse
picks up -> auto-batches -> dispatches workers -> manages lifecycle.

Also updated AGENTS.md auto-dispatch docs and supervisor help text.
@marcusquinn marcusquinn merged commit 79781f2 into main Feb 11, 2026
6 of 8 checks passed
@gemini-code-assist
Copy link

Summary of Changes

Hello @marcusquinn, 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 introduces a significant improvement to how automatically dispatched tasks are managed within the system. By implementing an auto-batching mechanism, all tasks picked up via cmd_auto_pickup are now consistently grouped into batches. This ensures that these autonomous tasks benefit from structured concurrency control, completion tracking, and lifecycle management, which was previously missing for unbatched tasks.

Highlights

  • Auto-batching for auto-picked tasks: When cmd_auto_pickup processes #auto-dispatch tasks, they are now automatically assigned to a batch, ensuring proper management and concurrency control.
  • Batch assignment logic: If an active batch with non-terminal tasks exists, new auto-picked tasks are added to it; otherwise, a new batch named auto-YYYYMMDD-HHMMSS with a concurrency of 3 is created.
  • Enhanced task management: This change resolves the issue where previously auto-picked tasks were unbatched, lacking batch-level concurrency control, completion tracking, and auto-release features.
Changelog
  • .agents/AGENTS.md
    • Updated the documentation for #auto-dispatch to reflect that auto-picked tasks now automatically create or join batches.
  • .agents/scripts/supervisor-helper.sh
    • Added logic to automatically assign newly picked-up tasks to an existing active batch or create a new one.
    • Updated the help text for cron integration and auto-pickup to describe the new auto-batching feature.
Activity
  • No human activity (comments, reviews, approvals) has been recorded on this pull request yet.
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.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 11, 2026

Caution

Review failed

The pull request is closed.

Walkthrough

Auto-dispatch now includes auto-batching for picked tasks: when auto-pickup detects unbatched tasks, the system either appends them to an existing active batch or creates a new auto-batch (auto-YYYYMMDD-HHMMSS) with concurrency 3. Documentation is updated to reflect this behavior change.

Changes

Cohort / File(s) Summary
Documentation
.agents/AGENTS.md
Auto-dispatch description updated to reflect new auto-batching behavior when no active batch exists.
Auto-batching Implementation
.agents/scripts/supervisor-helper.sh
Implements auto-batching logic during auto-pickup (t296): detects unbatched tasks and either appends to existing active batch or creates new auto-batch with concurrency 3; includes batch task tracking, position preservation, and logging.

Sequence Diagram

sequenceDiagram
    participant AutoPickup as Auto-Pickup System
    participant BatchManager as Batch Manager
    participant TaskSystem as Task System
    
    AutoPickup->>AutoPickup: Detect new queued tasks
    AutoPickup->>BatchManager: Check for active batch<br/>(non-terminal tasks)
    
    alt Active Batch Exists
        BatchManager-->>AutoPickup: Return active batch ID
        AutoPickup->>TaskSystem: Append unbatched tasks<br/>to batch
        TaskSystem->>TaskSystem: Update batch_tasks<br/>Preserve positions
        TaskSystem-->>AutoPickup: Confirm append + count
    else No Active Batch
        BatchManager-->>AutoPickup: No batch found
        AutoPickup->>BatchManager: Create auto-batch<br/>auto-YYYYMMDD-HHMMSS
        BatchManager->>TaskSystem: Set concurrency 3
        AutoPickup->>TaskSystem: Submit unbatched tasks<br/>as initial batch_tasks
        TaskSystem-->>AutoPickup: Confirm batch creation + count
    end
    
    AutoPickup->>AutoPickup: Log auto-batch count
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🚀 Tasks arrive without a home,
Auto-pickup sweeps them in,
Batches form (or spawn anew),
Concurrency dances—three by three,
Order blooms from chaos, zing!

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/t296-auto-batch-pickup

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
Copy link

🔍 Code Quality Report

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

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

�[0;34m[INFO]�[0m Recent monitoring activity:
Wed Feb 11 22:57:02 UTC 2026: Code review monitoring started
Wed Feb 11 22:57:02 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 9

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 9
  • VULNERABILITIES: 0

Generated on: Wed Feb 11 22:57:05 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link

marcusquinn added a commit that referenced this pull request Feb 11, 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 enhances the supervisor's auto-pickup functionality by automatically assigning picked-up tasks to batches, a significant step towards better task management. However, a high-severity SQL Injection vulnerability was identified where SQL queries are constructed using manual string concatenation, which is a fragile pattern even with sql_escape. It's recommended to use parameterized queries to prevent this. Additionally, the review suggests improving error logging adherence to the style guide and optimizing database writes for better performance.

Comment on lines +13085 to +13096
max_pos=$(db "$SUPERVISOR_DB" "
SELECT COALESCE(MAX(position), -1) FROM batch_tasks
WHERE batch_id = '$(sql_escape "$active_batch_id")';
" 2>/dev/null || echo "-1")
local pos=$((max_pos + 1))

while IFS= read -r tid; do
[[ -z "$tid" ]] && continue
db "$SUPERVISOR_DB" "
INSERT OR IGNORE INTO batch_tasks (batch_id, task_id, position)
VALUES ('$(sql_escape "$active_batch_id")', '$(sql_escape "$tid")', $pos);
"

Choose a reason for hiding this comment

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

security-high high

This SQL query is vulnerable to SQL Injection. Directly embedding shell variables into the query string, even with sql_escape, is a fragile security practice. This can lead to vulnerabilities if the escaping function has flaws, especially as data sourced from the database might originate from less trusted sources like the TODO.md file. Both security best practices and the style guide recommend using parameterized queries (prepared statements) to separate query logic from data, preventing injection attacks. This pattern is also observed on line 13095.

Comment on lines +13059 to +13064
unbatched_queued=$(db "$SUPERVISOR_DB" "
SELECT t.id FROM tasks t
WHERE t.status = 'queued'
AND t.id NOT IN (SELECT task_id FROM batch_tasks)
ORDER BY t.created_at;
" 2>/dev/null || true)

Choose a reason for hiding this comment

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

medium

The use of 2>/dev/null here and in other parts of this function (lines 13079, 13088, and 13111) suppresses potentially useful error messages from database operations. This can make debugging difficult if a query fails.

According to the repository style guide, blanket error suppression is discouraged. It would be better to redirect stderr to a log file, for example 2>> "$SUPERVISOR_LOG".

References
  1. The style guide states that 2>/dev/null is acceptable only when redirecting to log files, not for blanket suppression of errors. (link)

Comment on lines +13091 to +13099
while IFS= read -r tid; do
[[ -z "$tid" ]] && continue
db "$SUPERVISOR_DB" "
INSERT OR IGNORE INTO batch_tasks (batch_id, task_id, position)
VALUES ('$(sql_escape "$active_batch_id")', '$(sql_escape "$tid")', $pos);
"
pos=$((pos + 1))
added_count=$((added_count + 1))
done <<< "$unbatched_queued"

Choose a reason for hiding this comment

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

medium

This while loop executes a separate INSERT statement for each task ID. If a large number of tasks are picked up, this will result in many individual database transactions, which is inefficient and can be slow.

To improve performance, these inserts should be wrapped in a single database transaction. This significantly reduces the overhead of database writes.

Example:

db "$SUPERVISOR_DB" "BEGIN TRANSACTION;"
while IFS= read -r tid; do
    [[ -z "$tid" ]] && continue
    db "$SUPERVISOR_DB" "
        INSERT OR IGNORE INTO batch_tasks (batch_id, task_id, position)
        VALUES ('$(sql_escape "$active_batch_id")', '$(sql_escape "$tid")', $pos);
    "
    pos=$((pos + 1))
    added_count=$((added_count + 1))
done <<< "$unbatched_queued"
db "$SUPERVISOR_DB" "COMMIT;"

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant