Skip to content

refactor(config): simplify guarded config writes - #159605

Merged
steipete merged 3 commits into
mainfrom
codex/fs-safe-config-atomic-prototype-20260926
Sep 27, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/fs-safe-config-atomic-prototype-20260926

Conversation

@steipete

@steipete steipete commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Config writes duplicate filesystem mutation fencing and descriptor tracking that released fs-safe 0.21.0 can now own.

User Impact

No intended user-visible change: root and included config writes retain conflict checks, backups, permissions, and conditional recovery. No configuration or migration is required.

Why This Change Was Made

Use fs-safe's mutation guards and destination receipts, removing 115 net production implementation lines (119 physical lines). OpenClaw retains config policy and include-directory mode preservation.

A small descriptor-based rename observer remains necessary: rename can succeed before fs-safe's destination verification throws. Recording that effect preserves the existing recovery behavior without claiming the destination has been verified.

Evidence

  • Main integration: 340 tests passed across config writes, include mutations, and prepared backup recovery on rebased head b61c130ae7366b8dc4680acdc92a93fe1dccdbd7; one worker, 663.40 seconds wrapper wall including compilation. The three branch patches remain identical after integrating main's newer recovery handling and canonical CI fixture repairs.
  • Fault injection: the updater's complete config-fence file reproduced one failure before the fixture correction and passed all 27 cases afterward. The spy is now installed before filesystem capture and armed at the original commit boundary; an explicit assertion proves late revocation actually happened. All original bytes, inode, timestamp, backup, directory-entry, and mode assertions remain. Green wrapper wall: 117.19 seconds; repaired case: 465 ms. No production change was needed for that fixture.
  • Real CLI: isolated supported pnpm openclaw --profile <profile> config set commands passed for root and include writes, recovery backups, root-byte preservation, and file/directory modes. Synthetic state was removed; no operator Gateway changed.
  • Native Windows: all five real-handle publication/rollback cases passed in Windows shard 2 against the unchanged production patch. They cover sharing violations, partial-write revocation, parent-directory move denial, and same-byte replacement. Bodies took 1,417 / 238 / 159 / 137 / 142 ms.
  • Review and static checks: independent review through P2 found no actionable issues. The complete selected type/lint/format/export/guard checks passed; the updater fixture correction also received fresh P2 review and its complete changed-file gate.

Published updater → candidate config publication is verified. In run 36351266940, genuine published [email protected] installed frozen candidate b61c130a. Both candidate-package and installed-payload identity checks passed. The initial update receipt records successfulUpdateCheck.outcome: "passed", plugins.status: "ok", and plugins.changed: true; candidate source produces that positive result only after its awaited config commit, and the published parent consumes it after joining child settlement. Automatic config/state survival passed for 4,800 sessions, 23,890 events, and 2,200 cron jobs. No later standalone Doctor or recovery supplied this result. This evidence applies to the unchanged atomic implementation on current head.

The complete upgrade scenario remains failed. Its later gateway-start exceeded the unchanged readiness budget: HTTP bound around 49 seconds and plugin loading finished around 74 seconds, with no recorded exception or OOM before subsequent startup work exhausted the wait. Gateway health/RPC, volume-history, idempotence, and restart checks were not reached. The separate post-core exit snapshot is unavailable; no natural child exit code is claimed. The verified result artifact retains the initial update receipt, failure report and lane log.

The earlier base scenario 36342219335 failed before candidate execution when the published baseline reached ready after its 90-second budget. A subsequent successful candidate build in 36348693598 hit source-reachability validation after this PR was rebased; a temporary branch now retains the frozen commit, and 36351266940 reused that exact integrity-verified tarball. No budgets or assertions were weakened and no replacement package was rebuilt.

Earlier CI failures and retained proof

The rotated-parent registry failure in runs 36314958232 and 36321950634 was repaired canonically by #159735 (77847b567203). A local 326-pass/one-skip replay alone did not establish that fix. The subsequent ended-schema failure in run 36333119253 was resolved by main's revert 1664e4cf2626; the original 68-file selection then passed all 949 tests locally in 557.75 seconds. These canonical repairs are incorporated.

Run 36335209359 exposed the updater spy-capture mismatch repaired here. The original hosted group had 1,015 passes, one failure, and one skip; an interrupted 57-file local replay is not counted as proof. Run 36339385089 subsequently hit unrelated ACP/media test-type errors, now repaired on main by #159836 (0b6f02faae37) and incorporated through the rebase. Original failure logs are retained.

In run 36348533086, check-dependencies failed: full-tree Knip could not discover the newly added shell-invoked scripts/pr-lib/merge-prior-ci.mjs. Canonical main fix 0d02ab7aaf657c1872a5dac32369e88504e3bd5c registers the real entry and has green main CI. Current head dc671053a71a7a070683de2cb54ffee8838f06e2 incorporates it; all three branch patches are identical in range-diff, and config/updater production files and dependency inputs are unchanged. The published-updater proof remains pinned to b61c130a; the workflow was subsequently cancelled after the corrected head was pushed.

Run 36349688566 exposed a separate native-completion fixture failure: the retired-turn-receipt case observed two timers instead of zero. The original sequential Memory→Codex prefix passes all 242+279 tests locally (1,533.50 seconds); a focused allocation trace passes all four cases and observes the expected 10-ms retry followed by zero timers (349.21 seconds, predominantly compilation). These are non-reproductions, not fixes. Canonical main repair #159864, aea667c764a8592d58a0efa4e85d741a70b4862b, scopes real database setup/teardown to the durable-receipt case while preserving every delivery, pin-release and zero-timer assertion. Current head dc671053a71a7a070683de2cb54ffee8838f06e2 incorporates that repair; all three branch patches remain identical in range-diff and config/updater production and dependency inputs are unchanged. The shared repair owner retains the Linux causal qualification. No competing fixture edit or unchanged CI rerun was made here; fresh receiving CI is required.

Earlier applicable proof includes 356 config/include/rollback/source-lock/uninstall tests (266.72 seconds), 334 config/include/deferred-migration tests (686.56 seconds), and a post-rename verification regression that failed with the callback-only implementation and passed with the retained observer (175 ms). Existing review and platform evidence applies to the unchanged production patch; fresh hosted CI remains required before landing.

@clawsweeper

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

@steipete
steipete marked this pull request as ready for review September 27, 2026 11:11
@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 27, 2026
@clawsweeper

clawsweeper Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 27, 2026, 7:00 PM ET / 23:00 UTC (Revision 9).

ClawSweeper review

What this changes

The branch moves root and included-config atomic write guards to fs-safe while retaining OpenClaw’s conflict checks, backups, permissions, and conditional recovery.

Merge readiness

✅ Ready for maintainer review

Current main and the latest release still use the existing guarded writer, so this PR remains distinct work. The scoped behavior evidence is strong and this review found no concrete introduced defect. The published-updater run verified config publication but timed out during later Gateway readiness.

Priority: P2
Reviewed head: dc671053a71a7a070683de2cb54ffee8838f06e2

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused implementation and cross-platform behavior evidence are strong; the full upgrade scenario has a documented later-stage gap.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (linked_artifact): The changed config writer reaches fs-safe through real root/include CLI writes and native Windows handle cases, with observed publication, backups, modes, and recovery. A published updater also reached successful candidate config publication and state survival; its later Gateway readiness timed out, so the complete upgrade scenario is not claimed. No stored data-model contract changes.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The changed config writer reaches fs-safe through real root/include CLI writes and native Windows handle cases, with observed publication, backups, modes, and recovery. A published updater also reached successful candidate config publication and state survival; its later Gateway readiness timed out, so the complete upgrade scenario is not claimed. No stored data-model contract changes.
Evidence reviewed 11 items Current-main behavior: The fetched main revision still defines the older guarded filesystem writer; the atomic-guard cutover is absent there.
Release boundary: The latest release tag resolves to this commit and its config writer still uses the older guarded implementation.
Changed production boundary: The config guard checks live authority, path identity, and snapshot state before mutation; destination receipts update the identity used for recovery.
Findings None None.
Security None None.

How this fits together

CLI, updater, and Gateway config requests reach OpenClaw’s config writer with a snapshot and any included files. The writer checks ownership and conflicts, delegates file replacement to fs-safe, then records publication or performs conditional recovery.

flowchart LR
A[CLI and updater requests] --> B[Config snapshot and includes]
B --> C[OpenClaw write guard]
C --> D[fs-safe atomic write]
D --> E[Config and backup files]
D --> F[Publication receipt]
F --> G[Conditional recovery]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -119, Tests +106. Total -13 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 4 167 286 -119
Tests 5 163 57 +106
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 330 343 -13

Review metrics

Metric Value Why it matters
Production versus test lines production −119 physical lines; tests +106 physical lines The implementation shrinks while tests retain and add publication and recovery coverage.

Technical review

Best possible solution:

Keep fs-safe responsible for atomic filesystem effects and OpenClaw responsible for config conflicts and recovery, with root and included writes preserving their backup and rollback behavior.

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

Not applicable: this is a behavior-preserving refactor. Root/include CLI runs, native Windows handle cases, and fault-injection tests provide checks for the behavior it must retain.

Is this the best way to solve the issue?

Yes: the released fs-safe contract is the narrower owner for atomic file effects, while the config writer retains its conflict and recovery policy, including the pre-verification rename observation.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 0722b96fe87a.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded config-writer refactor with limited direct user impact.
  • merge-risk: 🚨 compatibility: Changing config publication can affect existing backups and Windows fallback behavior; scoped real-behavior evidence addresses those paths beyond ordinary CI.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The changed config writer reaches fs-safe through real root/include CLI writes and native Windows handle cases, with observed publication, backups, modes, and recovery. A published updater also reached successful candidate config publication and state survival; its later Gateway readiness timed out, so the complete upgrade scenario is not claimed. No stored data-model contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed config writer reaches fs-safe through real root/include CLI writes and native Windows handle cases, with observed publication, backups, modes, and recovery. A published updater also reached successful candidate config publication and state survival; its later Gateway readiness timed out, so the complete upgrade scenario is not claimed. No stored data-model contract changes.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 870ff12 adds src/config/write-authority.ts:20 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 870ff120a7f7; files: src/config/write-authority.ts)
  • obviyus: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • vincentkoc: 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 (8 earlier review cycles)
  • reviewed 2026-09-27T11:19:05.909Z sha 5e225f7 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-27T13:27:16.393Z sha 7ccb8df :: needs maintainer review before merge. :: none
  • reviewed 2026-09-27T13:40:22.836Z sha 7ccb8df :: needs maintainer review before merge. :: none
  • reviewed 2026-09-27T16:32:06.178Z sha e8a4897 :: blocked before merge. :: none
  • reviewed 2026-09-27T17:07:06.633Z sha fe5a2762bec23f2f0a333a650fc3a56096ce3edb :: needs maintainer review before merge. :: none
  • reviewed 2026-09-27T18:15:39.479Z sha 7d2dc70f498ab462a164d268852dfcac94cd7cfb :: blocked before merge. :: none
  • reviewed 2026-09-27T21:00:30.087Z sha 5667d4df5ba1667a7d2df388bd0a2e44289d7b89 :: blocked before merge. :: none
  • reviewed 2026-09-27T22:06:16.712Z sha 5667d4df5ba1667a7d2df388bd0a2e44289d7b89 :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the codex/fs-safe-config-atomic-prototype-20260926 branch 2 times, most recently from 7ccb8df to e8a4897 Compare September 27, 2026 16:24
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Sep 27, 2026
@steipete
steipete force-pushed the codex/fs-safe-config-atomic-prototype-20260926 branch from e8a4897 to fe5a276 Compare September 27, 2026 16:58
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Sep 27, 2026
@openclaw-barnacle openclaw-barnacle Bot added the cli CLI command changes label Sep 27, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Sep 27, 2026
@steipete
steipete force-pushed the codex/fs-safe-config-atomic-prototype-20260926 branch 2 times, most recently from b61c130 to 5667d4d Compare September 27, 2026 20:53
Replace the filesystem-wide write proxy with fs-safe atomic authority
callbacks and destination-state facts. Keep config/include conflict policy,
backup identity checks, and rollback decisions with the config writer.
Preserve ordinary root rename of hardlinked configs without changing aliases.

This local prototype depends on the pending fs-safe atomic hook API. Keep the
released dependency pin unchanged until that API ships.

Validation: owning core and config/CLI test types pass against the local
proposal; 355 existing consumer cases pass with five native Windows skips.
After restoring root hardlink admission, the affected 257-case cohort passes.
The new real-file regression fails on the stricter variant and passes with
alias bytes intact (1.173s body; 55.70s single-worker cold command).
Fresh independent review reports no actionable P0-P2 findings.
Retain descriptor-derived successful-rename observations so post-rename verification failures still receive conditional rollback. Cover that publication boundary and hardlink compatibility through the existing config IO fixture, extracting coherent cases without growing its oversized test file.
Install the fsync spy before the writer captures filesystem functions. Arm revocation at beforeCommit and assert it occurs, preserving the existing file, backup, identity, and directory-mode assertions.
@steipete
steipete force-pushed the codex/fs-safe-config-atomic-prototype-20260926 branch from 5667d4d to dc67105 Compare September 27, 2026 22:52
@steipete
steipete merged commit 6b890a5 into main Sep 27, 2026
202 of 204 checks passed
@steipete
steipete deleted the codex/fs-safe-config-atomic-prototype-20260926 branch September 27, 2026 23:11
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 28, 2026
* refactor(config): prototype atomic mutation guards

Replace the filesystem-wide write proxy with fs-safe atomic authority
callbacks and destination-state facts. Keep config/include conflict policy,
backup identity checks, and rollback decisions with the config writer.
Preserve ordinary root rename of hardlinked configs without changing aliases.

This local prototype depends on the pending fs-safe atomic hook API. Keep the
released dependency pin unchanged until that API ships.

Validation: owning core and config/CLI test types pass against the local
proposal; 355 existing consumer cases pass with five native Windows skips.
After restoring root hardlink admission, the affected 257-case cohort passes.
The new real-file regression fails on the stricter variant and passes with
alias bytes intact (1.173s body; 55.70s single-worker cold command).
Fresh independent review reports no actionable P0-P2 findings.

* refactor(config): preserve recovery with fs-safe guards

Retain descriptor-derived successful-rename observations so post-rename verification failures still receive conditional rollback. Cover that publication boundary and hardlink compatibility through the existing config IO fixture, extracting coherent cases without growing its oversized test file.

* test(config): preserve updater revocation injection

Install the fsync spy before the writer captures filesystem functions. Arm revocation at beforeCommit and assert it occurs, preserving the existing file, backup, identity, and directory-mode assertions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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: L 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