Skip to content

t2837: Fix pulse --batch mode that still runs auto-pickup and ingests unrelated tasks#2843

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

t2837: Fix pulse --batch mode that still runs auto-pickup and ingests unrelated tasks#2843
alex-solovyev merged 1 commit intomainfrom
bugfix/pulse-batch-skip-auto-pickup

Conversation

@alex-solovyev
Copy link
Collaborator

@alex-solovyev alex-solovyev commented Mar 4, 2026

Summary

  • Gate all cmd_auto_pickup call sites in cmd_pulse() on batch_id being empty, so pulse --batch <id> only manages tasks within the specified batch
  • Prevents Phase 0 (auto-pickup), Phase 0.9 (sanity check → auto-pickup), and Phase 2b (stall recovery → auto-pickup) from ingesting unrelated #auto-dispatch tasks and creating phantom batches during targeted batch dispatch
  • Each suppressed path logs an informational message referencing t2837 for traceability

Root Cause

When running pulse --batch <id>, three code paths in cmd_pulse() called cmd_auto_pickup unconditionally:

  1. Phase 0 — scanned TODO.md for all #auto-dispatch tasks
  2. Phase 0.9 — sanity check re-ran auto-pickup when queue appeared empty
  3. Phase 2b — stall recovery re-ran auto-pickup when no active batch was found

Auto-pickup adds tasks to the supervisor DB and creates new batches for unbatched tasks. In targeted batch mode, this caused 13 unrelated tasks to be ingested into a phantom batch, which were then cancelled as collateral when the phantom batch was cancelled — leaving them as cancelled in the DB but [ ] in TODO.md, triggering Phase 0.5c annotation loops on every subsequent pulse.

Testing

  • ShellCheck: zero violations on modified file
  • The fix is purely additive gating — existing autonomous pulse behaviour (no --batch flag) is completely unchanged

Closes #2837

Summary by CodeRabbit

  • Improvements
    • Batch processing optimized with improved dispatch logic that respects batch boundaries and prevents cross-batch task leakage
    • Reduced processing overhead during batch operations through skipped validation when batch mode is active
    • Enhanced logging provides better visibility into batch-related decisions, dispatch actions, and recovery behaviors

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

coderabbitai bot commented Mar 4, 2026

Walkthrough

Modifies pulse.sh to skip auto-pickup, sanity checks, and stall recovery phases when --batch flag is provided, preventing unrelated tasks from being ingested into targeted batch dispatch operations.

Changes

Cohort / File(s) Summary
Batch-Scoped Pulse Dispatch
.agents/scripts/supervisor-archived/pulse.sh
Adds conditional guards across multiple phases (0, 0.5–0.9, 2, 2b) to skip auto-pickup, sanity/dedup checks, and stall recovery when --batch is active. Retains existing behavior when no explicit batch is specified. Includes logging to reflect skipped operations during batch-driven dispatch.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Suggested labels

bug

Poem

A pulse with purpose, now knows its place,
No phantom batches mar the case,
When --batch calls with steady hand,
Auto-pickup bows, per the command. ✨🎯

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: fixing pulse --batch mode to skip auto-pickup and prevent ingestion of unrelated tasks, which is the core objective.
Linked Issues check ✅ Passed All coding objectives from issue #2837 are met: auto-pickup is gated when batch_id is set across all three affected phases, preventing phantom batch creation and task ingestion.
Out of Scope Changes check ✅ Passed All changes directly address the batch-scoped dispatch issue; no out-of-scope modifications detected. The gating logic and logging are entirely scoped to the stated objectives.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bugfix/pulse-batch-skip-auto-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

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:44:52 UTC 2026: Code review monitoring started
Wed Mar 4 17:44:53 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:44:55 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 critical issue in the pulse --batch mode where the supervisor incorrectly invoked cmd_auto_pickup in several phases. This led to the unintended ingestion of unrelated tasks, creation of "phantom batches," and subsequent collateral cancellations. The changes introduce gating mechanisms to ensure cmd_auto_pickup is skipped when a batch ID is specified, thereby preventing these erroneous behaviors and ensuring pulse --batch operates solely on its intended tasks.

