Skip to content

fix: add debug logging to AI lifecycle loop#2110

Merged
marcusquinn merged 2 commits intomainfrom
bugfix/phase4b2-skip-ai-lifecycle
Feb 21, 2026
Merged

fix: add debug logging to AI lifecycle loop#2110
marcusquinn merged 2 commits intomainfrom
bugfix/phase4b2-skip-ai-lifecycle

Conversation

@marcusquinn
Copy link
Owner

@marcusquinn marcusquinn commented Feb 21, 2026

Adds logging to diagnose why only 1 task is processed per pulse cycle.

Summary by CodeRabbit

  • Chores
    • Enhanced logging for task status transitions and failure diagnostics.
    • Improved tracking of eligible tasks for better operational observability.
    • Added conditional behavior for AI lifecycle-enabled vs. legacy processing flows.
    • Refined error reporting and fallback warnings during task processing.

@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 enhances the AI lifecycle management by integrating comprehensive debug logging to pinpoint an issue where only a single task is processed per cycle. Concurrently, it refines the system's robustness by preventing older, non-AI-aware recovery processes from interfering with active AI lifecycle operations, thereby ensuring consistent and predictable task handling.

Highlights

  • Debugging AI Lifecycle: Introduced new debug logging within the 'process_ai_lifecycle' function to count eligible tasks and log status transitions for individual tasks, aiding in diagnosing why only one task is processed per pulse cycle.
  • AI Lifecycle Compatibility: Implemented a conditional guard in 'pulse.sh' to prevent the legacy stale 'pr_review' recovery mechanism from executing when the 'SUPERVISOR_AI_LIFECYCLE' is active, ensuring AI decisions are not inadvertently overridden.
Changelog
  • .agents/scripts/supervisor/ai-lifecycle.sh
    • Added a log entry to show the total number of eligible tasks at the start of the 'process_ai_lifecycle' function.
    • Included a log entry to track the status change of each task ('tid → new_status') after processing.
    • Added a warning log for tasks that fail during 'process_task_lifecycle' (non-zero return).
  • .agents/scripts/supervisor/pulse.sh
    • Wrapped the "Phase 4b2: Stale pr_review recovery" logic within an 'if' condition, ensuring it only runs if 'SUPERVISOR_AI_LIFECYCLE' is not set to "true".
    • Updated comments to clarify the purpose of this guard, preventing legacy recovery from clobbering AI decisions.
Activity
  • No specific activity has been recorded for 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 21, 2026

Caution

Review failed

The pull request is closed.

Walkthrough

Enhanced observability and lifecycle control in supervisor scripts: added task eligibility tallies and status-change logging to ai-lifecycle.sh, while introducing conditional gating in pulse.sh to skip legacy pr_review recovery when AI lifecycle is enabled, with adjusted failure logging.

Changes

Cohort / File(s) Summary
Observability Instrumentation
.agents/scripts/supervisor/ai-lifecycle.sh
Added task eligibility counter and per-task status-change logging (ai-lifecycle: $tid → $new_status). Introduced error/warning fallback logs when process_task_lifecycle returns non-zero to improve failure visibility.
Conditional Legacy Path Gating
.agents/scripts/supervisor/pulse.sh
Phase 4b2 stale pr_review recovery now guarded by SUPERVISOR_AI_LIFECYCLE flag. When enabled, legacy pr_review path is skipped entirely. When disabled, original flow executes with refined logging for successful lifecycle invocation and cmd_pr_lifecycle failures.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🔍 Logs now flow where once was dark,
Each task's journey leaves a mark—
Conditions guard the legacy way,
While AI-lifecycle leads the play! 🤖

✨ 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/phase4b2-skip-ai-lifecycle

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, 38 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Sat Feb 21 15:59:08 UTC 2026: Code review monitoring started
Sat Feb 21 15:59:08 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 38

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 38
  • VULNERABILITIES: 0

Generated on: Sat Feb 21 15:59:11 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link

@marcusquinn marcusquinn merged commit 1004faa into main Feb 21, 2026
10 of 11 checks passed
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 adds debug logging to the AI lifecycle loop to diagnose why only one task is processed per pulse cycle. It also introduces a guard in the pulse scheduler to skip legacy stale PR recovery when the AI lifecycle is active, preventing potential state clobbering. The logging enhancements are well-placed and follow the project's established patterns, though some minor style guide adherence and a likely underlying bug regarding stdin consumption were identified.

total_eligible=$(printf '%s\n' "$eligible_tasks" | grep -c '.' || echo "0")
log_info "ai-lifecycle: $total_eligible eligible tasks"

while IFS='|' read -r tid tstatus tpr trepo; do

Choose a reason for hiding this comment

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

high

Regarding the issue where only one task is processed per cycle: if process_task_lifecycle (called inside this loop) executes commands that read from stdin (like gh, opencode, or ssh), it will consume the remaining lines of $eligible_tasks, causing the loop to terminate early. To prevent this, ensure all commands inside the loop have their stdin redirected from /dev/null.

local repos_with_changes=""

local total_eligible=0
total_eligible=$(printf '%s\n' "$eligible_tasks" | grep -c '.' || echo "0")

Choose a reason for hiding this comment

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

medium

The use of || echo "0" as a guard for grep -c is functionally correct, but for commands that may fail under set -e, the recommended practice is to use || true to prevent premature script termination. While grep -c already outputs 0 to stdout even when no matches are found (though it exits with code 1), || true ensures adherence to the set -e safety pattern.

Suggested change
total_eligible=$(printf '%s\n' "$eligible_tasks" | grep -c '.' || echo "0")
total_eligible=$(printf '%s\n' "$eligible_tasks" | grep -c '.' || true)
References
  1. Use || true guards for commands that may fail under set -e (grep, arithmetic) (link)
  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.

@marcusquinn marcusquinn added the needs-review Flagged for human review by AI supervisor label Feb 22, 2026
@marcusquinn
Copy link
Owner Author

Flagged for Human Review

Reason: t1311 has malformed blocked-by dependency (blocked-by:` with backtick instead of task ID). This prevents dispatch and auto-unblock detection. The blocker field needs manual correction in TODO.md to either remove the dependency or specify the correct blocking task ID.

This issue has been flagged by the AI supervisor for human review. Please assess and take appropriate action.


Flagged by AI Supervisor (automated reasoning cycle)

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

Labels

needs-review Flagged for human review by AI supervisor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant