Skip to content

fix(auth): keep setup replacements inactive until activation - #144524

Merged
obviyus merged 5 commits into
mainfrom
feat/setup-pending-credentials
Sep 11, 2026
Merged

obviyus merged 5 commits into
mainfrom
feat/setup-pending-credentials

Conversation

@obviyus

@obviyus obviyus commented Sep 11, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

A rejected replacement credential could enter normal rotation. Successful testing activated replacements without a separate choice, and retry details were lost after restart.

Why This Change Was Made

The shared credential owner persists retry state in the existing payload, excludes inactive replacements from use and copying, and activates only after testing, confirmation, and config application. Setup and Model Setup use this same flow.

User Impact

Working connections survive rejection or cancellation. Saved replacements can be retried after restart; ordinary login remains immediate. Before downgrading to older binaries, remove inactive replacements or restore pre-setup state because older versions do not enforce inactivity.

Evidence

Real Gateway and browser checks cover rejected replacements, continued use of the old credential, decline, cancellation, restart retry, explicit activation, and stale activation after deletion. Targeted setup, credential-persistence, noninteractive, and rendering tests passed. Live proof used one credential with distinct profiles; external browser login and refresh were not covered.

Related: #136257, #144195. Downgrade boundary.

@obviyus
obviyus requested a review from a team as a code owner September 11, 2026 00:39
@clawsweeper

clawsweeper Bot commented Sep 11, 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime commands Command implementations agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Sep 11, 2026
@obviyus

obviyus commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator Author

landpr-approve-admin-merge
pr: 144524
head: 6c23938
scope: owner-review

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 11, 2026
@clawsweeper

clawsweeper Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 10, 2026, 9:48 PM ET / September 11, 2026, 01:48 UTC (Revision 4).

ClawSweeper review

What this changes

Setup saves replacement credentials as inactive, retains their retry settings across restarts, and requires successful verification and explicit activation before normal use.

Merge readiness

⛔ Blocked before merge - 2 items remain

This remains a useful repair absent from current main. The earlier CLI findings are addressed, and this review found no additional blocking defect.

Priority: P2
Reviewed head: aedcac5cd90f60c5484aded16a88e45e8cad22c8

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent repair with meaningful boundary coverage and resolved prior findings; runtime execution was not independently repeated.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied repository state identifies a maintainer-authored PR, so the ordinary contributor proof gate is exempt. Its captured body reports real Gateway verification, decline, restart recovery, and stale-deletion rejection for the changed setup owner; those runtime claims were not independently replayed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied repository state identifies a maintainer-authored PR, so the ordinary contributor proof gate is exempt. Its captured body reports real Gateway verification, decline, restart recovery, and stale-deletion rejection for the changed setup owner; those runtime claims were not independently replayed.
Evidence reviewed 9 items Still necessary on main: Fetched main retains the process-local savedCandidates map and saves setup credentials without an inactive descriptor. The latest supplied release, v2026.9.3, does not contain this credential-owner module. No merged replacement for this repair was established.
Credential activation boundary: Replacement activation requires confirmation after the selected connection test; promotion rereads the exact credential under the existing store lock and rejects deletion or modification. Gateway promotion waits for the config-application receipt.
Normal-use exclusion: The scoped access owner checks operation liveness, selected profile, and agent directory. Callers apply it to credential resolution and selection; portability and OAuth reconciliation independently exclude inactive replacements.
Findings None None.
Security None None.

How this fits together

OpenClaw setup turns provider sign-ins into stored credentials and configured model connections. The shared credential store feeds runtime selection, while Gateway and CLI setup control verification and activation.

flowchart TD
  A[Provider sign-in] --> B[Save candidate credential]
  B --> C{Replacement connection?}
  C -->|Yes| D[Inactive saved sign-in]
  D --> E[Scoped connection test]
  E --> F{Successful and confirmed?}
  F -->|No| D
  F -->|Yes| G[Apply config and promote credential]
  C -->|No| E
  G --> H[Normal model access]
Loading

Before merge

  • Resolve merge risk (P1) - Older binaries can use saved inactive replacements because they do not enforce the descriptor; the accepted downgrade procedure requires removing those replacements or restoring pre-setup state.
  • Resolve merge risk (P1) - Noninteractive credential replacement now leaves the candidate inactive and requires Model Setup activation, so unattended replacement workflows must account for that intentional behavior change.
Agent review details

Security

None.

PR surface

Source +762, Tests +613, Docs +20, Other 0. Total +1395 across 38 files.

View PR surface stats
Area Files Added Removed Net
Source 27 1050 288 +762
Tests 9 759 146 +613
Docs 1 20 0 +20
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 38 1830 435 +1395

Review metrics

