Skip to content

fix(models): keep large fleets responsive during model preparation - #150223

Merged
steipete merged 10 commits into
mainfrom
upd/fleet-snapshot-batch-block
Sep 17, 2026
Merged

steipete merged 10 commits into
mainfrom
upd/fleet-snapshot-batch-block

Conversation

@steipete

@steipete steipete commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Related: #149538, #148529

Thanks to @609NFT for the 632-agent reports and detailed profiles in #149538 and #148529.

What Problem This Solves

Large fleets keep the Gateway's main thread inside buildSnapshotBatch on the microtask queue during model preparation and post-ready rebuilds, delaying health and status requests. The lead's separate 632-agent × 54-model reproduction recorded a 730-second gap around bind/model preparation, a 23.4-second post-ready gap, and 22 timed-out health probes out of 300 after readiness. This PR isolates and measures the batch owner with a 200-agent reproduction.

Why This Change Was Made

The reported profiles put 71–96% under buildSnapshotBatch: repeated activation/config serialization and fleet roster walks, followed by 49.5 seconds in recursive plugin argument restoration. Already-resolved promises kept that work on the microtask queue.

Preparation now captures one immutable runtime/authored config pair per fleet generation and carries its provenance forward. Activation fingerprints, roster indexes, and argument-graph analysis reuse those prepared facts. Unchanged plugin selections preserve capture identity. Nine real event-loop yields separate bounded workspace/agent/source/registry/snapshot work, with current-owner checks after yielding and auth replay tied to the credential-capture boundary.

Valid config hashing retains the lazy memo keyed by the actual deeply frozen object. Invalid diagnostic snapshots short-circuit in the reset/bootstrap comparison and config.get before hashing; reset still compares selected target, existence, validity, and raw revision. Valid fresh-install defaults retain their resolved revision even when the physical config file is absent. Capture records carry source/origin provenance, without eager fingerprints.

Catalog finalization now prepares the shared {agents, plugins} fingerprint in the existing build-local config map. Per-agent native source fingerprints combine it with that agent's selections and configured refs. Worker-generation code separately memoizes runtime/source config digests by immutable object identity, using its existing SHA-256/stable-stringify encoding; mutable worker reconstructions rehash. That separate encoding preserves distinctions such as undefined versus null. Full worker payloads, credential data, serialized SecretRef provenance, and generation checks remain intact.

Merged #149314 is already in the benchmark baseline. It covers immutable metadata-inventory fingerprint caching and other startup work; it does not change activation result/config hashing or plugin argument restoration. This PR complements PR A #149600 (cron skill-review reconciliation), PR B #149716 (chat metadata), and PR C #150004 (eager Codex catalog-home roster construction). PR C merged after the measured baseline; these measured revisions do not include it.

User Impact

The pre-rebase 200-agent measurement restored model preparation near the prior fast candidate: 22.499 s finally, versus 23.331 s in V2, 46.531 s in the record-based sample, and 68.872 s before this PR. The Gateway answers health during preparation (8/23 within the phase), with phase RSS reduced to 943.9 MiB. The final 11.950-second blocked overlap and phase-health result remain worse than the best V2 sample; this PR does not claim all startup stalls are resolved.

Explicit dev reset recovers invalid config without a WeakMap exception. No new operator setting, CLI option, dependency, schema migration, or action is required. Normal update/recovery ownership is preserved; no published-driver × candidate upgrade result is claimed.

The 30-second full openclaw status --json gate is NOT fully met: 1/3 final attempts succeeded. The separate online CLI status follow-up landed in #150269; these historical measurements do not include that change. Direct Gateway status succeeds independently; it is not a substitute for full CLI completion.

Evidence

Attribution of the slower sample

The 46.531-second clean sample on 01d7c3 did not reproduce during attribution: the same production code measured 21.621 seconds, while prior production measured 18.548 seconds. Counts rule out the proposed 200-capture amplification in this fixture. Both versions create one runtime/source pair during model preparation and reuse it 400 times. The record-based change adds one authored-source hash, about 5 ms, rather than 200 hashes of separate captures. The 1,600 computations on 801 other config/environment inputs are unchanged across the counter runs; the shared runtime capture itself is hashed once in every variant. The historical wall-time difference remains unattributed; single runs do not control host activity, filesystem caches, or unrelated background work.

Through model-runtime completion Prior production (4687) Record-based (01d7) Final
Public hash calls / computations 2,200 / 1,601 2,202 / 1,602 2,200 / 1,601
Public hash computation time 110.644 ms 113.223 ms 108.594 ms
Capture creates / reuses 1 / 400 1 / 400 1 / 400
Distinct original / authored source objects 1 / 1 1 / 1 1 / 1
Native-source full-fleet serializations 200 200 1 shared preparation + 200 small combinations
Worker-generation full-fleet serializations 200 composites containing both config graphs 200 composites containing both config graphs 2 shared config/source digests + 200 small combinations
Native-source fingerprint time 1,213.987 ms 1,263.658 ms 13.211 ms (5.741 shared + 7.470 combinations)
Worker-generation fingerprint time 2,623.680 ms 2,820.393 ms 18.241 ms (13.236 config/source + 5.005 combinations)

Whole-boot counts through the same model-complete checkpoint were 2,230 calls / 1,631 computations for prior production, and 2,235 / 1,635 for record-based production. Both had three captures overall, three original objects, and two authored-source objects. Final whole-checkpoint public hashing is 2,230 calls / 1,631 computations (293.391 ms), with the same three capture creates and 400 reuses. Worker-config hashing makes 400 calls over two immutable objects: two computations and 398 hits. The final instrumented model phase is 14.156 seconds; its batch takes 7.933 seconds, followed by a 6.088-second synchronous committed-catalog refresh tail. That remaining scheduling work is a follow-up at refreshCommittedProviderCatalogs in src/agents/prepared-model-runtime.refresh-scope.ts; the full-roster hashing identified in catalog finalization is fixed here.

The prior production tree was materialized as a four-file overlay in the assigned worktree and verified byte-for-byte against 4687f3106744463b51f5072f8493b1dd5fdc09ad; the Git branch/HEAD was not switched. Both initial counter windows end at model-runtime completion, before readiness. One failed probe attempt and an early-bootstrap probe-preflight overlap were retained as tooling limitations, not product failures. Counters record numeric object identities and timing only; final performance claims below use a separate uninstrumented run.

Uninstrumented 200-agent comparison

Measurement Original baseline Prior V2 Record V3 Final clean
Time to bind (s) 590.277 412.619 386.943 323.618
Time to ready (s) 680.264 443.032 440.950 359.880
Model-runtime phase (s) 68.872 23.331 46.531 22.499
Largest full timer gap overlapping model-runtime (s) 90.026 8.951 23.787 13.843
Largest blocked overlap inside model-runtime (s) 68.872 8.704 23.396 11.950
Health replies within model-runtime / attempts 0/69 14/24 21/46 8/23
Health replies eventually from model-runtime attempts 4/69 18/24 24/46 12/23
Model-runtime peak RSS (MiB) 1187.6 1004.8 958.0 943.9
Overall peak Gateway RSS (MiB) 1605.6 1660.7 1667.9 1516.9
Largest timer gap before ready (s) 90.026 39.576 40.730 30.286
Post-ready observation window (s) 100.456 100.867 100.869 100.683
Largest timer gap after ready (s) 9.265 10.663 13.581 6.936
Health replies within post-ready window / attempts 94/101 94/101 91/101 98/101
Health replies eventually from post-ready attempts 95/101 95/101 92/101 99/101
Post-ready peak RSS (MiB) 1173.4 1121.9 1037.2 1135.2
Full CLI status exit 0 + valid JSON within 30 s 0/3 0/3 0/3 1/3
Separate direct Gateway status exit 0 + valid JSON Not run 1/1 (3.282 s) 1/1 (5.661 s) 1/1 (2.099 s)

The fixture uses 200 distinct workspaces/agent databases, 54 model refs each (10,800 total), 53 inline models and one unresolved ref, the same 12 bundled plugins, and no model turns or channel traffic. Each run uses Node 26.8.2, the same source-performance profile, isolated HOME/state, a free loopback port, an independent 10 ms timer, one health probe per second with a 5-second deadline, and three full CLI status probes with 30-second deadlines. Diagnostic-tail work is excluded from the primary post-ready window. A full gap crossing a phase boundary is reported separately from its overlap inside the phase.

The clean run had no fingerprint preload (measurement.instrumentation is null). The fixture manifest is identical across runs, while absolute paths differ because each run uses fresh isolated state. The final 13.843-second full gap crosses post-bind plugin loading; maximum overlap inside the phase is 11.950 seconds. A 30.286-second pre-ready gap and 6.936-second post-ready gap remain. Post-ready health completed 98/101 requests within its 100.683-second window. Final phase health and blocked overlap are not back to V2's 14/24 and 8.704 seconds. These are individual synthetic runs with host load and filesystem caches uncontrolled.

Full CLI outcomes were timeout at 30.015 s, valid JSON/exit zero at 27.112 s, and timeout at 30.017 s. A separate diagnostic attempt spent 19.938 s in status.config, including 200 metadata scans totaling 18.620 s and 200 freezes totaling 0.627 s; status.local-agents and status.agent-admission remained pending at its 30.020-second deadline. Those scan timings are nested inside config time. Separately, direct Gateway status returned independently parsed valid JSON in 2.099 s, with a 367 ms handler.

The follow-up entry point is src/commands/status.scan-overview.ts:168; its full metadata reader reaches the per-workspace loop in src/config/io.plugin-metadata.ts:218, followed by local admission in src/commands/status.agent-local.ts:42. Online status should consume the authorized Gateway's prepared status projection—admission state, session counts, heartbeat/tasks, and runtime vitals—while preserving explicit offline/local diagnostics and response scopes. This PR does not change that CLI path.

All owned Gateways and diagnostic processes exited, with the isolated ports verified closed. Final local evidence is retained under .local/fleet-serve/l470-after-200-final9a4/; the separate counter report is under .local/fleet-serve/l470-fingerprint-final9a4-200/. No remote-catalog timeout occurred in the final clean run; the synthetic missing-System-Agent memory warning remained.

