Repository navigation
fix: reuse plugin captures during model catalog refresh - #153041
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 19, 2026, 2:25 PM ET / 18:25 UTC (Revision 2). ClawSweeper reviewWhat this changesKeeps final model normalization within the catalog’s selected plugin generation and adds regression checks for capture reuse and discovered model routes. Merge readiness✅ Ready for maintainer review The fix remains necessary on current main. No actionable introduced defects were found; the patch addresses the traced allocation path without expanding capture ownership or cleanup policy. Priority: P1 Review scores
Verification
How this fits togetherGateway catalog workers combine agent credentials and plugin discovery into available model inventories. Provider normalization determines the executable model routes returned to the Gateway. flowchart TD
A[Agent credentials and configuration] --> B[Catalog worker]
C[Captured plugin generation] --> B
B --> D[Provider discovery]
D --> E[Normalize models within selected generation]
C --> E
E --> F[Gateway model inventory]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +4, Tests +23. Total +27 across 4 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Use the existing selected generation for final normalization while preserving inventory-owned captures and task-local credentials. Do we have a high-confidence way to reproduce the issue? Yes, source establishes the unscoped lazy-normalization path, and the submitted worker regression reports a before/after allocation difference. This review did not execute a current-main reproduction. Is this the best way to solve the issue? Yes. Restoring the existing generation scope at the escaping read is a narrow repair that avoids another cache or capture-deletion policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 1e8ba48c32a8. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Fixed: model catalog refreshes reuse the selected plugin generation's captured source files. |
|
🦞 Confirming the pre-fix symptoms on 2026.9.5: the catalog worker copied Codex dependencies at about 95% of one CPU core and retained 5 GiB in scratch storage; this fix is not yet deployed here. |
) Reuse the selected plugin generation during final model catalog normalization so repeated refreshes do not create duplicate source captures. Refs openclaw#152689.
…l generation The parentPort branch in prepared-model-catalog.worker.ts retained every distinct PluginRegistry it ever produced (retainedRegistries: Set<...>) and called discardPreparedPluginGeneration in finally. On abnormal worker lifecycle events (crash, SIGKILL, restartOnError, pool teardown failure) the scratch tree rooted at data.sourceCaptureDirectory survived across all retained registries — each openclaw-model-catalog-* dir holds dozens to hundreds of openclaw-plugin-build-* captures and never gets reclaimed. Replace the Set with a single 'current' slot keyed on generationFingerprint. A replacement acquisition is held in 'attempted' until the run commits an 'ok' result, then swapped into 'current'; the previous generation is released only after the swap holds. Failed acquisitions never enter the retained slot, so request floods cannot pile scratch-tree captures. Also wrap facts.templateModelRegistry.getAll() in withPluginRuntimeGenerationScope so lazy normalization keeps provider hooks on the selected catalog generation. Adapted from openclaw#153038 and openclaw#153041. The fork diverges from upstream by ~4,950 commits at this base, so a direct cherry-pick would require resolving conflicts in seven files across two PRs plus introducing retainPreparedPluginRegistry and a WorkerGeneration.discovery slot that this fork does not need (loadAgentRuntimePluginRegistryHandle already binds synchronously inside the request scope). Docs: docs/fork/2026.9.5-catalog-tmp-leak-bound-captures.md No public API changes. Worker-thread internal lifecycle only. Refs: openclaw#153038, openclaw#153041 DELEG-REF: catalog-tmp-leak-bound-captures-2026-09-22
Refs #152689
What Problem This Solves
Repeated model catalog refreshes for multiple agents can create additional copies of the same plugin source. The loader's lookup cache is bounded, but earlier captures remain available to their live inventory. Cycling enough workspace/provider combinations therefore keeps adding copies and can exhaust constrained temporary storage.
User Impact
Final model normalization reuses the plugin generation already selected for the catalog request. It keeps the source files required by that generation available and continues publishing executable models discovered through refreshed credentials. The updated Gateway uses this repair when its catalog workers start. No configuration change or migration is required.
This addresses the duplicate-loading path in the reported storage growth. The separate Codex closed-client warning and the size of legitimate initial plugin captures are outside this contribution.
Why This Change Was Made
The model registry normalizes provider models and transports lazily in
getAll(). Catalog preparation ran inside the selected generation, but this final read happened after that scope had ended. Provider hooks could consequently fall back to loading another registry for each workspace.The worker now performs that read inside its existing
pluginGenerationScope, which already contains any registry selected by widened discovery. The change adds no cache, lifetime owner, or capture deletion policy. It follows zl0nline's allocation trace, independently reproduced through the actual worker path.Evidence
Validated on
a7932939c0ba:21b9d735160f, then one with this change, including forced refreshes. Source-version and per-agent credential assertions remain in place.[email protected]updater successfully installed the frozen candidate in thecustom-plugin-siblingsscenario. Actual Doctor and private Gateway-canary executions loaded the plugin, its original source and enablement were preserved, and all 10,261 application payload files matched the candidate. This cell used--no-restart; it does not claim a managed-service restart.Hosted CI reported a speech-to-music fixture cleanup failure also reproduced on the unchanged base. The aggregate CI/security-review gates reflect that result. The separate repair, #153064, is merged; this contribution's checks and behavior passed independently.
The additional all-release generated-artifact check reported UI/native locale drift on unchanged inputs. Its failed result is retained separately; package integrity and the installed-updater check passed.