Skip to content

t1456: count all full-loop workers in pulse utilization#4234

Merged
marcusquinn merged 1 commit intomainfrom
bugfix/t1456-full-loop-worker-counting
Mar 12, 2026
Merged

t1456: count all full-loop workers in pulse utilization#4234
marcusquinn merged 1 commit intomainfrom
bugfix/t1456-full-loop-worker-counting

Conversation

@marcusquinn
Copy link
Owner

@marcusquinn marcusquinn commented Mar 12, 2026

Summary

  • update pulse wrapper active-worker matcher to count all .opencode run full-loop workers, including PR advancement workers
  • keep supervisor exclusion by filtering /pulse and Supervisor Pulse command noise
  • align pulse.md capacity snippet with the same all-full-loop matcher

Verification

  • shellcheck .agents/scripts/pulse-wrapper.sh
  • markdown-formatter check .agents/scripts/commands/pulse.md

Closes #4233

Summary by CodeRabbit

  • Chores
    • Updated worker counting logic to include all full-loop workers (issue and PR advancement), refining system capacity calculations to more accurately reflect available processing capacity.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 12, 2026

Walkthrough

This PR fixes worker-counting logic in the pulse automation system to account for all full-loop workers (both issue and PR advancement), rather than only issue workers. The change updates filtering patterns in both the pulse wrapper script and documentation to count /full-loop processes while excluding supervisor processes and "Supervisor Pulse" titles, improving occupancy accounting during PR-heavy cycles.

Changes

Cohort / File(s) Summary
Pulse worker-counting logic
.agents/scripts/commands/pulse.md, .agents/scripts/pulse-wrapper.sh
Broadened worker matcher from issue-only patterns to all /full-loop processes while explicitly excluding "Supervisor Pulse" titles and supervisor processes. Updates both the count_active_workers function and pulse command documentation to consistently count both issue and PR advancement workers.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested labels

bug

Poem

🔄 When PR workers twirled while issues slept,
Pulse counting logic incompletely wept,
Now both full-loop dancers in the light,
Occupancy accounting: shining bright! ✨

🚥 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 clearly and specifically summarizes the main change: updating pulse worker counting to include all full-loop workers (both issue and PR advancement), which is the core objective of this PR.
Linked Issues check ✅ Passed The PR successfully addresses all acceptance criteria from issue #4233: counts both issue and PR workers via /full-loop pattern, excludes supervisor processes through /pulse and Supervisor Pulse filters, and updates the pulse.md guidance snippet accordingly.
Out of Scope Changes check ✅ Passed All changes are narrowly scoped to the stated objective: modifications only affect worker-counting logic in pulse-wrapper.sh and the corresponding pulse.md guidance snippet, with no extraneous changes.
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/t1456-full-loop-worker-counting
📝 Coding Plan
  • Generate coding plan for human review comments

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

