Skip to content

fix(config): preserve root and recovery backups after failed saves - #146291

Merged
obviyus merged 3 commits into
mainfrom
bugloop/config-write-recovery
Sep 13, 2026
Merged

obviyus merged 3 commits into
mainfrom
bugloop/config-write-recovery

Conversation

@obviyus

@obviyus obviyus commented Sep 12, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes root config write regressions introduced by #145983: failed config saves could remove the root and recommend a destructive retry, or discard recovery backups before staging succeeded.

Why This Change Was Made

Root and included-file saves share staged publication and safe restoration. Backup bytes are prepared asynchronously; rotation follows successful staging. Partial failures report the original error, recovery status, and backup location. The writer rechecks captured include path identities during publication and restoration. Backup permissions change only through admitted regular-file descriptors.

The decision which backup files may be mutated is made by exactly one mechanism at src/config/backup-rotation.ts:78.

The decision whether captured include paths are unchanged is made by exactly one mechanism at src/config/io.write-safety.ts:80.

User Impact

Failed staging preserves all five recovery generations. Interrupted saves restore the original file when safe. Gateway clients receive complete recovery details. Cancelled login and setup writes retain the cancellation reason.

Evidence

Before: permission-denied fallback plus a concurrent include edit removed the root; following retry advice lost Gateway settings and cold startup failed. Five disk-full saves consumed the backup history. The same CLI scenarios now restore the root, preserve all five root and include backups, and retain Gateway settings on the next save. Authenticated cold health passes; a wrong token is rejected. All three Gateway save methods return complete structured recovery failures. Aliased includes survive denied rename, validate, and cold-start; linked backup targets retain their bytes and permissions. Detailed consumer coverage is retained in proof/consumers.md.

Compatibility

No config keys, stored formats, protocol schema, or protocol version change. Partial publication failures use the existing UNAVAILABLE outcome. Plain-root legacy mutation adapters retain their supplied revision; include-bearing adapters without a committed snapshot use the existing unknown revision and can refresh before their next edit.

Consumers

  • Config CLI saves preserve root and include recovery backups, including through symlinked includes, and report restoration outcomes.
  • Gateway config.set, config.patch, and config.apply preserve complete recovery messages and structured details.
  • Login and service-install writers check live authority immediately before file effects.
  • Deferred chat and Telegram native login consent recheck retained flow and caller authority at publication.
  • Gateway setup activation carries cancellation through the shared config writer.
  • Legacy include mutation adapters receive an unknown revision when no committed composite revision is available.
Internal call migration

The counts below refer to retired adapters and synthetic test-fixture fields. Filesystem options, the public authority callback, and real token/version contracts remain supported.

census: generic assertConfigPathForWrite reviewed — 0 callers listed
census: generic chmod reviewed — 0 callers listed
census: generic copyFallbackOnPermissionError reviewed — 0 callers listed
census: generic copyFile reviewed — 0 callers listed
census: generic dirMode reviewed — 0 callers listed
census: generic fileSystem reviewed — 0 callers listed
census: generic maintainConfigBackups reviewed — 0 callers listed
census: generic mkdir reviewed — 0 callers listed
census: generic open reviewed — 0 callers listed
census: generic overwrite reviewed — 0 callers listed
census: generic promises reviewed — 0 callers listed
census: generic rename reviewed — 0 callers listed
census: generic tempPrefix reviewed — 0 callers listed
census: generic to reviewed — 0 callers listed
census: generic token reviewed — 0 callers listed
census: generic unlink reviewed — 0 callers listed
census: generic version reviewed — 0 callers listed

Invalidation

Existing config watchers and runtime refresh remain unchanged. Captured path facts are scoped to one write and its restoration. Failed saves publish no success acknowledgement.

Contention

Backup preparation yields to unrelated Gateway requests. With a 2,000 ms injected preparation delay, an unrelated health request completed in 90 ms (limit: 1,000 ms). Candidate staging, backup renames, and final checks stay synchronous.

Tests

374 targeted config-owner and CLI tests passed, including linked backup slots, alias fallback, alias replacement, and missing-parent repair. Registered openclaw config set, config.set, config.patch, config.apply, models.authLogin, and wizard.next cover config writes. Provider login is synthetic. Service-token/install tests use a mocked writer and prove forwarding and refusal, not native service effects. Package-entry consumers cover legacy revision compatibility.

CI hits the same server-startup-finish.ts:416 type error as main run 34718269980, introduced by #146275. The config tests, formatting, line limits, assertions, and unused-export checks pass.

