t296: Auto-create batches on auto-pickup#1162
Conversation
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.
Summary of ChangesHello @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 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
|
|
Caution Review failedThe pull request is closed. WalkthroughAuto-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
Sequence DiagramsequenceDiagram
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
✨ 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 Feb 11 22:57:05 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
|
There was a problem hiding this comment.
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.
| 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); | ||
| " |
There was a problem hiding this comment.
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.
| 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) |
There was a problem hiding this comment.
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
- The style guide states that
2>/dev/nullis acceptable only when redirecting to log files, not for blanket suppression of errors. (link)
| 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" |
There was a problem hiding this comment.
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;"


Summary
cmd_auto_pickuppicks up#auto-dispatchtasks, they are now automatically assigned to a batchauto-YYYYMMDD-HHMMSSbatch with concurrency 3Problem
The cron pulse runs
auto-pickupevery 2 minutes, which scans TODO.md for#auto-dispatchtasks and adds them to the supervisor DB. Butcmd_adddoesn'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:auto-YYYYMMDD-HHMMSSwith concurrency 3Testing
Files Changed
.agents/scripts/supervisor-helper.sh— auto-batch logic incmd_auto_pickup, updated help text.agents/AGENTS.md— updated auto-dispatch documentationRef #1155
Summary by CodeRabbit
Release Notes