Repository navigation
fix(plugins): reuse gateway lifecycle metadata and isolate plugin state - #114476
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 27, 2026, 7:31 AM ET / 11:31 UTC. ClawSweeper reviewWhat this changesThis PR reuses stable plugin metadata and native resolver work during gateway startup, clears retained caches when plugin lifecycle state changes, and keeps gateway-owned routes, authorization, session actions, and dashboard capabilities isolated from agent-scoped registries. Merge readiness⛔ Blocked until real behavior proof is added - 6 items remain Keep this PR open for human review. The patch has no concrete source-level blocker in the reviewed decision paths, but it changes process-wide plugin caching, lifecycle invalidation, gateway authorization, session actions, and provider metadata; the supplied body still lacks inspectable after-fix behavior proof, and the protected Priority: P2 Review scores
Verification
How this fits togetherPlugin discovery builds metadata and a runtime registry used by gateway request dispatch, provider selection, session actions, and dashboard capabilities. The gateway should retain its own attached plugin extensions while agent-scoped activation can temporarily replace the active registry for an agent run. flowchart LR
Config[Plugin configuration] --> Discovery[Manifest and install discovery]
Discovery --> Metadata[Plugin metadata snapshot]
Metadata --> Registry[Plugin runtime registry]
Registry --> Gateway[Gateway routes and authorization]
Agents[Agent-scoped activation] --> Active[Active agent registry]
Gateway --> Pinned[Gateway-pinned extensions]
Active --> Pinned
Pinned --> Clients[Sessions, dashboard, providers]
Decision needed
Why: The protected Before merge
Agent review detailsSecurityNone. PR surfaceSource +170, Tests +1844. Total +2014 across 36 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Add redacted after-fix evidence from a real plugin install or reload plus a gateway readiness run that demonstrates cache reuse and correct invalidation, then complete human review of the gateway-pinning behavior against the exact head. Do we have a high-confidence way to reproduce the issue? No high-confidence live reproduction is attached. The source-level regression cases are clear from the added tests: replace the active registry after pinning the gateway registry, or retire plugin metadata and confirm aliases, manifests, and resolver state refresh. Is this the best way to solve the issue? Unclear. Reusing the existing plugin metadata lifecycle is a plausible ownership boundary and the patch adds focused coverage, but the combined cache and gateway-isolation approach needs inspectable real runtime proof before it can be called the best fix. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a62abee4271a. 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 (5 earlier review cycles)
|
|
Exact-head plugin lifecycle proof for Reproducible same-machine production gateway measurementBoth revisions ran on the same fresh 16-vCPU Linux Blacksmith Testbox, using Node OPENCLAW_BUILD_PRIVATE_QA=1 node scripts/build-all.mjs sourcePerformance
node --import tsx scripts/bench-gateway-startup.ts \
--case default --case skipChannels \
--case fiftyPlugins --case fiftyStartupLazyPlugins \
--runs 3 --warmup 1 --timeout-ms 45000
node --import tsx scripts/bench-gateway-startup.ts \
--case fiftyPlugins --case fiftyStartupLazyPlugins \
--runs 1 --warmup 0 --timeout-ms 45000 \
--cpu-prof-dir /tmp/openclaw-plugin-lifecycle-cpu
node --import tsx scripts/bench-gateway-restart.ts \
--case skipChannels --case fiftyPlugins \
--runs 1 --warmup 0 --restarts 3 \
--timeout-ms 45000 --post-ready-delay-ms 250
pnpm dev --profile plugin-lifecycle-audit gateway run \
--port '<ephemeral>' --bind loopback --auth none \
--tailscale off --allow-unconfiguredMedian production startup:
The default end-to-end readiness sample is 16.0% slower; this benchmark includes the separately deferred model-runtime sidecar, which alone takes about 3.8–4.3 seconds. This change therefore does not claim a universal cold-start speedup. The measurable wins are bounded plugin discovery, 8.6% faster 50-plugin lazy startup, 20.3% faster channel-disabled restart recovery, 5.6% faster 50-plugin restart recovery, and correct gateway-generation ownership. Actual three-restart recovery:
Live named development gateway: Lifecycle and security proof
Exact-head gatesAll metadata, resolver, provider, and descriptor caches here are bounded process memory owned by the existing plugin lifecycle. There are no persistent cache files, new SQLite tables, schema-version changes, migrations, new configuration surfaces, or environment variables. |
|
Merged via squash.
|
…te (openclaw#114476) * fix(plugins): reuse gateway metadata and preserve reload isolation * test(plugins): split lifecycle regressions and simplify gateway dispatch * perf(plugins): reuse proven immutable snapshot graphs * test(plugins): isolate snapshot lifecycle regression mocks * perf(plugins): retain one gateway metadata cache * test(plugins): preserve frozen proxy descriptor invariants * test(plugins): isolate lifecycle metadata mock ownership * test(plugins): bind shared worker mocks before module evaluation
* refactor: consolidate command and cron preparation paths Keep one sub-CLI metadata/registration catalog, common cron payload updates, canonical agent migration visitors, and shared account-state projection. Trust typed internal adapters while retaining external validation, effect authority, cancellation settlement, supported migrations and path containment. Wave-5 y10: BELOW-500, 353 net production lines removed (+440/-793 in 19 files). Branch-only handoff for the coordinator's bundle; no standalone PR. Best-effort tradeoffs accepted: - Cron mid-setup reload recovery (#146582): synthetic retirement, no human incident. Setup may fail; the next invocation refreshes the cache. - Recursive shared preparation retry (#102494/#138337): synthetic concurrent callers; production serializes same-job work. Duplicate direct callers may share cancellation. Failed-owner eviction preserves the next sequential run. - Progress publication generation (#143621): synthetic held update/reset. Presentation dedupe may briefly be stale until a subsequent render/reset. - Doctor adapter schema mirror (#69919): malformed synthetic hooks. Invalid executable adapters fail visibly; missing-hook fallbacks and config checks stay. - Setup adapter schema mirror (#165492): typed internal union. Invalid internal adapters fail when used; both supported wizard forms remain. - Injected process schema mirror (#84381): malformed injection was not human SIGTERM report #71710. Invalid adapters fail registration; cancellation stays. - Loaded registry row revalidation/copy (#114942/#158830/#114476): rows already admitted/normalized. Corrupt trusted rows can fail; first-wins authority stays. - Custom compatibility duplicate check (#14223): all callers parse/type it. Hand-crafted invalid JS uses the default branch; external flags still reject it. - Log probe identity matching (#88159, superseded by #168587): abort now joins the sole probe, so replacement cannot race its result. Recovery/settlement stay. - Whole-config deep copy (#71218): no detached-copy incident. Structural copy updates agents/defaults; unrelated future mutation must respect config ownership. - Repeated plugin-root probes (#70012): no disappearing-root incident. Resolve roots once; root replacement can fail discovery. Symlink containment stays. - Second payload getter read (#135319): synthetic review/corpus, not a human report. Ordinary decoded records are read once; stateful accessors may differ. Proof: fresh independent review clean; core types, targeted lint/format, runtime and static cycles, assertion/line-cap ratchets, and suppression suite passed. Focused CLI cohort: 8 files / 41 tests passed. Earlier unchanged account/setup and cold-import checks passed. Cron and commands cohorts were interrupted after partial results; complete owner tests, payload merging, test-graph types, broad check-changed and build/smoke remain unproved at commit preparation. Unattributed local 120-second timeouts retained: two root-command-descriptions catalog cases and agent-via-gateway's Gateway attempt-budget case. No timeout, retry, skip or kept-behavior expectation changes. Env-name budget mismatch (455 vs 454) also exists at original HEAD and pinned main 7dccff5. All runtime proof used isolated HOME/OpenClaw/XDG state; Phase E untouched. * refactor: consolidate cron payload and lazy CLI paths Share daemon and cron method forwarding through the existing lazy binder, remove the cron CLI reexport shim, and consolidate normalization and merge handling without changing public fields, explicit clears, or effect authority. Remove the obsolete bundled discovery reentry mechanism and impossible Doctor issue helper. The full lane now removes 475 net production lines. Best-effort tradeoffs accepted: - Unknown Doctor issue variants supplied by hand-crafted JavaScript return the invalid value rather than a custom error. Typed local producers and exhaustive switches remain; reporting feature #95979 cites no human unknown-kind incident. - Synchronous bundled-module self-discovery may fail through the existing loader diagnostic instead of returning empty inventory. Commit 65f18d6 only pins injected Jiti reentry, not a human incident; ordinary caches remain. - Cron defaults trust staggerMs normalized earlier in the same synchronous call. No await or mutation boundary intervenes; externally supplied invalid values remain rejected by the normalizer. * fix(channels): retain replacement preview deduplication Withdraw the progress compositor generation removal after the Mattermost retiring-publication case failed CI and bounded serial head/base replays remained inconclusive under load. Restore that file exactly to the branch base and keep all Mattermost tests unchanged, following the campaign fallback. Prune the single obsolete mock-export allowance left by the removed bundled discovery reentry fixture. The local mock ratchet passes with 9586 factories. The remaining lane reduction is 471 net production lines across 25 paths.
…#173036) * refactor: consolidate command and cron preparation paths Keep one sub-CLI metadata/registration catalog, common cron payload updates, canonical agent migration visitors, and shared account-state projection. Trust typed internal adapters while retaining external validation, effect authority, cancellation settlement, supported migrations and path containment. Wave-5 y10: BELOW-500, 353 net production lines removed (+440/-793 in 19 files). Branch-only handoff for the coordinator's bundle; no standalone PR. Best-effort tradeoffs accepted: - Cron mid-setup reload recovery (openclaw#146582): synthetic retirement, no human incident. Setup may fail; the next invocation refreshes the cache. - Recursive shared preparation retry (openclaw#102494/openclaw#138337): synthetic concurrent callers; production serializes same-job work. Duplicate direct callers may share cancellation. Failed-owner eviction preserves the next sequential run. - Progress publication generation (openclaw#143621): synthetic held update/reset. Presentation dedupe may briefly be stale until a subsequent render/reset. - Doctor adapter schema mirror (openclaw#69919): malformed synthetic hooks. Invalid executable adapters fail visibly; missing-hook fallbacks and config checks stay. - Setup adapter schema mirror (openclaw#165492): typed internal union. Invalid internal adapters fail when used; both supported wizard forms remain. - Injected process schema mirror (openclaw#84381): malformed injection was not human SIGTERM report openclaw#71710. Invalid adapters fail registration; cancellation stays. - Loaded registry row revalidation/copy (openclaw#114942/openclaw#158830/openclaw#114476): rows already admitted/normalized. Corrupt trusted rows can fail; first-wins authority stays. - Custom compatibility duplicate check (openclaw#14223): all callers parse/type it. Hand-crafted invalid JS uses the default branch; external flags still reject it. - Log probe identity matching (openclaw#88159, superseded by openclaw#168587): abort now joins the sole probe, so replacement cannot race its result. Recovery/settlement stay. - Whole-config deep copy (openclaw#71218): no detached-copy incident. Structural copy updates agents/defaults; unrelated future mutation must respect config ownership. - Repeated plugin-root probes (openclaw#70012): no disappearing-root incident. Resolve roots once; root replacement can fail discovery. Symlink containment stays. - Second payload getter read (openclaw#135319): synthetic review/corpus, not a human report. Ordinary decoded records are read once; stateful accessors may differ. Proof: fresh independent review clean; core types, targeted lint/format, runtime and static cycles, assertion/line-cap ratchets, and suppression suite passed. Focused CLI cohort: 8 files / 41 tests passed. Earlier unchanged account/setup and cold-import checks passed. Cron and commands cohorts were interrupted after partial results; complete owner tests, payload merging, test-graph types, broad check-changed and build/smoke remain unproved at commit preparation. Unattributed local 120-second timeouts retained: two root-command-descriptions catalog cases and agent-via-gateway's Gateway attempt-budget case. No timeout, retry, skip or kept-behavior expectation changes. Env-name budget mismatch (455 vs 454) also exists at original HEAD and pinned main 89f8219. All runtime proof used isolated HOME/OpenClaw/XDG state; Phase E untouched. * refactor: consolidate cron payload and lazy CLI paths Share daemon and cron method forwarding through the existing lazy binder, remove the cron CLI reexport shim, and consolidate normalization and merge handling without changing public fields, explicit clears, or effect authority. Remove the obsolete bundled discovery reentry mechanism and impossible Doctor issue helper. The full lane now removes 475 net production lines. Best-effort tradeoffs accepted: - Unknown Doctor issue variants supplied by hand-crafted JavaScript return the invalid value rather than a custom error. Typed local producers and exhaustive switches remain; reporting feature openclaw#95979 cites no human unknown-kind incident. - Synchronous bundled-module self-discovery may fail through the existing loader diagnostic instead of returning empty inventory. Commit ca10460 only pins injected Jiti reentry, not a human incident; ordinary caches remain. - Cron defaults trust staggerMs normalized earlier in the same synchronous call. No await or mutation boundary intervenes; externally supplied invalid values remain rejected by the normalizer. * fix(channels): retain replacement preview deduplication Withdraw the progress compositor generation removal after the Mattermost retiring-publication case failed CI and bounded serial head/base replays remained inconclusive under load. Restore that file exactly to the branch base and keep all Mattermost tests unchanged, following the campaign fallback. Prune the single obsolete mock-export allowance left by the removed bundled discovery reentry fixture. The local mock ratchet passes with 9586 factories. The remaining lane reduction is 471 net production lines across 25 paths.
What Problem This Solves
The gateway repeatedly rediscovered installed plugins, rescanned native SDK aliases, rebuilt provider metadata, and reused a few plugin-derived values outside the gateway lifecycle that actually owns them. Agent-scoped registry activation could also incorrectly change gateway-owned RPC authorization, session actions, board grants, and handler dispatch.
Design and Compatibility
Map,Set, accessor, cycle, andProxygraphs, and exposeplugins.metadata.freezeas its own diagnostic span. Real V8 measurements rejected an additional deep-freeze cache, so this change deliberately keeps one lifecycle-owned metadata cache rather than introducing a second one.Same-Machine Gateway Performance
Baseline
08b1ff73e2f35ef02eb5530d700f017f44c974b4; PR67bb8be275955addb1e65af8700215f11840d222. Both revisions were built and measured on the same 16-vCPU Linux Blacksmith Testbox with the pinned Node 24 and pnpm 11 toolchain. Each productiondist/entry.jsstartup case used one warmup and the median of three measured runs./readyz/readyzThe default end-to-end readiness sample is 16.0% slower; this benchmark includes the separately deferred model-runtime sidecar, which alone takes about 3.8–4.3 seconds. This change therefore does not claim a universal cold-start speedup. The measurable wins are bounded plugin discovery, 8.6% faster 50-plugin lazy startup, 20.3% faster channel-disabled restart recovery, 5.6% faster 50-plugin restart recovery, and correct gateway-generation ownership.
Actual process restarts used the same production gateway, three restarts per case, and zero failed readiness probes.
/readyzrecovery/readyzrecoveryThe final revision was additionally verified with real V8 CPU profiles and
pnpm dev --profile plugin-lifecycle-audit gateway run, including a successful live/readyzrequest.Validation
node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core-test.tsbuildinfo.pnpm plugin-sdk:surface:check: all 142 public SDK entrypoints.pnpm buildand private-QA gateway source-performance build.AI
AI-assisted implementation and review. Findings were verified against complete owner modules, gateway entry points, callers, sibling implementations, upstream loader behavior, security boundaries, focused regression tests, and actual production gateway measurements.