Skip to content

t1409: Refactor memory-pressure-monitor — classify processes as app vs tool#2998

Merged
marcusquinn merged 1 commit intomainfrom
refactor/memory-pressure-monitor-app-classification
Mar 6, 2026
Merged

t1409: Refactor memory-pressure-monitor — classify processes as app vs tool#2998
marcusquinn merged 1 commit intomainfrom
refactor/memory-pressure-monitor-app-classification

Conversation

@marcusquinn
Copy link
Owner

Summary

  • Classifies monitored processes as app (claude, electron, shipit, opencode) or tool (shellcheck, language servers) — app processes skip runtime alerts entirely, eliminating ~5,400 false-positive warnings per day
  • Raises SESSION_COUNT_WARN default from 5 to 8 to match normal headless dispatch operation
  • Adds _is_app_process() helper with case-insensitive matching and dot-prefix stripping (.opencodeopencode)

Changes

File Change
.agents/scripts/memory-pressure-monitor.sh Add APP_PROCESS_NAMES array, _is_app_process() helper; skip runtime checks for app processes in do_check() and cmd_status(); add Type column to status output; raise session threshold; bump to v2.0.0
tests/test-memory-pressure-monitor.sh Add 9 new tests for process classification (app/tool/case-insensitive/dot-prefix/threshold) — 37 total, all passing

Verification

  • ShellCheck: zero violations on both files
  • Tests: 37/37 passing (9 new)
  • Bash 3.2 compatible (no ${var,,} syntax — uses tr for case conversion)
  • Functional: --status correctly shows app/tool type column; app processes show no runtime warnings

Closes #2992

…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
@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 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

  • Process Classification: Implemented a system to classify monitored processes as either "app" (long-running, e.g., Claude, Electron) or "tool" (short-lived, e.g., shellcheck, language servers).
  • Reduced False Positives: Configured "app" processes to skip runtime alerts entirely, addressing approximately 5,400 false-positive warnings per day.
  • Session Count Threshold Adjustment: Increased the default SESSION_COUNT_WARN threshold from 5 to 8 to better reflect normal headless dispatch operations.
  • Helper Function: Introduced _is_app_process() for case-insensitive matching and handling of dot-prefixed process names.
Changelog
  • .agents/scripts/memory-pressure-monitor.sh
    • Added APP_PROCESS_NAMES array to define known application processes.
    • Implemented _is_app_process() helper function for process type identification.
    • Modified do_check() to conditionally skip runtime checks for app processes.
    • Updated cmd_status() to include a 'Type' column (app/tool) in the output.
    • Increased the default SESSION_COUNT_WARN value from 5 to 8.
    • Updated the script version from 1.1.0 to 2.0.0.
  • tests/test-memory-pressure-monitor.sh
    • Added 9 new test cases to validate the _is_app_process() function, covering app/tool classification, case-insensitivity, and dot-prefix handling.
    • Included a test to verify the updated default SESSION_COUNT_WARN threshold.
Activity
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 Mar 6, 2026

🔍 Code Quality Report

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

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

�[0;34m[INFO]�[0m Recent monitoring activity:
Fri Mar 6 15:52:08 UTC 2026: Code review monitoring started
Fri Mar 6 15:52:09 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 108

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 108
  • VULNERABILITIES: 0

Generated on: Fri Mar 6 15:52:11 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 6, 2026

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 6, 2026

Warning

Rate limit exceeded

@marcusquinn has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 21 minutes and 11 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 48b5a040-e213-4aa3-b0fd-e948734b6e5d

📥 Commits

Reviewing files that changed from the base of the PR and between 4a4b6c1 and f7f5d09.

📒 Files selected for processing (2)
  • .agents/scripts/memory-pressure-monitor.sh
  • tests/test-memory-pressure-monitor.sh
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/memory-pressure-monitor-app-classification

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.

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 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.

Comment on lines +330 to +346
_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
}

Choose a reason for hiding this comment

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

medium

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.

Suggested change
_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"
}

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

Labels

refactor Auto-created from TODO.md tag

Projects

None yet

Development

Successfully merging this pull request may close these issues.

t1409: refactor: memory-pressure-monitor

1 participant