5D Library › Zero-Touch Multi-Site Fault Tolerance, Payment Anti-Fraud State Machines and Passive Cashflow Queuing · 中文
Chapter 8. A Nine-Flag Audit and a Pre-Registered Experiment
Nine questions
This chapter turns the book into nine questions a script can check against the deployment settings of any zero-touch site network, the author’s own included. They are not security or business advice.
- Are receipts matched on fewer than 8 trailing digits? (Chapter 1)
- Does a cheat who takes an instant good lose nothing when caught? (Chapter 1)
- Does the self-referral graph use IP subnets? (Chapter 2)
- Is unlocking level 2 by self-referral cheaper than its list price? (Chapter 2)
- Is order handling without a transition table? (Chapter 3)
- Do idempotency keys live shorter than the 511-minute retry schedule? (Chapter 3)
- Are there fewer than the 4 workers bursts require, with no load shedding? (Chapter 4)
- While streamed requests are served, is the drain time under 300 s? (Chapter 5)
- Is the cash reserve below the 90,000 a three-month shock requires? (Chapter 6)
The audit as a program
The program writes the nine questions as nine automatic flags and applies them to two configurations: a common “quick build” (4 trailing digits checked, instant delivery with no stake, subnets in the association graph, unlock with 3 invitees, no transition table, keys kept 10 minutes, 1 worker, an immediate switch, a reserve of 15,000) and a “hardened” configuration corrected chapter by chapter in this book.
Calculation
# Chapter 8. [p15] Eight automatic flags for a zero-touch site network.
# F1 receipts matched on fewer than 8 trailing digits (p01);
# F2 instant delivery with nothing at stake when caught (p02);
# F3 shared-subnet edges in the self-referral graph (p03);
# F4 level 2 cheaper by self-referral than its list price (p04);
# F5 order handlers without a transition table (p05);
# F6 idempotency keys kept shorter than the retry schedule (p06);
# F7 fewer workers than the burst requirement, and no shedding (p08);
# F8 drain time under 300 s while long streams are served (p10);
# F9 cash reserve below what a three-month shock needs (p13).
DESIGNS = {
"quick": dict(tail=4, instant=True, stake=0, subnet=True, m=3,
table=False, ttl=10, workers=1, shed=False, drain=0,
reserve=15000),
"hardened": dict(tail=None, instant=True, stake=200, subnet=False,
m=8, table=True, ttl=1440, workers=4, shed=True,
drain=300, reserve=90000),
}
def flags(d):
return [
("F1 tail-digit receipt match", d["tail"] is not None
and d["tail"] < 8),
("F2 instant delivery, no stake", d["instant"] and d["stake"] == 0),
("F3 subnet edges in referral graph", d["subnet"]),
("F4 self-referral below list", d["m"] * (39 + 3) < 299),
("F5 no transition table", not d["table"]),
("F6 key TTL < 511 min", d["ttl"] < 511),
("F7 workers < 4 without shedding", d["workers"] < 4
and not d["shed"]),
("F8 drain < 300 s", d["drain"] < 300),
("F9 reserve < 90,000", d["reserve"] < 90000),
]
if __name__ == "__main__":
for name, d in DESIGNS.items():
fl = flags(d)
n = sum(f for _, f in fl)
print(" {} design: {} of {} flags".format(name, n, len(fl)))
for label, f in fl:
print(" [{}] {}".format("X" if f else " ", label))
print("\nReading: each flag is a sentence from an earlier chapter")
print("turned into a test that a script can run on a deployment's")
print("settings. The quick build trips all nine. The hardened one")
print("trips none, which says only that its settings agree with")
print("this book's models - not that the models are right.")
# quick design: 9 of 9 flags
# [X] F1 tail-digit receipt match
# [X] F2 instant delivery, no stake
# [X] F3 subnet edges in referral graph
# [X] F4 self-referral below list
# [X] F5 no transition table
# [X] F6 key TTL < 511 min
# [X] F7 workers < 4 without shedding
# [X] F8 drain < 300 s
# [X] F9 reserve < 90,000
# hardened design: 0 of 9 flags
# [ ] F1 tail-digit receipt match
# [ ] F2 instant delivery, no stake
# [ ] F3 subnet edges in referral graph
# [ ] F4 self-referral below list
# [ ] F5 no transition table
# [ ] F6 key TTL < 511 min
# [ ] F7 workers < 4 without shedding
# [ ] F8 drain < 300 s
# [ ] F9 reserve < 90,000
#
# Reading: each flag is a sentence from an earlier chapter
# turned into a test that a script can run on a deployment's
# settings. The quick build trips all nine. The hardened one
# trips none, which says only that its settings agree with
# this book's models - not that the models are right.The quick build trips all nine flags; the hardened configuration trips none. But tripping none says only that its settings agree with this book’s models, not that the models are right: their parameters (the strength of bursts, the share of forgeries, the length of a shock) all need testing against real data. That is part of what the experiment below must do.
A pre-registered experiment
Hypothesis · not established
Study protocol. Buyers are randomised by account to “release after verification” (HOLD) or “release first, audit later” (OPTIMISTIC); the latter audits a third of orders and sets a stake and cascading revocation as in Chapter 1. Primary outcome: the share of checkout starts that end in a completed purchase, expected to rise from 0.27 to 0.30. Harm that must be reported: the share of orders later found forged, expected to rise from 0.010 to 0.015. Test: two-sided at 0.05 with power 0.90 (Kohavi et al. 2020). Carried out with pre-registered code by an independent analyst with no financial relationship with the author; results published whether positive or negative.
Calculation
# Chapter 8. [p16] Sample sizes for a pre-registered release experiment.
# Buyers are randomised by account between HOLD (access after the
# receipt is verified, typically hours later) and OPTIMISTIC (access
# at once; a third of orders audited; stake and cascading revocation
# as in p02). Two-sided 0.05, power 0.90, normal approximation.
# (a) primary: completed purchases among checkout starts, 0.27 under
# HOLD vs 0.30 under OPTIMISTIC;
# (b) harm: share of orders later found fraudulent, 0.010 vs 0.015;
# (c) the same harm if the audit share were raised to catch a 0.010
# vs 0.012 difference.
import math
from statistics import NormalDist
def n_props(p1, p2, alpha=0.05, power=0.90):
z = NormalDist().inv_cdf
pb = (p1 + p2) / 2
a = z(1 - alpha / 2) * math.sqrt(2 * pb * (1 - pb))
b = z(power) * math.sqrt(p1 * (1 - p1) + p2 * (1 - p2))
return math.ceil((a + b) ** 2 / (p1 - p2) ** 2)
if __name__ == "__main__":
a = n_props(0.27, 0.30)
b = n_props(0.010, 0.015)
c = n_props(0.010, 0.012)
print(" (a) checkout starts per arm, 0.27 vs 0.30 : {:,d}".format(a))
print(" (b) orders per arm, fraud 0.010 vs 0.015 : {:,d}".format(b))
print(" (c) orders per arm, fraud 0.010 vs 0.012 : {:,d}".format(c))
print("\nReading: the conversion question needs a few thousand")
print("checkouts per arm. The fraud question needs over ten thousand")
print("orders per arm - more than a year's orders at 40 a day split")
print("into two arms - and a finer difference several years. Fraud")
print("must be tracked by audit for the life of the policy, not")
print("settled by one experiment.")
# (a) checkout starts per arm, 0.27 vs 0.30 : 4,757
# (b) orders per arm, fraud 0.010 vs 0.015 : 10,375
# (c) orders per arm, fraud 0.010 vs 0.012 : 57,154
#
# Reading: the conversion question needs a few thousand
# checkouts per arm. The fraud question needs over ten thousand
# orders per arm - more than a year's orders at 40 a day split
# into two arms - and a finer difference several years. Fraud
# must be tracked by audit for the life of the policy, not
# settled by one experiment.The conversion question needs 4,757 checkout starts per arm. The forgery question needs 10,375 orders per arm; telling apart a finer difference such as 0.010 against 0.012 needs 57,154 per arm, which at 40 orders a day takes several years. The protocol therefore makes conversion the primary outcome, reports the forgery rate as a harm, and keeps auditing for the whole life of the policy rather than expecting one experiment to settle it.
Summary
Nine questions – tails, stakes, subnets, unlock price, transition table, key lifetime, workers, drain time, cash reserve – can all be written as an automatic audit. An experiment on release-then-audit takes conversion as its primary outcome, with 4,757 checkout starts per arm; the forgery rate must be tracked by continuing audits.
References
Fan, Y. (2026). Zero-Touch Multi-Site Fault Tolerance, Payment Anti-Fraud State Machines and Passive Cashflow Queuing: Receipt-Hash Deduplication, Self-Referral Blocking, Host-Header Routing and Availability Bounds [零人工多站点容错架构、支付防欺诈状态机与被动现金流排队论] (Version 1.0.0). 5D Library. https://doi.org/10.5281/zenodo.24090201 · Licensed under Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0).