Skip to content

fix(models): keep plugin-owned credentials out of ambient discovery - #189184

Merged
obviyus merged 2 commits into
mainfrom
fix/ambient-skip-plugin-owned-auth
Oct 31, 2026
Merged

obviyus merged 2 commits into
mainfrom
fix/ambient-skip-plugin-owned-auth

Conversation

@obviyus

@obviyus obviyus commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

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 #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 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.

@clawsweeper

clawsweeper Bot commented Oct 31, 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.

@github-actions

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 42977e4a1d20e1ca045b70ce223119980b694bb2
  • Maintainer: @obviyus
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/agent-auth-discovery.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. 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. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 31, 2026
@clawsweeper

clawsweeper Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR excludes plugin-owned synthetic credentials from both ambient discovery APIs.

Example: Catalog preparation encounters TypeSafe with authScope set to plugin.

  • Before: Discovery invokes its instance-bound auth hook, producing a missing-credential warning or copying a live key into ambient discovery facts.
  • After: Discovery skips the hook, while catalog availability and provider dispatch resolve credentials through the live plugin owner.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused ownership repair with meaningful regressions, production-boundary HTTP evidence and green exact-head gates.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The supplied exact-head production-path trace loads the real TypeSafe plugin, prepares the catalog and invokes decisions.evaluateV2 through its real HTTP transport; authorized requests succeed, foreign ownership is rejected, rotated keys replace stale credentials, and disabling the owner prevents new requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Plugin-owned providers can emit repeated catalog authentication warnings while their instance-bound credentials are requested outside the owning scope.
Reason: The maintainer-authored direction restores an existing ownership contract with a narrow change and preserves ordinary provider authentication.

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
Reviewed head: 42977e4a1d20e1ca045b70ce223119980b694bb2

Before merge

None.

Findings

None.

Agent review details

How this fits together

Ambient 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]
Loading

Technical review

Best 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

  • Per-provider ambient discovery isolation keeps the original intent (0588f51: Keep one failing provider from emptying the model catalog while propagating request-wide failures.)
  • Plugin-owned credential authority keeps the original intent (33f497e: Bind plugin credentials to the exact live instance and preserve revocation checks through preparation and dispatch.)
  • Missing plugin credential regression keeps the original intent (1b15408: Keep healthy providers available when a plugin-owned provider lacks live authentication.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Pinned patch and current main: The introduced diff adds the scope exclusion to both ambient APIs; fetched main still invokes synthetic auth without that exclusion. (src/agents/agent-auth-discovery.ts:180, 42977e4a1d20)
  • Existing credential ownership contract: Plugin-owned auth validates the exact live instance, registration and secrets revision; external synthetic-auth capture already excludes instance-owned credentials. (src/plugins/provider-auth-scope.ts:99, 42977e4a1d20)
  • Independent availability owner: Catalog decisions resolve plugin-owned credentials within the retained plugin generation and avoid caching those evaluations. (src/agents/model-catalog-decisions.ts:274, 42977e4a1d20)
  • Focused regressions and earlier finding: The changed tests protect exclusion with and without live credentials and healthy-sibling survival when ownership conflicts; both scope lookups now execute inside provider isolation, resolving the earlier finding. (src/agents/model-auth.plugin-scope.test.ts:573, 42977e4a1d20)
  • Supplied production-path authority trace: The PR body records real TypeSafe plugin loading, catalog preparation and decisions.evaluateV2 over real loopback HTTP: authorized dispatch succeeds, duplicate ownership is rejected, rotated credentials replace the old key, and disablement prevents further requests. (42977e4a1d20)
  • Exact-head landing signals: GitHub reports a clean merge and successful openclaw/ci-gate, dependency-review and security-sensitive-review statuses; the security guard explicitly requires no separate SecOps approval for this author. (42977e4a1d20)

Likely related people:

  • Peter Steinberger: Raw commit 2640154 adds src/agents/agent-auth-discovery.ts:110 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 2640154bcf80; files: src/agents/agent-auth-discovery.ts)

PR surface

Source +21, Tests +49. Total +70 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 31 10 +21
Tests 1 56 7 +49
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 87 17 +70

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This fixes catalog warnings and improper credential transfer for installs using plugin-owned providers, with a limited affected surface.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (4 earlier review cycles)
  • reviewed 2026-10-31T07:41:36.442Z sha cb4f6ec :: needs real behavior proof before merge. :: [P2] Keep ownership lookup errors inside provider isolation
  • reviewed 2026-10-31T08:36:33.014Z sha 42977e4 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-31T09:22:24.268Z sha 42977e4 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-31T09:27:29.920Z sha 42977e4 :: needs maintainer review before merge. :: none

Reviewed October 31, 2026, 5:47 AM ET / 09:47 UTC (Revision 5).

@obviyus

obviyus commented Oct 31, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 31, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. clawsweeper:intake:bug Preliminary submission classification; full source review pending. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 31, 2026
@obviyus

obviyus commented Oct 31, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 31, 2026
@obviyus
obviyus merged commit bc82773 into main Oct 31, 2026
197 of 198 checks passed
@obviyus
obviyus deleted the fix/ambient-skip-plugin-owned-auth branch October 31, 2026 10:21
@obviyus

obviyus commented Oct 31, 2026

Copy link
Copy Markdown
Collaborator Author

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.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 1, 2026
…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]>
RomneyDa added a commit that referenced this pull request Nov 17, 2026
Backport #189184 with focused discovery and consumer regressions.

Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. security-sensitive-changed 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