Skip to content

refactor(auth): move Copilot OAuth ownership to plugin - #118063

Merged
steipete merged 7 commits into
mainfrom
refactor/copilot-oauth-ownership
Aug 2, 2026
Merged

steipete merged 7 commits into
mainfrom
refactor/copilot-oauth-ownership

Conversation

@steipete

@steipete steipete commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

GitHub Copilot OAuth still had two active owners: the bundled provider plugin already owned interactive device login and request-time authentication, while the session SDK continued seeding a 604-line core implementation. That duplicate also kept credential refresh, enterprise routing, model-policy side effects, and doctor copy in core.

This removes the parallel core implementation in src/llm/utils/oauth/github-copilot.ts:1-604, its 628-line internal test at src/llm/utils/oauth/github-copilot.test.ts:1-628, and the orphaned types at src/llm/github-copilot-oauth-types.ts:1-36. It also removes the built-in registration formerly at src/llm/utils/oauth/index.ts:21,27.

Why This Change Was Made

extensions/github-copilot is now the sole owner of active Copilot device login, legacy credential normalization, auth-doctor guidance, and enterprise request routing. Core retains only generic provider-plugin dispatch:

  • ProviderPlugin.loginOAuth adapts the public callback-based AuthStorage.login API to an owning provider.
  • Existing refreshOAuth and formatApiKey hooks own refresh and runtime credential formatting.
  • A generic manifest-ownership check distinguishes genuinely unknown providers from configured-but-unavailable plugins.
  • Legacy enterprise tenant metadata remains profile-scoped. The plugin carries it in an opaque provider credential between formatApiKey and prepareRuntimeAuth, avoiding a lossy migration into one provider-global config value.
  • Unsupported tenant metadata fails before credential egress; the plugin owns the actionable doctor hint.

The local autoreview bundler refused the full deletion because Iv1.b507a08c87ecfe98 matched its secret-like heuristic in both the removed core copy and the surviving extension. Maintainer verification confirmed this is GitHub's public OAuth device-flow client_id, public by OAuth protocol design, already present on origin/main, and accepted by the repository's CI TruffleHog policy. No scanner configuration or identifier obfuscation is included.

The dated compatibility shims listed under plugin-sdk-provider-owned-helper-shims remain untouched until their 2026-10-01 removal window.

User Impact

Normal GitHub Copilot onboarding and request-time authentication continue through the extension. Legacy public OAuth profiles normalize to the durable GitHub token, and legacy enterprise profiles preserve their per-profile tenant routing.

AuthStorage.login("github-copilot", ...) now lazy-loads the registered provider. If the owning plugin is disabled, missing, or unavailable, it throws a typed OAuthProviderConfiguredUnavailableError with an actionable enable/install/doctor message instead of silently returning no credential. Genuinely unowned provider ids retain the existing unknown-provider error.

Two owner-approved semantic changes are explicit:

  • The retired session login no longer enumerates and auto-enables every Copilot model after authentication. Model enablement belongs to onboarding/doctor rather than being a hidden login side effect.
  • A profile with unsafe legacy tenant metadata can remain catalog-visible until request preparation, but request preparation rejects it before any credential egress and directs the operator to re-authenticate.

No config option, environment variable, CLI flag, SQLite schema, or protocol surface was added.

Evidence

  • Focused proof after rebasing onto fresh origin/main:
    • node scripts/run-vitest.mjs src/plugins/provider-runtime.test.ts src/agents/sessions/auth-storage.test.ts src/agents/auth-profiles/oauth.test.ts src/agents/auth-profiles.doctor.test.ts extensions/github-copilot/index.test.ts extensions/github-copilot/oauth.test.ts extensions/github-copilot/domain.test.ts
    • 4 Vitest shards passed, 157 tests passed.
  • Canonical oxfmt completed for every touched file.
  • git diff --check passed before and after the final rebase.
  • Test-only autoreview bundle: clean, no accepted/actionable findings.
  • Full-bundle autoreview: TruffleHog scan clean, then stopped on the public-client-id bundler false positive documented above.
  • node scripts/check-changed.mjs classified the change for remote proof but could not launch because no Crabbox/Testbox backend was ready; hosted PR CI is the heavy proof path.
  • Production LOC: +392 / -705, net -313. Tests: +378 / -705, net -327. Docs: +1.
  • No live GitHub authentication calls were made; device-flow and routing behavior use contract tests only.
  • Final hosted CI completed with every selected check green except the expected check-plugin-sdk-api-baseline mismatch described below. Security-fast also confirmed the public device-flow client id passes the repository TruffleHog policy.