Rebase onto current main

The latest rebase moves this series onto 90b421ae252ceaea5bf5a9f106eab51bf384431b, which includes the Control UI budget and worktree-fixture fixes from #150491 and the wrapper-inventory fix from #150453. All ten commits are patch-identical in git range-diff, including the inventory additions; there were no conflicts, and git diff --check passed. The following paragraph records the earlier mechanical rebase.

Rebased the published series from 1fdce1a4aa636b400179a0e43933d7fe52d45ddd onto main c32a31812663e577467453df24844aa82fb36d27. The only conflict was scripts/pr-lib/wrapper-components.txt: all 1,122 main entries were retained and the same two PR modules were inserted in sorted order, producing 1,124 unique entries with no deletions.

The resolution is mechanical. The first nine commits are patch-identical in git range-diff; the default matcher shows the tenth inventory commit as removed/re-added because its two additions now sit within main's expanded inventory. Its added paths are byte-identical to the original patch. Independent comparison also confirms unchanged added/deleted line bytes across all 51 PR files. No production hunk, fixture behavior, or main-side landing was dropped or altered by conflict resolution. Per the lead's explicit mechanical-rebase rule, no fresh autoreview was run.

All 28 requested focused files were exercised. 382 runtime/Gateway tests have passing results, covering catalog selection, all 20 chat-metadata lifecycle cases, invalid-config recovery, config/activation/argument sharing, lifecycle transitions, and worker metadata/credential reconstruction. The initial direct catalog-integration run hit its unchanged 120-second case timeout; that result is retained. A separate run through the retained CI-native group passed and exited normally in 103.959 seconds, with no watchdog or retry; no assertion or timeout was changed.

The two tooling suites reported 133 passed, 24 failed, 2 skipped. Fresh-main and provisioning failures include the known main-side omission of src/plugins/discovery-availability.js, plus observed fixture command timing/termination failures (a 30-second case timeout, Git spawnSync ETIMEDOUT, and two null process-status results). The known inventory owner remains with its separate lane; these results are not presented as green tooling proof.

Full node scripts/check-changed.mjs passed, including core/test typechecks, core/script lint, zero dead exports, and zero runtime import cycles. No extension-lint host substitute was needed. The resolution changes 0 production lines and 0 test lines relative to the previously reviewed patch; it only relocates the same two tooling inventory additions within main's list.

The new source base uses its frozen lockfile. The focused runner rebuilt runtime artifacts for the rebased head; no separate full build or 200-agent benchmark is claimed for this mechanical resolution. Prior benchmark tables remain historical evidence on their recorded revisions.

Wrapper inventory correction

The inventory follow-up 1fdce1a4aa636b400179a0e43933d7fe52d45ddd was published first under the lead ruling. It then conflicted with newer main and could not receive a pull-request CI run; the author-owned rebase described above resolves that conflict.

The canonical source inventory in scripts/pr-lib/wrapper-components.txt omitted two modules introduced by this PR. Main's newer provisioning wrapper reaches src/config/runtime-snapshot.ts and src/config/runtime-source-projection.ts; their runtime imports require src/shared/immutable-data.ts and src/config/runtime-config-capture-state.ts. Fresh materialized wrapper trees therefore failed with ERR_MODULE_NOT_FOUND before the fresh-main/provisioning assertions. Both files are now included in the existing inventory. Tooling +2/−0; production 0; tests 0.

src/agents/prepared-model-runtime.oauth-providers.ts is intentionally excluded: its sole runtime importer is src/agents/prepared-model-runtime.facts.ts, outside the wrapper's materialized import closure. The comparator's AuthStorage import is type-only. The two added inventory files introduce no further runtime module dependencies beyond Node built-ins.

Scoped node scripts/check-changed.mjs -- scripts/pr-lib/wrapper-components.txt passed, including the tooling guards and script lint. Local Codex P1 review is scoped-clean. The operation-lock suite reported 139 passed, 1 failed, 1 skipped in 219.09 seconds. The lead accepted this proof for the inventory-only correction and classified the remaining failure as an observed host-load timeout on the shared worker host:

  • Case: scripts/pr per-PR operation lock > finishes native cleanup with linked wrapper (merge-run, failure=none).
  • Observed case duration: 17,669 ms. Its unchanged spawnSync limit is 15,000 ms.
  • Exact assertion: expect(result.error, output).toBeUndefined() at test/scripts/pr-operation-lock.test.ts:1966.
  • Received: Error { code: "ETIMEDOUT", syscall: "spawnSync .../.worktrees/pr-42/scripts/pr" }, after the fixture printed its synthetic MERGED receipt.

No timeout or assertion was changed. test/scripts/pr-worktree-provision.test.ts is absent from this branch's base and was not run locally. It exists on newer main and runs in CI with that main-side wrapper; the lander will rebase once main is green, including the separate sibling discovery-availability.ts inventory correction. This follow-up does not rebase or change that sibling owner.

Chat metadata lifecycle fixture correction