Follow-up: Settings reload/save after a missing root can create defaults; that existing UI behavior is tracked separately.

@obviyus
obviyus requested a review from a team as a code owner September 12, 2026 18:21
@clawsweeper

clawsweeper Bot commented Sep 12, 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 gateway Gateway runtime cli CLI command changes commands Command implementations size: L maintainer Maintainer-authored PR labels Sep 12, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 12, 2026
@clawsweeper

clawsweeper Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 12, 2026, 5:34 PM ET / 21:34 UTC (Revision 4).

ClawSweeper review

What this changes

The PR shares config-save staging and recovery across root and included files, preserves backups when staging fails, and reports partial-write recovery outcomes.

Merge readiness

⛔ Blocked before merge - 2 items remain

This remains a useful repair absent from current main. The previous backup-permission finding is addressed, and no new blocking code defect was established; published-updater compatibility evidence remains outstanding.

Priority: P1
Reviewed head: 606b3d8e94e7423756ed95487870b931eca2fdab

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused recovery repair with meaningful boundary coverage and no established blocking defect; update integration evidence remains a merge requirement.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied MEMBER association exempts this PR from the ordinary external-contributor proof gate. Reported CLI/Gateway recovery observations remain useful evidence; the separate published-updater compatibility requirement remains unresolved.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied MEMBER association exempts this PR from the ordinary external-contributor proof gate. Reported CLI/Gateway recovery observations remain useful evidence; the separate published-updater compatibility requirement remains unresolved.
Evidence reviewed 10 items Current main still needs the repair: Current main retains maintainConfigBackups, which advances the five-slot ring before copying the current file; the proposed staged-publication owner is absent.
Latest release comparison: The v2026.9.4 source also rotates backups before copying the primary backup. This release does not contain the proposed repair.
Shared publication and recovery: The root writer records removal separately from completed publication, attempts guarded restoration, and exposes partial publication through ConfigWritePostCommitError; include writes use the same staging and rollback helpers.
Findings None None.
Security None None.

How this fits together

OpenClaw’s config writer accepts changes from CLI commands, Gateway requests, login, and setup flows. It publishes configuration files and recovery backups before callers apply the resulting runtime configuration.

flowchart TD
 A[CLI and Gateway changes] --> B[Validate config and capture ownership]
 B --> C[Prepare backup bytes]
 C --> D[Stage candidate file]
 D --> E[Recheck authority and publish]
 E --> F[Apply config and acknowledge]
 E --> G[Restore owned file or report recovery details]
Loading

Before merge

  • Resolve merge risk (P1) - The shared publication path and service-update authority callbacks lack published-updater compatibility evidence; an integration failure could prevent an existing installation from persisting config during service repair.
  • Complete next step (P2) - Attach published-updater × candidate evidence showing existing-config preservation and service recovery through the changed config writer.
Agent review details

Security

None.

PR surface

Source +132, Tests +538, Docs +6, Other 0. Total +676 across 23 files.

View PR surface stats
Area Files Added Removed Net
Source 11 424 292 +132
Tests 10 701 163 +538
Docs 1 6 0 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 23 1132 456 +676

Review metrics

Metric Value Why it matters
Production versus regression coverage Production net +132 lines; tests net +538 lines Production growth has a stated recovery and path-identity purpose, while most added coverage exercises failure outcomes through config entry points.

Merge-risk options

Maintainer options:

  1. Complete the updater compatibility evidence (recommended)
    Attach a published-updater × candidate result showing existing-config preservation and service recovery through the changed writer.

Technical review

Best possible solution:

Keep one guarded publication and recovery owner, with demonstrated preservation of existing configuration and successful service recovery when invoked by a published updater.

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

Yes, source inspection establishes the backup-consumption path, and the PR describes permission-denied fallback and disk-full CLI scenarios. This read-only review did not execute them.

Is this the best way to solve the issue?

Yes, sharing staged publication and guarded restoration is a focused owner-level repair; update compatibility still needs the applicable published-driver evidence.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 9b59fe4ef7da.

Labels

Label justifications:

  • P1: The repair addresses failed saves that can leave the root config absent or consume recovery history.
  • merge-risk: 🚨 compatibility: Changed service-update authority and config publication need compatibility evidence from a published updater operating on existing state.
  • 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 MEMBER association exempts this PR from the ordinary external-contributor proof gate. Reported CLI/Gateway recovery observations remain useful evidence; the separate published-updater compatibility requirement remains unresolved.