�[0;34m[INFO]�[0m Recent monitoring activity:
Thu Mar 12 19:25:54 UTC 2026: Code review monitoring started
Thu Mar 12 19:25:54 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 402

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 402
  • VULNERABILITIES: 0

Generated on: Thu Mar 12 19:25:57 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 refines the system's ability to accurately measure "pulse utilization" by ensuring all relevant "full-loop" workers, including those dedicated to PR advancement, are counted. It also improves the filtering of supervisor processes to prevent their activity from skewing worker counts, and updates related documentation for consistency.

Highlights

  • Worker Counting Logic: The pulse wrapper's active-worker matcher was updated to include all ".opencode run" full-loop workers, specifically incorporating PR advancement workers.
  • Supervisor Exclusion: The logic now explicitly filters out "/pulse" and "Supervisor Pulse" command noise to maintain accurate supervisor exclusion.
  • Documentation Alignment: The pulse.md capacity snippet was aligned to reflect the updated all-full-loop worker matching logic.
Changelog
  • .agents/scripts/commands/pulse.md
    • Updated the WORKER_COUNT calculation to include all full-loop workers (issue and PR advancement) and explicitly exclude 'Supervisor Pulse' noise.
  • .agents/scripts/pulse-wrapper.sh
    • Modified the count_active_workers function to count all full-loop workers and filter out 'Supervisor Pulse' processes.
Activity
  • No human activity 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.

@sonarqubecloud
Copy link

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 updates the active worker counting logic to be more inclusive of all .opencode run full-loop workers, which is a good improvement for accuracy. The changes are consistent across both the shell script and the markdown documentation. My review focuses on improving the efficiency of the process counting commands by replacing the chain of grep processes with a single, more performant awk command. This is particularly relevant for pulse-wrapper.sh, which is likely executed frequently.

# command payload can contain '/full-loop' text from pre-fetched state)
WORKER_COUNT=$(ps axo command | grep '\.opencode run' | grep '/full-loop Implement issue #' | grep -v '/pulse' | grep -v grep | wc -l | tr -d ' ')
# Count all full-loop workers (issue + PR advancement), excluding supervisor /pulse noise
WORKER_COUNT=$(ps axo command | grep '\.opencode run' | grep '/full-loop' | grep -v '/pulse' | grep -v 'Supervisor Pulse' | grep -v grep | wc -l | tr -d ' ')

Choose a reason for hiding this comment

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

medium

This long chain of grep commands can be made more efficient and arguably more readable by using a single awk command. This avoids spawning multiple processes for filtering and counting.

Suggested change
WORKER_COUNT=$(ps axo command | grep '\.opencode run' | grep '/full-loop' | grep -v '/pulse' | grep -v 'Supervisor Pulse' | grep -v grep | wc -l | tr -d ' ')
WORKER_COUNT=$(ps axo command | awk '/\.opencode run/ && /\/full-loop/ && !/\/pulse/ && !/Supervisor Pulse/ {c++} END{print c+0}')
References
  1. Optimize shell script pipelines by consolidating multiple filtering commands (like grep chains) into a single, more efficient tool like awk to improve performance, similar to replacing grep | sed with a single sed command.

count_active_workers() {
local count
count=$(ps axo command | grep '\.opencode run' | grep '/full-loop Implement issue #' | grep -v '/pulse' | grep -c -v grep) || count=0
count=$(ps axo command | grep '\.opencode run' | grep '/full-loop' | grep -v '/pulse' | grep -v 'Supervisor Pulse' | grep -c -v grep) || count=0

Choose a reason for hiding this comment

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

medium

This chain of grep commands can be inefficient, especially in a script that might be called frequently as part of the pulse mechanism. Using a single awk command to perform the filtering and counting would be more performant as it avoids creating multiple processes.

Suggested change
count=$(ps axo command | grep '\.opencode run' | grep '/full-loop' | grep -v '/pulse' | grep -v 'Supervisor Pulse' | grep -c -v grep) || count=0
count=$(ps axo command | awk '/\.opencode run/ && /\/full-loop/ && !/\/pulse/ && !/Supervisor Pulse/ {c++} END{print c+0}') || count=0
References
  1. Optimize shell script pipelines by consolidating multiple filtering commands (like grep chains) into a single, more efficient tool like awk to improve performance, similar to replacing grep | sed with a single sed command.

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: 1

🧹 Nitpick comments (1)
.agents/scripts/commands/pulse.md (1)

43-44: Prefer the shared helper over duplicating the matcher.

This snippet now hardcodes the same ps | grep chain that count_active_workers() owns in pulse-wrapper.sh. Calling the helper here would keep Step 1 aligned automatically and avoid the next worker-matching fix needing two manual edits.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.agents/scripts/commands/pulse.md around lines 43 - 44, Replace the
duplicated ps|grep chain with the shared helper by invoking
count_active_workers() from pulse-wrapper.sh rather than hardcoding
WORKER_COUNT; remove the long grep pipeline that sets WORKER_COUNT and either
source or use the existing pulse-wrapper.sh helper so the script calls
count_active_workers() to obtain the worker count (reference symbol:
count_active_workers() and variable WORKER_COUNT).
🤖 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/commands/pulse.md:
- Around line 43-44: Replace the duplicated ps|grep chain with the shared helper
by invoking count_active_workers() from pulse-wrapper.sh rather than hardcoding
WORKER_COUNT; remove the long grep pipeline that sets WORKER_COUNT and either
source or use the existing pulse-wrapper.sh helper so the script calls
count_active_workers() to obtain the worker count (reference symbol:
count_active_workers() and variable WORKER_COUNT).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 78eb4ce4-62c7-45cf-8fdd-fc6af42cfb70

📥 Commits

Reviewing files that changed from the base of the PR and between cf44b1d and d84c362.

📒 Files selected for processing (2)
  • .agents/scripts/commands/pulse.md
  • .agents/scripts/pulse-wrapper.sh

count_active_workers() {
local count
count=$(ps axo command | grep '\.opencode run' | grep '/full-loop Implement issue #' | grep -v '/pulse' | grep -c -v grep) || count=0
count=$(ps axo command | grep '\.opencode run' | grep '/full-loop' | grep -v '/pulse' | grep -v 'Supervisor Pulse' | grep -c -v grep) || count=0
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Make the supervisor exclusion more specific.

Line 1685 filters out any argv containing /pulse or Supervisor Pulse, but worker commands include free-form issue/PR text in their title/prompt. That means a real /full-loop worker on a pulse-related task can still be excluded here, so utilization remains undercounted for those jobs. Match the supervisor on its dedicated prompt/title shape instead of broad substring drops across the whole command line. As per coding guidelines, automation scripts should focus on reliability and robustness.

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.

t1456: count all full-loop workers in pulse utilization accounting

1 participant