Threshold-Based Maker-Checker Invoice Approvals: Why Minor-Unit Canonicalization Matters
How floating-point rounding, currency ambiguity, and JSON key reordering create approval bypasses—and how integer minor units close the gap.
Key Takeaways
- Representing money as floating-point numbers (e.g., 1000.00 vs 1000.0001) causes dangerous hash mismatches and threshold edge cases.
- Our InvoiceApprovalAdapter enforces positive 64-bit safe integers in minor units (amountMinor) and 3-letter uppercase ISO 4217 currency codes.
- Policy rules deterministically route small EUR invoices to auto-allow while pausing above-threshold or foreign-currency invoices for human approval.
1. Business & threat context
When building invoice approval rules for AI agents, subtle serialization differences between Python, TypeScript, and C# can break cryptographic intent binding or misroute threshold checks.
A JSON payload containing {"amount": 1000.00} serializes differently across runtimes, and floating-point comparisons can misbehave at boundary values. Worse, if currency is not checked alongside the numeric threshold, a rule written for €1,000 may accidentally auto-approve a mismatching currency.
Deterministic across every language
Integer minor units + RFC 8785 canonical JSON guarantee identical SHA-256 digests across Python agents, .NET gateways, and TypeScript portals.
2. How ActEscrow solves it (Service 01)
ActEscrow requires all monetary values in integer minor units (e.g. 50000 for €500.00) paired with explicit ISO currency conditions, serialized through our RFC 8785 CanonicalJson serializer before SHA-256 hashing.
{
"id": "invoice-auto-under-1000-eur",
"tool": "erp.invoice.approve",
"decision": "Allow",
"conditions": [
{ "field": "currency", "op": "Eq", "value": "EUR" },
{ "field": "amountMinor", "op": "Lte", "value": 100000 }
]
}3. Production implementation checklist
When evaluating Ad-Hoc Webhook Approval Scripts alongside a customer-owned enforcement boundary, engineering and finance leaders should verify the following operational controls:
- Reject floating-point monetary fields at adapter validation time
- Always pair numeric threshold conditions with an explicit ISO currency check
- Verify that the ERP's stored invoice amount and currency match the approved intent
Boundary cases worth writing tests for
Most threshold bugs live exactly at the edge. With the example rule above, Lte 100000 in EUR, the boundary behaves as follows, and each line deserves a test.
- amountMinor 100000, currency EUR: matches the Allow rule, because Lte includes the boundary (€1,000.00).
- amountMinor 100001, currency EUR: does not match, falls through to later rules and, if nothing else matches, the default Deny.
- amountMinor 100000, currency SEK: does not match the EUR rule; it needs its own rule or it is denied.
- amountMinor missing or sent as a string: never satisfies the condition, so the rule cannot match.
- amountMinor 1000.5 or 1e5: rejected before policy, because only integers are accepted.
Minor units are not always cents
Minor units depend on the currency. EUR and SEK use two decimal places, so 100000 minor units is 1,000.00. JPY has no minor unit in ISO 4217, so 100000 means ¥100,000. Some currencies such as KWD use three decimal places. This is a second reason to pair every amount condition with a currency condition: the same integer means very different amounts across currencies.
The gateway does not convert currencies during policy evaluation, and it should not. Conversion needs a rate, a rate needs a clock and a network source, and the policy engine is deliberately free of both. Write one rule per currency you accept and let everything else fall to Deny.
On reproducible digests
Canonical JSON with integer amounts makes digests reproducible across languages when every side uses the same canonicalization rules. It is a property you test with shared fixtures, not something to assume.
Security scope and deployment prerequisites
This is a pilot implementation, not a zero-risk guarantee or compliance certification. Examples describe repository capabilities or deployment recommendations, not proof that a live installation has enabled them.
Every enrolled write fails closed during control-plane outages. Privileged control-plane MFA is mandatory outside Development, but accepted MFA claims do not prove recent authentication or hardware-backed WebAuthn unless the identity provider enforces those properties.
Per-agent deactivation blocks new evaluations and redeems and cancels Pending/Approved actions; it cannot recall an already executing ERP write. Evidence verifies recorded events, not unrecorded ERP activity; independently retained heads and trusted keys are needed to detect truncation or replacement.
Production blockers remain
The static portal still uses sessionStorage tokens (BFF not implemented). Off-host backup signing, immutable backup storage, live IdP MFA/logout testing, restore drills, adapter validation, monitoring, and legal review require deployment-specific work. Anchoring and SIEM forwarding are optional and must be configured and tested. See the repository deployment guide and runbook gap register before using real customer data.
Related deep dives
Defending Against AI-Assisted Invoice Redirection Fraud: Two-Person IBAN & BIC Verification
Nov 21, 2026 · 3 min readEngineeringStandalone Policy Engines (OPA, Cedar, Cerbos) vs. Full-Lifecycle Action Assurance
Nov 18, 2026 · 3 min readEngineeringDesigning Fail-Closed Offline Resilience: Signed Policy Bundle Caching (R17)
Nov 13, 2026 · 3 min read