Evidence

What I checked:

  • Current main still needs the repair: Current main retains maintainConfigBackups, which advances the five-slot ring before copying the current file; the proposed staged-publication owner is absent. (src/config/backup-rotation.ts:145, 9b59fe4ef7da)
  • Latest release comparison: The v2026.9.4 source also rotates backups before copying the primary backup. This release does not contain the proposed repair. (src/config/backup-rotation.ts, 3a9d69db306c)
  • Shared publication and recovery: The root writer records removal separately from completed publication, attempts guarded restoration, and exposes partial publication through ConfigWritePostCommitError; include writes use the same staging and rollback helpers. (src/config/io.write.ts:481, 606b3d8e94e7)
  • Previous permission concern addressed: Backup mutation admits source and destination artifacts through openRootFileSync and changes permissions through the admitted source descriptor. Include path proofs check directory and symlink identities during publication and restoration. (src/config/backup-rotation.ts:62, 606b3d8e94e7)
  • Filesystem dependency boundary: The changed publication owner calls replaceFileAtomicSync and tempFile through OpenClaw wrappers that directly re-export @openclaw/fs-safe; package.json pins version 0.8.5. This establishes the relevant dependency contract. (src/infra/replace-file.ts:5, 606b3d8e94e7)
  • Pinned filesystem contract inspected: Repository ownership was verified through GitHub. At v0.8.5, synchronous atomic replacement stages the candidate before beforeRename; root-file admission rejects symlinks and hardlinks by default. The annotated tag resolves to the cited dependency commit. (src/replace-file.ts, eb2294eeb6af)

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)

Rank-up moves

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

  • Attach the published-updater × candidate result for existing-config preservation and service recovery.

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-12T18:31:10.093Z sha fb060c6 :: blocked before merge. :: none
  • reviewed 2026-09-12T20:08:27.187Z sha ed1729c :: needs real behavior proof before merge. :: [P2] Preserve alias-safe permission handling for include backups
  • reviewed 2026-09-12T20:58:52.769Z sha 606b3d8 :: blocked before merge. :: none

@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 12, 2026
@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: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 12, 2026
@obviyus

obviyus commented Sep 13, 2026

Copy link
Copy Markdown
Collaborator Author

landpr-approve-admin-merge
pr: 146291
head: 606b3d8
scope: owner-review

@obviyus

obviyus commented Sep 13, 2026

Copy link
Copy Markdown
Collaborator Author

landpr-approve-unrelated-red
pr: 146291
head: 606b3d8
run: 34717982282 attempt: 1
failed: check-additional-extension-package-boundary job=103618630752 conclusion=failure
failed: check-lint job=103618630612 conclusion=failure
failed: check-prod-types job=103618630683 conclusion=failure
failed: check-test-types job=103618630665 conclusion=failure
failed: check-test-types-core-1 job=103618630659 conclusion=failure
failed: check-test-types-core-2 job=103618630700 conclusion=failure
check: openclaw/ci-gate

@obviyus
obviyus merged commit 535fcd9 into main Sep 13, 2026
193 of 200 checks passed
@obviyus
obviyus deleted the bugloop/config-write-recovery branch September 13, 2026 02:38
@obviyus

obviyus commented Sep 13, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks @obviyus!

Proof: Real config saves preserve recovery files, and the recovered configuration starts an authenticated Gateway.

  • Bug: Interrupted saves could remove active config or discard recovery backups.
  • Fix: Stage before rotating backups, restore safely, and report the recovery outcome.
Before After
Failed saves could lose config and recovery history Safe restoration or explicit recovery guidance; failed staging preserves all five backups

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 13, 2026
…penclaw#146291)

## What Problem This Solves

Fixes root config write regressions introduced by openclaw#145983: failed config saves could remove the root and recommend a destructive retry, or discard recovery backups before staging succeeded.

## Why This Change Was Made

Root and included-file saves share staged publication and safe restoration. Backup bytes are prepared asynchronously; rotation follows successful staging. Partial failures report the original error, recovery status, and backup location. The writer rechecks captured include path identities during publication and restoration. Backup permissions change only through admitted regular-file descriptors.

The decision `which backup files may be mutated` is made by exactly one mechanism at `src/config/backup-rotation.ts:78`.

The decision `whether captured include paths are unchanged` is made by exactly one mechanism at `src/config/io.write-safety.ts:80`.

## User Impact

