Skip to content

fix(sessions): honor file-lock cancellation - #117446

Merged
steipete merged 1 commit into
mainfrom
codex/goal100k-session-lock-coverage-0801-2d45
Aug 1, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/goal100k-session-lock-coverage-0801-2d45

Conversation

@steipete

@steipete steipete commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • reject cancelled file-lock admission even when @openclaw/fs-safe acquires after its retry wait
  • release the exact newly acquired sidecar before preserving the caller's original abort reason
  • restore retained lifecycle coverage for signal/exit cleanup, watchdog fencing, Linux PID starttime, SDK contention aborts, and SQLite mid-contention aborts

Root cause

The SDK checked the abort signal before entering the dependency-owned retry loop and again only after dependency errors. If cancellation arrived while @openclaw/fs-safe was waiting, and the current owner then released the sidecar, acquisition could succeed and be returned after the caller had already cancelled.

The adapter now checks cancellation immediately after successful acquisition. A cancelled admission best-effort releases that exact dependency handle, then throws through the canonical abort helper so the original signal reason wins.

Dependency contract

The installed @openclaw/fs-safe 0.5.0 implementation was inspected directly in dist/sidecar-lock.js, dist/sidecar-lock-reclaim.js, and dist/file-lock.js. It owns the bounded retry loop and returns an exact-entry fenced release handle after acquisition. The adapter therefore owns the post-success cancellation fence and can safely release only the newly acquired handle without disturbing a successor.

Proof

  • deterministic red before the fix: abort after observing real sidecar contention, release holder, pending acquisition incorrectly resolves
  • deterministic green after the fix: same ordering rejects with the exact reason, a successor acquires, and no sidecar leaks
  • focused remote tests: 37/37 passed
    • src/plugin-sdk/session-write-lock-runtime.test.ts
    • src/agents/session-write-lock.test.ts
  • remote pnpm check:changed: passed
  • Blacksmith Testbox: tbx_01kyys9kgbmwg6xvk3455gbt1z (jade-crayfish-5b9e)
  • final GPT-5.6-sol xhigh autoreview: clean, correctness 0.99
  • final rebase had no touched-path overlap; patch tree was unchanged
  • exact-head hosted CI: all effective checks and openclaw/ci-gate passed at 692580dc8258837ea7d823a13baf3c1e001437b6

Scope

Production delta: +6 LOC. No public API, config, schema, dependency, default, or environment surface changes.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Aug 1, 2026
@clawsweeper clawsweeper Bot added 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. P2 Normal backlog priority with limited blast radius. labels Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 10:56 AM ET / 14:56 UTC.

ClawSweeper review

What this changes

The PR fences session file-lock acquisition after the dependency returns, releases a newly acquired lock if cancellation won the race, and adds contention and lifecycle regression coverage.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Current main still returns a file-lock handle immediately after the dependency acquisition, so this PR addresses a real cancellation race and is not obsolete. The focused repair and contention regression look appropriate, but the installed @openclaw/fs-safe source is absent and GitHub DNS is unavailable, so its exact release-handle contract cannot be independently confirmed here. Likely related people: steipete (high confidence from the prior current-main session-lock refactor and this focused follow-up).

Priority: P2
Reviewed head: 692580dc8258837ea7d823a13baf3c1e001437b6
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) This is a focused, source-supported repair with credible contention evidence; direct confirmation of the dependency release contract remains the material merge-confidence gap.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR body records a deterministic real-filesystem contention sequence with before/after outcomes, exact abort reason, successor acquisition, no-leak result, focused remote tests, and exact-head CI; the Testbox and hosted-CI records could not be reopened because GitHub DNS is unavailable.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body records a deterministic real-filesystem contention sequence with before/after outcomes, exact abort reason, successor acquisition, no-leak result, focused remote tests, and exact-head CI; the Testbox and hosted-CI records could not be reopened because GitHub DNS is unavailable.
Evidence reviewed 4 items Current-main race remains: Current main checks cancellation before calling the file-lock manager and in the error path, but returns the acquired handle directly after the awaited acquisition; a signal that fires during the dependency retry loop can therefore be missed.
Patch and regression cover the owner boundary: The proposed post-acquisition fence releases the just-acquired lock before rethrowing the canonical abort reason, and its contention test holds a real sidecar, cancels the waiter, releases the holder, then verifies a successor can acquire without a leaked sidecar.
Dependency boundary requires direct confirmation: OpenClaw delegates file-lock creation to the public @openclaw/fs-safe/file-lock API. No installed package artifacts were present in this checkout, and direct GitHub retrieval failed because DNS could not resolve GitHub; this review therefore cannot independently prove that release() is fenced to the exact acquired entry.
Findings None None.
Security None None.

How this fits together

The plugin SDK adapts session-file writes to a sidecar lock while SQLite-backed session-key locking uses the shared session-lock owner. Callers request an acquisition with timeout and cancellation; the adapter returns a release handle or surfaces the canonical abort/lock error.

flowchart LR
  A[Session write caller] --> B[Plugin SDK lock adapter]
  B --> C[File lock manager]
  C --> D[Sidecar lock acquisition]
  D --> E{Signal cancelled?}
  E -->|No| F[Release handle to caller]
  E -->|Yes| G[Release newly acquired sidecar]
  G --> H[Throw caller abort reason]
Loading

Decision needed

Question Recommendation
Can the session-lock owner confirm that @openclaw/fs-safe 0.5.0's returned release() handle releases only the exact successful acquisition, making the proposed post-acquisition cancellation fence safe to merge? Confirm contract and merge: Verify the direct dependency source or installed package shows exact-entry release semantics, then accept the focused cancellation fence and regression test.

Why: The code-level race and repair are clear, but the dependency source required to validate the release-handle ownership contract is unavailable in this read-only checkout and could not be retrieved over GitHub DNS.

Before merge

  • Resolve merge risk (P1) - The repair depends on @openclaw/fs-safe returning a release handle that releases only the exact acquired sidecar; confirm that direct dependency contract before merge because this checkout lacks the installed package and GitHub DNS is unavailable.
  • Complete next step (P2) - The proposed code is a narrow repair, but the required direct dependency-contract verification is a maintainer evidence check rather than an automated replacement-branch task.
Agent review details

Security

None.

PR surface

Source +6, Tests +197. Total +203 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 6 0 +6
Tests 2 213 16 +197
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 219 16 +203

Review metrics

None.

Stored data model

Persistent data-model change detected: serialized state: src/agents/session-write-lock.test.ts, serialized state: src/plugin-sdk/session-write-lock-runtime.test.ts, unknown-data-model-change: src/plugin-sdk/session-write-lock-runtime.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Verify the @openclaw/fs-safe 0.5.0 acquire/release contract directly, retain the deterministic contention regression, and merge this narrow adapter-level cancellation fence if the handle is exact-entry scoped.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Verify the @openclaw/fs-safe 0.5.0 acquire/release contract directly, retain the deterministic contention regression, and merge this narrow adapter-level cancellation fence if the handle is exact-entry scoped.

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

Yes, from source: hold a real file sidecar, begin an infinite-timeout acquisition with an abort signal, cancel while the dependency retries, then release the holder; current main can return the acquired handle because it has no post-success abort check. The proposed regression test encodes this order, but it was not executed in this read-only review.

Is this the best way to solve the issue?

Yes, conditional on the direct dependency contract: the adapter owns cancellation admission around the dependency-owned retry loop, so releasing only its newly acquired handle and throwing the original abort reason is narrower than changing shared lock-manager semantics or polling callers.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 5ad7c969b820.

Labels

Label justifications:

  • P2: This corrects a bounded session-write cancellation race without changing public configuration, defaults, or persisted data.
  • 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 PR body records a deterministic real-filesystem contention sequence with before/after outcomes, exact abort reason, successor acquisition, no-leak result, focused remote tests, and exact-head CI; the Testbox and hosted-CI records could not be reopened because GitHub DNS is unavailable.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body records a deterministic real-filesystem contention sequence with before/after outcomes, exact abort reason, successor acquisition, no-leak result, focused remote tests, and exact-head CI; the Testbox and hosted-CI records could not be reopened because GitHub DNS is unavailable.

Evidence

What I checked:

  • Current-main race remains: Current main checks cancellation before calling the file-lock manager and in the error path, but returns the acquired handle directly after the awaited acquisition; a signal that fires during the dependency retry loop can therefore be missed. (src/plugin-sdk/session-write-lock-runtime.ts:208, 5ad7c969b820)
  • Patch and regression cover the owner boundary: The proposed post-acquisition fence releases the just-acquired lock before rethrowing the canonical abort reason, and its contention test holds a real sidecar, cancels the waiter, releases the holder, then verifies a successor can acquire without a leaked sidecar. (src/plugin-sdk/session-write-lock-runtime.ts:208, 692580dc8258)
  • Dependency boundary requires direct confirmation: OpenClaw delegates file-lock creation to the public @openclaw/fs-safe/file-lock API. No installed package artifacts were present in this checkout, and direct GitHub retrieval failed because DNS could not resolve GitHub; this review therefore cannot independently prove that release() is fenced to the exact acquired entry. (src/infra/file-lock-manager.ts:7, 5ad7c969b820)
  • Current-main and provenance check: The PR head is not an ancestor of current main, so the central repair is not already implemented. The available history identifies steipete's current-main session-lock refactor as the immediately preceding touch to this runtime file; deeper history hydration failed with the same GitHub DNS outage. (src/plugin-sdk/session-write-lock-runtime.ts:142, 9214183f4528)

Likely related people:

  • steipete: Authored the available immediately preceding current-main refactor of the session-write-lock runtime and this narrowly scoped cancellation repair. (role: recent area contributor; confidence: high; commits: 9214183f4528, 692580dc8258; files: src/plugin-sdk/session-write-lock-runtime.ts, src/plugin-sdk/session-write-lock-runtime.test.ts)

Rank-up moves

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

  • Attach or confirm direct @openclaw/fs-safe 0.5.0 source evidence showing that the acquired handle releases only its own sidecar entry.

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-08-01T14:46:54.719Z sha 692580d :: needs maintainer review before merge. :: none

@steipete
steipete merged commit 71a5951 into main Aug 1, 2026
141 of 149 checks passed
@steipete
steipete deleted the codex/goal100k-session-lock-coverage-0801-2d45 branch August 1, 2026 15:01
@steipete

steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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 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