Repository navigation
test(gateway): add sustained heap retention diagnostics - #163764
Conversation
Add a synthetic dist Gateway workload with signed webchat clients, mock inference, Code Mode, verified subagent completion, minute memory samples, and paired native heap snapshots. Extend the streaming snapshot comparator with named strong paths and separate dominator chains. Keep retryable project-access refusals visible and revalidate turn admission after asynchronous preparation. The new admission regression fails against the exact prior helper and passes after the repair. Remote checks and independent review passed. Measurements do not establish a production leak fix.
|
🦞👀 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: blocked before merge. Reviewed October 2, 2026, 4:47 PM ET / 20:47 UTC (Revision 2). ClawSweeper reviewWhat this changesAdds an isolated sustained Gateway workload and extends heap-snapshot analysis with named retaining paths, dominator chains, and object selection. Merge readiness⛔ Blocked before merge - 1 item remains The diagnostic capability remains useful and absent from current main. No actionable patch defect was found, and the previous migration-proof blocker does not apply to newly created synthetic fixture state and diagnostic artifacts. Priority: P3 Review scores
Verification
How this fits togetherGateway diagnostics help operators investigate memory retained by OpenClaw's running server. The new workload drives public Gateway requests and captures snapshots that the offline comparator turns into retention reports. flowchart LR
A[Diagnostic settings] --> B[Isolated workload rig]
B --> C[Local mock models]
B --> D[Gateway public requests]
C --> D
D --> E[Memory samples and snapshots]
E --> F[Offline graph analysis]
F --> G[Named retention report]
Before merge
Agent review detailsSecurityNone. PR surfaceTests +79, Docs +27, Other +1073. Total +1179 across 9 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Keep sustained heap investigations isolated and reproducible, with explicit graph-analysis limits and reusable Gateway lifecycle owners. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR adds diagnostic capabilities and explicitly does not claim to fix a production memory leak. Is this the best way to solve the issue? Yes: it extends the existing snapshot comparator and reuses Gateway benchmark owners; existing allocation-sampling benchmarks do not provide this paired-snapshot retention workflow. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against aac001b30ba8. LabelsLabel 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)
|
* commit '79be075e5aa46be9e42dbd53ed6e30e81469210a': (33 commits) fix(ui): keep selected-text comment input readable while scrolling (#163772) test(memory): open corpus database explicitly fix: bound Doctor migration capture to plugin data (#163780) fix(ui): gate system information at the shared reader (#160982) chore(db): reclassify worker inventory sites with caller evidence (#163754) refactor(channels): deslop Slack and Matrix (#163740) fix(agents): reject empty sessions_search queries in the tool schema (#129120) perf(nodes): load only what a worker turn needs (#160442) test(cli): assert concise Gateway failure copy in CLI process tests (#163649) refactor(discord): deslop discord (#163728) fix(workboard): make Sessions boards work on multi-agent Gateways (#163761) test(gateway): add sustained heap retention diagnostics (#163764) test(ui): disambiguate session filter controls refactor(plugins): deslop imessage, mattermost, and voice-call (#163767) fix(qa): run Telegram plugin source in --source-gateway userbot runs (#163718) feat(macos): add a --no-activate launch flag for background automation (#163758) fix(agents): preserve host authority across module reloads (#163725) perf(gateway): serve the listener before multi-gigabyte store validation and honor clean-close receipts at startup (#163690) fix: keep video widgets scrollable and preload initial frames (#163762) feat(memory): add a provider-neutral memory provider runtime (#162175) ...
) * test(gateway): add sustained heap retention diagnostics Add a synthetic dist Gateway workload with signed webchat clients, mock inference, Code Mode, verified subagent completion, minute memory samples, and paired native heap snapshots. Extend the streaming snapshot comparator with named strong paths and separate dominator chains. Keep retryable project-access refusals visible and revalidate turn admission after asynchronous preparation. The new admission regression fails against the exact prior helper and passes after the repair. Remote checks and independent review passed. Measurements do not establish a production leak fix. * fix(tooling): register Gateway heap rig entry point
* commit '1fda703fb4d3630e4633461967b2a2186e8f15fd': (33 commits) fix(ui): keep selected-text comment input readable while scrolling (openclaw#163772) test(memory): open corpus database explicitly fix: bound Doctor migration capture to plugin data (openclaw#163780) fix(ui): gate system information at the shared reader (openclaw#160982) chore(db): reclassify worker inventory sites with caller evidence (openclaw#163754) refactor(channels): deslop Slack and Matrix (openclaw#163740) fix(agents): reject empty sessions_search queries in the tool schema (openclaw#129120) perf(nodes): load only what a worker turn needs (openclaw#160442) test(cli): assert concise Gateway failure copy in CLI process tests (openclaw#163649) refactor(discord): deslop discord (openclaw#163728) fix(workboard): make Sessions boards work on multi-agent Gateways (openclaw#163761) test(gateway): add sustained heap retention diagnostics (openclaw#163764) test(ui): disambiguate session filter controls refactor(plugins): deslop imessage, mattermost, and voice-call (openclaw#163767) fix(qa): run Telegram plugin source in --source-gateway userbot runs (openclaw#163718) feat(macos): add a --no-activate launch flag for background automation (openclaw#163758) fix(agents): preserve host authority across module reloads (openclaw#163725) perf(gateway): serve the listener before multi-gigabyte store validation and honor clean-close receipts at startup (openclaw#163690) fix: keep video widgets scrollable and preload initial frames (openclaw#163762) feat(memory): add a provider-neutral memory provider runtime (openclaw#162175) ...
What Problem This Solves
Gateway retention investigations need a repeatable long-running workload and named retaining paths to distinguish allocation churn, cache filling, and persistent growth.
User Impact
Adds source-checkout diagnostics tooling; Gateway behavior is unchanged. Operators can collect main-isolate snapshots with reconnecting Control UI clients and inspect named strong paths and dominator chains without a browser.
Why This Change Was Made
The rig starts an isolated dist Gateway, creates 2,000 sessions through public RPCs, and drives ten signed Control UI clients in webchat mode. It exercises session/catalog/history/model/project reads and subscriptions, plus about twenty mock-provider turns per hour, including Code Mode and verified subagent completions. Utility summaries use a separate mock server so they cannot consume scripted agent responses. The rig records the projects-list owner's explicit access-revision refusal and retries that read once.
The existing streaming snapshot comparator now reports named strong root paths and separate dominator chains, including specific-object selection. Weak/shortcut edges remain excluded, overlapping constructor totals and V8 ephemeron limitations are stated, and same-process/isolate identity remains required.
The documented rig command is registered as an executable root in Knip, so its imported helpers remain covered by the repository's dependency and unused-file scans.
Evidence
On a dedicated Linux rig, both source revisions
bfeca6756c2eand0fc181d08277were built with frozen dependencies. Official Node 26.10.0 and 24.19.0 binaries were checksum-verified. Each runtime has isolated state and loopback ports; real model services are not called.The Node 24 controls completed 30 minutes and both Node 26 runs completed 90 minutes. Post-GC comparison from minute 10:
0fc181d082770fc181d08277bfeca6756c2ebfeca6756c2eThe shorter control includes more warm-up; this is not a general runtime ranking. Node 26 growth slowed to 4.4–5.5 MiB/hour in the final half-hour. The largest changes were code/feedback structures. The catalog page backing array stayed at 974,840 bytes from minute 60 to 90 on both sources; the diagnostic ring remains capped at 1,000 records. This PR does not claim a production leak fix.
Each long run verified 30 parent turns and six child completions. One reference-source endpoint also accepted a late extra turn, canceled during shutdown. The delivered driver now rechecks admission immediately before sending
agentand joins admitted turns before capture; a deterministic regression fails on the exact prior helper and passes after the correction. The stable live-client 10→60 comparison is unaffected.Validation:
tbx_01m3ytp8rgqn02s2m1fj5gsjxj: snapshot comparator regression passed; earlier driver revision passed changed-file checks. A later queued lease was retired under the authorized AWS fallback.cbx_ea3b10b3f7e3: final driver/source hashes and pinned base verified; focused comparator test passed (99 ms test time, 3.58 s wall time with--maxWorkers=1). Final script lint andnode scripts/check-changed.mjs --base bfeca6756c2ed014bded0e4c85efe207b427f894passed in 4m33s, excluding sync.cbx_25076cec8cdd: the exact pre-fix helper failed the admission regression for the intended reason; the final admission test passed in 2 ms and the comparator in 96 ms. Both focused tests passed in 2.69 s wall time. Final changed-file checks passed; the command including install/red-control/tests/checks took 5m11s, excluding sync. A short real-Gateway boundary run accepted and verified exactly one turn and shut down cleanly.tbx_01m3z537yzpkrbr5mr29z2w9g0passedpnpm deadcode:dependencies,pnpm deadcode:unused-files, andpnpm deadcode:exportsin 4m51s, including dependency installation. Source/head assertions passed; all unused-file/export scans reported zero entries. Fresh independent review of the correction was scoped-clean through P1. The lease was released.Limits: compact synthetic transcripts, local mock inference/catalogs, fixed configuration, and privileged loopback clients do not reproduce native-provider backlogs, real channel adapters, slow clients, or a multi-hour production workload. End-of-run captures occur as workload clients retire; the minute-60 captures retain live clients. The reference runs use pinned runtime source revisions, not an assertion about an arbitrary later main revision.