Failed staging preserves all five recovery generations. Interrupted saves restore the original file when safe. Gateway clients receive complete recovery details. Cancelled login and setup writes retain the cancellation reason.

## Evidence

Before: permission-denied fallback plus a concurrent include edit removed the root; following retry advice lost Gateway settings and cold startup failed. Five disk-full saves consumed the backup history. The same CLI scenarios now restore the root, preserve all five root and include backups, and retain Gateway settings on the next save. Authenticated cold health passes; a wrong token is rejected. All three Gateway save methods return complete structured recovery failures. Aliased includes survive denied rename, validate, and cold-start; linked backup targets retain their bytes and permissions. Detailed consumer coverage is retained in `proof/consumers.md`.

## Compatibility

No config keys, stored formats, protocol schema, or protocol version change. Partial publication failures use the existing `UNAVAILABLE` outcome. Plain-root legacy mutation adapters retain their supplied revision; include-bearing adapters without a committed snapshot use the existing unknown revision and can refresh before their next edit.

## Consumers

- Config CLI saves preserve root and include recovery backups, including through symlinked includes, and report restoration outcomes.
- Gateway `config.set`, `config.patch`, and `config.apply` preserve complete recovery messages and structured details.
- Login and service-install writers check live authority immediately before file effects.
- Deferred chat and Telegram native login consent recheck retained flow and caller authority at publication.
- Gateway setup activation carries cancellation through the shared config writer.
- Legacy include mutation adapters receive an unknown revision when no committed composite revision is available.

<details>
<summary>Internal call migration</summary>

The counts below refer to retired adapters and synthetic test-fixture fields. Filesystem options, the public authority callback, and real token/version contracts remain supported.

census: generic assertConfigPathForWrite reviewed — 0 callers listed
census: generic chmod reviewed — 0 callers listed
census: generic copyFallbackOnPermissionError reviewed — 0 callers listed
census: generic copyFile reviewed — 0 callers listed
census: generic dirMode reviewed — 0 callers listed
census: generic fileSystem reviewed — 0 callers listed
census: generic maintainConfigBackups reviewed — 0 callers listed
census: generic mkdir reviewed — 0 callers listed
census: generic open reviewed — 0 callers listed
census: generic overwrite reviewed — 0 callers listed
census: generic promises reviewed — 0 callers listed
census: generic rename reviewed — 0 callers listed
census: generic tempPrefix reviewed — 0 callers listed
census: generic to reviewed — 0 callers listed
census: generic token reviewed — 0 callers listed
census: generic unlink reviewed — 0 callers listed
census: generic version reviewed — 0 callers listed

</details>

## Invalidation

Existing config watchers and runtime refresh remain unchanged. Captured path facts are scoped to one write and its restoration. Failed saves publish no success acknowledgement.

## Contention

Backup preparation yields to unrelated Gateway requests. With a 2,000 ms injected preparation delay, an unrelated health request completed in 90 ms (limit: 1,000 ms). Candidate staging, backup renames, and final checks stay synchronous.

## Tests

374 targeted config-owner and CLI tests passed, including linked backup slots, alias fallback, alias replacement, and missing-parent repair. Registered `openclaw config set`, `config.set`, `config.patch`, `config.apply`, `models.authLogin`, and `wizard.next` cover config writes. Provider login is synthetic. Service-token/install tests use a mocked writer and prove forwarding and refusal, not native service effects. Package-entry consumers cover legacy revision compatibility.

CI hits the same `server-startup-finish.ts:416` type error as [main run 34718269980](https://github.com/openclaw/openclaw/actions/runs/34718269980), introduced by openclaw#146275. The config tests, formatting, line limits, assertions, and unused-export checks pass.

Follow-up: Settings reload/save after a missing root can create defaults; that existing UI behavior is tracked separately.

Co-authored-by: Ayaan Zaidi <[email protected]>
obviyus added a commit that referenced this pull request Sep 13, 2026
…146856)

## What Problem This Solves

After a partially saved settings file cannot be restored, Settings can misread the error as a stale conflict. Reloading the missing file and editing again can overwrite the complete configuration and prevent Gateway startup.

## User Impact

Settings keeps the draft, shows recovery instructions, and blocks further writes in existing and fresh tabs. “Discard draft and reload” accepts only an existing, valid file. Ordinary conflicts keep Reload. Ordinary invalid files keep their validation issues, even when a routine backup exists.

## Why This Change Was Made