checks-node-compact-small-19 on b16332e9111244d9782bfce2e60b906230f2bb97 failed seven cases in server-chat-metadata-lifecycle.integration.test.ts. The three-argument response contract was intact: models.list still called respond(true, result, undefined), and the third argument is the optional RPC error. The mismatch was the second argument's available: false after the fixture marked native discovery ready.

The seven-case synthetic readiness callback required exact identity with the authored nativeConfig. This PR intentionally separates the public config stamp from the captured native observation config; the previous real Gateway catalog regression established that selection must use the discovery capture. The fixture now consumes the published owner's recorded observationConfig and retains its strict identity guard, structural config assertion, and every response, metadata, pin-authority, generation, stamp, registry, disposal, revision, and discovery-count assertion. A local owner reader consolidates three repeated lookups and shrinks the over-cap test file by seven lines. Production is unchanged; restoring the authored identity in production would reintroduce the independently proven native selection defect.

Attribution File runs passed Tests in each run
PR head b16332e9111244d9782bfce2e60b906230f2bb97 0/3 13 passed, 7 failed
Pinned main 387f69830a81968ed2d4ef830d67456167bc7f43 3/3 20 passed, 0 failed
Corrected fixture 3/3 20 passed, 0 failed

Both revisions used the same assigned worktree, Node 24.21.0, two workers, and unchanged test/dependency manifests. All seven original failures were payload-availability mismatches at the same registered-handler assertion. No sleeps, retries, changed deadlines, weakened expectations, or new production seams were added. The fixture-only local P1 review is scoped-clean, and the lead accepted publication of this correction before further hang attribution. The grouped native catalog integration subsequently hit its 120-second test timeout; an explicit-project probe then hit the 120-second local no-output watchdog without a result. These failures remain recorded. The remaining focused projects, changed-file gate, and fresh committed branch review have not been completed for this correction; the CI-group attribution is recorded below. No broader validation success is claimed.

No production boundary, capture, hash, or sharing logic changed. The successful full build from the preceding correction (8m 0.6s) remains applicable; neither it nor the historical 200-agent benchmark was repeated for this test-only change.

Native catalog hang attribution after publishing the fixture correction

The retained CI job runs agentic-gateway-methods-hosted-1 with gateway-methods and gateway-methods-isolated configs and exactly one included file: test/plugins/codex-model-catalog.gateway.test.ts. The reproduction used node --import tsx scripts/ci-run-node-test-shard.mts with that extracted group, two workers, the CI 300-second no-output watchdog and retry setting, and the unchanged 120-second test timeout. The isolated companion config has no matching test; it exits normally as in CI.

Revision Passed / runs Test timeouts Watchdogs / retries Test-body seconds by run
PR 445216f33ea26f87a72446e2eb47dd01d60e6073 3/3 0 0/0 94.700, 31.853, 29.047
Pinned main 79121743a16969fd86dfd88fcd5422dacea88ac3 3/3 0 0/0 62.887, 12.673, 17.728

All six invocations exited normally after the passing case. Whole-command times were 325.320/95.280/133.261 seconds on the branch and 243.804/40.094/46.671 seconds on main; first invocations include runtime rebuilds. Both used local Node 24.21.0 and task-owned caches without CI's restored cache seed; each revision used its own frozen lockfile. Main's newer fs-safe dependency and peer-lock entries are a comparison difference. This is a scoped reproduction, not a fleet performance comparison or a rerun of unrelated groups packed into that CI job.

The hang did not reproduce in this CI group, so no pending owner is attributed and the head-only condition for scratch instrumentation was not met. The earlier local grouped run timed out during its only case; it did not print a passing case followed by a teardown stall. Its cause remains unproven. Read-only comparison with #150354 confirms overlapping catalog-worker, publication-join and pool-close owners, but that is not evidence that one caused these timeouts. No shared-owner production fix was made, and the unused scratch diagnostic template was not committed.

The assigned branch and its locked dependencies were restored after the comparison. CI 35167882651 is attached to the published fixture-correction head. The earlier incomplete broader validation is not recast as a full-suite pass.

Rebased catalog-selection correction

The unchanged registered Gateway test in test/plugins/codex-model-catalog.gateway.test.ts exposed a publication defect after the rebase: native discovery recorded account/model readiness against the captured config, but createPreparedModelRuntimeSnapshot published the original config stamp as observationConfig. The native harness correctly requires the exact discovery config and plugin-config identity, so selection returned unavailable despite successful discovery. The owner now publishes agentFacts.input.config for observations while retaining publishedConfig for the public config stamp. No discovery retry, broader cache key, or auth/home-scope relaxation was added.

Attribution, unchanged test and deadlines Passed Failed
PR head e4035d9401faa02542d426fcff7d0fb3d49d3f22 0 10
Pinned main f542d35411621a9f2b17fa0186cb14880b83c976 10 0
Repaired source, original Gateway test 1 0

Both comparisons ran in the assigned worktree with Node 24.21.0, the gateway-methods project, two workers, and identical test/manifest/lock/project configuration. Every branch failure was the original line-191 availability assertion. One additional main invocation produced no test result: the existing 120-second no-output watchdog terminated it after worker preparation took 79 seconds. Its exit-143 log is retained separately; the watchdog and assertions were unchanged. CI uses Linux Node 24.19.0, so local comparison does not replace CI.

