Skip to content

fix(plugins): honor provider runtime cache invalidation - #139908

Merged
steipete merged 1 commit into
mainfrom
codex/plugin-provider-hook-owner
Sep 6, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/plugin-provider-hook-owner

Conversation

@steipete

@steipete steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Resolves a problem where provider preparation could keep selecting old plugin hooks after runtime discovery was explicitly refreshed, when the plugin kept the same ID and configuration. Updating the package entry could leave auth or model behavior attached to the previous owner.

Why This Change Was Made

The registry loader now owns provider lookup reuse, so its existing invalidation also governs subsequent hook selection. This removes duplicate config/default caches and their unused helper while preserving prepared-generation, loaded-registry, alias and model-owner selection. Production code decreases by 151 lines.

User Impact

Unprepared provider lookups follow refreshed metadata after runtime-discovery invalidation. Existing prepared handles and generations retain their selected provider, with current context supplied to each hook call.

Evidence

  • Both config/default regression cases failed on the original code after the actual runtime invalidation boundary; 107 tests across four owner/sibling suites pass after the change.
  • A real generated-provider filesystem probe reproduced stale selection on the original code. The candidate refreshes a same-ID package entry through the existing metadata/registry owners without changing the root generation. Repeated lookups produce exactly two registrations across two entries; five hook effects prove refreshed selection, prepared owner retention and current profile-selection input. Empty generation remains authoritative.
  • Full changed-file checks and independent P2 review passed, including production/test typechecks, typed lint, dead exports and import-cycle guards.

The filesystem probe uses synthetic local state and profile identifiers. It does not claim Gateway reload, external authentication/inference, or new callback-revocation behavior.

Related: #135599. This is an independently landable provider-owner cleanup from that lifecycle work.

Use the canonical registry loader cache for unprepared provider hook lookup. Remove duplicate config/default caches that retained old hook owners after explicit runtime discovery invalidation, along with their unused synchronous config-cache helper.

Preserve prepared generation and loaded registry precedence, alias/model ownership, and current per-call profile context. Production LOC: -151. Verified 107 owner/sibling tests, real generated-provider filesystem RED and GREEN, the complete changed-file gate, and independent P2 review.
@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: M maintainer Maintainer-authored PR labels Sep 6, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 Sep 6, 2026
@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 6, 2026, 4:01 AM ET / 08:01 UTC.

ClawSweeper review

What this changes

Provider hook selection now reuses the registry loader’s cache so explicit discovery refreshes affect subsequent lookups, while prepared handles retain their selected plugin.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused fix: current main still retains the provider caches that bypass runtime-discovery invalidation. No blocking defect was found, and the prior draft-status blocker is resolved.

Priority: P2
Reviewed head: 6647096ab21335e09abd6b2949d3ce6ca00d840c

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with meaningful regression coverage and no identified blocking defect.
Proof confidence 🌊 off-meta tidepool Not applicable: The trusted-author exemption applies. The captured body reports a filesystem probe through provider lookup and registry invalidation that observed refreshed hooks, retained prepared ownership, and current profile inputs; its raw output was not supplied. This patch does not materially change cross-principal authority.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The trusted-author exemption applies. The captured body reports a filesystem probe through provider lookup and registry invalidation that observed refreshed hooks, retained prepared ownership, and current profile inputs; its raw output was not supplied. This patch does not materially change cross-principal authority.
Evidence reviewed 8 items Current main still needs the fix: Current main retains both provider-local caches. Their key records metadata plugin IDs but not changed package entry locations, allowing same-ID refreshed metadata to reuse an old provider.
Canonical invalidation boundary: Runtime-discovery invalidation calls clearPluginRegistryLoadCache, which clears loader registry snapshots. The revised provider lookup reaches that existing cache through resolvePluginProvidersCore instead of retaining a second cached provider selection.
Prepared ownership and lookup scope preserved: The changed implementation preserves generation precedence, authoritative empty generations, loaded-registry lookup, provider/model ownership scoping, and existing prepared handles. Hook invocations still receive the current call context.
Findings None None.
Security None None.

How this fits together

Provider runtime lookup selects plugin hooks from provider names, model ownership, configuration, and plugin metadata. Those hooks guide authentication, model handling, and inference; prepared attempts retain their selected provider.

