Skip to content

test(agents): coordinate settings lock contention - #146949

Merged
vincentkoc merged 1 commit into
mainfrom
fix/settings-storage-lock-handshake
Sep 13, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
fix/settings-storage-lock-handshake

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 13, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes: the shared settings-storage concurrent first-write test can time out in CI because one child process waits for a contender-created marker before the parent has confirmed that the contender reached the lock boundary.

User Impact

User impact: no user-visible behavior changes; maintainers get deterministic coverage for cross-process settings lock contention without increasing timeouts or weakening the final state assertion.

Why This Change Was Made

This maintainer-requested test stabilization makes the parent own the contention handshake. The first writer remains inside the lock until the contender has attempted exclusive acquisition of the exact settings lock and observed EEXIST; the parent then verifies that the first writer is still pending and the lock still exists before releasing it. This guarantees the pre-fix missing-directory path cannot proceed as serialized first writes without failing the handshake. The managed 10-second child timeout, final two-field assertion, and cleanup remain unchanged.

Evidence

Pre-fix CI failures:

Local proof:

  • Final head 60c62a2681bd3dd749c377ba20dc6a5a63de2fb9: node scripts/run-vitest.mjs src/agents/sessions/settings-storage.test.ts passed 15/15.
  • Final head: file-lock siblings (src/plugin-sdk/file-lock.test.ts, src/infra/stale-lock-file.test.ts, and PID identity tests) passed 59/59.
  • The initial parent-release candidate completed 25/25 fresh-cache stress invocations, covering 50 parameterized cases. Lead review then identified that its readiness marker preceded the actual lock attempt; the final head moves readiness to the exact EEXIST observation and reruns the focused and sibling gates above.
  • Changed-file dry-run selected coreTests. The selected gate passed 14 checks before the borrowed-worktree compiler boundary rejected external dependencies; the previously failing check-tsgo-core-boundary.mts surface then passed from the matching physical owner checkout at base f3bdcc10d628ac914b5796554cefa28c6c50cab9.
  • Mandatory autoreview at P0-P2 on the final staged candidate: scoped clean, no accepted or actionable findings.

@clawsweeper

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

@vincentkoc vincentkoc self-assigned this Sep 13, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review September 13, 2026 10:55
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper review

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS maintainer Maintainer-authored PR labels Sep 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 13, 2026, 7:13 AM ET / 11:13 UTC (Revision 2).

ClawSweeper review

What this changes

The PR coordinates competing settings writers through the parent test process, releasing the first writer only after the second observes actual lock contention.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused test stabilization absent from reviewed main. No actionable correctness or security findings remain, and the maintainer-authored PR is protected from automatic closure.

Priority: P3
Reviewed head: 60c62a2681bd3dd749c377ba20dc6a5a63de2fb9

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, sound test improvement with relevant reported validation and no actionable findings.
Proof confidence 🌊 off-meta tidepool Not applicable: This MEMBER-authored test-only PR is exempt from the external contributor runtime-proof gate; its reported focused runs exercise real child processes against settings storage, and no production authority changes require additional proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This MEMBER-authored test-only PR is exempt from the external contributor runtime-proof gate; its reported focused runs exercise real child processes against settings storage, and no production authority changes require additional proof.
Evidence reviewed 7 items Introduced change and preserved assertions: The complete introduced diff changes only the existing concurrent-first-write test. Readiness follows EEXIST on the exact lock path; the parent checks the first writer remains pending before release. Both saved fields, successful process exits, and lock removal remain asserted.
Dependency boundary: Settings storage calls acquireFileLockSyncWithRetry, whose lock manager re-exports the synchronous lock from @openclaw/fs-safe/file-lock; package.json pins fs-safe 0.8.5. This establishes the dependency contract relevant to the interception; no Codex dependency is involved.
Pinned lock implementation inspected: Verified repository identity through the GitHub repository API and resolved v0.8.5 to this commit. Its synchronous lock imports the default fs object and calls fs.openSync with O_EXCL, so the child-local interception observes the real acquisition attempt without replacing its outcome.
Findings None None.
Security None None.

How this fits together

Settings storage serializes global and project settings updates through a filesystem lock. This regression test runs independent Node processes and verifies that both updates survive concurrent initial saves.

flowchart TD
  A[Parent test process] --> B[First settings writer]
  B --> C[Hold settings lock]
  A --> D[Competing settings writer]
  D --> E[Observe exclusive acquisition failure]
  E --> A
  A --> F[Release first writer]
  F --> G[Verify both saved settings]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +31. Total +31 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 42 11 +31
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 42 11 +31

Review metrics

None.

Technical review

Best possible solution:

Keep the existing cross-process regression test with contention-based coordination and unchanged saved-state assertions.

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

No deterministic CI-timeout reproduction was established during this read-only review; the old timing dependency is visible in source, and the body links failing CI runs.

Is this the best way to solve the issue?

Yes. Observing the actual exclusive-lock failure strengthens the existing regression without adding production seams, increasing managed timeouts, or weakening the final state checks.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is focused test stabilization with no production behavior change.
  • 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: This MEMBER-authored test-only PR is exempt from the external contributor runtime-proof gate; its reported focused runs exercise real child processes against settings storage, and no production authority changes require additional proof.

Evidence

What I checked:

  • Introduced change and preserved assertions: The complete introduced diff changes only the existing concurrent-first-write test. Readiness follows EEXIST on the exact lock path; the parent checks the first writer remains pending before release. Both saved fields, successful process exits, and lock removal remain asserted. (src/agents/sessions/settings-storage.test.ts:350, 60c62a2681bd)
  • Dependency boundary: Settings storage calls acquireFileLockSyncWithRetry, whose lock manager re-exports the synchronous lock from @openclaw/fs-safe/file-lock; package.json pins fs-safe 0.8.5. This establishes the dependency contract relevant to the interception; no Codex dependency is involved. (src/infra/file-lock-manager.ts:7, 60c62a2681bd)
  • Pinned lock implementation inspected: Verified repository identity through the GitHub repository API and resolved v0.8.5 to this commit. Its synchronous lock imports the default fs object and calls fs.openSync with O_EXCL, so the child-local interception observes the real acquisition attempt without replacing its outcome. (src/file-lock-sync.ts:284, eb2294eeb6af)
  • Failure cleanup remains bounded: The test retains its 10-second managed child timeout and finally-block abort/join. runNodeScript delegates timeout and abort handling to the existing process-group cleanup owner. (test/helpers/run-node-script.ts:32, 60c62a2681bd)
  • Still necessary on reviewed main and release: Reviewed main retains the pre-acquisition readiness marker and five-second child-local wait. Inspection of v2026.9.4 likewise found the old handshake. The merged production repair at fix(settings): preserve concurrent first saves #134072 does not supersede this later test stabilization. (src/agents/sessions/settings-storage.test.ts:348, e96f62c64330)
  • Merged feature history: Git history and the GitHub commit patch connect the existing two-scope regression test to the merged concurrent-first-save repair. GitHub confirms that repair is merged. Local blame could not complete because a required historical object was unavailable; routing does not rely on that failed blame. (src/agents/sessions/settings-storage.test.ts:327, ee0669922117)

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-13T11:02:30.049Z sha 6dd3c2acefb0fca686e2f7a25b7570edd8d86583 :: needs maintainer review before merge. :: none

@vincentkoc
vincentkoc force-pushed the fix/settings-storage-lock-handshake branch from 6dd3c2a to 60c62a2 Compare September 13, 2026 11:05
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@vincentkoc vincentkoc changed the title chore(agents): coordinate settings lock contention test test(agents): coordinate settings lock contention Sep 13, 2026
@vincentkoc
vincentkoc merged commit bc6b662 into main Sep 13, 2026
108 of 109 checks passed
@vincentkoc
vincentkoc deleted the fix/settings-storage-lock-handshake branch September 13, 2026 11:24
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

vincentkoc added a commit to zachisfine/openclaw that referenced this pull request Sep 13, 2026
* temp/pr-146799: (70 commits)
  test: reuse explicit fallback config fixtures (openclaw#146948)
  fix(computer): return fresh window observations after actions (openclaw#146822)
  refactor(feishu): remove unreachable requester topic selection (openclaw#146904)
  improve(gateway): reduce CPU spent listing agent-owned sessions (openclaw#137745)
  fix(ui): avoid recapturing chat drafts during UI updates (openclaw#146884)
  fix(ui): show system uptime in the debug overlay (openclaw#146960)
  fix(retry): honor waits beyond the native timer limit (openclaw#145718)
  fix(ui): keep chat history idle when run status changes (openclaw#146802)
  fix(ui): reuse persisted text during chat streaming (openclaw#146831)
  refactor(qa): share harness drift result construction (openclaw#146903)
  test(agents): coordinate settings lock contention (openclaw#146949)
  fix(worker): avoid repeatedly serializing screenshot history (openclaw#146907)
  fix(secrets): stop buffered upload writes after cancellation (openclaw#146840)
  perf(doctor): avoid unnecessary state runtime imports (openclaw#146926)
  improve: reduce compaction request estimation work (openclaw#146961)
  fix(ci): wait for forwarded avatar imports before assertions (openclaw#146729)
  perf(workers): skip configured Git author lookups (openclaw#146833)
  fix: admit borrowed memory writes through the agent database owner (openclaw#146760)
  fix(discord): prevent voice playback gaps and stale turn controls (openclaw#146798)
  improve: reduce worktree filesystem stalls and archive syncs (openclaw#146906)
  ...
vincentkoc added a commit that referenced this pull request Sep 13, 2026
* commit 'ccfd2377cd07d1ad3a583ba64d08e29a065f7061': (1587 commits)
  fix(ui): avoid recapturing chat drafts during UI updates (#146884)
  fix(ui): show system uptime in the debug overlay (#146960)
  fix(retry): honor waits beyond the native timer limit (#145718)
  fix(ui): keep chat history idle when run status changes (#146802)
  fix(ui): reuse persisted text during chat streaming (#146831)
  refactor(qa): share harness drift result construction (#146903)
  test(agents): coordinate settings lock contention (#146949)
  fix(worker): avoid repeatedly serializing screenshot history (#146907)
  fix(secrets): stop buffered upload writes after cancellation (#146840)
  perf(doctor): avoid unnecessary state runtime imports (#146926)
  improve: reduce compaction request estimation work (#146961)
  fix(ci): wait for forwarded avatar imports before assertions (#146729)
  perf(workers): skip configured Git author lookups (#146833)
  fix: admit borrowed memory writes through the agent database owner (#146760)
  fix(discord): prevent voice playback gaps and stale turn controls (#146798)
  improve: reduce worktree filesystem stalls and archive syncs (#146906)
  fix(ui): avoid extra chat rail work while replies stream (#146883)
  improve(ui): speed up populated Usage timelines (#146947)
  test(gateway): retain auth recovery failure diagnostics (#146925)
  fix(tests): create private temporary home directories (#146931)
  ...

# Conflicts:
#	test/tsconfig/tsconfig.core.test.agents-other.json
#	test/tsconfig/tsconfig.core.test.agents-root.json
steipete added a commit that referenced this pull request Sep 13, 2026
Fix spurious settings-lock CI failures when contender startup consumes the first writer's independent deadline. Both child writers now share the existing 20-second test deadline, with explicit abort and process-tree joining. The regression still verifies contention, release ordering, both persisted settings fields, and lock removal.

Test-only; no user-visible behavior change. Delayed-start differential proof failed before and passed after the repair; disabling the file lock still fails both revised cases. The author recorded ten successful runs of all 15 settings-storage tests and passing changed checks. Refreshed exact-head CI run 34759062677 passed without reruns. Independent review and ClawSweeper found no actionable findings.

Related: #146949
Refs #144558
pdonizete added a commit to pdonizete/openclaw that referenced this pull request Sep 13, 2026
Brings in:
- openclaw#146949 (bc6b662) test(agents): coordinate settings lock contention
- openclaw#147028 (d4d3d6c) fix(sessions): align the reclamation-memory test with the archive session owner
- openclaw#147029 (1311b42) fix(test): avoid settings lock writer startup timeouts

Required to clear the 4 failing CI checks on PR openclaw#144507; the PR's
WhatsApp voice-note 16 kHz + WhatsApp-vendor fix is preserved
intact (main did not touch the changed lines).

Co-Authored-By: Claude Code <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 14, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 14, 2026
Fix spurious settings-lock CI failures when contender startup consumes the first writer's independent deadline. Both child writers now share the existing 20-second test deadline, with explicit abort and process-tree joining. The regression still verifies contention, release ordering, both persisted settings fields, and lock removal.

Test-only; no user-visible behavior change. Delayed-start differential proof failed before and passed after the repair; disabling the file lock still fails both revised cases. The author recorded ten successful runs of all 15 settings-storage tests and passing changed checks. Refreshed exact-head CI run 34759062677 passed without reruns. Independent review and ClawSweeper found no actionable findings.

Related: openclaw#146949
Refs openclaw#144558
fuller-stack-dev added a commit that referenced this pull request Sep 15, 2026
Keep real lock contention proof while excluding parent fixture scheduling from the bounded production retry loop. The parent releases and joins the first writer before allowing the contender to retry. Production lock limits and storage behavior are unchanged.

Delayed-parent proof reproduces the original timeout and passes with this fixture. Bypassing locking still fails both concurrency cases. Full settings-storage tests pass with CI-like permissions; focused lint, format and independent review pass.

Refs #146949, #147029
fuller-stack-dev added a commit that referenced this pull request Sep 15, 2026
* fix: join outbound lease renewal before cancellation cleanup

* test(agents): join the first settings writer before retrying

Keep real lock contention proof while excluding parent fixture scheduling from the bounded production retry loop. The parent releases and joins the first writer before allowing the contender to retry. Production lock limits and storage behavior are unchanged.

Delayed-parent proof reproduces the original timeout and passes with this fixture. Bypassing locking still fails both concurrency cases. Full settings-storage tests pass with CI-like permissions; focused lint, format and independent review pass.

Refs #146949, #147029

---------

Co-authored-by: Jason (Json) <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 16, 2026
…w#148390)

* fix: join outbound lease renewal before cancellation cleanup

* test(agents): join the first settings writer before retrying

Keep real lock contention proof while excluding parent fixture scheduling from the bounded production retry loop. The parent releases and joins the first writer before allowing the contender to retry. Production lock limits and storage behavior are unchanged.

Delayed-parent proof reproduces the original timeout and passes with this fixture. Bypassing locking still fails both concurrency cases. Full settings-storage tests pass with CI-like permissions; focused lint, format and independent review pass.

Refs openclaw#146949, openclaw#147029

---------

Co-authored-by: Jason (Json) <[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 maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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