The new colocated regression awaits completed catalog loading and then evaluates the recorded readiness facts without polling. It failed pre-fix with availability: false instead of true, and passes after the owner repair. It also verifies the public stamp, model-neutral stamp advancement, cloned-config and agent-directory isolation, and revocation. 361 focused tests across 24 files pass, including previous lifecycle, invalid-config recovery, worker reconstruction, and chat-metadata regressions. The original Gateway integration passes through its later refresh/account-change/revocation assertions. node scripts/check-changed.mjs passed completely, with core/test typechecks, lint, zero dead exports and zero runtime import cycles; no extension-lint host substitute was needed. Full pnpm build passed in 8m 0.6s. Fresh Codex autoreview --mode branch --base origin/main --max-priority P1 is scoped-clean on b16332e9111244d9782bfce2e60b906230f2bb97.

This correction changes no capture shape, hashing, sharing key, or scheduling logic. The 200-agent table above is retained evidence from pre-rebase 9a4f5e11cf50a74cca1dcfe6bd9da52295385b4b; it was not remeasured on this rebased correction. It is not a new performance or CLI-responsiveness claim.

Earlier regression and validation (before rebase)

The retained pre-fix invalid-reset result is:

TypeError: Invalid value used as weak map key
  hashRuntimeConfigValue src/config/runtime-snapshot.ts:191
  recheckGatewayRunReset src/cli/gateway-cli/pre-bootstrap.ts:444

Restoring the prior memo before applying diagnostic guards reproduces four failures: the original CLI case plus absent/null/string source cases. Raw-content and file-target drift refusals pass. After the owner fix, all six cases pass 10/10 each (60/60). Additional config-response coverage verifies invalid diagnostics avoid hashing and valid fresh-install defaults retain applied revision equality.

Boundary negatives also reproduce 201 full-config hashes instead of one for an uncaptured immutable config, 400 roster projections instead of two, 9→17 whole-roster digests as the fixture grows from 8→16 agents, and 33 worker config digests instead of one. The corrected code passes those bounds, keeps roster/plugin mutation and per-agent selection/ref invalidation, and preserves independently reconstructed worker fingerprints, including undefined/null and authored SecretRef distinctions. Catalog mutation tests request real catalog refresh before reading completed-discovery facts.

360 focused tests across 24 files pass, including the prior lifecycle and chat-metadata CI regressions. The three catalog-sharing cases passed again after an import-only cleanup. node scripts/check-changed.mjs passed completely, including typechecks, lint, dead exports, and zero runtime import cycles; no extension-lint host substitute was needed. pnpm build passed (10m 15.8s), the matching sourcePerformance build passed (57.4s), and fresh Codex autoreview --mode branch --base origin/main --max-priority P1 is scoped-clean on the committed head.

Hash entry-point audit

Entry point Value type / admission boundary
Runtime snapshot publication, source capture, cache key and write notifications Config/source records supplied by their owners; deeply frozen objects share lazy hashes, mutable objects rehash. Capture accepts config objects and carries source/origin provenance.
Gateway CLI pre-bootstrap.ts comparison Invalid diagnostic source can be absent/null/non-object. These snapshots compare target/existence/validity/raw revision and short-circuit before hashing. Valid normalized source objects retain hash comparison.
gateway/config-get-response.ts Invalid snapshots return no resolved revision and never enter hashing; raw revision, issues and current applied revision remain available. Valid defaults, including a missing physical file, still hash their normalized source object.
Config reload, Doctor preflight checkpoint, system-agent execution Existing validity/admission checks precede hashing of config/source records.
Prepared-runtime owner, inbound registry and facts Config/environment records; prepared config objects are immutable captures. Optional environment inputs are guarded/defaulted.
Models config, provider-auth and auth-provider config Discovery/environment records, ModelAuthAvailabilityRef objects via the existing cast, and explicitly constructed provider wrappers.
Transcript reload Explicit config wrapper object.
Activation reuse Mixed components; existing object narrowing precedes its memo, primitives follow its pure hash path.
Plugin argument restoration Graph traversal returns for primitives before weak access.
Runtime reader and roster facts Reader only looks up capture provenance. Roster memo keys immutable config objects, checks external legacy-owner metadata, and retains callback-local batching for mutable configs.
Worker generation Config/source object leaves use the existing stable-facts encoding and an immutable-identity memo. Mutable reconstructed worker objects are independently hashed; no diagnostic inputs enter this owner.
Production/test LOC and ownership justification

Whole PR: production +458/−134 (net +324); tooling +2/−0; tests +1,489/−170; docs +3/−1. This chat-metadata fixture correction against b16332e: production +0/−0; tests +12/−19. The catalog-selection correction against e4035d9: production +1/−1; tests +95/−0. The earlier sharing correction against 01d7c3 was production +78/−49; tests +266/−6. Counts include imports, comments, moves, and formatting.

