A3: simulated ledger with idempotency (WEB-22, WEB-23, ADR-59, ARC-75..77, DAT-80)

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>
This commit is contained in:
davideandClaude Sonnet 5.5 committed 2026-11-16 13:23:29 +01:00
1 parent 0eba7bcfe6
commit eded058dbb
12 files changed
+924 -4

No files matched your search

+11
View File
@@ -143,3 +143,14 @@ LOGGING = {
"handlers": {"console": {"class": "logging.StreamHandler"}},
"root": {"handlers": ["console"], "level": os.environ.get("LOG_LEVEL", "INFO")},
}
# ADR-58, ADR-59: the network profile and how money moves. The alpha runs on regtest with a
# simulated ledger; the simulated ledger can never run on mainnet (B2 adds the full profile).
PLM_NETWORK = os.environ.get("PLM_NETWORK", "regtest")
if PLM_NETWORK not in ("regtest", "mainnet"):
raise ImproperlyConfigured(f"PLM_NETWORK must be 'regtest' or 'mainnet', not {PLM_NETWORK!r}")
LEDGER_BACKEND = os.environ.get("LEDGER_BACKEND", "simulated")
if LEDGER_BACKEND not in ("simulated", "chain"):
raise ImproperlyConfigured(f"LEDGER_BACKEND must be 'simulated' or 'chain', not {LEDGER_BACKEND!r}")
if LEDGER_BACKEND == "simulated" and PLM_NETWORK == "mainnet":
raise ImproperlyConfigured("the simulated ledger cannot run on mainnet (ADR-59)")