Repository navigation
fix(gateway): Gateway rescans plugin files after sign-in, sign-out or config changes - #174860
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. What this changesThis PR makes Gateway reload work use the published plugin inventory after committing configuration or plugin changes. Example: A sign-out triggers configuration reload and cron reconciliation.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR fixes a remaining post-commit metadata rescan on current main, preserves management isolation, and has no actionable code findings. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe plugin lifecycle lease gives management operations fresh metadata; Gateway publication selects the runtime inventory consumed by cron, model, skills, and channel owners. flowchart TD
A[Configuration or plugin change] --> B[Lifecycle lease]
B --> C[Fresh management cache]
C --> D[Runtime commit and inventory publication]
D --> E[Leave temporary cache scope]
E --> F[Published plugin inventory]
F --> G[Cron models skills and channels]
Technical reviewBest possible solution: Land the focused cache-scope fix through normal merge gates while retaining fresh pre-commit management reads. Do we have a high-confidence way to reproduce the issue? Source confirms that the lifecycle lease installs an operation cache which prevents post-commit readers from selecting Gateway metadata; the supplied regression and packaged Gateway report match that path, but no target code was executed during this read-only review. Is this the best way to solve the issue? The change fixes cache ownership at existing commit boundaries instead of threading snapshot arguments through every reader, while preserving lease authority and preparation isolation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against dbb6b191e995. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +36, Tests +100, Docs +2, Other -1. Total +137 across 9 files. Added test files: 1. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed October 16, 2026, 11:23 PM ET / October 17, 2026, 03:23 UTC (Revision 2). |
…ventory Config hot reload holds the plugin lifecycle lease, which carries a fresh operation plugin cache so management reads see other processes' commits. Gateway runtime work after the commit inherited that cache through AsyncLocalStorage: commit listeners, cron reconciliation, the prepared model runtime refresh, skills discovery and channel owners started by the reload could not see the published inventory and reloaded plugin metadata from disk. runAfterPluginLifecycleCommit leaves the lease's cache scope at each transaction owner's commit edge, after the new metadata is published. Work before the commit keeps the operation cache.
f673436 to
8253dec
Compare
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed in a5dee9e. Bug: config reload runs inside the plugin lifecycle lease, whose fresh operation cache leaked into work after the commit. Cron, model-runtime refresh, skills discovery and channels started by the reload could not see the published plugin inventory and reloaded plugin metadata from disk. Fix: Proof: new regression test (real lease, cron auth-alias reader after commit, no metadata load; fails without the fix), packaged-Gateway trace (19 post-commit skills-root rescans to 0), green CI and ClawSweeper |
… config changes (openclaw#174860) Related: openclaw#173626, openclaw#169562 ## What Problem This Solves Fixes: after a config change, sign-in, sign-out or key removal, Gateway work that runs after the change is applied reloads plugin metadata from disk instead of using the inventory the Gateway just published. ## User Impact User impact: config reloads no longer rescan plugin files for cron reconciliation, model-runtime refresh, skills discovery or channels started by the reload. This keeps the Gateway event loop free for `models.list` and other requests during these events. No behavior change for plugin install, update or doctor flows. ## Why This Change Was Made Config hot reload runs inside `withPluginLifecycleLease`. The lease carries a fresh operation `PluginCache` through AsyncLocalStorage, so management reads see commits from other processes. Everything after the runtime commit inherited that cache too. `getGatewayPluginMetadataSnapshot()` only answers for the process cache, so post-commit readers (`resolveProviderIdForAuth` from cron job loading, model-id normalization, skills discovery capture, channel owners started by the reload) found no snapshot and reloaded metadata from disk. Long-lived owners started there also held a cache that the lease retires on release. openclaw#173626 fixed the two hottest readers by passing the published snapshot explicitly (the openclaw#169562 pattern). This change fixes the owner: `runAfterPluginLifecycleCommit` (in `plugin-lifecycle-lease.ts`) leaves the lease's cache scope at each transaction owner's commit edge, after the new metadata is published: - `config-reload.ts`: `onRuntimeConfigCommitted`, `onConfigApplied`, and `notifyCommitted` (config.changed broadcast, skills discovery refresh). - `server-reload-hot.ts`: the cron drain, reconcile and start after commit, and the rest of the hot reload after commit (prepared model runtime refresh, MCP disposal, Gmail watcher, channel restarts, context windows). - `server-reload-managed-secrets.ts`: committed runtime policy reconcile. - `server-plugin-reload.ts`: the post-publication tail (memory and sidecar resume, lifecycle hooks, `startPublishedChannels`). Work before the commit keeps the operation cache: config validation, install records, secrets preparation and plugin preflight still see other processes' commits. No management read runs after the commit. The cache-boundary docs gain one sentence. ## Evidence - New regression test `server-reload-hot.published-plugin-metadata.test.ts`: real lifecycle lease, a published Gateway snapshot with a provider auth alias, and cron `reconcileSystemJobs` calling `resolveProviderIdForAuth` after the commit. It asserts the commit still runs in the operation cache, the alias resolves from the published snapshot, and `loadPluginMetadataSnapshot` is not called. Without the fix it fails: the reader loads empty metadata from disk and returns `fixture-alias`. - Focused local suites (config reload, lease retry, reload handlers, operator model policy, plugin reload, lifecycle lease): 400 pass. 7 cases in `server-plugin-reload.recovery.test.ts` fail locally; the identical set fails on the base head without this change. - Packaged-layout Gateway bench (sign-in, sign-out, key removal, plugin reload, settings change), with load tracing: the 19 post-commit skills-root rescans on the base drop to 0. The remaining loads are config-write validation before the commit (management, unchanged). - Main-thread CPU profiles, 4 interleaved runs: fix runs show no post-commit metadata loads. One base run spent 0.57 s there (model-id normalization and cron `describeCronInferenceMigration` → `resolveProviderIdForAuth`). Lag numbers were too noisy on the loaded host to report. Simplification: one helper owned by the lease module and applied at four commit edges; no new state. openclaw#173626's explicit snapshot inputs stay; they are harmless explicit parameters and can be removed separately. Production delta: +50/-8 lines ignoring re-indentation; one test file. Co-authored-by: Ayaan Zaidi <[email protected]>
Related: #173626, #169562
What Problem This Solves
Fixes: after a config change, sign-in, sign-out or key removal, Gateway work that runs after the change is applied reloads plugin metadata from disk instead of using the inventory the Gateway just published.
User Impact
User impact: config reloads no longer rescan plugin files for cron reconciliation, model-runtime refresh, skills discovery or channels started by the reload. This keeps the Gateway event loop free for
models.listand other requests during these events. No behavior change for plugin install, update or doctor flows.Why This Change Was Made
Config hot reload runs inside
withPluginLifecycleLease. The lease carries a fresh operationPluginCachethrough AsyncLocalStorage, so management reads see commits from other processes. Everything after the runtime commit inherited that cache too.getGatewayPluginMetadataSnapshot()only answers for the process cache, so post-commit readers (resolveProviderIdForAuthfrom cron job loading, model-id normalization, skills discovery capture, channel owners started by the reload) found no snapshot and reloaded metadata from disk. Long-lived owners started there also held a cache that the lease retires on release.#173626 fixed the two hottest readers by passing the published snapshot explicitly (the #169562 pattern). This change fixes the owner:
runAfterPluginLifecycleCommit(inplugin-lifecycle-lease.ts) leaves the lease's cache scope at each transaction owner's commit edge, after the new metadata is published:config-reload.ts:onRuntimeConfigCommitted,onConfigApplied, andnotifyCommitted(config.changed broadcast, skills discovery refresh).server-reload-hot.ts: the cron drain, reconcile and start after commit, and the rest of the hot reload after commit (prepared model runtime refresh, MCP disposal, Gmail watcher, channel restarts, context windows).server-reload-managed-secrets.ts: committed runtime policy reconcile.server-plugin-reload.ts: the post-publication tail (memory and sidecar resume, lifecycle hooks,startPublishedChannels).Work before the commit keeps the operation cache: config validation, install records, secrets preparation and plugin preflight still see other processes' commits. No management read runs after the commit. The cache-boundary docs gain one sentence.
Evidence
server-reload-hot.published-plugin-metadata.test.ts: real lifecycle lease, a published Gateway snapshot with a provider auth alias, and cronreconcileSystemJobscallingresolveProviderIdForAuthafter the commit. It asserts the commit still runs in the operation cache, the alias resolves from the published snapshot, andloadPluginMetadataSnapshotis not called. Without the fix it fails: the reader loads empty metadata from disk and returnsfixture-alias.server-plugin-reload.recovery.test.tsfail locally; the identical set fails on the base head without this change.describeCronInferenceMigration→resolveProviderIdForAuth). Lag numbers were too noisy on the loaded host to report.Simplification: one helper owned by the lease module and applied at four commit edges; no new state. #173626's explicit snapshot inputs stay; they are harmless explicit parameters and can be removed separately. Production delta: +50/-8 lines ignoring re-indentation; one test file.