Skip to content

Conversation

@marcusquinn
Copy link
Owner

@marcusquinn marcusquinn commented Feb 7, 2026

Summary

  • Cron PATH fix: Add PATH augmentation at supervisor-helper.sh startup for cron environments that lack /opt/homebrew/bin, ~/.local/bin, etc. This fixes gh/opencode/node being unreachable from cron-triggered pulses, which caused all pr_review tasks to loop forever in a no_pr retry cycle.
  • no_pr retry limit: Add retry counter (max 5) to the no_pr case in cmd_pr_lifecycle to prevent infinite loops. After 5 failures, task transitions to blocked with diagnostic info (whether gh is in PATH).
  • Test suite fix: Use git ls-files instead of find to validate JSON configs in test-batch-quality-hardening.sh, excluding gitignored working copies that caused a false positive failure.

Root Cause

Discovered during PR verification batch: cron jobs run with minimal PATH (/usr/bin:/bin:/usr/sbin:/sbin). The gh CLI at /opt/homebrew/bin/gh was unreachable, causing check_pr_status() to silently return no_pr for every task. The no_pr handler had no retry limit, creating an infinite loop across 69+ pulse cycles.

Changes

File Change
.agents/scripts/supervisor-helper.sh PATH augmentation + no_pr retry limit (5 max)
tests/test-batch-quality-hardening.sh Use git ls-files for JSON validation scope

Testing

  • shellcheck -S error supervisor-helper.sh -- 0 errors
  • bash -n supervisor-helper.sh -- syntax OK
  • test-batch-quality-hardening.sh -- 55/56 pass (1 expected diff: deployed vs repo version)

Summary by CodeRabbit

  • Bug Fixes

    • Improved error handling logic in automated workflows to allow proper fallback mechanisms.
    • Enhanced retry mechanism for PR lifecycle processes with configurable attempt limits.
  • Chores

    • Improved test validation to focus on git-tracked configuration files only.

- Add PATH augmentation at script startup for cron environments that lack
  /opt/homebrew/bin, ~/.local/bin, etc. This fixes gh/opencode/node being
  unreachable from cron-triggered pulses, which caused all pr_review tasks
  to loop forever in a no_pr retry cycle.
- Add retry counter (max 5) to the no_pr case in pr_lifecycle to prevent
  infinite loops. After 5 failures, task transitions to blocked with
  diagnostic info (whether gh is in PATH).
- Fix test suite false positive: use git ls-files instead of find to
  validate JSON configs, excluding gitignored working copies.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 7, 2026

Walkthrough

The PR refactors error handling in clawdhub-helper.sh to improve fallback execution flow, enhances supervisor-helper.sh with PATH augmentation for cron-triggered runs and introduces a no_pr retry-tracking mechanism with a 5-attempt blocking threshold, and restricts quality test scope to git-tracked configuration files only.

Changes

Cohort / File(s) Summary
Error Handling Refinement
.agents/scripts/clawdhub-helper.sh
Removed conditional || exit patterns after Playwright install and clawdhub CLI fallback sequences, replacing with clean exits. Added explicit return 0 after successful extraction to enable early function exit.
PATH Augmentation & Retry Tracking
.agents/scripts/supervisor-helper.sh
Added PATH augmentation for cron-triggered runs to ensure tool availability (gh, opencode, node, etc.). Introduced per-task no_pr_retries counter in JSON error field with retry-tracking for no_pr handling; blocks progression after 5 consecutive failures with logging of root cause.
Test Scope Refinement
tests/test-batch-quality-hardening.sh
Restricted test scope from all JSON files to git-tracked files only using git ls-files command. Updated file path resolution to use $REPO_DIR/$f and reporting messages to specify "git-tracked" status.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • PR #378: Directly implements the retry/blocking logic foundation for no_pr handling in supervisor-helper.sh that this PR extends with JSON field management.
  • PR #392: Introduces the pr-lifecycle and post-PR lifecycle logic in supervisor-helper.sh where this PR adds PATH augmentation and retry-tracking mechanisms.
  • PR #429: Modifies pr-lifecycle/no-PR handling in supervisor-helper.sh; relates through overlapping changes to the same no_pr control flow logic.

Poem

Shell scripts dance with careful grace,
Exit flows find their rightful place,
Retries bloom with counted pace,
Git tracks only what we trace,
DevOps automation—zero-debt chase! 🚀

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately captures the two main changes: cron PATH resolution and no_pr retry limit enforcement in supervisor-helper.sh.
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
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bugfix/supervisor-cron-path

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.

@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 addresses critical reliability issues within the supervisor system, primarily focusing on robust operation within cron environments and preventing task stagnation. By enhancing PATH resolution, it ensures essential command-line tools are always accessible. Additionally, it introduces a crucial retry limit for PR-related tasks, preventing infinite loops and providing clearer diagnostic feedback. Finally, it refines the test suite to improve accuracy and avoid misleading failures.

Highlights

  • Cron PATH Resolution: The supervisor-helper.sh script now augments the system's PATH environment variable at startup. This ensures that common tools like gh, opencode, and node are discoverable in cron environments, which typically have a minimal PATH, preventing issues where these tools were unreachable during cron-triggered pulses.
  • no_pr Retry Limit: A retry counter (maximum of 5 attempts) has been implemented for tasks that return a no_pr status in cmd_pr_lifecycle. This prevents infinite loops where tasks would continuously retry due to an unreachable PR. After 5 failures, the task transitions to a blocked state with diagnostic information, including whether the gh CLI is in the PATH.
  • Test Suite Improvement: The test-batch-quality-hardening.sh script has been updated to use git ls-files instead of find for validating JSON configuration files. This change ensures that only git-tracked files are checked, correctly excluding gitignored working copies and preventing false positive failures in the test suite.
Changelog
  • .agents/scripts/supervisor-helper.sh
    • Added logic to augment the PATH environment variable with common tool directories (e.g., /opt/homebrew/bin, ~/.local/bin) to ensure tools like gh are accessible in cron jobs.
    • Implemented a retry mechanism for the no_pr case in cmd_pr_lifecycle, tracking attempts in the task's error field.
    • Tasks reaching 5 no_pr retries will now transition to a blocked state, with an error message indicating the number of attempts and the gh CLI's PATH status.
  • tests/test-batch-quality-hardening.sh
    • Modified the JSON configuration file validation step to use git -C "$REPO_DIR" ls-files instead of find.
    • Updated comments and success/failure messages to reflect that only git-tracked JSON files are now validated, excluding gitignored working copies.
Activity
  • No specific activity (comments, reviews, etc.) 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.

@github-actions
Copy link

github-actions bot commented Feb 7, 2026

🔍 Code Quality Report

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

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

�[0;34m[INFO]�[0m Recent monitoring activity:
Sat Feb 7 15:34:42 UTC 2026: Code review monitoring started
Sat Feb 7 15:34:43 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 25
Sat Feb 7 15:34:43 UTC 2026: Qlty - 0 issues found, auto-formatting applied
Sat Feb 7 15:34:45 UTC 2026: Codacy analysis completed with auto-fixes

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 25
  • VULNERABILITIES: 0

Generated on: Sat Feb 7 15:34:48 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

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 introduces important robustness improvements to the supervisor script. The addition of PATH resolution for cron jobs is a critical fix for ensuring tool availability, and the retry limit on the no_pr case effectively prevents infinite loops. The test suite is also improved by scoping JSON validation to tracked files. I have a couple of suggestions to further enhance the code quality and correctness.

…eck SC1073/SC1072

The pattern 'if (...); then || exit' is invalid bash - the 'then' clause
already handles the conditional, making '|| exit' both syntactically wrong
and semantically redundant. Removed from 3 occurrences.
@github-actions
Copy link

github-actions bot commented Feb 7, 2026

🔍 Code Quality Report

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

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

�[0;34m[INFO]�[0m Recent monitoring activity:
Sat Feb 7 15:49:41 UTC 2026: Code review monitoring started
Sat Feb 7 15:49:42 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 25
Sat Feb 7 15:49:42 UTC 2026: Qlty - 0 issues found, auto-formatting applied
Sat Feb 7 15:49:44 UTC 2026: Codacy analysis completed with auto-fixes
Sat Feb 7 15:49:46 UTC 2026: Applied 1 automatic fixes

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 25
  • VULNERABILITIES: 0

Generated on: Sat Feb 7 15:49:47 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 7, 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.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In @.agents/scripts/supervisor-helper.sh:
- Around line 3165-3167: The current SELECT using json_extract on the
tasks.error column loses the no_pr_retries counter when other code
(cmd_transition) overwrites error with plain text; fix by changing
cmd_transition so when it writes a plain-text error it first reads the existing
tasks.error (via the same db/select used for no_pr_count), extracts any existing
no_pr_retries value, and then writes back a JSON object like {"msg":"CI checks
failed","no_pr_retries":<existing_or_0>} instead of a raw string; update
cmd_transition's error-write path to preserve or merge the no_pr_retries field
rather than replacing error with plain text so the json_extract(...) used for
no_pr_count continues to work.
- Around line 3162-3183: The db invocations that read and write the no_pr retry
counter are missing the SUPERVISOR_DB argument causing sqlite3 to misinterpret
the SQL as a filename and the retry counter (no_pr_count) to never persist;
update both calls to db so the first argument is $SUPERVISOR_DB (e.g., db
"$SUPERVISOR_DB" "...SQL...") when selecting and updating the tasks.error JSON,
and remove the unused no_pr_key variable to avoid dead code.

@marcusquinn marcusquinn merged commit 19965ca into main Feb 7, 2026
19 checks passed
marcusquinn added a commit that referenced this pull request Feb 7, 2026
…fix bot

The auto-fix GitHub Action (aa276b3) re-introduced the invalid
'; then || exit' syntax that was fixed in PR #435. This is a known
issue with the auto-fix workflow applying incorrect patterns.
marcusquinn added a commit that referenced this pull request Feb 7, 2026
The apply_automatic_fixes() function in monitor-code-review.sh used a
broad sed regex to add '|| exit' after 'cd' commands, but it matched
cd inside subshells within if conditions, producing invalid syntax:
  if (cd "$dir" && cmd); then || exit

This caused ShellCheck SC1073/SC1072 failures (PR #435, commit aa276b3).
Disabled the auto-fix until a safe implementation with post-fix ShellCheck
validation is available.
marcusquinn added a commit that referenced this pull request Feb 7, 2026
… marketplace path (#436)

* fix(security): replace eval with arrays in 4 scripts, fix marketplace.json path

t130.1: Fix .claude-plugin/marketplace.json source path from .agent to .agents
t135.7: Replace eval with bash arrays in wp-helper.sh (3), coderabbit-cli.sh (2),
codacy-cli.sh (3), and pandoc-helper.sh (1) - total 9 eval removals.
Refactored wp-helper build_ssh_command to execute_wp_via_ssh (direct execution).
All scripts pass ShellCheck -S error.

* fix(security): add trap cleanup for temp files in secret-helper and version-manager

t135.9 (partial): Add EXIT trap for mktemp cleanup in secret-helper.sh
(prevents credential leaks on interrupt) and version-manager.sh (prevents
partial changelog files). Trap is reset after normal cleanup completes.

* refactor: archive 12 completed one-time fix scripts to _archive/

t135.12: Move 11 fix-*.sh scripts and add-missing-returns.sh to
.agents/scripts/_archive/ with README documenting purpose and origin.
All scripts had 0 references in active codebase. Preserves git history
and patterns for future bulk fix operations.

* fix(clawdhub): remove invalid '; then || exit' re-introduced by auto-fix bot

The auto-fix GitHub Action (aa276b3) re-introduced the invalid
'; then || exit' syntax that was fixed in PR #435. This is a known
issue with the auto-fix workflow applying incorrect patterns.

* fix(ci): disable broken auto-fix that introduces ShellCheck regressions

The apply_automatic_fixes() function in monitor-code-review.sh used a
broad sed regex to add '|| exit' after 'cd' commands, but it matched
cd inside subshells within if conditions, producing invalid syntax:
  if (cd "$dir" && cmd); then || exit

This caused ShellCheck SC1073/SC1072 failures (PR #435, commit aa276b3).
Disabled the auto-fix until a safe implementation with post-fix ShellCheck
validation is available.
marcusquinn added a commit that referenced this pull request Feb 7, 2026
… HOMEBREW_PREFIX guard (t147.1)

- Add $SUPERVISOR_DB as first arg to both db() calls in no_pr retry
  counter logic (lines 3165, 3183). Without it, sqlite3 treated the SQL
  as a filename and failed silently — retry counter never persisted,
  making the 5-attempt threshold unreachable.
- Remove unused no_pr_key variable.
- Remove HOMEBREW_PREFIX guard around PATH augmentation. The idempotent
  PATH check already prevents duplicates; the guard was overly
  restrictive for cron environments where HOMEBREW_PREFIX may be set
  without all tool paths present.

Triaged all 4 unresolved review threads from PR #435:
- 3 fixed (critical db bug, unused var, PATH guard)
- 1 acknowledged won't-fix (json_extract counter reset is by design)

Refs: GH#438, t147.1
marcusquinn added a commit that referenced this pull request Feb 7, 2026
…147.1) (#450)

* chore: mark t142 complete in TODO.md (#449)

* chore: mark t135.9 complete in TODO.md (#448)

* fix(supervisor): add missing $SUPERVISOR_DB arg to db() calls, remove HOMEBREW_PREFIX guard (t147.1)

- Add $SUPERVISOR_DB as first arg to both db() calls in no_pr retry
  counter logic (lines 3165, 3183). Without it, sqlite3 treated the SQL
  as a filename and failed silently — retry counter never persisted,
  making the 5-attempt threshold unreachable.
- Remove unused no_pr_key variable.
- Remove HOMEBREW_PREFIX guard around PATH augmentation. The idempotent
  PATH check already prevents duplicates; the guard was overly
  restrictive for cron environments where HOMEBREW_PREFIX may be set
  without all tool paths present.

Triaged all 4 unresolved review threads from PR #435:
- 3 fixed (critical db bug, unused var, PATH guard)
- 1 acknowledged won't-fix (json_extract counter reset is by design)

Refs: GH#438, t147.1
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