Block Added / removed Capability or ownership boundary
Immutable graph owner and existing index freeze caller +81 / −22 Prove deeply frozen plain data once, including cycles and opaque-member rejection; reuse the same freeze owner. Weak references expire with objects.
Config capture, provenance, hash reuse, registration capture and public stamps +83 / −5 Retain authored/effective values and SecretRef/legacy provenance without freezing callers; bind plugin closures and reuse decisions to the same captured facts; keep runtime-following semantics.
Activation component fingerprints +35 / −7 Hash shared immutable fleet/model subtrees once; mutable inputs invalidate naturally.
Roster facts +24 / −6 Reuse roster/index facts by immutable config identity, with legacy-owner invalidation and existing lookup/clone semantics.
Unchanged plugin selections +20 / −2 Preserve capture roots when policy is unchanged, while retaining real allowlist/disable overrides.
Plugin argument restoration +4 / −0 Skip proven immutable data graphs and retain opaque-handle/proxy/accessor/mutable restoration.
Batch, configured facts and native catalog source +129 / −80 Carry captured/collected facts, share native config analysis in the existing batch map, and preserve bounded preparation and current-owner checks.
Auth capture boundary +28 / −6 Capture/replay credentials at the correct lifecycle boundary, including inherited-store relocation.
Existing OAuth comparator extraction +24 / −0 Keep the facts owner under its line cap; deletion is included in the batch/facts row. No new policy.
Diagnostic revision boundaries +10 / −4 Keep invalid snapshots out of object-keyed hashing while preserving reset drift checks and valid revision equality.
Worker-generation config digests +20 / −2 Share immutable config/source analysis without changing its serializer or trusting parent digest claims in the worker.

The scheduling code remains nine await nextTurn() sites plus two timer imports, with 19 added guard/plumbing lines for current-build checks. Other growth carries shared facts and lifecycle provenance; it does not add schedulers, persistent stores, or configuration.

Earlier exact-head CI corrections retained in this PR

The original clone failure came from read-counting Proxy fixtures placed inside published config; the fixture now publishes plain data and observes a separate overlay, preserving the same read bounds. The lifecycle corrections replaced microtask/timer ordering assumptions and config-reference mock predicates with actual source-start, preparation, supersession and publication boundaries. Their production tree remained unchanged. Those cases are included in the focused validation above; no sleeps, retries, weakened expectations, or baseline increases were added.

Original accepted before/final table (historical v2 evidence)
200-agent measurement Before Final
Model-runtime preparation 68.872s 23.331s
Largest blocked overlap within phase 68.872s 8.704s
Health replies completed during phase 0/69 14/24
Model-phase peak RSS 1,187.6 MiB 1,004.8 MiB
Largest post-ready gap 9.265s 10.663s
Valid full status JSON within 30s 0/3 0/3

The final column here describes e927ea9b01651b1ce19cfe67c70f60c29d31e526, not the current head. The current comparison above supersedes it.

Current head: 241983f40eec14e037f37b4065595f4f54eb4198. Release-note context is kept in this PR; the changelog remains release-owned.

ClawSweeper review disposition

Landing disposition: accept the documented read-only api.config registration snapshot contract for this scoped repair, with installed-plugin mutation compatibility explicitly unverified. Plugins that write into registration configuration or its descendants may throw or have writes ignored. That compatibility tradeoff is accepted for the shared immutable preparation design; it is not evidence that installed-plugin upgrades are compatible.

The published-driver × candidate upgrade rank-up request is skipped for this scoped model-preparation repair. Retained installed-plugin mutation compatibility remains unverified; no upgrade-acceptance result or complete 632-agent fleet recovery is claimed. The historical performance measurements and their remaining stalls are retained above.

The wrapper-inventory conflict identified in the review was resolved mechanically as documented above: main's entries were preserved, and the same two PR modules were inserted in sorted order. Native landing remains gated on green CI for the head being merged.

@clawsweeper

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

@steipete
steipete marked this pull request as ready for review September 16, 2026 18:31
@steipete
steipete requested a review from a team as a code owner September 16, 2026 18:31
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling plugin: file-transfer size: XL maintainer Maintainer-authored PR labels Sep 16, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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 Sep 16, 2026
@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 16, 2026, 11:15 PM ET / September 17, 2026, 03:15 UTC (Revision 13).

ClawSweeper review

What this changes

Shares immutable configuration facts and yields between model-preparation stages so large agent fleets leave more time for Gateway requests.

Merge readiness

⛔ Blocked before merge - 2 items remain

This remains a useful, distinct repair that current main does not implement. No blocking patch defect was identified; the PR now explicitly accepts the compatibility tradeoff requested by the previous review.

