Repository navigation
refactor(logging): share memory pressure threshold selection - #157164
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 24, 2026, 11:59 AM ET / 15:59 UTC (Revision 2). ClawSweeper reviewWhat this changesThe PR consolidates Gateway memory-pressure threshold selection into one ordered comparison and adds event-level tests for priority and inclusive boundaries. Merge readiness✅ Ready for maintainer review Keep open: the cleanup remains absent from current main and the latest release. Source review found no blocking defect, and the prior completed review reported no findings. Priority: P3 Review scores
Verification
How this fits togetherThe Gateway samples process and worker memory during diagnostic heartbeats. Its memory sampler selects a pressure level, records a diagnostic event and log, and signals idle-worker retirement for critical pressure. flowchart LR
A[Gateway heartbeat] --> B[Memory sample]
B --> C[Threshold selection]
C --> D[Pressure event]
D --> E[Diagnostic log]
C -->|critical| F[Critical notification]
F --> G[Idle worker retirement]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -20, Tests +59. Total +39 across 2 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Land the focused simplification through normal exact-head gates while preserving critical-worker notifications and pressure-repeat suppression. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR addresses duplication rather than a reported failure; the old and proposed selection paths can be compared directly in source. Is this the best way to solve the issue? Yes: the existing diagnostic-memory owner is the narrowest place for the shared selection, and the tests observe its emitted events without exposing a new API. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against efca9bd05a13. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
* commit '9a1a6f7db9783d0b8abaf918bfe12978ea745b57': (26 commits) fix(maintainer): restore cold PR worktree provisioning (#157394) feat(ios): establish native Cloudflare Access sign-in sessions (#146996) fix: restore the Gateway after interrupted Doctor maintenance (#156854) refactor(line): retire the Express webhook adapter (#157369) refactor(cron): consolidate unavailable delivery targets (#157393) ci: apply Go memory defaults to architecture checks fix(cli): preserve the first PowerShell completion test failure (#157267) refactor(agents): consolidate transcript-tail model selection (#157382) fix(release): honor frozen validation contracts (#157034) fix(perf): use settled Kova terminal CPU accounting (#157029) chore(windows): verify packaged repair worker lifecycle (#157047) refactor(logging): share memory pressure threshold selection (#157164) fix(release): verify bundled fs-safe native bindings (#157027) perf(skills): skip warm prompt search when minimum cannot fit (#157343) fix(ui): avoid retaining detached tooltip anchors (#157226) perf(ci): reuse compiler state and shorten guard and UI tests (#157265) perf(ui): preserve model caches on unrelated metadata updates (#157254) chore: remove the tracked PR-body artifact and ignore .artifacts (#157296) refactor: consolidate duplicate MCP lifecycle tests (#157360) test(qa): consolidate CLI runtime fixtures (#118496) ...
…w#157164) * refactor(logging): share memory pressure threshold selection * chore(ci): refresh diagnostic memory validation base Co-authored-by: Vincent Koc <[email protected]>
What Problem This Solves
Memory-pressure selection repeated the same threshold comparison and result construction in four branches. This cleanup puts that shared decision in one private selector while keeping the priority explicit.
Maintainer-sponsored refactor: @vincentkoc requested this duplication cleanup and authorized landing.
User Impact
No user-visible change. Threshold defaults, inclusive boundaries, event contents, critical notifications and repeat suppression stay the same. No configuration, schema, migration or operator action is introduced.
Why This Change Was Made
Four ordered readonly tuples now feed one comparison loop: RSS critical, heap critical, RSS warning, then heap warning. The first match returns the original memory snapshot; no match still returns null. Growth-pressure selection and notification ordering are unchanged.
Production changes by −20 lines (+11/−31); tests add 59 lines. The five public-entry cases cover all four priority/equality outcomes and no match without testing the private tuple representation.
Evidence
f999bd18a2d5f18db1bf84b341224c01c76aa744preserves the tested owner and test bytes.pnpm test src/logging/diagnostic-memory.test.ts --maxWorkers=1. Baseline-owner command wall was 18.70 s (Vitest 16.72 s); candidate wall was 17.89 s (Vitest 15.87 s). These are single-sample verification costs, not evidence of a runtime speedup.An initial proof guard failed before installation or tests because it did not decode its JSON input. Correcting that harness left the product bytes unchanged; the completed proof above is the corrected run. A nonfatal portal-sync timeout followed the confirmed Testbox stop. Hosted exact-head CI is pending.