The check-plugin-sdk-api-baseline check is expected to remain red because this PR adds the generic loginOAuth provider hook. Baseline regeneration is intentionally pending an orchestrator follow-up; every other CI check should be green before review.

@steipete
steipete marked this pull request as ready for review August 2, 2026 16:40
@steipete
steipete requested a review from a team as a code owner August 2, 2026 16:40
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling extensions: github-copilot size: XL maintainer Maintainer-authored PR labels Aug 2, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. labels Aug 2, 2026
@clawsweeper

clawsweeper Bot commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 2, 2026, 1:35 PM ET / 17:35 UTC.

ClawSweeper review

What this changes

Moves GitHub Copilot OAuth device login, refresh, tenant validation, and doctor guidance out of core and into the GitHub Copilot provider plugin, with core delegating through generic provider-runtime hooks.

Merge readiness

⛔ Blocked until real behavior proof is added - 6 items remain

Keep open. The current head clears the prior Plugin SDK baseline blocker and implements a coherent generic-to-plugin OAuth dispatch path, but the new public provider hook still needs maintainer acceptance and the PR lacks after-fix real GitHub Copilot login-and-request proof. The existing maintainer label also requires explicit human handling rather than cleanup closure.

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

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The current head addresses the earlier API-baseline blocker and presents a coherent, tested refactor, but missing real OAuth behavior proof remains a merge gate.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The PR supplies focused contract tests and hosted CI, but its body confirms no live GitHub authentication call; add redacted output showing post-change device login and a successful authenticated Copilot request, without private endpoints, tokens, IP addresses, or account details. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR supplies focused contract tests and hosted CI, but its body confirms no live GitHub authentication call; add redacted output showing post-change device login and a successful authenticated Copilot request, without private endpoints, tokens, IP addresses, or account details. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 7 items Plugin-owned session login path: The session SDK first preserves built-in providers, then lazily delegates an unregistered provider to plugin runtime and distinguishes unknown providers from known-but-unavailable plugin owners.
Generic provider contract: The provider runtime adds generic login and credential-resolution dispatch, returning typed unavailable or unowned outcomes instead of embedding GitHub Copilot behavior in core.
Provider-owned OAuth implementation: The GitHub Copilot plugin prompts for an optional validated enterprise tenant, runs the existing device flow, preserves profile-scoped tenant metadata, and rejects unsafe tenant values before token use.
Findings None None.
Security None None.

How this fits together

AuthStorage is the session SDK’s persisted credential store; it performs OAuth login and refresh before model requests use those credentials. This change leaves core responsible for generic provider lookup while the GitHub Copilot plugin owns vendor-specific device flow, tenant validation, token formatting, and runtime routing.

flowchart LR
  SDK[Session SDK AuthStorage] --> BuiltIn[Built-in OAuth registry]
  BuiltIn --> Dispatch[Generic provider dispatch]
  Dispatch --> Copilot[GitHub Copilot plugin]
  Copilot --> Credential[OAuth credential and tenant metadata]
  Credential --> Runtime[Authenticated Copilot model request]
  Copilot --> Doctor[Operator repair guidance]
Loading

Decision needed

Question Recommendation
Should ProviderPlugin.loginOAuth become the supported long-term Plugin SDK contract for session-SDK OAuth login, rather than keeping provider-specific built-ins in core? Accept the generic OAuth hook: Keep the documented and baselined loginOAuth hook as the single plugin-owned path, subject to real behavior proof before merge.

Why: The implementation is technically coherent, but a new public provider hook affects third-party plugin compatibility and future SDK maintenance; source inspection cannot choose that permanent API direction.

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR supplies focused contract tests and hosted CI, but its body confirms no live GitHub authentication call; add redacted output showing post-change device login and a successful authenticated Copilot request, without private endpoints, tokens, IP addresses, or account details. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - The added ProviderPlugin.loginOAuth hook is a public Plugin SDK contract; maintainers need to accept its long-term compatibility and deprecation posture before merge.
  • Resolve merge risk (P1) - The PR body explicitly reports no live GitHub authentication call. Focused tests and CI do not prove a post-change device login followed by an authenticated Copilot request.
  • Resolve merge risk (P1) - The branch is cleanly mergeable but behind current main; refresh the proof and required checks against the final merge result before landing.
  • Complete next step (P2) - A protected maintainer label, a new public Plugin SDK hook, and missing real behavior proof require maintainer review rather than an automated repair or cleanup action.
