Repository navigation
fix(models): keep plugin-owned credentials out of ambient discovery - #189184
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
|
Codex review: needs maintainer review before merge. What this changesThis PR excludes plugin-owned synthetic credentials from both ambient discovery APIs. Example: Catalog preparation encounters TypeSafe with authScope set to plugin.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open for landing: it fixes a current credential ownership defect while preserving provider isolation, with no actionable findings. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherAmbient discovery combines environment and synthetic authentication into catalog preparation facts; plugin-owned credentials instead belong to live instance-scoped availability and dispatch. flowchart TD
A[Provider metadata] --> B[Ambient discovery scope check]
B --> C[Agent scoped synthetic auth]
C --> D[Ambient catalog facts]
A --> E[Plugin owned live auth]
E --> F[Catalog availability]
E --> G[Guarded provider dispatch]
Technical reviewBest possible solution: Land the focused scope exclusion while retaining live plugin-owned authentication and existing per-provider failure isolation. Do we have a high-confidence way to reproduce the issue? Current main unconditionally invokes plugin-owned synthetic auth during ambient discovery, then copies successful results into credential facts; the PR records failing base regressions and observed startup warnings, but this review executed no target code. Is this the best way to solve the issue? The patch repairs the producer using the existing scope resolver and isolation owner, without adding state, changing dispatch ownership or duplicating credential policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d27a8c9d9fec. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +21, Tests +49. Total +70 across 2 files. Added test files: 0. View PR surface stats
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (4 earlier review cycles)
Reviewed October 31, 2026, 5:47 AM ET / 09:47 UTC (Revision 5). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed as bc82773. Ambient discovery no longer asks plugin-owned providers for credentials: their keys are instance-bound and failed in the catalog worker (the TypeSafe refresh failures on every Gateway start). Availability and dispatch still resolve them in the owner's scope; the PR body has the loopback trace for owner dispatch, foreign-owner rejection and revocation. |
…penclaw#189184) ## Problem A plugin-owned provider (`authScope: "plugin"`, for example TypeSafe) was missing from the model list on a live install, and its catalog refresh logged `Plugin-owned auth for provider "typesafe" is unavailable: live credential or no-auth evidence is missing` after nearly every Gateway start since Oct 28. Ambient credential discovery asked every synthetic-auth provider for a credential, including plugin-owned ones. A plugin-owned credential is instance-bound: `getPreparedPluginSecretInput` returns it only inside the owning plugin's Gateway request scope with live instance authority. The prepared model catalog worker builds ambient credentials in a worker thread (`prepared-model-catalog.worker.ts`), where that scope never exists, so the lookup always failed there. Where it did succeed on the main thread, the plugin's key went into the ambient credential map, which is a transferable discovery fact. `provider-runtime.ts` already forbids this for external synthetic auth: "Instance-owned credentials cannot become transferable worker bearer facts." Before openclaw#189059 this failure emptied the whole `models.list`. Since openclaw#189059 the provider is skipped, with a warning on every catalog build. ## Fix Ambient discovery skips providers whose auth scope is `plugin`, so it never calls their auth hook and never stores their key. The scope check runs inside the existing per-provider isolation (openclaw#189059), so an ownership lookup error (for example conflicting static credential owners) skips only that provider. Catalog availability already resolves plugin-owned credentials per model inside the owner's scope (`model-catalog-decisions.ts`), so these providers' models still show as available when their credential is live. ## User impact Plugin-owned providers no longer fail catalog refreshes or produce warnings at Gateway start. Their keys stay inside the plugin's scope. ## Authority chain Dispatch does not read ambient discovery credentials: runtime auth (`runtime-plan/prepare-auth.ts`) resolves plugin-owned credentials through the owning instance at run time. The existing `src/agents/model-auth.plugin-scope.test.ts` contracts, all passing on this head, cover each link: - authorized dispatch: "plans plugin-owned auth before agent stores, configured bindings and cooldowns" - foreign owner: "rejects hook/secret authority replacement during auth", "refuses static/runtime scope mismatch" - revocation after preparation, before provider I/O: "invalidates catalog readiness on revocation", "refuses revoked protected secret input rather than reusing a prior bearer", "retains credential authority through an awaited exchange (revoked during exchange: true)", "does not read a live credential after preparation is cancelled" The new regression also checks that, with ambient discovery skipping the provider, the owner path still resolves the live credential inside the plugin's scope. ## Production-path trace Run on head `42977e4a1d2` and repeated with `main`'s `agent-auth-discovery.ts`; behavior is identical, which is the point: ambient discovery never fed dispatch. Path: the real `extensions/typesafe` plugin loaded from `plugins.load.paths` (`loadAndActivateRootPluginRegistry`), catalog preparation through `acquireAgentRunPreparedModelRuntime` with runtime plugins (the path where ambient discovery runs), then a consumer plugin calling `api.runtime.decisions.evaluateV2`, which uses TypeSafe's plugin-owned auth and transport to send real HTTP to a loopback fake TypeSafe server. TypeSafe is decision-only (`chat: false`), so an agent chat turn cannot reach its provider I/O; this is the narrowest real path that does. Synthetic keys only. 1. Owner dispatch: catalog has `typesafe/kev-latest`; outcome `ok`; provider requests `[{"path":"/v1/systemone","authorization":"Bearer <synthetic-typesafe-key>"}]`. 2. Foreign owner: a second plugin registering `typesafe` is rejected at load (`provider already registered: typesafe`); registered owners stay `["typesafe"]`; zero requests carry the impostor's key. 3. Revocation after preparation, without re-preparing: after a key rotation republish, zero requests use the old prepared key and the next request uses the rotated key; with `plugins.entries.typesafe.enabled=false` the outcome is `unavailable (disabled)` and zero new provider requests are made. Not covered by this trace: a replaced live instance during an awaited exchange (covered by "retains credential authority through an awaited exchange" above), and the hosted `plugins.entries.typesafe.config.apiKey` route, which targets the public hosted endpoint and cannot point at a loopback server. ## Proof - `src/agents/model-auth.plugin-scope.test.ts` regression, with and without a live prepared credential: ambient discovery (sync and async) does not include the plugin-owned provider and never calls its auth hook. On `main` both cases fail: the hook runs, and with a live credential the plugin's key ends up in the ambient map. - Regression: a provider with conflicting static auth-scope owners next to a healthy sibling. Both ambient APIs keep the sibling's credential. Fails on the previous head with `conflicting static credential owners`. - Related suites pass: plugin-scope auth (36), discovery auth, external CLI discovery, synthetic auth discovery, prepared runtime sources, catalog worker pool, implicit discovery outcomes, `models.list` provider outcomes. - `pnpm check:changed` passes. `pnpm check:madge-import-cycles` reports 0 cycles. - Live evidence: Team server Gateway logs show this refresh failure after starts on Oct 28, 29, 30 and 31, with no config change to the TypeSafe plugin entry or secrets between a working and a failing start. No overlap with Pash/Sarah changes. ## Merge danger Two-way door: a revert fully undoes it. No state, config or contract change. Blast radius: model catalog discovery for installs with plugin-owned providers. Co-authored-by: Ayaan Zaidi <[email protected]>
Backport #189184 with focused discovery and consumer regressions. Co-authored-by: RomneyDa <[email protected]>
Problem
A plugin-owned provider (
authScope: "plugin", for example TypeSafe) was missing from the model list on a live install, and its catalog refresh loggedPlugin-owned auth for provider "typesafe" is unavailable: live credential or no-auth evidence is missingafter nearly every Gateway start since Oct 28.Ambient credential discovery asked every synthetic-auth provider for a credential, including plugin-owned ones. A plugin-owned credential is instance-bound:
getPreparedPluginSecretInputreturns it only inside the owning plugin's Gateway request scope with live instance authority. The prepared model catalog worker builds ambient credentials in a worker thread (prepared-model-catalog.worker.ts), where that scope never exists, so the lookup always failed there. Where it did succeed on the main thread, the plugin's key went into the ambient credential map, which is a transferable discovery fact.provider-runtime.tsalready forbids this for external synthetic auth: "Instance-owned credentials cannot become transferable worker bearer facts."Before #189059 this failure emptied the whole
models.list. Since #189059 the provider is skipped, with a warning on every catalog build.Fix
Ambient discovery skips providers whose auth scope is
plugin, so it never calls their auth hook and never stores their key. The scope check runs inside the existing per-provider isolation (#189059), so an ownership lookup error (for example conflicting static credential owners) skips only that provider. Catalog availability already resolves plugin-owned credentials per model inside the owner's scope (model-catalog-decisions.ts), so these providers' models still show as available when their credential is live.User impact
Plugin-owned providers no longer fail catalog refreshes or produce warnings at Gateway start. Their keys stay inside the plugin's scope.
Authority chain
Dispatch does not read ambient discovery credentials: runtime auth (
runtime-plan/prepare-auth.ts) resolves plugin-owned credentials through the owning instance at run time. The existingsrc/agents/model-auth.plugin-scope.test.tscontracts, all passing on this head, cover each link:The new regression also checks that, with ambient discovery skipping the provider, the owner path still resolves the live credential inside the plugin's scope.
Production-path trace
Run on head
42977e4a1d2and repeated withmain'sagent-auth-discovery.ts; behavior is identical, which is the point: ambient discovery never fed dispatch.Path: the real
extensions/typesafeplugin loaded fromplugins.load.paths(loadAndActivateRootPluginRegistry), catalog preparation throughacquireAgentRunPreparedModelRuntimewith runtime plugins (the path where ambient discovery runs), then a consumer plugin callingapi.runtime.decisions.evaluateV2, which uses TypeSafe's plugin-owned auth and transport to send real HTTP to a loopback fake TypeSafe server. TypeSafe is decision-only (chat: false), so an agent chat turn cannot reach its provider I/O; this is the narrowest real path that does. Synthetic keys only.typesafe/kev-latest; outcomeok; provider requests[{"path":"/v1/systemone","authorization":"Bearer <synthetic-typesafe-key>"}].typesafeis rejected at load (provider already registered: typesafe); registered owners stay["typesafe"]; zero requests carry the impostor's key.plugins.entries.typesafe.enabled=falsethe outcome isunavailable (disabled)and zero new provider requests are made.Not covered by this trace: a replaced live instance during an awaited exchange (covered by "retains credential authority through an awaited exchange" above), and the hosted
plugins.entries.typesafe.config.apiKeyroute, which targets the public hosted endpoint and cannot point at a loopback server.Proof
src/agents/model-auth.plugin-scope.test.tsregression, with and without a live prepared credential: ambient discovery (sync and async) does not include the plugin-owned provider and never calls its auth hook. Onmainboth cases fail: the hook runs, and with a live credential the plugin's key ends up in the ambient map.conflicting static credential owners.models.listprovider outcomes.pnpm check:changedpasses.pnpm check:madge-import-cyclesreports 0 cycles.No overlap with Pash/Sarah changes.
Merge danger
Two-way door: a revert fully undoes it. No state, config or contract change. Blast radius: model catalog discovery for installs with plugin-owned providers.