Skip to content

fix(gateway): plugin metadata lifecycle staleness in auth-bypass cache and config reload - #127664

Merged
steipete merged 1 commit into
mainfrom
steipete/frosty-greider-c6dc09
Aug 21, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/frosty-greider-c6dc09

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Two lifecycle-staleness defects surfaced by the plugin-metadata cache audit:

  1. src/gateway/server-http-plugin-auth.ts cached channel-declared HTTP auth-bypass paths in a WeakMap keyed only by config object identity, with no tie to the plugin registry/metadata generation. Replacing a channel plugin's declared bypass contract while the config object identity stayed stable (a metadata-only lifecycle reset) preserved the previous plugin's unauthenticated HTTP route exceptions.
  2. src/gateway/config-reload.ts's notifyPluginMetadataChanged() synchronously clears the process plugin-metadata snapshot slot and install-record caches, then schedules the standard config-diff reload pass. When config bytes are unchanged, that pass took its changedPaths.length === 0 early return, which skips both plugin reload and republishing — leaving the snapshot slot empty so configless readers cold-scan repeatedly and can diverge from the live runtime owners.

Why This Change Was Made

Both are lifecycle-ownership bugs in the plugin-metadata cache/reload path: a cache invalidation seam that every other plugin-derived process memo participates in (registerPluginMetadataProcessMemoLifecycleClear) was missing from the auth-bypass cache, and a signaled metadata-only refresh had no path to actually republish the runtime generation when config bytes matched.

