Skip to content

refactor(chutes): move OAuth refresh into provider plugin - #120840

Merged
steipete merged 2 commits into
mainfrom
steipete/happy-diffie-6a9b69
Aug 9, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/happy-diffie-6a9b69

Conversation

@steipete

@steipete steipete commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Chutes OAuth refresh was duplicated and live in core while login was provider-owned. Core hardcoded a Chutes fallback after generic provider dispatch.

Why This Change Was Made

Provider-specific auth belongs to the owner plugin. This registers the existing generic ProviderPlugin.refreshOAuth hook and removes the core refresh implementation and fallback, without adding a new SDK or provider-named seam.

Compatibility decision: retain the shipped deprecated provider-auth-login.runtime loginChutes shim plus the core login/token-exchange implementation and its deprecation inventory. The latest stable release shipped it; removeAfter is 2026-10-01, and explicit breaking-release approval is required. This PR does not shorten that window.

The maintainer owner decision accepts the generic configured-unavailable outcome when the Chutes owner plugin is disabled or removed; core must not continue executing Chutes vendor protocol in that state.

User Impact

Installed and enabled Chutes plugins keep existing OAuth profiles auto-refreshing. When the owner plugin is missing or disabled, Chutes now follows the generic configured-unavailable behavior instead of silently running vendor protocol in core.

Evidence

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling extensions: chutes size: L maintainer Maintainer-authored PR labels Aug 9, 2026
@steipete
steipete marked this pull request as ready for review August 9, 2026 02:42
@steipete
steipete requested a review from a team as a code owner August 9, 2026 02:42
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. labels Aug 9, 2026
@clawsweeper

clawsweeper Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 9, 2026, 12:39 AM ET / 04:39 UTC.

ClawSweeper review

What this changes

Moves Chutes OAuth token refresh from core auth-profile code into the Chutes provider plugin through the existing generic provider refresh hook.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

No blocking code finding remains: the current head addresses the prior lifecycle concern. Keep this maintainer-authored PR open for the explicit disabled/missing-plugin compatibility decision and exact-head CI completion.

Priority: P2
Reviewed head: a1c0f95295039bc081449f80b996da5da5b2ea20
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch follows an existing generic contract and directly covers the prior lifecycle concern; only the explicit compatibility choice and exact-head CI remain.
Proof confidence 🌊 off-meta tidepool Not applicable: The repository state identifies the author as a MEMBER, so the external-contributor proof gate does not apply; the supplied focused lifecycle and Testbox results are strong regression evidence but not live Chutes proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The repository state identifies the author as a MEMBER, so the external-contributor proof gate does not apply; the supplied focused lifecycle and Testbox results are strong regression evidence but not live Chutes proof.
Evidence reviewed 5 items Current-head lifecycle coverage: The new regression starts refresh while synchronous plugin registration is in flight, then proves registration completes before the async resolver dispatches, the credential rotates and persists, and disabled versus absent ownership keeps distinct generic outcomes.
Existing provider contract: The generic provider contract already declares an optional refreshOAuth hook, and the resolver dispatches it while preserving configured-unavailable and unowned outcomes.
Owner-boundary implementation: The Chutes plugin registers the existing hook and owns its token refresh protocol; core removes only the Chutes-specific fallback after generic dispatch.
Findings None None.
Security None None.

How this fits together

The auth-profile subsystem refreshes expired stored credentials, dispatching provider-specific protocol work to the provider plugin and then persisting the result. Core retains generic provider ownership and unavailable-state handling, while the Chutes plugin owns its OAuth HTTP exchange.

flowchart LR
A[Expired Chutes credential] --> B[Auth profile refresh]
B --> C[Provider ownership lookup]
C --> D[Chutes plugin refresh hook]
D --> E[Chutes token endpoint]
E --> F[Persist refreshed credential]
Loading

Decision needed

Question Recommendation
Should a disabled or missing Chutes owner plugin intentionally stop receiving core-managed OAuth refresh and return the generic configured-unavailable outcome? Accept plugin-owned refresh: Keep the canonical provider-owned path and make unavailable Chutes ownership a visible configured-unavailable state.

Why: The implementation is consistent with the existing provider contract, but it deliberately changes the upgrade behavior for profiles whose owner plugin is unavailable.

Before merge

  • Resolve merge risk (P1) - Users who explicitly disable or remove the Chutes owner plugin will now receive the generic configured-unavailable outcome instead of core performing Chutes refresh; this intentional compatibility change needs owner acceptance.
  • Resolve merge risk (P1) - The supplied exact-head CI set is still running, so merge should wait for its completion.
  • Complete next step (P2) - A maintainer must explicitly accept the intentional unavailable-owner compatibility outcome before merge.
