A model that reads invoices and suggests account codes is useful. A model that reads invoices and releases payments is a liability, even if it is right most of the time. The difference is not the model. It is where the system draws the line between proposing and doing.
Start with the action, not the model#
Before choosing a model, list what the workflow is allowed to do. Reading a document, suggesting a value and changing a financial record are different levels of authority, and the architecture should make that explicit.
| Authority | Example | Who can complete it |
|---|---|---|
| Read | Classify an attachment, extract fields | The system |
| Suggest | Propose an account code or a matching purchase order | The system, shown to a person |
| Change | Update a supplier record, post an invoice | A person with that permission |
| Commit | Release a payment, send to a customer | A person, with a recorded approval |
Most of the value sits in the first two rows. That is also where mistakes are cheap.
Keep the source attached#
An extracted field should point back to where it came from: the document, the page, ideally the region. Reviewers need the evidence next to the proposed value. A fluent explanation from the model is not a substitute for a source record.
type Evidence = {
documentId: string;
page: number;
excerpt: string; // the text the value was read from
};
type ProposedChange = {
id: string;
recordId: string;
field: "supplierId" | "accountCode" | "amount";
current: string | null;
proposed: string;
confidence: number; // model score, used for routing, not for trust
evidence: Evidence[];
};Approve a specific change#
Approval should authorise one concrete change to one record, not a vague instruction to continue. Store who approved it, what they saw and which version they saw. If the document or the proposal changes afterwards, the approval no longer applies.
type Approval = {
changeId: string;
approvedBy: string;
approvedAt: Date;
proposalHash: string; // hash of the exact proposal the reviewer saw
};
function canExecute(change: ProposedChange, approval: Approval | null) {
return approval !== null && approval.proposalHash === hashProposal(change);
}Design for interruption#
External APIs fail, tokens expire and messages arrive twice. Give the workflow explicit states so a failure leaves it somewhere recoverable:
- 01Proposed
- 02Approved
- 03Executing
- 04Completed
Execution should be idempotent where the target system allows it, and retries should be visible. Silently repeating a consequential action is how a payment gets sent twice.
Measure the workflow, not just the model#
Evaluate extraction against a representative set of real documents, and keep that set as new formats appear. Then track what happens in production:
- the corrections reviewers make, by field;
- suggestions rejected outright;
- items that stall in a state for longer than expected;
- execution failures by category.
Start with one narrow process whose results the team can inspect, and expand the system's authority only when the numbers justify it.