Priority: P1
Reviewed head: 241983f40eec14e037f37b4065595f4f54eb4198

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A useful repair with substantial runtime evidence, focused lifecycle coverage, and an explicitly accepted compatibility tradeoff.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The complete, snapshot-matched body connects the changed preparation owner to an isolated real Gateway run with 200 agents, external health probes, timer sampling, and RSS measurements showing improved preparation and service responsiveness. Historical revision limits are explicit; the accepted installed-plugin compatibility gap is not represented as proven.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The complete, snapshot-matched body connects the changed preparation owner to an isolated real Gateway run with 200 agents, external health probes, timer sampling, and RSS measurements showing improved preparation and service responsiveness. Historical revision limits are explicit; the accepted installed-plugin compatibility gap is not represented as proven.
Evidence reviewed 11 items Captured discussion and resolved prior request: The complete PR body was retrieved and its SHA-256 matched the supplied snapshot, eee8bc4661a7e9565a89a1208d97ced1988c943736b6db07520103c7ea5ef50c, covering all 34,150 UTF-16 units. Its disposition explicitly accepts read-only api.config compatibility risk and skips the published-driver upgrade rank-up for this scoped repair. This addresses the previous review’s sole retained rank-up.
Current main still needs this repair: Fetched main still prepares batches without the introduced shared configuration capture or event-loop yields. The related merged startup, chat-metadata, Codex-registration, and CLI-status changes address different owners.
Release comparison: The latest supplied release, v2026.9.4, has source projection without captureRuntimeConfig. No local release tag contains the initial PR commit; this review makes no shipped-fix claim.
Findings None None.
Security None None.

How this fits together

Model preparation combines configuration, plugin metadata, and each agent’s credentials into model catalogs used by Gateway requests. Repeated fleet-wide work in this process can prevent the Gateway from answering health and status requests.

flowchart TD
  A[Fleet configuration] --> B[Immutable configuration capture]
  C[Plugin metadata and agent credentials] --> D[Model preparation]
  B --> D
  D --> E[Yield and check current generation]
  E --> F[Publish agent model catalogs]
  E --> G[Service Gateway requests]
Loading

Before merge

  • Resolve merge risk (P1) - Accepted compatibility risk: installed plugins that mutate api.config descendants may fail after upgrade; installed-plugin mutation compatibility and published-driver upgrade behavior remain unverified.
  • Resolve merge risk (P1) - The historical synthetic benchmark establishes a scoped improvement, not complete 632-agent recovery or a fresh performance measurement of the rebased head.
Agent review details

Security

None.

PR surface

Source +324, Tests +1319, Docs +2, Other +2. Total +1647 across 51 files.

View PR surface stats
Area Files Added Removed Net
Source 23 458 134 +324
Tests 25 1489 170 +1319
Docs 2 3 1 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 51 1952 305 +1647

Review metrics

Metric Value Why it matters
Registration contract 1 existing plugin API property becomes read-only The api.config behavior change has explicit acceptance but remains relevant to installed-plugin compatibility.
Production versus test growth production net +324; tests net +1,319 Production growth is justified by shared capture, fingerprint reuse, and lifecycle handling; tests cover invalidation, isolation, scheduling, and recovery.

Merge-risk options

Maintainer options:

  1. Honor the recorded compatibility acceptance (recommended)
    Proceed under the explicitly accepted read-only registration-config contract while preserving the disclosed installed-plugin upgrade limitation.

Technical review

Best possible solution:

Retain shared immutable preparation with the recorded plugin-contract acceptance, while keeping broader startup and post-ready recovery with their existing owners.

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

Yes: current-main preparation loops and the documented 200-agent Gateway comparison establish a concrete starvation path; this read-only review did not execute it.

Is this the best way to solve the issue?

Yes, within the accepted scope: sharing captured facts and yielding in the existing preparation owner addresses the measured repeated work while preserving generation and agent boundaries.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: Large-fleet model preparation blocks Gateway requests in reported real deployments.
  • merge-risk: 🚨 compatibility: Freezing registration configuration can break installed plugins that mutate api.config, despite explicit acceptance of that tradeoff.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster 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 complete, snapshot-matched body connects the changed preparation owner to an isolated real Gateway run with 200 agents, external health probes, timer sampling, and RSS measurements showing improved preparation and service responsiveness. Historical revision limits are explicit; the accepted installed-plugin compatibility gap is not represented as proven.
  • proof: sufficient: Contributor real behavior proof is sufficient. The complete, snapshot-matched body connects the changed preparation owner to an isolated real Gateway run with 200 agents, external health probes, timer sampling, and RSS measurements showing improved preparation and service responsiveness. Historical revision limits are explicit; the accepted installed-plugin compatibility gap is not represented as proven.

Evidence

