Repository navigation
fix(settings): preserve concurrent first saves - #134072
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: found issues before merge. Reviewed August 31, 2026, 9:35 AM ET / 13:35 UTC. ClawSweeper reviewWhat this changesThe branch acquires the settings lock before reading or merging first writes, adds cross-process regression coverage, corrects a prompt-test fixture, and adds release-note text. Regression provenancePossible regression — probable (reviewed change; known regression link). No predecessor PR is attributed. Merge readinessKeep open: the lock-before-read repair addresses a source-reproducible concurrent first-write loss, but the exported storage API’s absent-directory no-op behavior and the release-owned changelog entry remain unresolved merge blockers. Priority: P1 Review scores
Verification
How this fits togetherSettingsManager persists global and project preferences through FileSettingsStorage. The storage callback merges a current settings file under a file lock before writing it back, so lock ordering determines whether independent processes preserve each other’s changes. flowchart LR
A[Settings update] --> B[Settings manager]
B --> C[File settings storage]
C --> D[File lock]
D --> E[Merge callback]
E --> F[Global or project settings file]
Decision needed
Why: The current branch changes an exported behavior whose claimed stable provenance is contradicted by the inspected commit graph, while the release-owned file has no independently visible exception. Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource -10, Tests +91, Docs +1. Total +82 across 4 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the lock-before-read repair, but establish the released direct-callback contract before merging; preserve side-effect-free no-op callers if that is the contract, and keep release-note context out of CHANGELOG.md unless release ownership explicitly approves it. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: current main invokes the first-write merge callback before lock acquisition when the directory is absent. The introduced test encodes the two-process interleaving for both scopes, but read-only review rules prohibit running it. Is this the best way to solve the issue? Unclear: locking before the read-modify-write callback is the correct repair boundary, but the direct no-op callback compatibility contract and release provenance need verification before this is the best complete solution. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 87dba63ec9c5. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
Acquire the canonical settings lock before reading or deriving updates, including absent directories. Keep missing reads lazy and verify both settings scopes with independent processes. Co-authored-by: Swagat Rathod <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
fd3363d to
4fdee64
Compare
|
Merged via squash.
|
* fix(settings): preserve concurrent first saves Acquire the canonical settings lock before reading or deriving updates, including absent directories. Keep missing reads lazy and verify both settings scopes with independent processes. Co-authored-by: Swagat Rathod <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]> * test(agents): prepare the model identity in prompt fixture * docs(changelog): avoid concurrent release note conflict --------- Co-authored-by: Ayaan Zaidi <[email protected]>
Related: #124471, #133413
What Problem This Solves
Fixes an issue where users saving different settings from concurrent OpenClaw processes could silently lose one setting when its directory did not exist yet. Both processes reported success, but the last writer replaced the other's update.
Why This Change Was Made
Acquire the existing canonical lock before reading settings or invoking the merge callback. The lock implementation already creates its parent directory, so this removes the separate delayed-lock path. Missing-settings reads retain their existing side-effect-free path. No schema, configuration, dependency, or public API changes.
Provenance: the first-write ordering shipped in 2026.8.1 via #124471 and was regressed by #133413 (
bec70700e08a09d5719e0acede249d4bcaefcfbf), verified against its raw parent diff. This restores that contract while preserving main's later read-side improvements.User Impact
Independent global and project settings survive concurrent initial saves. Existing lock ownership, stale-lock handling, and read behavior remain intact.
Evidence
check:changedpassed, including production/test types, lint, and structural guards.Original contributor credit is retained in the changelog and commit trailers.
Review Follow-through
ClawSweeper's lock-contract concern is resolved by direct inspection of the installed, pinned
@openclaw/[email protected]source:dist/file-lock-sync.js:83–90creates and canonicalizes the parent directory, andacquireFileLockSynccalls that owner at line 129 before exclusive lock acquisition. Both first-write scope regressions and the separate six-update SettingsManager proof passed against that exact dependency. No dependency upgrade is part of this change.The direct no-op callback compatibility finding is also intentionally skipped after checking the stable contract: published 2026.8.1 FileSettingsStorage.withLock explicitly creates the missing directory before locking, reading, or invoking the callback, including callbacks that return
undefined. The class was already exported through the agent-sessions SDK in that tag. This repair restores that shipped behavior; the side-effect-free direct callback branch was introduced by the later, unreleased regression in #133413. Read-only callers retain the canonicalreadSettingsScopeabsence path, which remains side-effect-free and tested. Running a callback once outside the lock to discover whether it writes would recreate stale input or require duplicate callback execution.The suggestion to remove the changelog bullet is intentionally skipped: this is maintainer-authorized release repair work with explicitly requested comprehensive release notes, rather than an ordinary contributor PR. The single user-facing bullet records the restored shipped contract and preserves original contributor credit.
CI Repairs
The initial exact-head CI found an unrelated global-session prompt fixture timeout and a workspace-icon test that counted unrelated header SVG fetches. The prompt fixture now includes the model identity supplied by real prepared attempt handles, preserving both sandbox-policy assertions. Its first case failed locally at 138.7 seconds before correction and passed in 199 ms afterward; all 25 prompt/setup tests pass without a timeout increase. Latest main already repaired workspace-icon fetch isolation in #133904 (
ca8064f2625), using the sharedmockWorkspaceIconFetchhelper. The redundant copied UI patch was dropped during rebase; this PR retains main’s canonical UI tests unchanged. No production prompt or UI behavior changes are included. The initial lint job was canceled by runner shutdown with no lint diagnostic; it is not reported as a code failure or a pass.The interrupted parent lint check passed on a single exact-job retry against unchanged source. A later docs-only relocation of the same settings note resolves a concurrent changelog insertion; text and contributor credit are unchanged. The new commit requires fresh CI independently of that parent result.