Agent review details

Security

None.

PR surface

Source -307, Tests -333, Docs +1, Generated 0. Total -639 across 29 files.

View PR surface stats
Area Files Added Removed Net
Source 17 403 710 -307
Tests 10 367 700 -333
Docs 1 1 0 +1
Config 0 0 0 0
Generated 1 1 1 0
Other 0 0 0 0
Total 29 772 1411 -639

Review metrics

Metric Value Why it matters
Public provider OAuth API 1 hook added: ProviderPlugin.loginOAuth This new Plugin SDK contract changes how session OAuth login reaches provider implementations and requires a compatibility decision.

Stored data model

Persistent data-model change detected: migration/backfill/repair: extensions/github-copilot/index.test.ts, migration/backfill/repair: src/agents/auth-profiles/doctor.ts, migration/backfill/repair: src/plugins/provider-runtime.errors.ts, serialized state: src/agents/sessions/auth-storage-oauth-registry.ts, serialized state: src/agents/sessions/auth-storage.test.ts, serialized state: src/llm/utils/oauth/github-copilot.test.ts, and 4 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Add real plugin-path proof (recommended)
    Before merge, attach redacted terminal output or logs showing device login, persisted credentials, and one successful authenticated Copilot request through the provider plugin.
  2. Accept the SDK contract explicitly
    A maintainer may approve loginOAuth as the durable public provider hook after reviewing its third-party plugin compatibility implications.
  3. Pause the refactor
    If maintainers do not want a new Plugin SDK OAuth hook, pause this PR rather than retaining a parallel or provider-specific core path.

Technical review

Best possible solution:

Accept one narrow, documented provider-owned OAuth hook only if maintainers want it as a durable Plugin SDK contract, then add redacted proof of a real device login and successful Copilot request through the plugin path before merging.

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

Not applicable as a defect reproduction: this is an ownership refactor. A high-confidence after-fix validation path exists, but the PR has not shown it: perform a real device login and make an authenticated Copilot request using the plugin-owned path.

Is this the best way to solve the issue?

Yes, conditionally. Moving GitHub-specific auth policy into its provider plugin while keeping generic dispatch in core fits the documented boundary, but maintainers must approve the new public hook and see real OAuth behavior proof.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 74f3ec1223ee.

Labels

Label justifications:

  • P2: The PR refactors an existing provider-authentication path with bounded blast radius, but requires compatibility and real-behavior validation.
  • merge-risk: 🚨 compatibility: Existing session OAuth dispatch changes from a registered built-in Copilot provider to a newly public plugin hook.
  • merge-risk: 🚨 auth-provider: OAuth login, refresh, tenant validation, and runtime credential formatting now depend on provider-plugin ownership and availability.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR supplies focused contract tests and hosted CI, but its body confirms no live GitHub authentication call; add redacted output showing post-change device login and a successful authenticated Copilot request, without private endpoints, tokens, IP addresses, or account details. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Plugin-owned session login path: The session SDK first preserves built-in providers, then lazily delegates an unregistered provider to plugin runtime and distinguishes unknown providers from known-but-unavailable plugin owners. (src/agents/sessions/auth-storage-oauth-registry.ts:26, 88364880eb4c)
  • Generic provider contract: The provider runtime adds generic login and credential-resolution dispatch, returning typed unavailable or unowned outcomes instead of embedding GitHub Copilot behavior in core. (src/plugins/provider-runtime.ts:831, 88364880eb4c)
  • Provider-owned OAuth implementation: The GitHub Copilot plugin prompts for an optional validated enterprise tenant, runs the existing device flow, preserves profile-scoped tenant metadata, and rejects unsafe tenant values before token use. (extensions/github-copilot/oauth.ts:40, 88364880eb4c)
  • Existing device-flow coverage remains at the owning boundary: Current main already keeps detailed GitHub device-flow coverage in the plugin, including HTTP failure cleanup, bounded response handling, enterprise routing, polling intervals, and cancellation behavior. (extensions/github-copilot/login.test.ts:57, 74f3ec1223ee)
  • Prior blocker addressed on the latest reviewed head: The only diff after the previous reviewed SHA regenerates the Plugin SDK API baseline for the changed public agent-runtime module; the supplied current-head check state reports check-plugin-sdk-api-baseline successful. Public docs: docs/.generated/plugin-sdk-api-baseline.sha256. (docs/.generated/plugin-sdk-api-baseline.sha256:9, 88364880eb4c)
  • History and ownership trail: Current-tree shortlog shows Peter Steinberger as the dominant contributor across the Copilot OAuth, plugin, and provider-runtime files; the built-in Copilot registry lines trace to the current baseline authored by Shakker. Deeper historical traversal was partially limited because this partial clone could not fetch promisor objects while GitHub DNS was unavailable. (src/llm/utils/oauth/index.ts:21, 74f3ec1223ee)

Likely related people:

  • steipete: The current PR is authored by this contributor, and the current-tree shortlog records 73 historical touches across the Copilot OAuth, Copilot plugin, and provider-runtime ownership surface. (role: feature owner and recent area contributor; confidence: high; commits: 1d49f6a193ac, 88364880eb4c; files: extensions/github-copilot/index.ts, extensions/github-copilot/oauth.ts, src/plugins/provider-runtime.ts)
  • Shakker: Blame attributes the current main registry entries that seed GitHub Copilot as a built-in OAuth provider to this baseline contributor. (role: current built-in OAuth registry provenance; confidence: medium; commits: d4490c6a9d9c; files: src/llm/utils/oauth/index.ts)
  • juyaohuidt: Recent current-main history identifies this contributor on the GitHub Copilot device-flow error-body cleanup that the plugin-owned login path continues to call. (role: recent adjacent device-flow contributor; confidence: medium; commits: 096cd231ea74; files: extensions/github-copilot/login.ts)

Rank-up moves

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

  • Attach redacted real device-login and authenticated-request evidence through the plugin-owned flow.
  • Obtain maintainer confirmation that ProviderPlugin.loginOAuth is the intended durable SDK contract.
  • Refresh required checks and proof after the final merge result is available.

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 (3 earlier review cycles)
  • reviewed 2026-08-02T16:45:36.544Z sha 8f1137ad1452e1333eb9334d6b262ba88d9d1133 :: needs real behavior proof before merge. :: [P1] Commit the plugin SDK API baseline with this new hook
  • reviewed 2026-08-02T16:57:36.325Z sha 555038b4285f0dd105736ecc2ab255d3ee28c25d :: needs real behavior proof before merge. :: [P1] Commit the SDK baseline for loginOAuth
  • reviewed 2026-08-02T17:25:29.206Z sha 34a3a8a :: needs real behavior proof before merge. :: [P1] Commit the Plugin SDK baseline for the new public contract

@steipete
steipete force-pushed the refactor/copilot-oauth-ownership branch 2 times, most recently from 555038b to f31fb0a Compare August 2, 2026 17:08
@steipete
steipete force-pushed the refactor/copilot-oauth-ownership branch from f31fb0a to 34a3a8a Compare August 2, 2026 17:19
@steipete
steipete merged commit c28b524 into main Aug 2, 2026
121 checks passed
@steipete
steipete deleted the refactor/copilot-oauth-ownership branch August 2, 2026 17:59
@steipete

steipete commented Aug 2, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 3, 2026
* refactor(auth): move Copilot OAuth ownership to plugin

* test(auth): cover plugin-owned Copilot OAuth

* test(auth): align OAuth runtime mocks

* refactor(auth): extract session OAuth adapter

* refactor(auth): centralize session OAuth dispatch

* test(auth): type OAuth refresh mock

* chore(plugin-sdk): regenerate API baseline for provider oauth dispatch
masatohoshino added a commit to masatohoshino/openclaw that referenced this pull request Aug 4, 2026
…in provider

openclaw#118063 moved GitHub Copilot's OAuth ownership out of BUILT_IN_OAUTH_PROVIDERS
and into its own plugin, so the comment claiming this case covers "a second
built-in provider" no longer describes the registry. The case still earns its
place: it proves the repaired branch is generic over whatever
getOAuthProviders() yields rather than special-cased to Anthropic. Comment only.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation extensions: github-copilot maintainer Maintainer-authored PR merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant