Skip to content

test(gateway): add sustained heap retention diagnostics - #163764

Merged
steipete merged 2 commits into
mainfrom
steipete/perf-micro-heap-growth-repro-node26-20260919
Oct 2, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/perf-micro-heap-growth-repro-node26-20260919

Conversation

@steipete

@steipete steipete commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

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 bfeca6756c2e and 0fc181d08277 were 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:

Runtime source Node Final minute Before → after MiB MiB/hour
0fc181d08277 26.10.0 90 300.098 → 318.388 +13.721
0fc181d08277 24.19.0 30 305.655 → 315.443 +29.382
bfeca6756c2e 26.10.0 90 300.809 → 317.682 +12.658
bfeca6756c2e 24.19.0 30 308.965 → 319.528 +31.713

The 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 agent and 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:

  • Blacksmith Testbox tbx_01m3ytp8rgqn02s2m1fj5gsjxj: snapshot comparator regression passed; earlier driver revision passed changed-file checks. A later queued lease was retired under the authorized AWS fallback.
  • AWS Crabbox 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 and node scripts/check-changed.mjs --base bfeca6756c2ed014bded0e4c85efe207b427f894 passed in 4m33s, excluding sync.
  • The final readiness-gate driver also passed a three-minute real-Gateway smoke with Code Mode, subagent completion, two heap snapshots, and clean shutdown.
  • AWS Crabbox 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.
  • Independent Codex review: scoped-clean through P1; no accepted/actionable findings.
  • CI initially found the missing Knip executable-root registration. After registering the documented command, Blacksmith Testbox tbx_01m3z537yzpkrbr5mr29z2w9g0 passed pnpm deadcode:dependencies, pnpm deadcode:unused-files, and pnpm deadcode:exports in 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.

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

clawsweeper Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts size: XL labels Oct 2, 2026
@steipete
steipete enabled auto-merge (squash) October 2, 2026 20:28
@clawsweeper

clawsweeper Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 2, 2026, 4:47 PM ET / 20:47 UTC (Revision 2).

ClawSweeper review

What this changes

Adds 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
Reviewed head: 7000abb9d31f87749cf5bb09ce253b9cebab51e4

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful diagnostic tooling with relevant real-Gateway evidence, focused regressions, and no identified blocking defect.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The captured Linux run evidence exercises the delivered rig through real dist Gateway RPCs, records paired post-GC measurements, and verifies Code Mode, child completion, final turn admission, and shutdown. Mock inference bounds the workload appropriately. Newly created fixture state and diagnostic artifacts do not change an existing stored-data contract, so migration proof is inapplicable.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured Linux run evidence exercises the delivered rig through real dist Gateway RPCs, records paired post-GC measurements, and verifies Code Mode, child completion, final turn admission, and shutdown. Mock inference bounds the workload appropriately. Newly created fixture state and diagnostic artifacts do not change an existing stored-data contract, so migration proof is inapplicable.
Evidence reviewed 8 items Reviewed introduction and follow-up correction: Reviewed the pinned merge-base-to-head changes. The only change since the previous reviewed head registers the documented rig as a Knip executable root; unrelated base-only changes were excluded.
Current-main necessity: Current main retains the existing constructor and dominator-size comparator without the introduced named paths or object-selection options. Tree inspection also found no sustained heap rig. The supplied latest release is v2026.9.7; its rig-path lookup returned 404.
Existing-state compatibility assessment: The rig refuses an existing root, creates its own configuration and workspaces, and uses the existing benchmark environment owner to isolate HOME, configuration, and state. JSON/JSONL outputs are named diagnostic artifacts and mock-server fixtures; no installed user schema or serialized-state contract changes. This resolves the prior migration-proof concern.
Findings None None.
Security None None.

How this fits together

Gateway 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]
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Tests +79, Docs +27, Other +1073. Total +1179 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 2 90 11 +79
Docs 1 27 0 +27
Config 0 0 0 0
Generated 0 0 0 0
Other 6 1089 16 +1073
Total 9 1206 27 +1179

Review metrics

Metric Value Why it matters
Diagnostic CLI surface 8 rig options and 3 comparator options added These settings belong to explicitly invoked source-checkout tools and do not change Gateway defaults.
Tooling versus test growth production/tooling net +1,073 lines; tests net +79 lines The stated growth supports sustained workload orchestration, synthetic fixtures, and named graph analysis.

Stored data model

Persistent data-model change detected: serialized state: scripts/gateway-heap-rig.mjs, serialized state: scripts/lib/gateway-heap-rig-catalog.mjs, serialized state: scripts/lib/gateway-heap-rig-turns.mjs, unknown-data-model-change: scripts/gateway-heap-rig.mjs, unknown-data-model-change: scripts/lib/gateway-heap-rig-catalog.mjs, unknown-data-model-change: scripts/lib/gateway-heap-rig-turns.mjs. Confirm migration or upgrade compatibility proof before merge.

