t1456: count all full-loop workers in pulse utilization#4234
t1456: count all full-loop workers in pulse utilization#4234marcusquinn merged 1 commit intomainfrom
Conversation
WalkthroughThis 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 Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
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: Thu Mar 12 19:25:57 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
Summary of ChangesHello, 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
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
|
|
There was a problem hiding this comment.
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 ' ') |
There was a problem hiding this comment.
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.
| 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
- Optimize shell script pipelines by consolidating multiple filtering commands (like
grepchains) into a single, more efficient tool likeawkto improve performance, similar to replacinggrep | sedwith a singlesedcommand.
| 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 |
There was a problem hiding this comment.
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.
| 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
- Optimize shell script pipelines by consolidating multiple filtering commands (like
grepchains) into a single, more efficient tool likeawkto improve performance, similar to replacinggrep | sedwith a singlesedcommand.
There was a problem hiding this comment.
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 | grepchain thatcount_active_workers()owns inpulse-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
📒 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 |
There was a problem hiding this comment.
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.



Summary
.opencode runfull-loop workers, including PR advancement workers/pulseandSupervisor Pulsecommand noiseVerification
shellcheck .agents/scripts/pulse-wrapper.shmarkdown-formatter check .agents/scripts/commands/pulse.mdCloses #4233
Summary by CodeRabbit