Ledger integrity under agent-speed traffic
By Syed Ahmed Basharat Ali. github.com/sa-basharat-ali/ledger-integrity
The problem
An agentic payments platform holds three records of the same money: the events it emitted, its internal double-entry ledger, and what the processor actually settled. Reconciliation is meant to prove they agree, but most of it is built for humans who retry rarely and can wait for a nightly batch.
This project simulates 23,014 payment intents ($5.5M over 14 days, 400 agents) with 300 injected failures and two confounders that are not failures, then measures which checks catch what and how fast.
Headline numbers
- Netting inside daily totals hid $32,732 (46%) of $71,570 in gross error.
- Daily totals fired on 13 of 14 days but could not say which intents were wrong.
- Torn writes and out-of-order rows are structural contradictions, detectable at a median latency of 0.00 hours.
- A retry that regenerated both its intent id and its idempotency key was caught 0 of 53 times and accounts for 93% of undetected dollar-hours.
- Fuzzy matching with a 10-minute window catches 53 of 53 of those retries and wrongly flags 61 legitimate payments.
What it means
Daily-total reconciliation sees the net error, not the gross, and cannot name the broken transaction. Structural checks should run the moment data lands. The most expensive failure has no structural signature, so catching it is a trade-off between missed retries and accusing real customers, and that exchange rate belongs in front of whoever owns the decision.
Simulated data with a deterministic seed; no real transactions. Built with Python (standard library only).