What I checked:

  • Captured discussion and resolved prior request: The complete PR body was retrieved and its SHA-256 matched the supplied snapshot, eee8bc4661a7e9565a89a1208d97ced1988c943736b6db07520103c7ea5ef50c, covering all 34,150 UTF-16 units. Its disposition explicitly accepts read-only api.config compatibility risk and skips the published-driver upgrade rank-up for this scoped repair. This addresses the previous review’s sole retained rank-up. (241983f40eec)
  • Current main still needs this repair: Fetched main still prepares batches without the introduced shared configuration capture or event-loop yields. The related merged startup, chat-metadata, Codex-registration, and CLI-status changes address different owners. (src/agents/prepared-model-runtime.build.ts:80, c939e56c3a75)
  • Release comparison: The latest supplied release, v2026.9.4, has source projection without captureRuntimeConfig. No local release tag contains the initial PR commit; this review makes no shipped-fix claim. (src/config/runtime-source-projection.ts:1, 3a9d69db306c)
  • Production preparation and publication boundaries: The batch captures configuration once per input identity, checks current ownership after yielding, preserves same-directory source serialization, and publishes the original public config stamp while retaining captured discovery facts. (src/agents/prepared-model-runtime.build.ts:91, 241983f40eec)
  • Credential replay boundary: Initial builds skip redundant invalidation only before credential capture and while inherited-store ownership still matches. Once capture starts, mutation invalidates the generation; focused coverage includes mutation during capture and inherited-store relocation. (src/agents/prepared-model-runtime-auth-publication.ts:317, 241983f40eec)
  • Real performance evidence and limits: The matched body records an isolated Node 26.8.2 Gateway with 200 workspaces/databases and 10,800 model references: preparation fell from 68.872 to 22.499 seconds, phase RSS from 1,187.6 to 943.9 MiB, and health replies during preparation rose from 0/69 to 8/23. Measurements belong to pre-rebase 9a4f5e11cf50a74cca1dcfe6bd9da52295385b4b; later corrections and mechanical rebases are separately documented. Remaining stalls and incomplete full-CLI status results are retained. (9a4f5e11cf50)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; 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 (12 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-16T22:36:55.885Z sha 9a4f5e11cf50a74cca1dcfe6bd9da52295385b4b :: blocked before merge. :: none
  • reviewed 2026-09-16T22:49:03.484Z sha e4035d9 :: blocked before merge. :: none
  • reviewed 2026-09-17T00:16:29.884Z sha b16332e9111244d9782bfce2e60b906230f2bb97 :: blocked before merge. :: none
  • reviewed 2026-09-17T00:54:58.319Z sha 445216f33ea26f87a72446e2eb47dd01d60e6073 :: blocked before merge. :: none
  • reviewed 2026-09-17T01:12:46.701Z sha 445216f33ea26f87a72446e2eb47dd01d60e6073 :: blocked before merge. :: none
  • reviewed 2026-09-17T01:32:07.032Z sha 1fdce1a4aa636b400179a0e43933d7fe52d45ddd :: blocked before merge. :: none
  • reviewed 2026-09-17T02:37:45.256Z sha 236f82ccf2c8bdd4dfcc7ac260a0c4b6794e4969 :: blocked before merge. :: none
  • reviewed 2026-09-17T02:56:10.271Z sha 241983f :: blocked before merge. :: none

steipete added a commit that referenced this pull request Sep 16, 2026
)

* fix(status): make online JSON status responsive on large fleets

Use the narrow Gateway connection reader and consume the Gateway's status
projection before local fleet discovery. Preserve read scope, expose prepared
roster/configuration facts additively, and identify local inspections that were
not collected. Keep the existing offline diagnostics path.

Related: #149538
Gateway-side sibling: #150223

* test(gateway): align status scope expectations with projection default
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime cli CLI command changes labels Sep 16, 2026
@steipete
steipete force-pushed the upd/fleet-snapshot-batch-block branch from 9a4f5e1 to e4035d9 Compare September 16, 2026 22:42
@steipete
steipete force-pushed the upd/fleet-snapshot-batch-block branch from 1fdce1a to 236f82c Compare September 17, 2026 02:21
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Sep 17, 2026
Capture runtime and source config at plugin registration and reuse
immutable fingerprints, roster facts, and plugin argument analysis.
Yield between agent preparation stages while preserving auth capture
ordering and shared credential-store ownership changes.

Refs #149538, #148529.
@steipete
steipete force-pushed the upd/fleet-snapshot-batch-block branch from 236f82c to 241983f Compare September 17, 2026 02:45
@steipete
steipete merged commit 75d29a7 into main Sep 17, 2026
219 checks passed
@steipete
steipete deleted the upd/fleet-snapshot-batch-block branch September 17, 2026 03:24
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 17, 2026
…claw#150269)

* fix(status): make online JSON status responsive on large fleets

Use the narrow Gateway connection reader and consume the Gateway's status
projection before local fleet discovery. Preserve read scope, expose prepared
roster/configuration facts additively, and identify local inspections that were
not collected. Keep the existing offline diagnostics path.

Related: openclaw#149538
Gateway-side sibling: openclaw#150223

* test(gateway): align status scope expectations with projection default
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 17, 2026
…penclaw#150223)

Large fleets repeatedly serialized configuration and rebuilt discovery facts during model preparation, starving Gateway health and status requests. Publish batched discovery as shared immutable facts, reuse config and catalog fingerprints, and yield at guarded lifecycle boundaries while preserving agent-specific credentials, cancellation, and serialized publication.

Keep captured observation config distinct from public config stamps so native catalog selection survives stamp advancement. Preserve invalid-config reset and diagnostic behavior by keeping invalid values out of object-keyed hashing, and include the new shared modules in the native wrapper inventory.

Related: openclaw#149538, openclaw#148529. Thanks to @609NFT for the 632-agent reports, profiles, and startup breakdowns that identified this bottleneck. Scoped performance measurements, regression proof, and remaining upgrade and fleet-recovery limits are recorded in openclaw#150223.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling cli CLI command changes docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. plugin: file-transfer 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