Skip to content

fix(setup): preserve config edits made during provider preparation - #144568

Merged
obviyus merged 1 commit into
mainfrom
fix/setup-prepare-concurrent-config
Sep 11, 2026
Merged

obviyus merged 1 commit into
mainfrom
fix/setup-prepare-concurrent-config

Conversation

@obviyus

@obviyus obviyus commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator

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.

@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 gateway Gateway runtime commands Command implementations size: M maintainer Maintainer-authored PR labels Sep 11, 2026
@clawsweeper clawsweeper Bot added 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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 11, 2026
@clawsweeper

clawsweeper Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 10, 2026, 9:47 PM ET / September 11, 2026, 01:47 UTC.

ClawSweeper review

What this changes

Gateway provider preparation and CLI login share a config writer that preserves unrelated concurrent edits and explains when credentials were saved but settings could not be applied.

Merge readiness

✅ Ready for maintainer review

This PR addresses a remaining Gateway setup defect that the related merged auth fixes do not cover. Source review found no blocking correctness or security defect, and the reported live observations support the intended behavior.

Priority: P2
Reviewed head: 8cc93350c442b37b36ed28473ae55845f3499f57

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with relevant live observations and regression coverage, with no blocking defect found.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The complete PR body records real Gateway-client preparation before/after observations using isolated state and synthetic credentials, including preserved concurrent settings and accurate saved-credential reporting after a filesystem permission failure; these directly exercise the changed publication path.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The complete PR body records real Gateway-client preparation before/after observations using isolated state and synthetic credentials, including preserved concurrent settings and accurate saved-credential reporting after a filesystem permission failure; these directly exercise the changed publication path.
Evidence reviewed 9 items Remaining defect on pinned main: Gateway preparation saves credentials and then calls writeWizardConfigFile with the pre-login snapshot and hash. An intervening edit therefore rejects settings publication even when unrelated.
Latest-release comparison: Inspection through the GitHub contents API found the same snapshot-bound preparation write in v2026.9.3, lines 300–304; the requested Gateway repair is not present there.
Shared replay and commit safeguards: The new writer uses current source configuration, rejects invalid snapshots and overlapping changes, preserves the pre-commit callback, and delegates persistence to the existing pending-plugin-install commit owner. Both production callers use it. This is an OpenClaw config contract; the changed behavior does not depend on the Codex harness.
Findings None None.
Security None None.

How this fits together

Provider setup collects credentials and connection settings through Gateway wizard requests or CLI login. The config writer combines those settings with current authored configuration before publishing the result.

flowchart TD
  A[Gateway setup or CLI login] --> B[Provider preparation]
  B --> C[Save credentials]
  B --> D[Compute settings changes]
  E[Current authored configuration] --> F[Validate and check conflicts]
  D --> F
  C --> F
  F --> G[Commit through existing config owner]
  F --> H[Report settings failure and saved credentials]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +54, Tests +227. Total +281 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 3 102 48 +54
Tests 4 248 21 +227
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 350 69 +281

Review metrics

Metric Value Why it matters
Production versus test growth Production +54 net lines; tests +227 net lines Production growth consolidates replay policy for two callers; most added code covers concurrent-edit behavior.

Technical review

Best possible solution:

Keep provider-specific replay in one shared writer while the existing config, credential, cancellation, and plugin-install owners retain their commit responsibilities.

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

Yes: start Gateway provider preparation, edit an unrelated setting while input is pending, then complete it. Pinned main still enforces the earlier snapshot; the contributor reports reproducing this flow, while this review verified it from source.

Is this the best way to solve the issue?

Yes: sharing the established CLI replay policy fixes the Gateway failure without weakening the config owner's final conflict checks or changing credential activation policy.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This fixes a bounded setup failure triggered by concurrent configuration edits, with no demonstrated widespread outage.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The complete PR body records real Gateway-client preparation before/after observations using isolated state and synthetic credentials, including preserved concurrent settings and accurate saved-credential reporting after a filesystem permission failure; these directly exercise the changed publication path.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The complete PR body records real Gateway-client preparation before/after observations using isolated state and synthetic credentials, including preserved concurrent settings and accurate saved-credential reporting after a filesystem permission failure; these directly exercise the changed publication path.

Label justifications:

  • P2: This fixes a bounded setup failure triggered by concurrent configuration edits, with no demonstrated widespread outage.
  • 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. Sufficient (live_output): The complete PR body records real Gateway-client preparation before/after observations using isolated state and synthetic credentials, including preserved concurrent settings and accurate saved-credential reporting after a filesystem permission failure; these directly exercise the changed publication path.
  • proof: sufficient: Contributor real behavior proof is sufficient. The complete PR body records real Gateway-client preparation before/after observations using isolated state and synthetic credentials, including preserved concurrent settings and accurate saved-credential reporting after a filesystem permission failure; these directly exercise the changed publication path.

Evidence

What I checked:

  • Remaining defect on pinned main: Gateway preparation saves credentials and then calls writeWizardConfigFile with the pre-login snapshot and hash. An intervening edit therefore rejects settings publication even when unrelated. (src/gateway/server-methods/system-agent.ts:297, 1c1f85474f5b)
  • Latest-release comparison: Inspection through the GitHub contents API found the same snapshot-bound preparation write in v2026.9.3, lines 300–304; the requested Gateway repair is not present there. (src/gateway/server-methods/system-agent.ts:301, 1391f7cd2d40)
  • Shared replay and commit safeguards: The new writer uses current source configuration, rejects invalid snapshots and overlapping changes, preserves the pre-commit callback, and delegates persistence to the existing pending-plugin-install commit owner. Both production callers use it. This is an OpenClaw config contract; the changed behavior does not depend on the Codex harness. (src/plugins/provider-auth-config.ts:37, 8cc93350c442)
  • Existing CLI contract: The documented CLI contract preserves unset or existing defaults and unrelated sign-in edits, and separately reports credentials saved before settings application fails. The extraction retains those policies in the CLI finalizer. Public docs: docs/cli/models.md. (docs/cli/models.md:336, 8cc93350c442)
  • Behavioral regression coverage: Four new registered-handler scenarios cover unrelated edits, independent model rows, overlapping provider settings, and invalid concurrent config. They exercise the real config writer with mocked provider preparation; existing cancellation and CLI default-policy assertions remain. (src/gateway/server-methods/system-agent-setup-concurrent.test.ts:135, 8cc93350c442)
  • Contributor live observations: The complete supplied PR body reports shipped Gateway-client before/after runs with isolated state and synthetic credentials: completing preparation retains a concurrent unrelated edit and the credential; a real config-directory permission failure reports saved credentials separately. The REST body read matched the supplied body and pinned head. These are contributor observations, not reviewer-executed results. (8cc93350c442)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; 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.

@obviyus
obviyus merged commit 6e0043d into main Sep 11, 2026
315 of 317 checks passed
@obviyus
obviyus deleted the fix/setup-prepare-concurrent-config branch September 11, 2026 02:16
@obviyus

obviyus commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator Author

Proof: Gateway provider preparation completes after an unrelated concurrent config edit. A real config write failure reports that credentials were saved.

  • Bug: setup saved the credential, then failed on the snapshot taken before login and returned a config-only error.
  • Fix: setup and CLI login share a writer that replays provider changes against current settings and reports partial persistence clearly.
Before After
Concurrent edit caused a raw config-changed error after saving credentials. Setup completes and preserves the concurrent edit.
Config permission failure did not explain that credentials were saved. The wizard explains that credentials were saved but provider settings could not be applied.

Validated with real Gateway calls in isolated state, independent behavior checks, 45 Gateway setup tests, 55 CLI auth tests, and focused lint.

Automated checks passed on attempt 2. The first attempt hit a Matrix import-hook timeout; the failed jobs passed on a fresh runner with no source or timeout changes. No failing-check exception was used.

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

commands Command implementations gateway Gateway runtime maintainer Maintainer-authored PR 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. size: M 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