Metric Value Why it matters
Production versus test growth Production +762 lines; tests +613 lines net Production growth implements persistent retry state, scoped credential access, and activation across existing setup entry points.

Merge-risk options

Maintainer options:

  1. Retain the accepted compatibility boundary (recommended)
    Carry the documented downgrade procedure and noninteractive activation behavior into landing without reopening the already-recorded storage decision.

Technical review

Best possible solution:

Keep verification and promotion with the existing setup and credential owners, preserving the working connection and the documented activation and downgrade boundaries.

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

Yes, from source: current main saves replacement profiles without an inactivity marker, allowing normal selection to consider them after a rejected setup attempt; this review did not execute the flow.

Is this the best way to solve the issue?

Yes. Extending the existing credential owner and setup activation flow avoids a parallel pending store, and the prior CLI corrections preserve confirmation across entry points.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 1c1f85474f5b.

Labels

Label justifications:

  • P2: This repairs credential replacement and retry behavior with a bounded setup-specific impact.
  • merge-risk: 🚨 compatibility: Older readers do not enforce inactivity, and noninteractive replacement now requires a separate activation step.
  • 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 supplied repository state identifies a maintainer-authored PR, so the ordinary contributor proof gate is exempt. Its captured body reports real Gateway verification, decline, restart recovery, and stale-deletion rejection for the changed setup owner; those runtime claims were not independently replayed.

Evidence

What I checked:

  • Still necessary on main: Fetched main retains the process-local savedCandidates map and saves setup credentials without an inactive descriptor. The latest supplied release, v2026.9.3, does not contain this credential-owner module. No merged replacement for this repair was established. (src/system-agent/setup-inference-credentials.ts:60, 1c1f85474f5b)
  • Credential activation boundary: Replacement activation requires confirmation after the selected connection test; promotion rereads the exact credential under the existing store lock and rejects deletion or modification. Gateway promotion waits for the config-application receipt. (src/system-agent/setup-inference-credentials.ts:230, aedcac5cd90f)
  • Normal-use exclusion: The scoped access owner checks operation liveness, selected profile, and agent directory. Callers apply it to credential resolution and selection; portability and OAuth reconciliation independently exclude inactive replacements. (src/agents/auth-profiles/setup-access.ts:12, aedcac5cd90f)
  • Previous findings addressed: Remote onboarding now relays confirmation and cancellation through the Gateway wizard, and local activation permits promotion after the plugin-install restart receipt. The corresponding tests cover accept, decline, cancellation, and local restart behavior. (src/commands/onboard-remote-gateway.ts:258, aedcac5cd90f)
  • Accepted persistence tradeoff: The design discussion explicitly accepts storing retry state in the existing credential payload without a schema bump and documents removing inactive replacements or restoring pre-setup state before downgrade: fix(auth): keep setup replacements inactive until activation #144524 (comment). This resolves the prior review's design question rather than creating another approval request. Public docs: docs/auth-credential-semantics.md. (docs/auth-credential-semantics.md:50, aedcac5cd90f)
  • Captured validation and limits: The supplied complete PR body reports real Gateway first-run, rejection, continued old-credential use, decline, cancellation, restart retry, activation, and stale-deletion rejection. It explicitly excludes live OAuth refresh and two-account coverage. The local proof scratch directory contains no media; tests and runtime execution were not run during this read-only review. (aedcac5cd90f)

Likely related people:

  • obviyus: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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-09-11T00:45:44.855Z sha 6c23938 :: blocked before merge. :: [P1] Carry replacement confirmation through remote CLI onboarding | [P2] Handle local CLI activation when plugin installation requests restart
  • reviewed 2026-09-11T01:05:11.831Z sha 2f590b1 :: blocked before merge. :: none
  • reviewed 2026-09-11T01:20:23.650Z sha e0ac49d :: blocked before merge. :: none

@obviyus

obviyus commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator Author

Design decision for this repair: keep saved replacement state in the existing auth-profile credential payload, with no schema change or migration. The approved work order delegates this choice and requires an additive, lenient implementation.

The auth-profile store owns the credential and retry settings. Setup owns scoped verification and explicit promotion. Normal readers in this version exclude inactive replacements. Reopening this version preserves the saved candidate and requires fresh verification; no verification verdict is persisted. Ordinary login and existing credential payloads remain valid.

Older binaries do not understand the descriptor. Downgrading with inactive replacements present is unsupported: remove those saved replacements or restore pre-setup state first. A schema/version fence would reject older readers for an otherwise additive payload change; this repair does not add that fence. The documentation records this limitation rather than claiming older-reader inactivity.

Promotion rereads the credential under the existing store lock. Failed verification, cancellation, or rejection retains the saved row and does not publish candidate config. No retention policy, table, column, or parallel pending store is added. The retained restart proof covers reopening and retry on the new reader; live OAuth refresh and mixed-version operation are not claimed.

@obviyus

obviyus commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator Author

landpr-approve-admin-merge
pr: 144524
head: 2f590b1
scope: owner-review

@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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 11, 2026
@obviyus

obviyus commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator Author

landpr-approve-admin-merge
pr: 144524
head: d32a09e
scope: owner-review

@obviyus

obviyus commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator Author

landpr-approve-admin-merge
pr: 144524
head: e0ac49d
scope: owner-review

@obviyus

obviyus commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator Author

landpr-approve-admin-merge
pr: 144524
head: aedcac5
scope: owner-review

@obviyus
obviyus merged commit a305caf into main Sep 11, 2026
191 of 192 checks passed
@obviyus
obviyus deleted the feat/setup-pending-credentials branch September 11, 2026 01:59
@obviyus

obviyus commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator Author

Landed as a305caf.

Proof: Real first-run and replacement setup verified rejection preservation, decline/cancellation, retry after restart using the saved profile, explicit activation, and stale-deletion rejection. Control UI end-to-end proof and focused CLI/OAuth tests passed. Final exact-head review had zero findings and cleared security.

  • Bug: A rejected setup replacement could enter normal rotation, and a successful test activated it without a separate decision.
  • Fix: The existing credential store retains inactive replacements; setup verifies the selected connection, asks for activation, and promotes it after config application. Ordinary login remains immediate.
Before After
A saved replacement could affect working authentication before approval. Rejection or decline keeps the working credential and rotation unchanged.
Retry details were process-local. The same saved sign-in can be retried after restart.

Final CI: https://github.com/openclaw/openclaw/actions/runs/34551602406 — success. No red-CI waiver was used. Earlier Matrix download and terminal timing failures cleared on their bounded hosted retries; the preceding size failure was reproduced on main base 17819a7 (353130 gzip bytes against 353107, command exit 1).

Guarded admin merge used the owner-review approval at #144524 (comment). The accepted storage/downgrade boundary remains documented at #144524 (comment); noninteractive replacements intentionally require later activation. Live proof used one approved credential under separate profile IDs; live OAuth refresh and two-account coverage were not claimed.

Deleted-test ledger: keeps a working configured credential when a replacement is rejected moved from base src/system-agent/setup-inference-activate.test.ts:331 into the retained table at src/system-agent/setup-inference-activate.test.ts:350. Its original behavior remains, with implicit-rotation and restart coverage added.

obviyus added a commit that referenced this pull request Sep 11, 2026
…144568)

## What Problem This Solves

Fixes an issue where users preparing a provider through Gateway setup received a raw config-changed error after saving credentials if another config edit occurred during login. The unrelated edit survived, but the provider settings were not applied and the error did not explain that the credential was already saved.

## Why This Change Was Made

CLI login and Gateway preparation now share one config writer. It applies only the provider's changes to the latest authored config, merges model rows by ID, rejects conflicting or invalid edits, and uses the existing saved-credential/settings-failure error. Pending plugin-install records remain with their existing commit owner.

The setup path no longer binds publication to the snapshot taken before login. Strict snapshot checks remain for migration promotion and verified setup operations that require them. Credential persistence, cancellation, and default-model policy retain their existing owners.

## User Impact

Unrelated edits made while provider setup waits for input survive, and setup can complete. If settings cannot be applied, setup explains that credentials were saved and retains the config owner's recovery guidance.

## Evidence

- Reproduced on main `a321595f496e5a95d2bd0ffe81f7a080b4fcdfc8` through the shipped Gateway client: start preparation, edit an unrelated setting while the provider key prompt waits, then complete. Before: raw config-changed error with credential saved. After: setup completes with the edit and credential retained.
- Real config-directory permission failure: before, config-only error despite a saved credential; after, explicit saved-credential/settings-failure message. Used isolated state and synthetic credentials.
- 45 targeted Gateway setup tests and 55 CLI auth tests pass. The three original new regressions fail on main. Added protection for a config that becomes invalid during login.
- Focused lint, formatting, line-count and assertion checks pass. Full type checks run in GitHub CI.

Related: #144181, #144436. No changes to the credential replacement paths under #144524.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 11, 2026
…w#144524)

Related: openclaw#136257

## What Problem This Solves

Fixes an issue where replacing credentials in setup could add a rejected credential to normal rotation. A successful test also activated the replacement without a separate decision, and retry details were lost when the process stopped.

## Why This Change Was Made

Keep the existing per-submission profile IDs from openclaw#144195. Save the retry details in the credential's existing payload, exclude inactive replacements from normal use and copying, and activate only after a tool-free test, explicit confirmation, and config application. Both setup and Model Setup use the same credential owner; the in-memory retry cache is removed. No database schema change is required.

Noninteractive replacements are prepared in an isolated store and saved for later activation. Existing credential reuse and first-run noninteractive behavior remain available.

## User Impact

- Rejection, decline, or cancellation keeps the working connection and rotation unchanged.
- Saved credentials can be retried after restart without another login.
- Status distinguishes saved inactive credentials from usable access.
- Ordinary login remains immediate.

## Evidence

- Baseline: a targeted owner regression showed that a rejected replacement entered implicit rotation; the configured-profile sibling passed.
- Baseline real Gateway flow: a successful replacement activated without a separate confirmation.
- Candidate: targeted setup, discovery, shared credential-persistence, and noninteractive replacement/reuse checks pass.
- Real Gateway proof and independent source-blind acceptance cover first-run setup, invalid replacement, continued use of the old credential, decline, cancellation, restart retry, explicit activation, and deletion rejecting stale activation.
- Control UI end-to-end proof covers saved retry and explicit No/Yes choices. Focused rendering checks also pass.
- Targeted lint and whitespace checks pass. Full type checks and the complete test matrix run in CI.

The live provider proof used one approved credential under distinct profile IDs; it does not claim coverage across two provider accounts. OAuth provider refresh and external browser login are outside the live proof.

## Review Corrections

- OAuth reconciliation excludes inactive shared replacements before it can displace working agent-local credentials.
- Remote CLI onboarding relays the existing activation wizard's confirmation and cancellation; local CLI completes promotion after an accepted plugin-install restart receipt.
- A failed replacement test can return to the current connection without activating the candidate.
- The UI status renderer shares its translation call; the existing compressed-size budget is unchanged.

[Storage design and downgrade boundary](openclaw#144524 (comment)): the existing payload owns saved state. Older binaries do not enforce inactivity; remove inactive replacements or restore pre-setup state before downgrading.

## Deleted Test Ledger

The standalone test `keeps a working configured credential when a replacement is rejected` at `src/system-agent/setup-inference-activate.test.ts:331` on base `df8884dc1d7da20b4110163c497dc0016ee8cd91` was removed. Its behavior moved to the table at `src/system-agent/setup-inference-activate.test.ts:350`, named `keeps a working credential and rotation when a replacement is rejected (configured: $explicitProfile, restart: $restartRequired)`. The configured-profile case retains the old credential/config assertions; the table adds implicit rotation and plugin-restart cases. No tested behavior was removed.

## Shared CI Budget

The startup-size limit is also failing on main: retained base proof at `7052ef9371a31744510429d66ddf5b974cd5f6ff` reports 353,134 gzip bytes against 353,107, exit 1. This lane's prior candidate and base had identical raw startup bytes; the compressed result varies with lazy asset references. The owner authorized the guarded shared-failure exception. No size budget is changed. All candidate-caused type/lint failures are repaired separately.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 11, 2026
…penclaw#144568)

## What Problem This Solves

Fixes an issue where users preparing a provider through Gateway setup received a raw config-changed error after saving credentials if another config edit occurred during login. The unrelated edit survived, but the provider settings were not applied and the error did not explain that the credential was already saved.

## Why This Change Was Made

CLI login and Gateway preparation now share one config writer. It applies only the provider's changes to the latest authored config, merges model rows by ID, rejects conflicting or invalid edits, and uses the existing saved-credential/settings-failure error. Pending plugin-install records remain with their existing commit owner.

The setup path no longer binds publication to the snapshot taken before login. Strict snapshot checks remain for migration promotion and verified setup operations that require them. Credential persistence, cancellation, and default-model policy retain their existing owners.

## User Impact

Unrelated edits made while provider setup waits for input survive, and setup can complete. If settings cannot be applied, setup explains that credentials were saved and retains the config owner's recovery guidance.

## Evidence

- Reproduced on main `c073aed1cfd1ae78c62b1920e76456b595e26950` through the shipped Gateway client: start preparation, edit an unrelated setting while the provider key prompt waits, then complete. Before: raw config-changed error with credential saved. After: setup completes with the edit and credential retained.
- Real config-directory permission failure: before, config-only error despite a saved credential; after, explicit saved-credential/settings-failure message. Used isolated state and synthetic credentials.
- 45 targeted Gateway setup tests and 55 CLI auth tests pass. The three original new regressions fail on main. Added protection for a config that becomes invalid during login.
- Focused lint, formatting, line-count and assertion checks pass. Full type checks run in GitHub CI.

Related: openclaw#144181, openclaw#144436. No changes to the credential replacement paths under openclaw#144524.

Co-authored-by: Ayaan Zaidi <[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 app: web-ui App: web-ui commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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