Skip to content

improve(status): report external and ArrayBuffer memory - #141902

Merged
vincentkoc merged 4 commits into
mainfrom
fix/status-external-memory-tranche1
Sep 13, 2026
Merged

vincentkoc merged 4 commits into
mainfrom
fix/status-external-memory-tranche1

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 8, 2026 •

Copy link
Copy Markdown
Member
Additional instructions

MUST: Keep Allow edits from maintainers enabled for this PR so maintainers
can help update the branch when needed.

What Problem This Solves

Resolves a problem where operators inspecting Gateway status or concurrency
benchmark results could see RSS and V8 heap usage but lacked the corresponding
external and ArrayBuffer memory counters.

Why This Change Was Made

Add optional externalBytes and arrayBuffersBytes to the existing
processMemory response using the same process.memoryUsage() snapshot already
used for RSS and heap. Carry those counters through the existing benchmark
observations and summaries without new polling, forced garbage collection,
runtime configuration, or a protocol version change.

User Impact

  • Gateway status reports the counters in bytes; benchmark samples retain the
    existing Mb naming convention with values converted to MiB.
  • Responses from older Gateways remain readable. Missing optional counters stay
    unknown rather than becoming zero, while actual zero values are preserved.
  • Summaries include only observed values. Growth summaries require both
    before/after observations for that counter and preserve zero or negative
    changes.
  • RSS is process-wide; heap, external, and ArrayBuffer counters describe the
    responding Node thread/isolate, not an aggregate across worker threads.
  • ArrayBuffer memory is included in external memory, not an additional category
    to sum with it. These observations do not identify individual allocators,
    establish memory peaks, or measure a process tree.

This is an additive diagnostics change, not a claim of lower memory use or
faster runtime performance.

Evidence

Reconciled Remote Wire Proof

September 13, 2026: configured Blacksmith Testbox/Linux, Node 24.19.0,
pnpm 12.3.4, Vitest 5.0.0, with source, package, lockfile, and candidate file
hashes bound to the native capsule/receiver. The tested source was
c6923b4c99a971ef73a943fdc973a2c42a5deb9f; all seven P00 files, package.json,
and pnpm-lock.yaml remain byte-identical in the main-reconciled head
55079d16e561f991f129c74340548d9b8d1e9352.

  • 52 tests passed: 9 in src/gateway/server.health.test.ts, 4 in
    src/gateway/server-methods/health.owner-routing.test.ts, and 39 in
    test/scripts/bench-gateway-concurrency.test.ts.
  • The existing connect/health/presence/status test now feeds its actual status
    WebSocket response through readGatewayMemory. All five byte counters must
    be finite and nonnegative; each sample field must equal the same response's
    counter divided by 1048576. There is no second memory sample.
  • In the earlier 43-test run, removing the added producer fields made that wire test fail for
    Expected numeric process memory field: externalBytes. The producer was
    restored byte-for-byte before all three green suites ran. That intended-red
    proof is retained; it was not repeated for the byte-identical reconciliation.
  • The fixture mocks summary/collector collaborators; the memory producer,
    status handler, WebSocket transport, and production benchmark reader are
    real. This is not an operator Gateway workload.
  • Remote targeted and changed-file formatting, initial changed guards, script
    erasability, and production core types passed. The remaining changed checks
    were interrupted during core-test types by the local controller's disk
    safety guard. No final aggregate success record was emitted.
  • Fresh independent P2 review found no actionable findings; the reviewed
    reconciliation did not alter the seven-file patch. Complete client-side
    logs were retained, and exact lease cleanup was confirmed.

The Actions run
records the Testbox lifecycle; application results were captured by the client.
Complete captured stdout SHA256:
b3413319aa17949f34ce34126d9edbad7ad62bd67fefd25031a93e7618021aff;
stderr SHA256:
3613de49b1c91e6f23797759c2a344bf8563439c8ec8933e0c0b0e10e0c67b51.

Historical Proof and Remaining Gates

The unchanged original six-file candidate previously passed 35 focused tests,
all four tsgo lanes (including all 17 core-test shards), and 13 additional
selected guards with the frozen pnpm 12.3.4 installation. Earlier 16 guard
passes and three targeted type-aware lint passes used a different installation
and are retained only as historical evidence.

The initial changed-check run passed its first 10 steps, then stopped on the
untouched sdk-untrusted-context-identifier-aliases compatibility deadline in
the old base. The reconciled run passed main's separate removal-pending
disposition before the disk-guard interruption described above. This PR changes
no aliases, deadlines, or exceptions.

The prior exact-head CI failure was in an unrelated SQLite reclamation-memory
test. Its owner fix landed in
PR147028, and the native
main reconciliation includes that fix without adding it to this PR's seven-file
delta.

Landed: squash-merged on September 13, 2026 as
c8d4673c294c6b543533c5f03eb09115a4eb60b0 after native review, hosted-evidence
prepare, and merge completed. Required
CI passed for
exact head 55079d16e561f991f129c74340548d9b8d1e9352. The interrupted
changed-check invocation above remains incomplete; it is not relabeled as a
pass. No application tests, checks, builds, or benchmarks ran locally.

@clawsweeper

clawsweeper Bot commented Sep 8, 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.

@vincentkoc vincentkoc self-assigned this Sep 8, 2026
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime scripts Repository scripts size: M maintainer Maintainer-authored PR labels Sep 8, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 Sep 8, 2026
@clawsweeper

clawsweeper Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 13, 2026, 9:26 AM ET / 13:26 UTC (Revision 4).

ClawSweeper review

What this changes

Adds external and ArrayBuffer memory counters to Gateway status and includes their values and growth in concurrency benchmark reports.

Merge readiness

✅ Ready for maintainer review

The PR remains useful: current main and v2026.9.4 lack these status counters. No actionable correctness or security defect was found, and the prior review recorded no findings. Member authorship and the protected maintainer label also preclude automated closure.

Priority: P2
Reviewed head: 55079d16e561f991f129c74340548d9b8d1e9352

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused additive patch with meaningful compatibility and wire-boundary coverage and no actionable findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The MEMBER-authored PR is exempt from the external-contributor proof gate and changes no authority boundary. Reported Linux validation exercises the real status memory producer over WebSocket through the benchmark reader, with surrounding collectors mocked; it does not demonstrate an operator workload.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The MEMBER-authored PR is exempt from the external-contributor proof gate and changes no authority boundary. Reported Linux validation exercises the real status memory producer over WebSocket through the benchmark reader, with surrounding collectors mocked; it does not demonstrate an operator workload.
Evidence reviewed 10 items Current main still lacks the requested counters: The status handler on fetched main reports rssBytes, heapUsedBytes, and heapTotalBytes only.
Latest supplied release has the same diagnostic gap: Inspection of v2026.9.4 also shows only RSS and heap counters in the status response; the requested addition is not present in that release.
Existing producer and compatible reader: The handler adds both counters from its existing memoryUsage snapshot. The extracted benchmark reader retains required RSS/heap validation, preserves actual zero values, and omits absent or nonfinite optional counters.
Findings None None.
Security None None.

How this fits together

The Gateway answers status requests with a snapshot of its Node.js memory usage. The concurrency benchmark reads that response before and after a workload, converts bytes to MiB, and summarizes the observations.

flowchart LR
  A[Status request] --> B[Gateway status handler]
  C[Node memory snapshot] --> B
  B --> D[Status response in bytes]
  D --> E[Benchmark memory reader]
  E --> F[Optional counters in MiB]
  F --> G[Observed values and growth summaries]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +5, Tests +128, Other +45. Total +178 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 2 5 0 +5
Tests 3 136 8 +128
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 78 33 +45
Total 7 219 41 +178

Review metrics

Metric Value Why it matters
Diagnostic contract 2 optional response fields and 4 benchmark aggregates; 0 new configuration options The addition extends existing observations without requiring configuration migration or another sampling loop.

Technical review

Best possible solution:

Keep one status memory snapshot and one benchmark reader, preserving unknown optional counters and documenting that ArrayBuffer memory overlaps external memory.

Do we have a high-confidence way to reproduce the issue?

Not applicable as a defect reproduction: this adds diagnostics. Source inspection confirms that current main omits the requested counters from Gateway status.

Is this the best way to solve the issue?

Yes. Extending the existing snapshot and benchmark reader is a narrow solution; existing diagnostic-event sampling serves a different output path and need not be invoked by status.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 0a7b7fecfd7f.

Labels

Label justifications:

  • P2: This is a bounded operator-diagnostics improvement without evidence of an urgent runtime regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The MEMBER-authored PR is exempt from the external-contributor proof gate and changes no authority boundary. Reported Linux validation exercises the real status memory producer over WebSocket through the benchmark reader, with surrounding collectors mocked; it does not demonstrate an operator workload.

