jonnify·bcs /bcs/codemojex/guesses-on-fair-lanes/the-guess-and-the-lock

B7.3.1 · dive 1 of 3 · module B7.3

The guess and the lock.

A guess is six distinct codes, checked against the game’s set from the cache; a short-lived Valkey lock allows one move in flight per player, and an invalid or locked guess is refused before any charge.

A guess validated, a lock that allows one move in flight, and a refusal before any charge. Select a part.
a guesssix codesdistinct, in the setchecked from the cache valid a Valkey lockone move in flightper player and gamereleased onto the lane refusedinvalid or already lockedbefore any charge
readout · Select a part. A guess is six distinct codes checked from the cache; a Valkey lock keyed by player and game allows one move in flight; an invalid or already-locked guess is refused before any charge.
§1

The idea

codemojex · the guess and the lock

A guess is six codes in fixed positions, and before anything else it is checked: six of them, distinct, each addressing a cell in the game’s emoji set. A guess that fails the check never reaches the lane and is never charged. The check reads the set from the cache under the game’s version, so it costs no round trip on the hot path.

A player may have one guess in flight at a time. The reference implementation takes a short-lived lock in Valkey, keyed by the player and the game, so a double tap or a retry cannot enqueue the same guess twice or charge twice for one move. The lock is held only across the validate, charge, and enqueue step, and released the moment the job is on the lane.

Locks and lanes both live in the Valkey tier, the layer the system treats as reconstructable. A lock lost on a node restart costs at most a brief window where a duplicate could slip through, and idempotency on the charge closes that gap. The record of truth — the wallet and the secret — is on Postgres; the lock is a coordination hint, not the ledger.

§4

The doors

the sibling courses
§2

References

sources · related

Sources

Related