APRON
An AI procurement negotiator that never invents a number
Hover to spread the screens, click one to look closer, orSwipe through the screens, tap one to look closer, or flip through all 6.
A multi-tenant procurement system that reads purchase history, quotes, invoices, contracts and supplier email, finds verified savings, drafts negotiation asks within company policy, routes them for approval, and proves the savings against later invoices.
- RoleCore engineer and top committer on a five-person team
- Contribution197 of 586 commits, the most on the team
- Statusv1 delivered
- WhenSep – Oct 2026 · Ledgercross
In numbers
- from the first commit to v1, against a 146-issue plan
- 6 weeks
- test files: unit, RLS, golden, security, contract and e2e
- 727
- floats in money code: every price is a Decimal
- 0
- golden rules, most enforced by a linter or the database
- 13
The problem
Procurement teams overpay because the evidence is scattered: a price in an old PO export, a different pack size in a PDF quote, a contract clause nobody re-read. A language model can read all of it, but a model that hallucinates a price into a supplier email is worse than no tool.
The brief was an AI procurement employee that discovers savings, compares suppliers and negotiates within approved limits, without ever fabricating a price, quantity, supplier term or saving.
How it works
step through it · each step is a noteAI proposes, the system verifies, policy decides, a person approves
- 01Purchase history, quotes, contracts and forwarded supplier email come in. Lookalike senders are quarantined before anything reads them.
- 02Gemini turns each document into typed candidate fields, each pointing at a quoted span. Supplier text is passed as marked, untrusted data.
- 03Deterministic checks prove every span is on the page and every total reconciles. A failure writes nothing and asks a person.
- 04Decimal rules convert units, confirmed pack sizes, tax, FX and freight. Postgres is the system of record, not the model.
- 05A saving is only claimed when prices are truly comparable. A false saving is worse than a missed one.
- 06Gemini drafts the ask; the evidence firewall blocks any number it can't trace to a source row or recompute.
- 07Policy and a risk tier decide who must approve. Any policy violation forces a pending approval.
- 08The buyer sends from their own mail client. Savings count as realized only when a later invoice proves them.
My part
Built by a five-person engineering team at Ledgercross.
- Built the document pipeline as a chain of idempotent jobs: classification with a golden test set, chunking, and 1024-dimension Vertex AI embeddings into pgvector.
- Wrote contract-constraint extraction where every term carries the clause it came from, so a negotiation can cite it.
- Fixed the savings maths wherever it could lie: a seed that normalized $48 a box into a false saving, DAP counters that overstated agreed savings, and two screens that reported different savings for the same quote.
- Shipped supplier scoring v2 with per-item recommendations and reasons, tenant provisioning on organization creation, and the overview and contracts screens.
- Made the app usable on a 390 px phone and fixed load issues: a per-tenant rate limit that couldn't serve 50 concurrent buyers, and supplier mail bounced on a 429 instead of retried.
- Kept main green: cross-tenant fuzz maps, e2e specs and CI that had drifted behind UI and route changes.
Decisions
The model proposes; it never decides
Gemini returns candidate fields that each point at a quoted span. Deterministic checks prove the span is on the page and the totals reconcile; anything that fails writes nothing and opens a review item. Postgres, not the model, is the system of record.
An evidence firewall on every draft
Every claim in a negotiation draft must reference an evidence row, and its number must appear in the source or match a deterministic recalculation. Unsourced numbers block submission.
Boundaries a linter can check
The rules package may not import the database, the AI layer or float. Only one module may import the model SDK, and only one may send mail, producing a mailto: link. An AST check proves nothing under ai/ can reach purchase orders or policy, even transitively.
Tenant isolation that fails closed
Every tenant table ships with a row-level-security policy in the same migration, and a guard raises on any write outside a tenant transaction. The policy reads a SET LOCAL setting, which stays safe under pgbouncer transaction pooling.
The negotiation state machine
- 01A verified opportunity starts a negotiation. The target price has to sit inside company policy.
- 02A background job drafts the ask; the screen polls until the model has answered.
- 03Submitting requires the evidence firewall to pass. Then it waits for the approver its risk tier demands.
- 04An approver can send it back to change the target.
- 05Approved asks go out from the buyer's own mail client, and the supplier's reply is ingested and classified.
- 06A counter can loop back for another ask, at most three rounds: accept at target, escalate above walk-away, otherwise ask at the midpoint.
- 07Accepting a counter needs its own approval. A won deal records the saving as Agreed.
- 08A rejection closes it as lost. Any illegal transition returns 409 for every role, admins included.
Stack
- API & workerPython 3.12, FastAPI, SQLAlchemy 2 async, Alembic, Postgres job queue
- DataPostgreSQL 18, pgvector, pgbouncer, Row-level security, Cloudflare R2
- AIGemini on Vertex AI, Versioned prompts, Replay cassettes
- WebReact 19, Vite, TanStack Router & Query, Tailwind 4, Better Auth
- Quality & opsPlaywright, Schemathesis, Hypothesis, Dokploy, Doppler






