Skip to content

fix(catalog): keep capture contexts fresh in the prepared model catalog worker (backport #158323 to 2026.9.7) - #158808

Merged
steipete merged 1 commit into
release/2026.9.7from
backport/2026.9.7/158323
Sep 26, 2026
Merged

steipete merged 1 commit into
release/2026.9.7from
backport/2026.9.7/158323

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Related: #158323, #157842

What Problem This Solves

Backports the fix for native ESM memory retained when catalog requests alternate between unchanged loader workspaces to release/2026.9.7, together with accurate worker memory attribution.

User Impact

Catalog workers keep each workspace's current prepared generation, so alternating unchanged workspaces reuse their captured native dependencies. Worker diagnostics include heap, external memory, ArrayBuffers, sample age, and explicit incomplete coverage; exported bundles preserve these measurements.

The release branch keeps its existing exact-generation validation and current-request credential handling. A changed generation can still replace that workspace's context, and native module graphs from actual revisions remain until worker retirement. There are no configuration, CLI, dependency, schema, stored-data, update-driver, or rollback changes. ArrayBuffers are included in external memory, and worker heap limits do not cap external/native memory.

Why This Change Was Made

Cherry-pick provenance: 5e4b43cf86c76b188631ed420032dc221eadd794 (main merge of #158323). No prerequisite commits were needed.

The catalog worker's single current slot evicted workspace A when B ran. Returning to A captured another native ESM graph, which Node retains even after capture-file cleanup. The existing worker now owns a map of current generations by loader workspace. Replacement still acquires the new generation before releasing that workspace's predecessor; failed candidates retain their existing cleanup path.

Conflict resolution preserves the release branch's own owners and contracts:

  • Catalog worker and architecture docs retain release's full generation fingerprint, prepared agent facts, two request-envelope forms, and release custody. Main's earlier fix: stop catalog renewal from stalling agent runs #157459 catalog redesign was not imported.
  • Worker CPU types, sampler/tests, and pool keep release's registry and retirement implementation. The memory port, bounded requests, busy-worker native fallback, late-reply ordering, and missing-coverage contract are ported. Main-only lifecycle counts and pool census are excluded.
  • Diagnostic tests keep release's threshold policy. Bundle decoding gains the shared typed readers and worker-field preservation while retaining release's atomic writer. The wrapper source inventory includes the two new infra modules; the assertion baseline only shrinks.

Thanks @highfly-hi, @zl0nline, and @oleagui for the original retention and attribution evidence.

Evidence

All commands used Linux x64 / Node 24.19.0 Blacksmith Testboxes and isolated synthetic state. No operator Gateway or ~/.openclaw was used.

The release-baseline negative control fails at 20 native payloads versus the expected 2; baseline bundle import also fails because it drops the worker fields. Restoring the candidate passes all four regression files three times: 65 tests per pass. The catalog regression takes 3.230 / 2.717 / 2.250 s of test time, with 6.72 / 6.08 / 5.37 s Vitest wall on one worker. Baseline catalog test time is 3.618 s (21.17 s Vitest wall).

On the same rig, request 5→20 worker heap growth falls from 61,492,104 bytes to 1,299,312 bytes on the first repaired pass. Retained payloads plateau at 2, and external/ArrayBuffer bytes remain exactly flat after request 5. Every request verifies the current agent's synthetic credential through the canonical parent catalog API.

The direct/one-barrel consumer batch passed 273 exercised files / 6,955 tests, with 57 existing platform skips and zero failures. All 274 selected paths were supplied in captured search order; src/gateway/gateway-models.profiles.live.test.ts is an unexecuted live opt-in file. No live credentials or opt-in flags were enabled. The skips are 48 Windows-only MXC cases, seven POSIX process-fallback cases, one Windows git-null-config case, and one Windows PATHEXT case.

The negative controls, three regression passes, and consumer batch ran on lease tbx_01m3egv90p7xfv70pcga0nxajy, run, exit 0. Consumer runner wall: 1,246.84 s, including shared compiler preparation; complete command envelope: 1,499.608 s. No individual test exceeded 30 s and no file exceeded 120 s of test time; the highest file test cost was 71.935 s. Combined with the separate catalog sibling batch, this covers 285 files / 7,024 passing tests, excluding the additional three regression passes from that total.

Changed-file regression cost on one worker: worker CPU 446 / 347 / 313 ms test time (11.48 / 11.11 / 10.14 s Vitest wall); diagnostic memory 90 / 102 / 84 ms; bundle 74 / 54 / 42 ms. The two logging files share 2.35 / 1.65 / 1.60 s Vitest wall. PR CI timings are not yet available at authoring handoff.

  • node scripts/check-changed.mjs --base origin/release/2026.9.7 -- <20 changed paths>: exit 0, including core typing, all 25 test-type shards, lint, and repository guards. Lease tbx_01m3eg1hbppc3ta3vtw7x3nynb, run, command envelope 1,506.73 s. A portal-sync warning followed the successful command result.
  • Additional catalog sibling suites: 12 files / 69 tests passed, 66.81 s Vitest wall, 114.10 s wrapper wall including runtime preparation. Full pnpm build: passed, build phases 306.4 s. Lease tbx_01m3egbrzvfwep5wswss5pgzvj, run, combined command envelope 582.466 s.
  • Fresh isolated Codex autoreview of the release-branch diff: P1 scoped-clean, no accepted/actionable findings. Formatting and git diff --check pass.

The initial full-checkout transfer timed out before any tests; the successful proofs use the verified release-base source capsule. Two negative-control orchestration attempts were corrected (runner stops on the first expected-red project; remote argument-length limit). Neither was a candidate product/test failure. Native Testbox cleanup can leave its backing Actions run marked cancelled; the command exit is the proof outcome.

Production +375 / -89; tests/support +460 / -18; docs +26 / -4; wrapper inventory +2 / -0; assertion baseline 11→9. Auto-merge is off. This PR targets the release branch only and does not publish a release.

Backport the catalog native ESM retention repair and worker memory attribution
from #158323 to release/2026.9.7.

(cherry picked from commit 5e4b43c)

Conflicts: keep the release worker's exact-generation fingerprint and release
custody while retaining one current generation per loader workspace. Port
memory sampling, native fallback, coverage, and bundle import through the
release registry. Exclude main-only catalog/lifecycle refactors and preserve
the release atomic writer. No prerequisite commits are required.
@clawsweeper

clawsweeper Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts agents Agent runtime and tooling size: L labels Sep 26, 2026
@steipete
steipete marked this pull request as ready for review September 26, 2026 10:01
@steipete
steipete merged commit 6ba916d into release/2026.9.7 Sep 26, 2026
263 of 267 checks passed
@steipete
steipete deleted the backport/2026.9.7/158323 branch September 26, 2026 10:03
roboclaw-bot added a commit that referenced this pull request Sep 27, 2026
Merge the already-landed release/2026.9.7 history at 7bd08b5 into
the reviewed prepared branch without re-cherry-picking external sources.
Preserve canonical native admission, companion namespaces, exact-generation
fingerprints, worker publication and atomic index ownership alongside the
parent's legacy census, cleanup and live lease repairs.

Resolve four conflicts and retain both test inventories. A damaged native
instance is not tokenless legacy scratch: keep its published payload when
the coordinator disappears. Add the existing Doctor journal-history helper
to the extracted-wrapper manifest; no database source changes.

Canonical provenance remains in the merged history:
- #158770 / source #157565 (PollyBot13, landed by Peter Steinberger)
- #158808 / source #158323 (Peter Steinberger)
- #158910 / sources #158414 and #158769 (Peter Steinberger)

Verified 1,019 exact-parent, 82 exact-canonical and nine combined postimages.
Two composition regressions reproduced and corrected. 157 focused owner
cases and two wrapper closure checks pass, as do production/test types,
lint, formatting and all frozen eb377ac ratchets. Full build passed in
262 seconds. Independent P0-P2 review completed all three passes clean.

Compilation is not installed-driver qualification. Normal built integration
preflight still refused runtime-artifact-publication/systemd-competing-managers.
The separate coupled database backport and its bound fixture hunk remain
unapplied. Version and dependencies are unchanged; public size-policy hold
remains active.

Implementation and verification:
https://team.openclaw.ai/chat/roboclaw/subagent/69c28824-7ae8-4692-9037-6998b58bc7f4
Discussion, review and integration:
https://team.openclaw.ai/chat/roboclaw/dashboard/db4d78ac-b19b-4f64-adfb-0ca7973a62e4

Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: vyctorbrzezowski <[email protected]>
Co-authored-by: steipete <[email protected]>
Co-authored-by: jalehman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant