Why Invoice Reconciliation Pipelines Leak Cents (and How Fixed-Point BigInt + SHA-256 Merkle Trees Fix It)

Binary IEEE-754 float64 numbers cannot represent 0.10 USD without approximation (0.1 + 0.2 === 0.30000000000000004). Across ten thousand automated payouts, partial tax withholdings, or split fees, unquantized floats accumulate penny drift that breaks trial balances and audit trails.

1. Integer Micro-Dollars (10^-6 USD) and Banker's Rounding

In financial backends (mcp-automation-demo and the browser ledger workbench), internal arithmetic runs strictly on signed integers scaled at 10^-6 USD (1,000,000 micro-dollars per dollar) or Python Decimal:

2. Read-Only Ingestion (mode=ro) and Two-Flag Write Gates

Automated reconciliation tools should never alter source accounting books implicitly. Opening SQLite sources in read-only URI mode (mode=ro + PRAGMA query_only = ON) and separating --allow-write from --apply turns dry-run inspection into the safe default.

3. Verifiable History via SHA-256 Merkle Inclusion Proofs

Logging reconciled exports alongside a binary SHA-256 Merkle tree (0x00 || leaf domain separation for leaves, 0x01 || left || right for internal nodes) lets auditors verify any single invoice row against the root digest in O(log N) hashes. Altering even $0.01 invalidates the inclusion proof immediately.

Run live 128-bit BigInt ledger balancing, bank CSV matching, and Merkle leaf tamper checks in the browser: https://nahianakhtar.github.io/demos/ledger-audit/.