Codemojex · chapter C3 · the play path
Guesses on fair lanes.
A guess is the game’s one write, and the play path is where the architecture earns its keep. Codemojex.Guesses.submit/3 validates the six codes, overlays the player’s locks, charges the room’s currency, and only then enqueues a branded JOB on the player’s own lane — answering before the guess is scored. The scoring happens behind the bus, on one leased consumer.
Grounding — echo/apps/codemojex/lib/codemojex: game.ex (Codemojex.Guesses, the ScoreWorker) · locks.ex · rate_limiter.ex · application.ex (the four consumers) · design §Messaging / §Core flows / §Privacy and fairness.
submit/3 reads the game from the system of record, checks it is open and unexpired, validates the six codes against the game’s snapshotted keyboard, then overlays the player’s durable locks. A closed, expired, or malformed guess never becomes work.Three properties
the play pathAdmission before enqueue. A guess that is closed, expired, malformed, or unaffordable never becomes a job. submit/3 walks a cond of guards and charges the wallet before it enqueues — so everything on the queue is a validated, paid attempt, never waste. The surface answers accepted-and-on-its-way, and there is no process per game, so a large field of idle games costs nothing.
Per-player fairness. The guess lane is keyed by the player’s PLR, and the bus rotates service across lanes. A player who taps twice as fast gets their own lane serviced in turn — not twice the field’s throughput. Paying for speed buys a turn, not the field, and the fairness is structural: it is the group key on the queue, not a throttle at the edge.
At-least-once, made harmless. Delivery is at-least-once and every handler is idempotent. The enqueue answers :duplicate to a re-send; scoring is a pure function of the secret and the guess, so a re-scored guess is identical; and each consumer leases the job it works, so a crashed consumer’s in-flight job becomes visible again rather than lost. The attempt a player paid for is scored, once, even across a failure.
Scoring is linear only — 100 − 20·d per position summing to 600, no tiers, no bonus — and it lives in C4. C3 is the admission and the delivery: how a guess earns its place on the bus and rides it safely to the one authority that scores it.
The three dives
hub + 3 divesThe guess and the lock
Six codes validated against the snapshotted keyboard; the player’s durable position locks overlaid server-side, so a confirmed cell is guaranteed.
C3.2Charged, then enqueued
The wallet charges before the guess is accepted; only a charged guess becomes a JOB; the idempotent enqueue and paired TXN make re-delivery safe.
Fair lanes and the worker
Four lanes, per-player rotation, one leased scoring authority; a classic game broadcasts, a blind game stays sealed.
Grounding — the play path read on the running code: Codemojex.Guesses.submit/3 and Codemojex.ScoreWorker.handle/1 in game.ex, Codemojex.Locks, Codemojex.RateLimiter, the four EchoMQ.Consumer children in application.ex, and the scoring story feature.
References
sources · relatedSources
- Kreps — The Logthe bus as the ordered log work is dropped onto and drained from
- All-pay auctionevery guess pays its fee whether or not it wins
- Helland — Life Beyond Distributed Transactionsentities behind boundaries, idempotent activities
Related
- EchoMQ — the protocolthe bus the guesses ride, in depth
- Redis Patterns Appliedthe Valkey queue patterns applied
- C2 — Rooms, Modes, and the Secretthe room and keyboard a guess is validated against