Evidence

What I checked:

  • Current main still lacks the requested counters: The status handler on fetched main reports rssBytes, heapUsedBytes, and heapTotalBytes only. (src/gateway/server-methods/health.ts:174, 0a7b7fecfd7f)
  • Latest supplied release has the same diagnostic gap: Inspection of v2026.9.4 also shows only RSS and heap counters in the status response; the requested addition is not present in that release. (src/gateway/server-methods/health.ts:174, 3a9d69db306c)
  • Existing producer and compatible reader: The handler adds both counters from its existing memoryUsage snapshot. The extracted benchmark reader retains required RSS/heap validation, preserves actual zero values, and omits absent or nonfinite optional counters. (scripts/lib/gateway-bench-probes.ts:23, 55079d16e561)
  • Summary coverage protects meaningful edge cases: Tests cover populated, zero, missing, independently present, and invalid optional counters. Mixed-run assertions check that growth requires complete observation pairs and retains zero and negative changes. (test/scripts/bench-gateway-concurrency.test.ts:54, 55079d16e561)
  • Wire-test scope and reported remote results: The supplied PR snapshot, sourceRevision c26a59b0fc9b50f25e4b1b022088da0ed7b11cc1674067c89ffb05c284133a49, reports 52 passing tests on Linux at c6923b4 and an earlier intended failure when producer fields were removed. Source inspection confirms the WebSocket response passes through the production memory reader and all five conversions are asserted. Surrounding status/health collectors are mocked. The linked Actions run records Testbox lifecycle, while client output is represented by hashes rather than inspectable runtime logs; no operator workload or local execution is claimed. (src/gateway/server.health.test.ts:61, 55079d16e561)
  • Review continuity verified: The seven affected files, package.json, and pnpm-lock.yaml are unchanged from the previous reviewed head. The supplied completed-review projection contains no findings and no published rank-up moves. (55079d16e561)

Likely related people:

  • Peter Steinberger: 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 (3 earlier review cycles)
  • reviewed 2026-09-08T05:48:42.820Z sha ab53467 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-08T06:26:52.583Z sha ab53467 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-13T12:54:56.987Z sha c6923b4 :: needs maintainer review before merge. :: none

@vincentkoc
vincentkoc marked this pull request as ready for review September 13, 2026 12:48
@vincentkoc
vincentkoc merged commit c8d4673 into main Sep 13, 2026
186 checks passed
@vincentkoc
vincentkoc deleted the fix/status-external-memory-tranche1 branch September 13, 2026 13:33
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 13, 2026
* commit '0ac8a700e43efceef73d92fe8e50b185819e38ad': (27 commits)
  test(acpx): prove targeted turn cancellation (#137049)
  fix(ci): honor realtime meeting live-test opt-in (#147044)
  improve: reduce heartbeat enrollment work for large fleets (#147055)
  fix(gateway): install despite stale Linux session bus addresses (#146569)
  chore(i18n): refresh native locales (#147025)
  fix: avoid Gateway reinstalls when macOS service inspection is inconclusive (#146880)
  fix(pairing): QR setup rejects trusted-proxy gateways without a shared secret (#147036)
  fix(update): bound activation and accept slow Windows identity reads (#147019)
  perf(accounts): avoid materializing avatars for owner checks (#147032)
  improve(status): report external and ArrayBuffer memory (#141902)
  fix(update): preserve linked plugins during post-core sync (#147009)
  fix(channels): keep replies working after hot config reloads (#147001)
  refactor(gateway): defer worker transcript runtime loading (#143495)
  improve: reduce GitHub OAuth maintenance work for large agent rosters (#147021)
  fix(test): avoid settings lock writer startup timeouts (#147029)
  fix(update): correct backup guidance and cover incident regressions (#147023)
  refactor(gateway): share connection lifecycle across transports (#145950)
  refactor(telegram): share HTML text escaping (#146936)
  perf(build): reduce disk use in UI performance checks (#146687)
  refactor(memory-wiki): share freshness result construction (#146935)
  ...

# Conflicts:
#	src/config/sessions/session-accessor.sqlite-reclamation-memory.test.ts
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 14, 2026
)

* improve(status): report external and ArrayBuffer memory

* test(gateway): verify status memory over WebSocket
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: M 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