Agent review details

Security

None.

PR surface

Source -7, Tests +240. Total +233 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 4 68 75 -7
Tests 5 458 218 +240
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 526 293 +233

Review metrics

Metric Value Why it matters
Production versus test LOC production +68/-75 (net -7); tests +458/-218 (net +240) The production refactor removes duplicated core protocol while the added test volume covers loader ordering and persisted-credential behavior.

Stored data model

Persistent data-model change detected: persistent cache schema: src/agents/auth-profiles.chutes.lifecycle.test.ts, serialized state: src/agents/auth-profiles.chutes.lifecycle.test.ts, vector/embedding metadata: extensions/chutes/oauth.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Accept the unavailable-owner contract (recommended)
    Merge after the owner confirms that disabled or missing Chutes plugins should return configured-unavailable rather than use a core fallback.
  2. Pause for compatibility redesign
    Do not merge if maintaining refresh for disabled or removed plugin ownership remains a supported user contract.

Technical review

Best possible solution:

Adopt the single provider-owned refresh path once its explicit unavailable-owner behavior is accepted and the exact PR head is green.

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

Yes, by source: the lifecycle test constructs the prior loading window and verifies the post-fix dispatch and persistence path; this read-only review did not execute it.

Is this the best way to solve the issue?

Yes: the existing generic provider hook is the narrowest maintainable owner boundary, while restoring a Chutes-specific core fallback would duplicate vendor protocol.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This is a bounded provider-authentication refactor whose regression risk is limited to Chutes OAuth users.
  • 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: The repository state identifies the author as a MEMBER, so the external-contributor proof gate does not apply; the supplied focused lifecycle and Testbox results are strong regression evidence but not live Chutes proof.
  • remove P1: Current review triage priority is P2, so this older priority label is no longer current.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a bounded provider-authentication refactor whose regression risk is limited to Chutes OAuth users.
  • merge-risk: 🚨 auth-provider: Merging changes the component that refreshes stored OAuth credentials and the outcome when the provider owner is unavailable.
  • 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 repository state identifies the author as a MEMBER, so the external-contributor proof gate does not apply; the supplied focused lifecycle and Testbox results are strong regression evidence but not live Chutes proof.

Evidence

What I checked:

Likely related people:

  • steipete: Authored the generic resolver boundary and both current PR commits, including the lifecycle proof. (role: recent area contributor; confidence: high; commits: a26959b9270c, a9e2411461e3, a1c0f9529503; files: src/agents/auth-profiles/oauth.ts, src/plugins/provider-runtime.ts, extensions/chutes/index.ts)
  • vincentkoc: History associates this contributor with earlier Chutes OAuth and provider-runtime work. (role: historical Chutes/provider contributor; confidence: medium; commits: 6fc0303, 6467c196, d07ba5f; files: extensions/chutes, src/plugins/provider-runtime.ts)
  • wangmiao0668000666: History associates this contributor with Chutes token endpoint and error-response maintenance. (role: recent Chutes OAuth contributor; confidence: medium; commits: 538263b, f83cdec; files: extensions/chutes/oauth.ts)

Rank-up moves

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

  • Record acceptance of the disabled/missing-owner behavior.
  • Merge only after required checks complete on the current head.

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 (2 earlier review cycles)
  • reviewed 2026-08-09T02:49:20.785Z sha a9e2411 :: needs changes before merge. :: [P1] Preserve refresh while the provider registry is loading
  • reviewed 2026-08-09T03:46:30.478Z sha a9e2411 :: found issues before merge. :: [P1] Preserve refresh while the provider registry loads

@steipete

steipete commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

The P1 production-change recommendation was not applied. Direct source and history verification showed that the old Chutes fallback was already after configured-unavailable, so it could not bridge the alleged state.

Provider registration is synchronous from beginLoad through finishLoad; a promise-returning register is rejected. Production auth refresh crosses both keyed async and lazy runtime boundaries before provider lookup.

The added real lifecycle test starts an expired Chutes auth-profile refresh inside synchronous register, registers the provider hook, proves the load is no longer in flight before resolution, fails on any registration reentry, and verifies refreshed credential persistence. The same test proves that explicitly disabled manifest ownership returns configured-unavailable, while an absent owner returns unowned.