The decision `how a config save error is classified` is made by exactly one mechanism at `ui/src/lib/config/config-gateway-operations.ts:72`. The decision `whether this running Gateway has an unresolved publication outcome to expose` is made by exactly one mechanism at `src/gateway/server-methods/config.ts:785`.

The added state retains actual write failures for fresh readers without inferring recovery from a backup file. Related: #146291. AI-assisted.

## Consumers

- Settings save indicators retain drafts and expose guarded recovery reload.
- Workshop, cloud-worker, Labs and MCP configuration edits receive recovery failures through shared write admission.
- Provider login, logout and API-key edits, model setup, agent identity and shared GitHub operations wait for recovery.
- Config-backed preference sync keeps pending edits when writes are refused.
- Skill and plugin changes share admission; wrappers retain an originating request error and use the owner message for pre-dispatch refusal.

## Invalidation

The Gateway records actual unresolved publication failures. A matching fresh valid read or successful write can clear its captured record; older operations cannot clear a newer failure. Settings retains its draft until explicit valid reload. Failure recording has one writer at the publication outcome boundary.

## Evidence

A real Gateway and browser reproduced Reload → reduced settings → cold startup exit 78 before the fix. Afterward, failed restoration retained the original draft and blocked a fresh tab; restoration enabled a complete save. A normal backup plus an unrelated invalid port preserved the concrete validation issue without claiming failed restoration.

## Compatibility

Existing diagnostic snapshots and revision fields remain intact. Optional `writeError` carries the actual publication error. No configuration keys, storage schemas, migrations or protocol versions change.

## Contention

The existing queue is unchanged. A held pre-failure read cannot retire a newer recovery record; no lock or awaited publication step is added.

## Tests

Targeted integration tests passed: 7 Gateway, 87 UI owner and 4 Settings browser cases. Existing ordinary-conflict coverage remains. Sanitized browser captures show retained drafts, blocked fresh-tab fields and preserved validation issues.

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

## What Problem This Solves

After a partially saved settings file cannot be restored, Settings can misread the error as a stale conflict. Reloading the missing file and editing again can overwrite the complete configuration and prevent Gateway startup.

## User Impact

Settings keeps the draft, shows recovery instructions, and blocks further writes in existing and fresh tabs. “Discard draft and reload” accepts only an existing, valid file. Ordinary conflicts keep Reload. Ordinary invalid files keep their validation issues, even when a routine backup exists.

## Why This Change Was Made

The decision `how a config save error is classified` is made by exactly one mechanism at `ui/src/lib/config/config-gateway-operations.ts:72`. The decision `whether this running Gateway has an unresolved publication outcome to expose` is made by exactly one mechanism at `src/gateway/server-methods/config.ts:785`.

The added state retains actual write failures for fresh readers without inferring recovery from a backup file. Related: openclaw#146291. AI-assisted.

## Consumers

- Settings save indicators retain drafts and expose guarded recovery reload.
- Workshop, cloud-worker, Labs and MCP configuration edits receive recovery failures through shared write admission.
- Provider login, logout and API-key edits, model setup, agent identity and shared GitHub operations wait for recovery.
- Config-backed preference sync keeps pending edits when writes are refused.
- Skill and plugin changes share admission; wrappers retain an originating request error and use the owner message for pre-dispatch refusal.

## Invalidation

The Gateway records actual unresolved publication failures. A matching fresh valid read or successful write can clear its captured record; older operations cannot clear a newer failure. Settings retains its draft until explicit valid reload. Failure recording has one writer at the publication outcome boundary.

## Evidence

A real Gateway and browser reproduced Reload → reduced settings → cold startup exit 78 before the fix. Afterward, failed restoration retained the original draft and blocked a fresh tab; restoration enabled a complete save. A normal backup plus an unrelated invalid port preserved the concrete validation issue without claiming failed restoration.

## Compatibility

Existing diagnostic snapshots and revision fields remain intact. Optional `writeError` carries the actual publication error. No configuration keys, storage schemas, migrations or protocol versions change.

## Contention

The existing queue is unchanged. A held pre-failure read cannot retire a newer recovery record; no lock or awaited publication step is added.

## Tests

Targeted integration tests passed: 7 Gateway, 87 UI owner and 4 Settings browser cases. Existing ordinary-conflict coverage remains. Sanitized browser captures show retained drafts, blocked fresh-tab fields and preserved validation issues.

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

cli CLI command changes 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. P1 High-priority user-facing bug, regression, or broken workflow. 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