Repository navigation
perf(agents): scope model-catalog worker plugin imports - #135486
Conversation
…penclaw-crb2) The prepared-model-catalog worker has no gateway request scope, so its registry load falls through to metadataSnapshot.pluginIds — every installed plugin. Measured on a live gateway: 156 plugins, 55 loaded, 44.6s, inside a throwaway worker thread, with real side effects (it opened a plugin's SQLite database and registered channel hooks). Terminating that worker mid-import is the suspected trigger for V8 'Check failed: node->IsInUse()' in ~ModuleWrap, which aborts the entire process rather than just the worker. Scopes that load to model-contributing plugins, derived from manifest metadata so no plugin is imported to compute it. Measured against the bundled manifests: 150 records -> 80 scoped, 70 excluded, all 104 expected providers retained. Defensive by construction, because the failure being avoided is SILENT model loss, which is worse than the crash: - Greedy inclusion across 12 manifest signals. A false include costs milliseconds; a false exclude loses a model. - Agent harnesses are kept explicitly. codex and copilot declare only activation.onAgentHarnesses and nothing else model-shaped; dropping them would delete their runtime-chooser bindings. - assertModelCatalogCoversExpectedProviders() THROWS, naming the missing ids, if the catalog ever produces fewer providers than the manifests promise. - An empty scope, or any throw while resolving it, falls back to loading everything. Slow and correct beats fast and empty. - Gated on !isMainThread, so main-thread behaviour is bit-for-bit unchanged. scripts/proof-catalog-worker-scoped-registry.ts is a real-behavior proof against the real bundled manifests: it asserts no expected provider is lost, that the fail-crash guard actually fires when one is removed, and that the shipped app-server harnesses survive the narrowing. Co-Authored-By: Claude Opus 5 <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs real behavior proof before merge. Reviewed September 2, 2026, 10:55 AM ET / 14:55 UTC. ClawSweeper reviewWhat this changesScopes the off-main-thread full model-catalog worker to eligible catalog, CLI, and harness plugins, with a Gateway route integration test that retains a contributor while excluding an unrelated plugin. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked until real behavior proof is added - 4 items remain Keep open: the branch cleanly scopes the full-catalog worker’s runtime registry using manifest metadata, but the captured evidence has no inspectable exact-head installed-plugin trace proving that existing catalog contributors remain complete under real configurations. Priority: P1 Review scores
Verification
How this fits togetherGateway flowchart LR
A[Gateway models list request] --> B[Prepared runtime snapshot]
B --> C[Full catalog worker]
C --> D[Manifest eligibility and plugin scope]
D --> E[Scoped runtime registry]
E --> F[Catalog discovery]
F --> G[Gateway model inventory]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +30, Tests +197. Total +227 across 6 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one manifest-derived worker scope, then attach a redacted exact-head installed-plugin full-catalog trace showing preserved provider inventory and excluded unrelated runtime imports. Do we have a high-confidence way to reproduce the issue? No independent high-confidence reproduction was run: source establishes the worker’s prior unscoped fallback, but the supplied benchmark claims have no inspectable runtime trace. Is this the best way to solve the issue? Unclear: the manifest-derived scope follows the existing runtime load-plan boundary and the route-level regression is meaningful, but installed-plugin evidence is still needed to show it is the safest complete scope. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 4adab7342dd8. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (8 earlier review cycles)
|
Run the model-provider coverage guard against the catalog returned by the real worker, allowing only providers known to be inactive. Keep CLI backend ownership in scope without treating harness IDs as catalog providers.\n\nAdd an actual worker regression that loads a contributing model plugin while proving an installed unrelated plugin is not imported off-main-thread.\n\nValidation: 20/20 prepared-model-catalog worker integration tests\nValidation: pnpm tsgo:core\nValidation: pnpm check:changed (all relevant lanes pass; inherited core-test errors in a file identical to origin/main)\nValidation: pnpm tsx scripts/proof-catalog-worker-scoped-registry.ts\n\nBeads: openclaw-fzif\n\nCo-Authored-By: Claude <[email protected]>
P1 worker-coverage finding fixed at
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Keep manifest aliases in the plugin-loading scope while comparing worker output against canonical provider identities. Normalize active alias policies before deciding whether an expected canonical provider may be absent, and cover the alias-to-canonical path through the real worker. Validation: 44 focused worker/catalog tests; pnpm tsgo:core; pnpm check:changed (all branch-owned lanes pass; inherited core-test errors in a file identical to origin/main). Beads: openclaw-fzif
P1 alias-coverage finding fixed at
|
|
🦞🧹 I asked ClawSweeper to review this item again. |
Require output only for declarative model-catalog providers and discovery contributors, not every active provider surface. Preserve first-wins alias canonicalization, prove both regressions through the real worker, and replace synthetic proof rows with an installed-manifest worker run. Validation: 46 focused worker/catalog tests; pnpm tsgo:core; focused oxlint; production-boundary worker proof (151 manifests, 78 scoped plugins, 248 returned rows); pnpm check:changed (all branch-owned lanes pass; inherited core-test errors in a file identical to origin/main). Beads: openclaw-fzif
Both contributor-contract P1s fixed at
|
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Exact-head installed-plugin proof: I ran the real non-read-only prepared runtime and full-catalog worker against the 151 installed bundled manifests. The harness enabled the existing
The sorted provider list is byte-identical before and after ( Redacted exact-head import trace: The baseline trace imported unrelated The shipped Gateway |
|
Thanks @zeroaltitude! Proof: The shipped Gateway
|
) ## What Problem This Solves The off-main-thread prepared model-catalog worker rebuilt an unscoped plugin registry. A full catalog refresh imported unrelated plugin runtimes, paid their cold-load cost, and executed their registration code inside a disposable worker. ## Why This Change Was Made The worker now derives one fail-closed runtime scope from its prepared manifest snapshot. It uses the existing control-plane availability predicate and the existing runtime catalog-augment contract. Static manifest rows and lightweight provider discovery stay on their current paths. Selected provider, harness, memory, and runtime-augment owners still join through the existing runtime load plan. This replaces the earlier parallel eligibility and output-coverage policy. It adds no cache, fallback, configuration, synthetic catalog row, or crash-specific handling. ## User Impact Full model-catalog refreshes keep the same provider and model inventory while loading far fewer plugin runtimes off the main thread. ## Evidence - [Redacted exact-head installed-manifest trace](openclaw#135486 (comment)) - Current main, three cold processes: 83 imports, 35 registrations, 6.56 s median worker latency, and 670 MB median worker RSS growth. - Exact production tree, three cold processes: 4 imports, 1 registration, 4.23 s median worker latency, and 522 MB median worker RSS growth. - Final exact head: 231 rows across the same 45-provider set as current main; named unrelated plugins stayed unloaded. - Regression: the shipped Gateway `models.list` route with `view: "all"` fails on current main because an unrelated plugin executes in its non-read-only prepared worker, then passes on this head while the catalog contributor still returns its runtime row. - Focused validation: 145 worker, catalog, registry, alias, credential, and provider tests passed. - Formatting, focused Oxlint, and all permitted changed-file guards passed. Repository policy leaves local TypeScript typecheck and build to CI on this host. Co-authored-by: Ayaan Zaidi <[email protected]>
Collapses the model-list cleanup (#135912) and the provider-login branch into one change rebased onto main. - models.list reads one closed catalog source (gateway, prepared, published); the CLI `models list` and chat `/models` consume the prepared catalog directly. - Prepared model runtime: owners publish one curated build, live discovery runs only in the catalog worker, and secret-free provider-auth facts captured at build time replace native readiness reobservation and auth-mode flags. - Provider login: one login runtime shared by the CLI, chat `/login`, Telegram, and the Control UI; `openclaw.setup.auth.start` owns interactive sign-in. - First-run setup inference saves the credential, confirms the in-memory candidate with one tool-free turn, and commits config only on success. - xai catalog derives from the manifest; Codex native auth probes the CLI; doctor repairs legacy model refs and session routes. Integration with main: keeps the worker discovery plan (#137063), worker plugin scoping (#135486), auth order and profile identity (#132450, #137022), the plugin-owned Codex/Claude login readers, and the built-artifact preference for setup revalidation (#136036). Drops main's readiness reobservation (#134524) and stale-refresh catalog mode (#136915): the prepared build already carries the provider-auth facts those paths re-derived. Claude-Session: https://claude.ai/code/session_01CnvVXNnjjQGMrBLYjq29RP
What Problem This Solves
The off-main-thread prepared model-catalog worker rebuilt an unscoped plugin registry. A full catalog refresh imported unrelated plugin runtimes, paid their cold-load cost, and executed their registration code inside a disposable worker.
Why This Change Was Made
The worker now derives one fail-closed runtime scope from its prepared manifest snapshot. It uses the existing control-plane availability predicate and the existing runtime catalog-augment contract. Static manifest rows and lightweight provider discovery stay on their current paths. Selected provider, harness, memory, and runtime-augment owners still join through the existing runtime load plan.
This replaces the earlier parallel eligibility and output-coverage policy. It adds no cache, fallback, configuration, synthetic catalog row, or crash-specific handling.
User Impact
Full model-catalog refreshes keep the same provider and model inventory while loading far fewer plugin runtimes off the main thread.
Evidence
models.listroute withview: "all"fails on current main because an unrelated plugin executes in its non-read-only prepared worker, then passes on this head while the catalog contributor still returns its runtime row.