Technical review

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

Labels

Label changes:

  • add P3: This improves operator diagnostics without claiming a production leak fix or changing normal Gateway behavior.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The captured Linux run evidence exercises the delivered rig through real dist Gateway RPCs, records paired post-GC measurements, and verifies Code Mode, child completion, final turn admission, and shutdown. Mock inference bounds the workload appropriately. Newly created fixture state and diagnostic artifacts do not change an existing stored-data contract, so migration proof is inapplicable.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The captured Linux run evidence exercises the delivered rig through real dist Gateway RPCs, records paired post-GC measurements, and verifies Code Mode, child completion, final turn admission, and shutdown. Mock inference bounds the workload appropriately. Newly created fixture state and diagnostic artifacts do not change an existing stored-data contract, so migration proof is inapplicable.

Label justifications:

  • P3: This improves operator diagnostics without claiming a production leak fix or changing normal Gateway behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The captured Linux run evidence exercises the delivered rig through real dist Gateway RPCs, records paired post-GC measurements, and verifies Code Mode, child completion, final turn admission, and shutdown. Mock inference bounds the workload appropriately. Newly created fixture state and diagnostic artifacts do not change an existing stored-data contract, so migration proof is inapplicable.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured Linux run evidence exercises the delivered rig through real dist Gateway RPCs, records paired post-GC measurements, and verifies Code Mode, child completion, final turn admission, and shutdown. Mock inference bounds the workload appropriately. Newly created fixture state and diagnostic artifacts do not change an existing stored-data contract, so migration proof is inapplicable.

Evidence

What I checked:

  • Reviewed introduction and follow-up correction: Reviewed the pinned merge-base-to-head changes. The only change since the previous reviewed head registers the documented rig as a Knip executable root; unrelated base-only changes were excluded. (config/knip.config.ts:180, 7000abb9d31f)
  • Current-main necessity: Current main retains the existing constructor and dominator-size comparator without the introduced named paths or object-selection options. Tree inspection also found no sustained heap rig. The supplied latest release is v2026.9.7; its rig-path lookup returned 404. (scripts/heap-snapshot-diff.mjs:383, aac001b30ba8)
  • Existing-state compatibility assessment: The rig refuses an existing root, creates its own configuration and workspaces, and uses the existing benchmark environment owner to isolate HOME, configuration, and state. JSON/JSONL outputs are named diagnostic artifacts and mock-server fixtures; no installed user schema or serialized-state contract changes. This resolves the prior migration-proof concern. (scripts/gateway-heap-rig.mjs:73, 7000abb9d31f)
  • Captured real-Gateway evidence: The complete supplied PR body reports four dedicated Linux runs using checksum-verified Node binaries and isolated dist Gateways, including two 90-minute runs. Each long run verified 30 parent turns and six child completions. It also records a final-driver three-minute run with Code Mode, child completion, two snapshots, and clean shutdown, plus a boundary run verifying exactly one admitted turn. Copied post-GC measurements demonstrate collection and comparison; the stated synthetic limitations appropriately avoid claiming a production leak fix.
  • Meaningful regression coverage: The admission regression closes admission while asynchronous preparation is pending and asserts that no Gateway request launches. The comparator test exercises the executable CLI and independently checks named edges, shared-object dominators, truncation, and weak-only object selection. The captured body reports the exact earlier admission helper failing for the intended reason and the corrected helper passing. (test/scripts/gateway-heap-rig-turns.test.ts:7, 7000abb9d31f)
  • Implementation and dependency boundary: The mock-model configuration explicitly selects the OpenClaw agent runtime. Code Mode documentation identifies OpenClaw Code Mode as separate from Codex Code Mode; this patch supplies no affirmative dependency on the Codex harness or protocol. (scripts/e2e/lib/fixtures/mock-openai-config.mjs:36, 7000abb9d31f)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-02T20:30:08.195Z sha eb18d48 :: blocked before merge. :: none

@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 2, 2026
@steipete
steipete merged commit 05ce3c3 into main Oct 2, 2026
121 of 122 checks passed
@steipete
steipete deleted the steipete/perf-micro-heap-growth-repro-node26-20260919 branch October 2, 2026 20:50
vincentkoc added a commit that referenced this pull request Oct 2, 2026
* 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)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 3, 2026
)

* 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
wheakerd pushed a commit to wheakerd/clawdbot that referenced this pull request Oct 3, 2026
* 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)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant