fix(pilot): debounce process resource alarms#176
Conversation
Split CPU and memory process alarms so they no longer collide in aggregation. Debounce normalized CPU and soft memory thresholds, add hard and critical memory tiers, and cool down repeated process resource alerts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ralf0131
left a comment
There was a problem hiding this comment.
Summary
Splits the generic PROCESS_RESOURCE_ALARM into dedicated PROCESS_CPU_ALARM and PROCESS_MEMORY_ALARM types, with CPU normalization by core count (os.cpus()), tiered memory thresholds (soft 512MB / hard 1024MB / critical 2048MB), consecutive-sample requirements (3 samples) to suppress transient spikes, and a 1-hour cooldown to prevent alarm flapping. Comprehensive test coverage for all threshold tiers, normalization, suppression, and cooldown behavior. All CI green (Node 18/20/22). Clean, well-structured change.
Findings
No issues found — the implementation is correct, properly typed, and thoroughly tested.
*Automated review by *
ralf0131
left a comment
There was a problem hiding this comment.
Summary
Re-review after commit 011f1785. The new commit correctly addresses @Snssn's feedback — CPU alarms now compare raw process CPU percent (from calcCpuPercent()) against the 80% threshold, without normalizing by host core count. The 3-consecutive-sample debounce and tiered memory thresholds (soft/hard/critical) with independent per-type cooldowns are well-implemented and comprehensively tested.
Findings
- [Info]
src/metrics/metrics-writer.ts— The PR body still states "Normalize CPU usage by CPU count", but the implementation (after the fix) uses raw process CPU percent. Consider updating the body to match the actual behavior.
Verdict
LGTM. The fix is correct, code is clean, and test coverage (6 cases) is thorough. CLA is signed.
Automated review by github-manager-bot
Background
Process resource alarms currently fire on single CPU or memory threshold samples, which creates noisy alerts from transient CPU spikes and repeated memory readings near 512MB. CPU and memory also shared the same process alarm type, allowing aggregation windows to overwrite one resource signal with the other.
Core Changes
Modified Files
src/metrics/alarm-manager.tssrc/metrics/metrics-writer.tstests/unit/metrics/metrics-writer.test.tsVerification
npx vitest run tests/unit/metrics/metrics-writer.test.ts— 21/21 PASSnpx vitest run tests/unit/metrics/— 62/62 PASSnpm run typecheck— PASS0 ERROR/opt/homebrew/bin/codex,codex-cli 0.142.5Summary: 1 traces, 13 spans,Pass: 33 Warn: 138 Error: 0 Skipped: 02981a5fc3b47cbe517ba4f9039ee90d6