Gioca: the round, the player's funds and their bet; the bet is two steps
(a confirmation screen that sends nothing, then an explicit confirm) with a
fresh idempotency key per screen, and the server re-checks everything.
Portafoglio: spendable apart from in-confirmation, deposit address with a QR
of the player's own address, copy button, simulated test deposits.
Movimenti: the player's own ledger, paged, stacked as cards on a phone.
GET /app/stato/ feeds the page and its polling. Every view takes the user from
the session only. Checked end to end in a real browser (Playwright): status
moves from pending to confirmed without a reload, a double click is one bet.
Mutation checks: cross-account leak, non-idempotent POST and unrestricted
test-deposit amounts are all caught.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Registration (case-insensitive unique names, 8-256 char passwords, no email),
sign-in with a generic error and a fresh session, internal-only ?next=,
POST-only sign-out, password change that closes the other sessions. The
failed-login backoff, the registration quota and the password-change guard
live in the database so every web process shares them; the client IP is the
last X-Forwarded-For hop. One responsive stylesheet with light/dark theme,
labelled fields, alerts and no inline scripts or styles; Italian error pages
and a readable CSRF failure. Mutation checks: open redirects, uncounted
failures and a missing CSRF middleware are all caught.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
lifecycle.tick runs the round from open to closed one write-locked step at a
time, resumable from the database (an interrupted draw gives the same
winner). Draw primitives move to plm_engine.draw and are shared with the old
module. SimulatedChain and settle() stand in for blocks and confirmations;
the worker runs both every tick and opens the first round. The round secret
is stored encrypted and revealed with the winner; the proof exposes no
usernames. Mutation checks confirmed the wait for in-flight bets and the
txid ordering are caught by the tests.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
One Ledger interface (deposit, bet, confirm, reject, exclude, payout) with a
simulated implementation chosen by LEDGER_BACKEND, refused on mainnet. Every
operation is a single write-locked transaction with its audit row; the same
request key is the same operation, a key reused for something else is an
error. The server validates round, deadline, the round's own quota, limits and
funds. The balance is derived from the ledger. Tests include six processes
racing on one SQLite file; the idempotency tests were checked to fail when
the replay is removed.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Django 5.2 project (config/, apps/accounts with a custom User and
case-insensitive usernames, apps/lottery with the run_worker command,
apps/web with a placeholder home and /health/live, apps/ops), SQLite in WAL
with IMMEDIATE transactions, secrets and hosts from the environment. The
compose stack is now web + worker + caddy and serves https://localhost; the
old FastAPI service is out of the stack until roadmap D1. The three old
infrastructure tests follow the new Dockerfile and compose.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>