Highlights

  • Batch Mode Auto-Pickup Prevention: Implemented conditional logic to prevent cmd_auto_pickup from running in cmd_pulse() when a specific batch ID is provided, ensuring targeted batch dispatch.
  • Phantom Batch Mitigation: Eliminated the creation of phantom batches and the ingestion of unrelated #auto-dispatch tasks that previously occurred during targeted batch operations.
  • Enhanced Traceability: Added informational log messages for each instance where auto-pickup is suppressed due to batch mode, referencing the relevant task for clarity.
Changelog
  • .agents/scripts/supervisor-archived/pulse.sh
    • Modified Phase 0 auto-pickup logic to skip execution if batch_id is set, adding a log_info message.
    • Wrapped Phase 0.9 sanity check logic with a condition to only run if batch_id is not set.
    • Updated Phase 2b stall recovery to skip auto-pickup if batch_id is set, including a log_info message for this scenario.
Activity
  • No human activity (comments, reviews, etc.) has occurred 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.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 4, 2026

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
.agents/scripts/supervisor-archived/pulse.sh (1)

1875-1890: Add explicit skip logging for Phase 0.9 in batch mode.

This path now skips correctly, but unlike Phase 0 and Phase 2b it has no explicit trace log when --batch is set.

Suggested patch
-	if [[ -z "$batch_id" ]]; then
+	if [[ -z "$batch_id" ]]; then
 		local queued_before_sanity
 		queued_before_sanity=$(db "$SUPERVISOR_DB" "SELECT COUNT(*) FROM tasks WHERE status = 'queued';" 2>/dev/null || echo 0)
 		if [[ "$queued_before_sanity" -eq 0 ]]; then
 			# No queued tasks — check if there are open tasks in TODO.md that should be dispatchable
 			if [[ -n "$all_repos" ]]; then
 				while IFS= read -r repo_path; do
 					_run_sanity_check_for_repo "$repo_path"
 				done <<<"$all_repos"
 			else
 				_run_sanity_check_for_repo "$(pwd)"
 			fi
 		fi
+	else
+		log_info "Phase 0.9: Skipping sanity check/auto-pickup (--batch $batch_id specified, t2837)"
 	fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.agents/scripts/supervisor-archived/pulse.sh around lines 1875 - 1890, The
Phase 0.9 branch currently only runs when batch_id is empty and lacks an
explicit log when skipped in batch mode; add a trace/log call in the else branch
of the if [[ -z "$batch_id" ]]; then ... fi block so that when batch_id is set
you emit a message like "Skipping Phase 0.9 sanity check due to --batch" (use
the same logging helper used elsewhere in this script to match Phase 0/Phase 2b
messages), keeping the existing logic that calls _run_sanity_check_for_repo when
batch_id is empty.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In @.agents/scripts/supervisor-archived/pulse.sh:
- Around line 1875-1890: The Phase 0.9 branch currently only runs when batch_id
is empty and lacks an explicit log when skipped in batch mode; add a trace/log
call in the else branch of the if [[ -z "$batch_id" ]]; then ... fi block so
that when batch_id is set you emit a message like "Skipping Phase 0.9 sanity
check due to --batch" (use the same logging helper used elsewhere in this script
to match Phase 0/Phase 2b messages), keeping the existing logic that calls
_run_sanity_check_for_repo when batch_id is empty.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 472d8830-bda1-49e6-a2e1-a49c058d932f

📥 Commits

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

📒 Files selected for processing (1)
  • .agents/scripts/supervisor-archived/pulse.sh

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

The pull request effectively addresses the issue of pulse --batch mode incorrectly running auto-pickup and ingesting unrelated tasks. The changes correctly gate the cmd_auto_pickup calls in Phase 0, Phase 0.9 (sanity check), and Phase 2b (stall recovery) based on the presence of a batch_id. This prevents the creation of phantom batches and collateral cancellations, as detailed in the PR description. The addition of log_info messages for skipped phases enhances traceability and debugging. The modifications are additive and maintain the existing autonomous pulse behavior when the --batch flag is not used.

@alex-solovyev alex-solovyev merged commit 26803f3 into main Mar 4, 2026
27 of 29 checks passed
@alex-solovyev alex-solovyev deleted the bugfix/pulse-batch-skip-auto-pickup branch March 4, 2026 19:22
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: pulse --batch still runs auto-pickup, ingesting unrelated tasks into phantom batches

1 participant