t1409: Refactor memory-pressure-monitor — classify processes as app vs tool#2998
Conversation
…monitor
Eliminates ~5,400 false-positive runtime warnings per day by classifying
monitored processes into two categories:
- App processes (claude, electron, shipit, opencode): long-running by
design. Runtime alerts are skipped entirely — only RSS is monitored.
Handles dot-prefixed binaries (.opencode) via prefix stripping.
- Tool processes (shellcheck, language servers): short-lived. Both RSS
and runtime alerts remain active. ShellCheck auto-kill unchanged.
Also raises SESSION_COUNT_WARN default from 5 to 8 — with headless
dispatch running multiple workers, 5 concurrent sessions is normal
operation.
Adds 9 new tests for process classification (37 total, all passing).
ShellCheck clean. Bash 3.2 compatible (no ${var,,} syntax).
Closes #2992
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 refactors the memory-pressure-monitor.sh script to intelligently differentiate between long-running "app" processes and short-lived "tool" processes. By classifying processes, the monitoring system now skips runtime alerts for applications designed for continuous operation, significantly reducing noise from false-positive warnings. Additionally, the default warning threshold for concurrent interactive sessions has been adjusted to align with typical system behavior. 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
|
🔍 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: Fri Mar 6 15:52:11 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
|
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Code Review
This pull request introduces a valuable distinction between 'app' and 'tool' processes to reduce false-positive memory alerts, a change that is well-implemented and thoroughly tested. The logic is sound, documentation is updated accordingly, and the increase in the session warning threshold is a sensible adjustment. I have one suggestion to refactor the new _is_app_process function for improved conciseness and performance. Overall, this is a solid improvement that effectively addresses alert noise.
| _is_app_process() { | ||
| local cmd_name="$1" | ||
| # Strip leading dot (e.g., ".opencode" → "opencode") — some binaries | ||
| # are installed with a dot-prefixed wrapper name | ||
| cmd_name="${cmd_name#.}" | ||
| # Case-insensitive: convert to lowercase via tr (bash 3.2 compatible) | ||
| local cmd_lower | ||
| cmd_lower=$(printf '%s' "$cmd_name" | tr '[:upper:]' '[:lower:]') | ||
| local app_name app_lower | ||
| for app_name in "${APP_PROCESS_NAMES[@]}"; do | ||
| app_lower=$(printf '%s' "$app_name" | tr '[:upper:]' '[:lower:]') | ||
| if [[ "$cmd_lower" == "$app_lower" ]]; then | ||
| return 0 | ||
| fi | ||
| done | ||
| return 1 | ||
| } |
There was a problem hiding this comment.
The _is_app_process function can be simplified and made more efficient. The current implementation uses a shell for loop and invokes tr for each item on every call, which is not optimal for performance.
A more idiomatic approach for this kind of set membership test in shell scripting is to use grep. A single grep -qixF command can perform a case-insensitive, fixed-string, whole-line match against the list of app names. This is more concise, easier to maintain, and more performant as it avoids a shell loop and repeated sub-process calls.
| _is_app_process() { | |
| local cmd_name="$1" | |
| # Strip leading dot (e.g., ".opencode" → "opencode") — some binaries | |
| # are installed with a dot-prefixed wrapper name | |
| cmd_name="${cmd_name#.}" | |
| # Case-insensitive: convert to lowercase via tr (bash 3.2 compatible) | |
| local cmd_lower | |
| cmd_lower=$(printf '%s' "$cmd_name" | tr '[:upper:]' '[:lower:]') | |
| local app_name app_lower | |
| for app_name in "${APP_PROCESS_NAMES[@]}"; do | |
| app_lower=$(printf '%s' "$app_name" | tr '[:upper:]' '[:lower:]') | |
| if [[ "$cmd_lower" == "$app_lower" ]]; then | |
| return 0 | |
| fi | |
| done | |
| return 1 | |
| } | |
| _is_app_process() { | |
| local cmd_name="$1" | |
| # Strip leading dot (e.g., ".opencode" → "opencode") — some binaries | |
| # are installed with a dot-prefixed wrapper name | |
| cmd_name="${cmd_name#.}" | |
| # Case-insensitive, fixed-string, whole-line match against app names. | |
| # `grep` returns 0 on match, 1 on no-match, which is what we need. | |
| printf '%s\n' "${APP_PROCESS_NAMES[@]}" | grep -qixF -- "$cmd_name" | |
| } |



Summary
SESSION_COUNT_WARNdefault from 5 to 8 to match normal headless dispatch operation_is_app_process()helper with case-insensitive matching and dot-prefix stripping (.opencode→opencode)Changes
.agents/scripts/memory-pressure-monitor.shAPP_PROCESS_NAMESarray,_is_app_process()helper; skip runtime checks for app processes indo_check()andcmd_status(); add Type column to status output; raise session threshold; bump to v2.0.0tests/test-memory-pressure-monitor.shVerification
${var,,}syntax — usestrfor case conversion)--statuscorrectly showsapp/tooltype column; app processes show no runtime warningsCloses #2992