flowchart TD
  A[Provider and model request] --> B{Prepared handle available?}
  B -->|Yes| C[Retain selected plugin]
  B -->|No| D[Generation or loaded registry]
  D -->|Discovery needed| E[Registry loader cache]
  F[Explicit discovery invalidation] --> E
  C --> G[Invoke hook with current context]
  D -->|Provider found| G
  E --> G
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -151, Tests +39, Docs +6, Other 0. Total -106 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 2 70 221 -151
Tests 2 84 45 +39
Docs 1 6 0 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 2 0
Total 6 162 268 -106

Review metrics

None.

Technical review

Best possible solution:

Keep registry reuse under the loader’s invalidation owner while preserving attempt-scoped provider selection and current per-call inputs.

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

Yes, from source: repeat an unprepared lookup with unchanged configuration and plugin IDs after refreshing the package entry and invalidating discovery; current main can return the old cached provider. This review did not execute that path.

Is this the best way to solve the issue?

Yes. Removing the redundant cache makes existing loader invalidation effective without adding another invalidation mechanism or changing the provider API.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 83d1f53c51a2.

Labels

Label justifications:

  • P2: This repairs stale provider selection after explicit discovery invalidation, with a bounded runtime-cache scope.
  • 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: The trusted-author exemption applies. The captured body reports a filesystem probe through provider lookup and registry invalidation that observed refreshed hooks, retained prepared ownership, and current profile inputs; its raw output was not supplied. This patch does not materially change cross-principal authority.

Evidence

What I checked:

  • Current main still needs the fix: Current main retains both provider-local caches. Their key records metadata plugin IDs but not changed package entry locations, allowing same-ID refreshed metadata to reuse an old provider. (src/plugins/provider-hook-runtime.ts:41, 83d1f53c51a2)
  • Canonical invalidation boundary: Runtime-discovery invalidation calls clearPluginRegistryLoadCache, which clears loader registry snapshots. The revised provider lookup reaches that existing cache through resolvePluginProvidersCore instead of retaining a second cached provider selection. (src/plugins/registry-refresh.ts:72, 6647096ab213)
  • Prepared ownership and lookup scope preserved: The changed implementation preserves generation precedence, authoritative empty generations, loaded-registry lookup, provider/model ownership scoping, and existing prepared handles. Hook invocations still receive the current call context. (src/plugins/provider-hook-runtime.ts:197, 6647096ab213)
  • Focused regression coverage: The new parameterized test covers config-owned and default lookups across the real invalidation entrypoint, then checks refreshed selection and prepared-owner retention with updated profile input. Provider discovery is mocked, so this is supplemental regression coverage rather than independent live proof. (src/plugins/provider-runtime.test.ts:1044, 6647096ab213)
  • Captured proof and related work: The supplied body, captured under sourceRevision 292186924d9912af3d91a3c32edd9458f978d9c880a610d905e9e13d1518313b, reports a generated-provider filesystem before/after probe, two registrations across two entries, five hook effects, and 107 passing tests. It explicitly excludes Gateway reload and external authentication claims. The broader open feat: manage and reload plugins without restarting the Gateway #135599 describes splitting into independently landable changes; it does not supersede this fix. No probe transcript was supplied or independently executed. (6647096ab213)
  • Review continuity: The prior completed review covered this same head, recorded no findings or published rank-up moves, and requested readiness from draft. The supplied timeline records ready_for_review at 2026-09-06T07:55:35Z, and the PR snapshot reports draft=false. (6647096ab213)

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (1 earlier review cycle)
  • reviewed 2026-09-06T07:50:12.882Z sha 6647096 :: needs changes before merge. :: none

@steipete
steipete marked this pull request as ready for review September 6, 2026 07:55
@steipete
steipete merged commit 7abfd9e into main Sep 6, 2026
246 checks passed
@steipete
steipete deleted the codex/plugin-provider-hook-owner branch September 6, 2026 08:14
@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 7, 2026
…39908)

Use the canonical registry loader cache for unprepared provider hook lookup. Remove duplicate config/default caches that retained old hook owners after explicit runtime discovery invalidation, along with their unused synchronous config-cache helper.

Preserve prepared generation and loaded registry precedence, alias/model ownership, and current per-call profile context. Production LOC: -151. Verified 107 owner/sibling tests, real generated-provider filesystem RED and GREEN, the complete changed-file gate, and independent P2 review.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation maintainer Maintainer-authored PR 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