Repository navigation
fix(gateway): plugin metadata lifecycle staleness in auth-bypass cache and config reload - #127664
Conversation
…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.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 21, 2026, 6:29 PM ET / 22:29 UTC. ClawSweeper reviewWhat this changesThis 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 provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessKeep 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 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherGateway 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]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +41, Tests +134. Total +175 across 4 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest 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. LabelsLabel changes:
Label 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
|
|
Merged via squash.
|
…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.
What Problem This Solves
Two lifecycle-staleness defects surfaced by the plugin-metadata cache audit:
src/gateway/server-http-plugin-auth.tscached channel-declared HTTP auth-bypass paths in aWeakMapkeyed 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.src/gateway/config-reload.ts'snotifyPluginMetadataChanged()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 itschangedPaths.length === 0early 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
Evidence
HEADversions 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).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.