User Impact

  • Gateway HTTP auth: a replaced channel plugin's bypass contract now takes effect immediately instead of leaking the predecessor's unauthenticated route exceptions.
  • Config reload: a metadata-only refresh (e.g. after an install/doctor flow that doesn't touch config bytes) now reliably replaces the plugin runtime generation and republishes the metadata snapshot, instead of leaving the process snapshot slot empty.

Evidence

  • New regression tests added; verified they fail on pre-fix code by temporarily restoring the HEAD versions of both production files and re-running (2 failures), then restoring the fix (green).
  • src/gateway/server-http-plugin-auth.test.ts (new): 4/4 passing, including a test proving a stale failed resolution settling after a lifecycle reset does not evict the fresh cache generation.
  • src/gateway/config-reload.test.ts: 388/388 passing, including the new forced-reload test and a follow-up assertion that the token is consumed (a later identical-bytes watcher echo does not re-trigger a plugin reload).
  • Sibling coverage green: src/channels/plugins/gateway-auth-bypass.test.ts, src/gateway/server-methods/plugins.test.ts.
  • node scripts/check-changed.mjs — format/typecheck/lint/guards — exits 0.
  • autoreview (Codex, gpt-5.6-sol, high effort) on the full uncommitted diff: clean, 0 accepted/actionable findings, confidence 0.96.

…cache and config reload

The gateway HTTP auth-bypass path cache was keyed only by config object
identity, so replacing a channel plugin's declared bypass contract while
config identity stayed stable preserved obsolete unauthenticated HTTP
routes. It now clears on plugin metadata lifecycle resets alongside every
other plugin-derived process memo.

notifyPluginMetadataChanged cleared the process plugin metadata snapshot
slot, but when config bytes were unchanged the config-reload diff took its
early no-op return and skipped both plugin reload and republishing, leaving
the snapshot slot empty so configless readers cold-scanned repeatedly. An
unchanged-bytes metadata signal now forces a plugin-reload plan so the
runtime generation republishes.
@clawsweeper

clawsweeper Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review August 21, 2026 22:23
@steipete
steipete requested a review from a team as a code owner August 21, 2026 22:23
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S maintainer Maintainer-authored PR labels Aug 21, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. 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. labels Aug 21, 2026
@clawsweeper

clawsweeper Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 21, 2026, 6:29 PM ET / 22:29 UTC.

ClawSweeper review

What this changes

This PR invalidates cached plugin HTTP auth-bypass paths on metadata resets and forces a plugin runtime reload when metadata changes but configuration bytes do not.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open: this is a focused, owner-boundary repair for stale Gateway plugin metadata. Source review finds no blocking patch defect; the remaining merge gate is exact-head CI for the security-adjacent runtime reload.

Priority: P1
Reviewed head: 3419ba6e2e8e7e9aa41e5a03cc93a295aa6c704d

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, coherent repair with source-backed owner-boundary coverage; exact-head CI remains the relevant merge gate.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored internal Gateway lifecycle fix is exempt from the external-contributor real-behavior-proof gate; the supplied focused regressions are 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 maintainer-authored internal Gateway lifecycle fix is exempt from the external-contributor real-behavior-proof gate; the supplied focused regressions are supplemental evidence.
Evidence reviewed 5 items Current-main defect: Current main returns through the unchanged-diff path before invoking plugin reload, so a metadata-only notification cannot republish the cleared metadata generation.
Auth cache owner: The patch makes the bypass-path cache generation-local and clears it through the existing plugin-metadata lifecycle hook; stale rejected resolutions only evict their former generation.
Runtime publication path: A forced reload reaches the actual Gateway plugin replacement owner, which publishes a completed metadata snapshot before replacing the attached plugin runtime.
Findings None None.
Security None None.

Live Verification

Command: pnpm openclaw --help

Result: PASS (completed)

pnpm openclaw --help
runner@runnervm76f27:/tmp/clawsweeper-live-proof-127664-tLf3u1/target$ pnpm openclaw --help
$ node scripts/run-node.mjs --help
pnpm openclaw --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 113.33 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.8s
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 12.9s
[plugin-control-plane-loads] verified 35 built modules with native require and checked doctor closures
runtime-postbuild: 10 phases completed in 3845ms (slowest: built plugin control-plane loads 3229ms)

OpenClaw 2026.8.1 (3419ba6) — All your chats, one OpenClaw.

Usage: openclaw [options] [command]

Options:
  --container ‹name›   Run the CLI inside a running Podman/Docker container named ‹name› (default: env OPENCLAW_CONTAINER)
  --dev                Dev profile: isolate state under ~/.openclaw-dev, default gateway port 19001, and shift derived ports (browser/canvas)
  -h, --help           Display help for command
  --log-level ‹level›  Global log level override for file + console
… output truncated …

Assertions:

  • PASS expect_output: OpenClaw

How this fits together

Gateway plugin metadata determines which channel callback routes may bypass Gateway HTTP authentication and feeds the active plugin runtime. A metadata lifecycle reset clears process caches, then the config reloader must replace and republish the matching runtime generation.

flowchart LR
  A[Plugin metadata update] --> B[Lifecycle cache reset]
  B --> C[Gateway config reloader]
  C --> D{Configuration changed?}
  D -->|yes or metadata refresh| E[Plugin runtime replacement]
  D -->|no change| F[No-op reload path]
  E --> G[Published metadata snapshot]
  G --> H[HTTP auth bypass decision]
Loading

Before merge

  • Resolve merge risk (P1) - A metadata-only signal now performs plugin runtime replacement and MCP-runtime disposal; exact-head CI should confirm the replacement path remains healthy under the current base.
  • Resolve merge risk (P1) - Production code grows by 41 net lines for a bug fix. The request/applied generation counters and generation-local cache capture lifecycle ownership and stale-failure safety; no smaller net-neutral owner-boundary refactor is evident from the reviewed paths.
Agent review details

Security

None.

PR surface

Source +41, Tests +134. Total +175 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 50 9 +41
Tests 2 134 0 +134
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 184 9 +175

Review metrics

Metric Value Why it matters
Production versus test LOC production +50/-9 (net +41); tests +134/-0 The added state tracks metadata refresh generations and protects it with focused cache and reloader regressions; the positive production delta is justified by lifecycle ownership but warrants review.

Stored data model

Persistent data-model change detected: persistent cache schema: src/gateway/server-http-plugin-auth.ts, vector/embedding metadata: src/gateway/config-reload.test.ts, vector/embedding metadata: src/gateway/server-http-plugin-auth.test.ts, vector/embedding metadata: src/gateway/server-http-plugin-auth.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Verify the replacement boundary before merge (recommended)
    Require exact-head Gateway checks to cover metadata-only plugin replacement because this path governs unauthenticated callback exceptions and runtime service turnover.
  2. Accept the bounded lifecycle change
    Merge with the focused regression coverage if maintainers accept the normal plugin-reload and MCP-disposal impact of metadata refreshes.

Technical review

Best possible solution:

Retain the shared lifecycle-clear hook and commit-scoped refresh token, then merge only after exact-head Gateway checks confirm the replacement runtime republishes metadata successfully.

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

Yes—current main’s unchanged-diff early return and the uncoupled auth-bypass WeakMap make both failures source-reproducible; the PR adds focused regressions for each path.

Is this the best way to solve the issue?

Yes—the shared metadata lifecycle hook is the correct cache owner, and the existing Gateway reload path is the correct place to republish a metadata-only generation.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P1: A stale plugin contract can preserve unauthenticated Gateway HTTP route exceptions after a metadata replacement.
  • add merge-risk: 🚨 security-boundary: The changed cache governs which plugin HTTP routes skip Gateway authentication.
  • add merge-risk: 🚨 availability: Metadata-only notifications now trigger plugin runtime replacement and MCP-runtime disposal.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored internal Gateway lifecycle fix is exempt from the external-contributor real-behavior-proof gate; the supplied focused regressions are supplemental evidence.

Label justifications:

  • P1: A stale plugin contract can preserve unauthenticated Gateway HTTP route exceptions after a metadata replacement.
  • merge-risk: 🚨 security-boundary: The changed cache governs which plugin HTTP routes skip Gateway authentication.
  • merge-risk: 🚨 availability: Metadata-only notifications now trigger plugin runtime replacement and MCP-runtime disposal.
  • 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 maintainer-authored internal Gateway lifecycle fix is exempt from the external-contributor real-behavior-proof gate; the supplied focused regressions are supplemental evidence.

Evidence

What I checked:

Likely related people:

  • steipete: Authored the published-metadata lifecycle work and this focused follow-up; history shows sustained ownership of Gateway reload and plugin metadata paths. (role: feature owner and recent area contributor; confidence: high; commits: cddc1acdf7f9, 3419ba6e2e8e; files: src/gateway/config-reload.ts, src/gateway/server-http-plugin-auth.ts, src/plugins/plugin-metadata-lifecycle.ts)
  • metaforismo: Previously repaired preservation of restart intent across coalesced Gateway config writes, an adjacent concurrency boundary. (role: adjacent reload-lifecycle contributor; confidence: medium; commits: 1eb038bd43e9; files: src/gateway/config-reload.ts)

Rank-up moves

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

  • Wait for exact-head Gateway checks to complete successfully.

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.

@steipete
steipete merged commit 680001b into main Aug 21, 2026
305 checks passed
@steipete
steipete deleted the steipete/frosty-greider-c6dc09 branch August 21, 2026 22:35
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 22, 2026
…cache and config reload (openclaw#127664)

The gateway HTTP auth-bypass path cache was keyed only by config object
identity, so replacing a channel plugin's declared bypass contract while
config identity stayed stable preserved obsolete unauthenticated HTTP
routes. It now clears on plugin metadata lifecycle resets alongside every
other plugin-derived process memo.

notifyPluginMetadataChanged cleared the process plugin metadata snapshot
slot, but when config bytes were unchanged the config-reload diff took its
early no-op return and skipped both plugin reload and republishing, leaving
the snapshot slot empty so configless readers cold-scanned repeatedly. An
unchanged-bytes metadata signal now forces a plugin-reload plan so the
runtime generation republishes.
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: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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