This repository was archived by the owner on Oct 3, 2026. It is now read-only.
Repository navigation
Make Film Club room mutations atomic - #28
Merged
Merged
Conversation
Replace whole-room route read/modify/write with create-if-absent, join, append, and owner-delete so concurrent writes cannot clobber each other or resurrect a deleted room. Keep existing Redis keys and room JSON; do not migrate history. Co-authored-by: Kris Krüg <WalksWithASwagger@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalksWithASwagger
marked this pull request as ready for review
September 20, 2026 22:55
WalksWithASwagger
deleted the
cursor/atomic-club-room-mutations-cb37
branch
September 20, 2026 22:55
This was referenced Sep 20, 2026
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #18.
Outcome
Film Club create/join/submit/delete no longer use unconstrained whole-room read/modify/write. Routes call a small atomic store API so concurrent successful writes are preserved, capacity and create-if-absent are enforced in the mutation, and a submit racing a delete cannot resurrect a room.
Stored history is unchanged: same
room:{code}keys, same room JSON shape, no TTL, no key migration, no production rewrite.Approach
SET NXfor create-if-absent, and a bounded Lua compare-and-swap (createScript/ EVALSHA). Lua does not re-encode rooms withcjson, so empty arrays and existing critiques are not rewritten by the script.409/503without logging private payloads.isStoreConfigured()).Route consumers enumerated
GET /api/club/rooms/[code]getget(detached snapshot)POST /api/club/roomsget+setcreateIfAbsentPOST .../joinget+setjoinMemberPOST .../submitget+set(could fall back to a stale room after delete)appendSubmissionDELETE /api/club/rooms/[code]get+deldeleteIfOwnerset/delare no longer on the write API.Tests
Deterministic interleavings covered at store and actual route level: join/join, submit/submit, join/submit, submit/delete, create collision, duplicate member update, capacity race, snapshot isolation, legacy critique readability, and safe unavailable errors.
Focused command:
Verification
npm run typechecknpm run lintnpm testnpm run buildnpm run test:browsernpx playwright install chromium.CLUB_TEST_REDIS_URL+CLUB_TEST_REDIS_TOKEN+CLUB_TEST_NAMESPACE)docs/film-club.md.Smoke/search checks were not run; #18 does not require them and they need a live server.
Hard gates
Rollback
A code revert restores the old racy writers against the same keys and shape. It does not rewrite stored rooms. Rooms mutated after deploy are still valid legacy JSON.