Skip to content

perf(plugins): reuse lifecycle metadata on secrets hot paths - #126629

Merged
steipete merged 1 commit into
mainfrom
steipete/plugin-metadata-hotlane
Aug 21, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/plugin-metadata-hotlane

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

One secrets prepare call (prepareSecretsRuntimeSnapshot → resolveRuntimeWebTools) with a keyless external web-search provider config re-scanned all 148 bundled plugin manifests up to 16 times — ~2,368 manifest opens, ~2.1s per call on an M3 Ultra, and warm calls stayed just as slow. The cost repeated on every prepare/refresh even though the gateway publishes a complete, lifecycle-owned plugin metadata snapshot at startup.

This is also the root-cause answer to the downstream ask in #107155 (Microsoft Lobster patch 0003): keyless host-proxied web search stays fast without any new config key (omitAuth), manifest field, or fast-path carve-out.

Why This Change Was Made

The published snapshot cache was missed on the key, not bypassed by import: web-provider discovery mints bundled-compat activation configs (rewritten plugins.allow/entries[].enabled) whose policy hash never matches; loadManifestMetadataSnapshot minted config ?? {}, turning configless readers into incompatible explicit-policy readers; hot reload published a narrower compatibility envelope than startup; and the manifest-contract lane rebuilt registries outside the snapshot entirely.

The fix follows the repo doctrine "hot paths carry prepared facts forward": thread the prepared manifest registry through all web-provider discovery lanes (pattern copied from providers.runtime.ts), use the original config for snapshot lookups with activation applied as a projection, pass undefined config through as a configless default-context read, and publish the same compatibility envelope on hot reload as on startup.

User Impact

Gateway secrets preparation with any web-search/web-fetch config gets dramatically cheaper: zero plugin-manifest disk opens per prepare when the published snapshot is live (was 1,332–2,368), and CLI-style processes without a published snapshot drop from ~1.3s to ~0.25s per warm call (one scan instead of sixteen). No config surface changes; no behavior changes to provider selection, credential resolution, or SSRF/cache policy.

Evidence

  • fs-counting regression test asserts zero openclaw.plugin.json opens during a warm prepare with a published snapshot and a keyless external provider config (src/secrets/runtime.fast-path.test.ts)
  • Gateway reload regression proves the restored compatibility envelope (src/gateway/server-reload-handlers.test.ts)
  • 256 targeted tests + check:changed green; measured 20.5× (210ms → 10.3ms) warm prepare in-harness, 1,332 → 0 manifest opens
  • Autoreview (Codex/gpt-5.6-sol, high): "patch is correct (0.97), no P0"
  • Production LOC +181/−40; tests +201/−29

@clawsweeper

clawsweeper Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: M maintainer Maintainer-authored PR labels Aug 20, 2026
@steipete
steipete marked this pull request as ready for review August 20, 2026 09:57
@steipete
steipete requested a review from a team as a code owner August 20, 2026 09:57
@clawsweeper clawsweeper Bot added 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. P2 Normal backlog priority with limited blast radius. labels Aug 20, 2026
@clawsweeper

clawsweeper Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 20, 2026, 12:35 PM ET / 16:35 UTC.

ClawSweeper review

What this changes

The PR passes gateway-prepared plugin manifest metadata through secrets and web-provider discovery so repeated preparation avoids rereading plugin manifests.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open. Current main does not contain this branch’s manifest-record threading, and the reviewed patch has no discrete correctness finding; it needs a clean rebase/exact-head validation before maintainer landing.

Priority: P2
Reviewed head: e080fe22eb6d8d61895b1387ec7d55b79f08dd7f

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is a coherent lifecycle-metadata reuse change with focused regression coverage; final confidence depends on its exact merge result and pending checks.
Proof confidence 🌊 off-meta tidepool Not applicable: This is a maintainer-authored PR, so the external-contributor proof gate does not apply; its reported benchmark and focused tests remain useful supplemental evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This is a maintainer-authored PR, so the external-contributor proof gate does not apply; its reported benchmark and focused tests remain useful supplemental evidence.
Evidence reviewed 7 items Prepared metadata reaches runtime loading: The branch derives candidates from original configuration, carries prepared manifest records, and supplies them to the runtime plugin-load options.
Secrets callers cover search and fetch paths: Both bundled web-search and web-fetch fallback paths now pass the resolver context’s manifest records into provider resolution.
Reload ownership remains in the current gateway path: The managed reload path supplies source configuration and commits through its transaction-owned publication callback, so this PR should preserve that ownership during a rebase.
Findings None None.
Security None None.

Live Verification

Command: pnpm openclaw gateway --help

Result: PASS (completed)

pnpm openclaw gateway --help
runner@runnervm76f27:/tmp/clawsweeper-live-proof-126629-M2yfff/target$ pnpm openclaw gateway --help
$ node scripts/run-node.mjs gateway --help
pnpm openclaw gateway --help
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 100.17 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.7s
node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

[tsdown-build] invocation 2/2 finished in 13.9s
[plugin-control-plane-loads] verified 35 built modules with native require and checked doctor closures
runtime-postbuild: 10 phases completed in 4861ms (slowest: built plugin control-plane loads 3457ms)
│
◇

OpenClaw 2026.8.1 (e080fe2) — All your chats, one OpenClaw.

Usage: openclaw gateway [options] [command]

Run, inspect, and query the WebSocket Gateway

Options:
  --allow-unconfigured      Allow gateway start without enforcing gateway.mode=local in config (does not repair config) (default: false)
  --ambient-channels        Allow the gateway to auto-configure channels from ambient environment variables (default: false)
  --auth ‹mode›            
… output truncated …

Assertions:

  • PASS expect_output: Usage:

How this fits together

Gateway startup and reload prepare plugin metadata, then secrets preparation resolves web-search and web-fetch providers before the runtime uses them. The change reuses that lifecycle-owned metadata across provider discovery instead of repeatedly scanning plugin manifests.

flowchart LR
  A[Gateway startup or reload] --> B[Prepared plugin metadata]
  B --> C[Secrets preparation]
  C --> D[Web provider discovery]
  D --> E[Resolved providers and credentials]
Loading

Before merge

  • Resolve merge risk (P1) - The branch is behind current main and checks are still incomplete; the final merge result must retain the transaction-owned reload publication path that carries source configuration.
  • Resolve merge risk (P1) - Production changes are net +137 lines across compatibility-sensitive plugin discovery and provider resolution; the added plumbing is coherent, but it merits exact-head validation of allowlist, disablement, and reload behavior.
  • Complete next step (P2) - No repair job is warranted: this maintainer-owned PR has no actionable review finding and needs normal exact-head merge validation.
Agent review details

Security

None.

PR surface

Source +137, Tests +172. Total +309 across 19 files.

View PR surface stats
Area Files Added Removed Net
Source 14 177 40 +137
Tests 5 201 29 +172
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 19 378 69 +309

Review metrics

Metric Value Why it matters
Production versus test delta production +177/-40; tests +201/-29 The net production growth threads an existing lifecycle fact through discovery and runtime adapters; tests materially cover snapshot reuse and reload compatibility.

Stored data model

Persistent data-model change detected: vector/embedding metadata: src/plugins/plugin-registry-contributions.ts, vector/embedding metadata: src/plugins/web-provider-resolution-shared.ts, vector/embedding metadata: src/secrets/runtime.fast-path.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Refresh the merge result and validate lifecycle behavior (recommended)
    Rebase or inspect GitHub’s clean merge result, then run exact-head targeted tests and the required build/profile checks so reload ownership and plugin activation remain unchanged.

Technical review

Best possible solution:

Rebase onto current main, retain the managed reload publication boundary, and land only after exact-head checks confirm prepared metadata reuse without changing provider activation or SecretRef policy.

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

Yes, source-reproducible: the branch adds a focused manifest-open regression harness for a published snapshot, although this read-only review did not execute it.

Is this the best way to solve the issue?

Yes, conditionally: forwarding lifecycle-owned metadata through the existing provider paths is the canonical fix, provided the clean merge preserves reload-generation ownership.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 7975432eb525.

Labels

Label justifications:

  • P2: This is a bounded gateway preparation performance repair without evidence of an urgent outage.
  • merge-risk: 🚨 compatibility: The patch changes plugin activation and metadata selection during existing startup and reload provider discovery.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This is a maintainer-authored PR, so the external-contributor proof gate does not apply; its reported benchmark and focused tests remain useful supplemental evidence.

Evidence

What I checked:

Likely related people:

  • steipete: Recent history shows sustained work on plugin metadata, web-provider resolution, secrets, and gateway reload behavior, including this branch. (role: recent area contributor; confidence: high; commits: e080fe22eb6d, fd216cb5509e, a59abcf4a8e7; files: src/plugins/web-provider-runtime-shared.ts, src/plugins/web-provider-resolution-shared.ts, src/secrets/runtime-web-tools.ts)
  • vincentkoc: History credits Vincent Koc for web-fetch fallback performance and plugin-registry work that this change extends. (role: earlier web-provider performance contributor; confidence: medium; commits: 2f6459093ad3, 8283c5d6cc3f; files: src/plugins/web-provider-runtime-shared.ts, src/secrets/runtime-web-tools.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Validate the rebased exact head with the focused secrets/plugin tests and the required build or profiling checks.

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 (2 earlier review cycles)
  • reviewed 2026-08-20T10:04:09.419Z sha 922a00b :: needs maintainer review before merge. :: none
  • reviewed 2026-08-20T10:35:26.841Z sha 922a00b :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Aug 20, 2026
@steipete
steipete force-pushed the steipete/plugin-metadata-hotlane branch from 922a00b to e080fe2 Compare August 20, 2026 16:29
@steipete
steipete force-pushed the steipete/plugin-metadata-hotlane branch from e080fe2 to 3762c1b Compare August 21, 2026 17:43
@steipete
steipete merged commit 8a7bb5d into main Aug 21, 2026
225 checks passed
@steipete
steipete deleted the steipete/plugin-metadata-hotlane branch August 21, 2026 17:57
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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