cultcache-py: single-file store lock, fsync and unique staging; msgpack hard; slot-nil reader #16

Merged
libby merged 3 commits from libby/cultcache-py-store-lock into main 2026-11-07 12:13:22 +00:00
Member

Brief B of the 2026-11-06 parity audit (Python CultCache store).

  • push/push_all/delete take the cross-process lock on <path>.lock (flock; LockFileEx whole-file on Windows), as cultcache-ts store-file.ts; staged file <path>.tmp-<pid>-<uuid>, fsync before replace, directory fsync after.
  • msgpack is a hard dependency (pyproject already said so); optional-import fallbacks removed.
  • Python reads tests/vectors/slot-nil (15 accepted, 2 refused, rewritten bytes equal the reference).

Tests: python -m unittest discover -s tests in packages/cultcache-py: Ran 175 tests, OK (166 before). New tests fail when the rule breaks (checked by mutation: lock disabled -> 3 failures; fsync removed -> 2; fixed staged name -> 1; nullable nil removed -> 1 failure + 14 errors).
A write waits while a flock holder and the real TypeScript withStoreWriteLock (koffi, node 24) hold the lock.
Not run: a Rust holder (no harness; fs2 lock_exclusive is flock on Unix, which the flock holder stands in for) and the Windows LockFileEx path (no Windows here; the ctypes code is unexercised).

🤖 Generated with Claude Code

Brief B of the 2026-11-06 parity audit (Python CultCache store). - push/push_all/delete take the cross-process lock on `<path>.lock` (flock; LockFileEx whole-file on Windows), as cultcache-ts store-file.ts; staged file `<path>.tmp-<pid>-<uuid>`, fsync before replace, directory fsync after. - msgpack is a hard dependency (pyproject already said so); optional-import fallbacks removed. - Python reads tests/vectors/slot-nil (15 accepted, 2 refused, rewritten bytes equal the reference). Tests: `python -m unittest discover -s tests` in packages/cultcache-py: Ran 175 tests, OK (166 before). New tests fail when the rule breaks (checked by mutation: lock disabled -> 3 failures; fsync removed -> 2; fixed staged name -> 1; nullable nil removed -> 1 failure + 14 errors). A write waits while a flock holder and the real TypeScript withStoreWriteLock (koffi, node 24) hold the lock. Not run: a Rust holder (no harness; fs2 lock_exclusive is flock on Unix, which the flock holder stands in for) and the Windows LockFileEx path (no Windows here; the ctypes code is unexercised). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
pyproject (and cultnet-py) already declare msgpack as required; the code treated it
as optional behind a cultcache-py[msgpack] extra that does not exist.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
push, push_all and delete hold <path>.lock (flock; LockFileEx over the whole file on
Windows, as cultcache-ts store-file.ts) across the read and the replace. The staged file
is <path>.tmp-<pid>-<uuid>, fsynced before os.replace, with a directory fsync after off
Windows; a failed write removes its staged file and leaves the store.

Tests fail when the rule breaks: a write waits while a flock holder (Rust's lock) and the
TypeScript runtime's withStoreWriteLock hold the lock, three processes lose no writes,
fsync precedes replace, staged names differ, a failed replace leaves no staged file.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
cultcache-py: read the slot-nil vector; changelog for the store lock and msgpack
Some checks failed
CultMesh QUIC native / Build win32-x64 (pull_request) Has been skipped
CultMesh QUIC native / Build linux-x64 (pull_request) Has been skipped
CultMesh QUIC native / Release native binaries (pull_request) Has been skipped
CultMesh portability and performance / ubuntu-latest one-command multiplayer onboarding (pull_request) Has been cancelled
CultMesh portability and performance / windows-latest one-command multiplayer onboarding (pull_request) Has been cancelled
CultMesh portability and performance / ubuntu-latest reactive semantics and leases (pull_request) Has been cancelled
CultMesh portability and performance / windows-latest reactive semantics and leases (pull_request) Has been cancelled
CultNet cross-runtime interop / C# / TypeScript / Rust / Python / Kotlin (pull_request) Has been cancelled
CultMesh QUIC native / Verify committed binaries match SHA256SUMS (pull_request) Has been cancelled
00ecdcf9e6
tests/vectors/slot-nil was read by TS only. The Python reader accepts the same 15 rows
and refuses the same 2 as the C# reference and rewrites the reference's bytes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
libby merged commit 530acdac20 into main 2026-11-07 12:13:22 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
GameCult/CultLib!16
No description provided.