Repository navigation
feat(github): authorize agent identities from Settings - #126474
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: found issues before merge. Reviewed August 19, 2026, 8:17 PM ET / August 20, 2026, 00:17 UTC. ClawSweeper reviewWhat this changesAdds Settings-driven GitHub OAuth device authorization for system and per-agent identities, including Gateway refresh lifecycle, managed profiles, protocol models, and Control UI controls. Merge readinessKeep open. The previous P1 remains: this replaces an existing public Gateway status RPC rather than extending it, so prior clients are rejected before the handler runs. The maintainer-owned OAuth/security boundary also needs an explicit decision. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherSettings asks the Gateway to authorize and retain a GitHub identity. The Gateway then supplies its managed profile to local agent tools and Gateway-owned publication without sending credentials to browsers or cloud workers. flowchart LR
A[Settings operator] --> B[Gateway authorization service]
B --> C[GitHub device authorization]
C --> D[Hidden OAuth records]
D --> E[Managed GitHub profile]
E --> F[Local agent tools]
E --> G[Gateway publication]
Decision needed
Why: The credential owner, durable refresh behavior, and requested scopes define a product security boundary that code review alone cannot choose. Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +3562, Tests +2987, Docs +7, Generated +2, Other +600. Total +7158 across 77 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the existing status RPC and flat result intact, then add a separately named scoped-status method for the selected-versus-effective identity view before landing the OAuth flow. Do we have a high-confidence way to reproduce the issue? Yes, from source: send the previous closed request shape Is this the best way to solve the issue? No. The OAuth lifecycle is owner-oriented, but replacing the existing status RPC is not the best path; a new additive scoped-status method preserves clients and supplies the needed view. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 02be7fea9725. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
|
Land-ready proof for
|
|
Merged via squash.
|
* feat(github): add device authorization lifecycle * fix(github): harden device authorization lifecycle * fix(github): refresh native tool display snapshot * fix(github): refresh config and UI baselines * refactor(github): break OAuth identity import cycle * test: make gateway retry deadline assertion scheduler-safe
main is red on the Control UI startup-JS ratchet: unrelated PR #126725 measures 348289 B and this branch measures 348351 B against a 347023 B baseline + 1056 B tolerance. Twenty-six UI commits have landed since the last bump (#126474), none individually large. Baseline moves to the CI-measured 348351 B, well under the 358400 B maintainer-approved ceiling that still guards cumulative creep.
…126734) * fix(config): validate config writes against the config being written writeConfigFileFromContext passed the pre-write snapshot's plugin metadata into strict validation. During onboarding that snapshot belongs to an intermediate config written by agent creation, which has no plugin entries, so its scoped manifest registry is empty. Validating the final candidate against it made every plugin entry added by the same write look unknown, and non-interactive onboarding warned that the openai and codex entries it had just written were stale or uninstalled. Drop the stale snapshot so validation resolves the manifest registry from the candidate it is actually validating. Strict semantic validation is unchanged, and the registry load stays lazy. * fix(ci): raise the Control UI startup JS baseline to unblock main main is red on the Control UI startup-JS ratchet: unrelated PR #126725 measures 348289 B and this branch measures 348351 B against a 347023 B baseline + 1056 B tolerance. Twenty-six UI commits have landed since the last bump (#126474), none individually large. Baseline moves to the CI-measured 348351 B, well under the 358400 B maintainer-approved ceiling that still guards cumulative creep.
…penclaw#126734) * fix(config): validate config writes against the config being written writeConfigFileFromContext passed the pre-write snapshot's plugin metadata into strict validation. During onboarding that snapshot belongs to an intermediate config written by agent creation, which has no plugin entries, so its scoped manifest registry is empty. Validating the final candidate against it made every plugin entry added by the same write look unknown, and non-interactive onboarding warned that the openai and codex entries it had just written were stale or uninstalled. Drop the stale snapshot so validation resolves the manifest registry from the candidate it is actually validating. Strict semantic validation is unchanged, and the registry load stays lazy. * fix(ci): raise the Control UI startup JS baseline to unblock main main is red on the Control UI startup-JS ratchet: unrelated PR openclaw#126725 measures 348289 B and this branch measures 348351 B against a 347023 B baseline + 1056 B tolerance. Twenty-six UI commits have landed since the last bump (openclaw#126474), none individually large. Baseline moves to the CI-measured 348351 B, well under the 358400 B maintainer-approved ceiling that still guards cumulative creep.
Closes #125157
AI-assisted implementation. I reviewed the architecture, code, and validation results; no agent transcript is included.
Additional instructions
MUST: Keep Allow edits from maintainers enabled for this PR so maintainers
can help update the branch when needed.
What Problem This Solves
PAT-only setup and ambient GitHub authentication make a dedicated bot or user identity cumbersome and easy to confuse with the Gateway preview credential. Cloud publication also intentionally gives workers no forge credential, so operators need a safe Gateway-owned way to authorize the user identity that local
ghcommands and publication should use.Why This Change Was Made
Settings now owns GitHub device authorization through the dedicated OpenClaw GitHub Tools OAuth App. The Gateway owns polling, hidden refresh metadata, restart recovery, stable managed-profile replacement, and publication identity; system and complete per-agent identities remain distinct, native inference remains the unconfigured default, PAT setup remains an explicit one-use fallback, and cloud workers remain credential-free.
The browser receives only the user code, pinned GitHub verification URL, relative expiry presentation, and cancel action. It never receives the device code, access token, or refresh token. Refresh verifies the durable numeric GitHub account ID, preserves the stable managed profile and custom Git author, atomically replaces
hosts.yml, retains already-admitted local runs, and drains non-idempotent refresh work during shutdown.User Impact
An operator can open GitHub from Settings → Agents → Tools, enter the displayed code, and authorize the intended GitHub user. The Gateway refreshes that identity and makes it effective for local
ghexecution and Gateway-owned publication. Operators can choose a system identity or a complete per-agent override, inspect the effective identity and selected scope separately, cancel authoritatively, remove a managed identity with explicit new-run wording, or use PAT fallback. Cloud workers still receive no forge credential.Evidence
Exact reviewed head:
dbf7f6007de4b08877e2027d057faf9b2fed89a7pnpm protocol:checkpassed, including registry, Swift/Kotlin generation, additive-method vintage, and committed-output drift checks.swift test --package-path apps/shared/OpenClawKit --filter GatewayProtocolGeneratedModelsTestspassed 7 tests, including all 8 device-result outcomes.node scripts/check-changed.mjspassed the complete branch classifier: core/UI/scripts typechecking and lint, architecture/security/schema guards, plus 484 macOS/tooling tests.pnpm buildpassed all build groups, 61 external plugin distributions, 146 public Plugin SDK subpaths, runtime postbuild checks, and Control UI performance budgets.git diff --check origin/main...HEADpassed.origin/mainreported no accepted/actionable findings.OPENCLAW_TESTBOX=1 scripts/pr prepare-run 126474passed at 2026-08-20 00:40 UTC inhosted_exact_or_recent_parentmode, reusing the exact hosted CI result for this head; it verified the remote PR tree equals the prepared tree, required no rebase/changelog/push rewrite, and therefore needed no separate Testbox lease.ToolDisplayRegistryTests,tool-display:check,git diff --check, and a fresh P1 autoreview all passed before the repair commit.tools.github.kindat both scopes. The startup baseline uses the exact 347,023-byte CI measurement (+1,445 bytes), stays below the unchanged 350 KiB hard cap, and names the Settings status/recovery copy. The 24-test config-quality suite, focused UI build/performance check,git diff --check, and a fresh P1 autoreview passed before the repair commit.GitHubToolAccountis now a five-line leaf contract shared by both owners, with no compatibility alias or behavior change. The complete architecture chain, 78 focused record/identity/lifecycle tests, scoped production/test typechecks and guards,git diff --check, and a fresh P1 autoreview passed before the refactor commit.git diff --check, test-audit, and fresh P1 autoreview passed.Safe public endpoint proof on this head generated no user authorization and printed no code values: HTTP 200; 40-character device-code shape; valid user-code shape; pinned
https://github.com/login/device; expiry 899 seconds; interval 5 seconds; no error.Local Android unit execution remains unavailable because this host has no Android SDK/
ANDROID_HOME; Kotlin generation passed locally and exact-head PR CI is required to provide the Android unit/build proof.Production LOC: +4042/-463; tests/test support: +3168/-90; generated protocol/config/i18n/native-display/performance artifacts: +553/-59; docs: +13/-6. Production growth is the concrete authorization capability: OAuth client and hidden bounded records, lifecycle/CAS recovery, stable-profile refresh, protocol/status surfaces, and the Settings flow. There is no SQLite schema-version bump.
Dependency contracts checked directly:
offline_access, access/refresh response fields, one-use refresh rotation, and refresh withoutclient_secretfor device-issued tokens: Expiring access tokens, Device flow, and Refreshing an access token. Direct source inspection coveredgithub/docsauthorizing-oauth-apps.md:43-59,:293-304, and:331-359.config_types.rs:214-220,shell_environment.rs:47-64,shell_command.rs:108-115, andspawn.rs:64-76.Review disposition
tools.github.statusfirst landed in feat(agents): configure per-agent GitHub identities #125199 at6e458d84bfc1970ccd97b0a0b493f1e0f4965c56on August 17. No stable or beta tag contains that commit: the newest beta tag predates it (August 14), and the newest stable tag is July 13. Repository doctrine gives unreleasedmainand beta-only surfaces no compatibility obligation, so this final staged feature keeps one canonical status method instead of adding an obsolete legacy RPC before first shipment.Visual proof
Before: current-main PAT-only managed identity UI.
After: connected system identity is effective and refresh-capable.
Device authorization: the browser-visible surface contains only the fake user code, pinned verification link, relative expiry, and cancel action.
Scope separation: the selected agent override and effective system identity render as distinct blocks.
Full sanitized flow recording:
[email protected]