Inspiration
Invoice automation often collapses three jobs into one: suggest the payout fields, decide they are correct, and send money. The risky cases are not always “the model invented a number.” Often the characters are real, but they come from the wrong line - subtotal, tax, or purchase order with the same digits as the amount due.
We wanted an embeddable gate in front of payout: accept an untrusted registration proposal from whatever upstream the host already has, prove it against the invoice text, and require one human approval before any provider call.
What it does
Source-Bound Invoice Payout Gate checks a text-PDF invoice claim before payout.
- Upstream may supply payee, currency, amount, and quote - from a form, a deterministic parser, or a model.
- Kernel source binding checks that the quoted span actually appears in the selected PDF text range.
- A product rule allows payment figures only from an exact
Amount due: {value}label. Matching digits on another line still cannot pay. - A person approves once. The engine persists one submit permit; the same subject is not sent again through this gate.
- Status query is read-only. It does not resubmit and does not invent a settled outcome when provider lookup is not proven.
The hackathon demo is a 100-invoice bank plus Word upload so judges can edit a declaration, check again, submit once, and inspect provider status. Provider sandbox credentials are a test adapter for the event, not the product thesis.
How we built it
We composed two published layers:
- ProDocuX Kernel for source-bound evidence on a text PDF.
- pdx-artifact-engine for a durable external operation: one subject, one approval, one submit permit before the network call, with manual reconciliation when lookup by the client key is not proven.
The host around that core is intentionally thin: the Amount due gate, a payout adapter for the demo, and a FastAPI site that keeps checked declaration, edit form, and original document separate so judges can see whether the failure is in the declaration or on the invoice.
In this demo, most proposals are produced by label parsing or by the reviewer editing fields. A live model proposer exists as an optional path and remains non-authorizing; judges do not need model keys.
What we learned
- A verified span is not a certificate of the business total. Binding proves origin; the product still refuses the wrong label.
- “Who proposed the fields” and “what may authorize payout” must stay separate. Forms, rules, and models are interchangeable proposal sources.
- Submitted is not settled. A provider item can stay pending while the engine record correctly remains open for manual reconciliation.
- UI copy has to say exactly what to change. Otherwise people cannot tell a declaration error from a missing Amount due line.
Challenges
Caller-supplied value equality can accept a forged amount. Source binding closed that gap and surfaced the next one: quotes that point at subtotal, tax, or purchase order.
Amount substrings were another trap - a declared 1.00 can sit inside 91.00. Payable amounts have to be exact positive-cent values tied to the Amount due label.
On the engine side, stage 1 stays strict: one send, no automatic new key, no same-key resubmit, query-only afterward. That is less flashy than an always-green demo path, and it matches the embeddable-gate contract.
What's next
- Keep the gate embeddable in real invoice pipelines where the host already has its own extraction or forms.
- Use live proposers only as advisory input when documents are less label-regular than this bank.
- Strengthen provider reconciliation when lookup can be proven, without weakening one-approval-one-send.
Built With
- cloud-storage
- fastapi
- google-cloud-run
- httpx
- javascript
- paypal-payouts-api
- pdx-artifact-engine
- prodocux
- pypdf
- pytest
- python
- python-docx
- reportlab
- secret-manager
- sqlite