Exact proof:

  • node scripts/run-vitest.mjs src/agents/auth-profiles.chutes.lifecycle.test.ts (2 passed)
  • node scripts/run-vitest.mjs src/agents/auth-profiles.chutes.test.ts src/plugins/provider-runtime.test.ts extensions/chutes/oauth.test.ts (84 passed)
  • node scripts/check-changed.mjs -- src/agents/auth-profiles.chutes.lifecycle.test.ts green on Blacksmith Testbox run 31294140350
  • P1 Codex autoreview clean

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@steipete

steipete commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

The latest ClawSweeper comment still records reviewed head a9e2411461e3, so it raced the follow-up push and did not inspect current head a1c0f9529503.

Current head adds src/agents/auth-profiles.chutes.lifecycle.test.ts, a real loader/auth-profile regression that starts expired Chutes refresh inside synchronous plugin registration, rejects any second registration immediately, verifies the load marker clears before the refresh resolves, and proves the refreshed credential is persisted. It also proves a disabled manifest owner remains configured-unavailable and a provider with no owner remains unowned.

Focused proof on the current file is green (2 tests), the requested Chutes/provider acceptance set is green (84 tests), the path-scoped changed gate is green, and fresh autoreview found no P1-or-higher issue after the reentry assertion was hardened.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. P2 Normal backlog priority with limited blast radius. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P1 High-priority user-facing bug, regression, or broken workflow. labels Aug 9, 2026
@steipete

steipete commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

Maintainer owner decision: accepted. Chutes OAuth refresh is provider-owned, so an explicitly disabled or removed Chutes plugin must not continue executing Chutes vendor protocol from core. The intended outcome is the generic visible configured-unavailable state, with re-enable/install or re-authentication as the repair path. Restoring a core fallback would recreate the ownership fork this PR removes.

The current-head lifecycle regression also proves that a normally enabled plugin refreshes successfully across synchronous registration, while disabled ownership and absent ownership remain distinct. Exact-head CI run 31294769803 is green, and the current-head ClawSweeper review reports no actionable findings.

@steipete

steipete commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

Land-ready proof for a1c0f95295039bc081449f80b996da5da5b2ea20.

Root cause: Chutes OAuth refresh protocol had two owners—the generic provider-plugin dispatch and a Chutes-specific core fallback. The Chutes plugin is the architectural owner. The canonical fix registers its existing refreshOAuth hook, removes the live core refresh fallback and duplicate core refresh implementation, and retains only the deprecated login/token-exchange compatibility shim through its approved removeAfter: 2026-10-01 window.

Production LOC is +68/-75 (net -7); tests are +458/-218 (net +240). Coverage includes the generic provider hook and sibling provider-runtime behavior, synchronous plugin registration followed by refresh persistence, and distinct disabled-owner (configured-unavailable) versus absent-owner (unowned) outcomes.

Focused proof:

  • node scripts/run-vitest.mjs extensions/chutes/oauth.test.ts extensions/chutes/implicit-provider.test.ts src/agents/auth-profiles.chutes.test.ts — 24 passed.
  • node scripts/run-vitest.mjs src/agents/chutes-oauth.flow.test.ts src/agents/chutes-oauth.test.ts src/commands/chutes-oauth.test.ts — 15 passed.
  • node scripts/run-vitest.mjs src/agents/auth-profiles.chutes.lifecycle.test.ts — 2 passed.
  • node scripts/run-vitest.mjs src/agents/auth-profiles.chutes.test.ts src/plugins/provider-runtime.test.ts extensions/chutes/oauth.test.ts — 84 passed.

Blacksmith Testbox tbx_01kzj4jwnda1589cje9gcctsbp passed full pnpm check:changed (https://github.com/openclaw/openclaw/actions/runs/31289799926). Testbox tbx_01kzjbnaesrdb98vtxcb9sghx0 passed the path-scoped lifecycle changed gate (https://github.com/openclaw/openclaw/actions/runs/31294140350). Exact-head CI run 31294769803 is green (https://github.com/openclaw/openclaw/actions/runs/31294769803).

The completed current-head ClawSweeper review reports no findings and confirms the earlier lifecycle P1 is addressed (#120840 (comment)). The accepted owner decision is that a disabled or removed Chutes plugin intentionally yields generic configured-unavailable behavior; core must not execute Chutes vendor protocol (#120840 (comment)).

Known proof gap: no live Chutes credentials or network were used; token HTTP behavior is mock-backed.

@steipete
steipete merged commit 7443882 into main Aug 9, 2026
138 checks passed
@steipete
steipete deleted the steipete/happy-diffie-6a9b69 branch August 9, 2026 04:50
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 10, 2026
…20840)

* refactor(chutes): move OAuth refresh into provider plugin

* test(chutes): prove OAuth refresh load ordering
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling extensions: chutes maintainer Maintainer-authored PR merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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