Skip to content

Judge and take a lease at one instant - #475

Merged
benschac merged 1 commit into
mainfrom
cairn-fixes/landed-review-lease-races
Dec 1, 2026
Merged

benschac merged 1 commit into
mainfrom
cairn-fixes/landed-review-lease-races

Conversation

@benschac

@benschac benschac commented Dec 1, 2026 •

Copy link
Copy Markdown
Owner

Codex found five races between reading a lease and acting on it.

A plan claim could be taken after its owner had renewed: both takeover writes now require the lease to be the one that was judged, and a retry reads the decision again. prd status judged leases while holding the lock that blocks renewals: it now judges every row at the instant it took the lock. init never renewed its lease: it starts once .cairn is in place. A renewal that waited for the write lock was stamped with the time it started waiting: it is stamped once it holds the lock. A clock set back kept a dead owner's lease fresh until the clock caught up: a renewal more than 30 seconds ahead of the clock counts as lapsed.

Co-Authored-By: Claude Fable 5.2 noreply@anthropic.com

What this changes

Checks

Provenance

Review by Codex

This commit fixes what Codex's first round found on #456. Its second round, on this commit, found two things, left open because two rounds are done:

  • P2, open. A lease more than 30 seconds in the future counts as lapsed, so a clock set back can expire a live owner's fresh lease; a status run from another namespace then deletes its staged files.
  • P2, open. Takeover compares the renewed_at timestamp, not a renewal generation, so a renewal that writes the same millisecond goes unnoticed.

🤖 Generated with Claude Code

benschac commented Dec 1, 2026 •

Copy link
Copy Markdown
Owner Author

Merge activity

@benschac
benschac force-pushed the cairn-fixes/landed-review-lease-races branch 2 times, most recently from 5d60b15 to ed06bd1 Compare December 1, 2026 17:28
@benschac
benschac changed the base branch from cairn-fixes/landed-review-retired-stage to graphite-base/475 December 1, 2026 17:33
@benschac
benschac changed the base branch from graphite-base/475 to main December 1, 2026 17:34
Codex found five races between reading a lease and acting on it.

A plan claim could be taken after its owner had renewed: both takeover writes now require the lease to be the one that was judged, and a retry reads the decision again. prd status judged leases while holding the lock that blocks renewals: it now judges every row at the instant it took the lock. init never renewed its lease: it starts once .cairn is in place. A renewal that waited for the write lock was stamped with the time it started waiting: it is stamped once it holds the lock. A clock set back kept a dead owner's lease fresh until the clock caught up: a renewal more than 30 seconds ahead of the clock counts as lapsed.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@benschac
benschac force-pushed the cairn-fixes/landed-review-lease-races branch from ed06bd1 to 19d6e6e Compare December 1, 2026 17:35
@benschac
benschac merged commit 955f517 into main Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant