# Thalo Works

- **Event:** [Meta Global AI Developer Hackathon](https://cerebralvalley.ai/e/meta-ai-developer-hackathon)
- **When:** Oct 26, 12:00 PM – Nov 4, 9:00 PM (EST)
- **Where:** Online
- **Team:** [mark zellner](https://cerebralvalley.ai/u/markzee)
- **GitHub:** https://github.com/BLTCPT/erpcraft
- **Demo video:** https://www.youtube.com/watch?v=NIa9dcRX8FI
- **Gallery:** https://cerebralvalley.ai/e/meta-ai-developer-hackathon/hackathon/gallery
- **Page:** https://cerebralvalley.ai/e/meta-ai-developer-hackathon/hackathon/gallery/640

ERPCraft

A free, open-source, clean-room ERP in Rust — AI-native from day one, with a double-entry ledger the database itself refuses to let you break.

ERPCraft is an enterprise resource planning system for the world its builder actually lives in: small manufacturers who run their businesses on spreadsheets because the incumbent ERPs are closed, expensive, and held together by consultants — and who are now being asked to trust AI agents with real books.

So ERPCraft is built around one idea: an AI agent should drive the exact same commands a human does, propose before it posts, and work on top of a ledger whose correctness does not depend on any caller behaving — its invariants are enforced by the database itself on every connection the application opens, and that enforcement has been probe-tested from outside, including with raw SQL.

The vision is the full ERP: general ledger, order-to-cash, purchasing, inventory, manufacturing planning, and reporting, owned by the people who run it. This repository is the working core of that vision, built and verified in the open:

- A double-entry ledger enforced by the database itself. Every posting must balance (debits = credits) — the rule lives in SQLite triggers, not application code. Entries can only be created as drafts and post through the one balance-checked transition; direct posted inserts are refused, amounts are integer cents at rest (a fractional "cent" cannot be stored, let alone posted), and on application connections the append-only guards also fire on the implicit deletes of INSERT OR REPLACE, so history cannot be rewritten through that path either. The journal is append-only; corrections are reversing entries that reference the original. Money is integer cents, never floating point. An external review probed exactly these boundaries with executable tests; every hole it found is fixed and now covered by regression tests in the suite.
- Order-to-cash with a GL posting engine. Quotes to sales orders to invoices to payments to returns, where the transitions themselves generate the revenue, COGS, payment, and reversal postings. Correctness is pinned by a hand-computed "oracle day": 14 transactions whose ending trial balance ($129,975.00 per side) is the acceptance suite.
- A variant configurator modeled on SAP LO-VC object dependencies — precondition, selection condition, and constraint — as a typed AST, evaluated deterministically in the core. Selected components roll into line price and standard cost. AI works only at the edges: it authors dependency rules behind a propose to confirm gate and explains refusals in plain language. Ask for a galvanized finish on an aluminum bracket and the system refuses, naming the rule: "Galvanized finish is available only on steel brackets."
- Procure-to-pay with a three-way match. The buying mirror of order-to-cash: suppliers to requisitions (approved before they convert) to purchase orders to goods receipts (Dr inventory / Cr GR-IR clearing) to supplier invoices (GR-IR clears at the PO price; the difference posts to purchase price variance) to payments. The three-way match is computed live from the three documents on every read: invoice more than was received, or at any price but the PO price (zero price tolerance, deliberately — any difference is a variance), and the invoice lands on hold — recorded, visible, and unpayable until the variance is resolved or a named person overrides it with a recorded reason (the variance facts stay on the invoice either way). The supplier's own invoice number is a duplicate key: the same number against the same PO can never be recorded — and so never paid — twice.
- Controls foundations. Fiscal periods gate the single posting path — close a period and every door refuses postings dated into it, rolling the whole document transition back. A users/roles registry backs a segregation-of-duties rule: payments above a configured threshold require a named actor and a different approver with an approver/admin role, recorded on the payment and its journal entry. The rule gates the capability, not just the document methods: the generic cash-out journal builders enforce it too.
- One dispatch table, four doors. 85 commands served identically to an operator CLI, an MCP server on stdio, an HTTP API, and the natural-language agent — JSON out, plain-language refusals, exit codes 0/1/2. Anything a human can do, an agent can drive; there is no second, weaker API. (The HTTP door binds 127.0.0.1 and is a trusted local operator door, like the CLI; the propose to confirm gate is the agent surface's contract, and the segregation-of-duties rule applies at every door.)
- A natural-language agent behind a propose to confirm gate. Plain English ("Invoice Acme for the 40 units we shipped Tuesday") becomes proposed dispatch calls. The confirmation is rendered from actual ledger data — never from model prose — and nothing posts until a human confirms. The agent also answers questions, can propose releasing a plan, receives goods against purchase orders, and pays supplier invoices — including the held ones, where a payment can only be proposed when the prompt itself carries the match-override reason and the approver's name — enforced in code, not just documented: override attribution the model supplies that does not appear in the human's own words is discarded. Confirmations are one-shot (a confirmed action cannot be replayed) and revalidated at confirm time, and every confirmation is rendered from the actual document it will post — quantity, price, configuration.
- AI-native MRP on the Warp Speed pattern. Materials planning that is dynamic (every run recomputes from current orders, stock, BOMs, and configurations — plans are never stored, so a changed order re-plans instantly), explainable (every planned order carries its netting math and demand reasons; a shortage is simply a planned order whose start date has already passed), and agent-native ("Can we build 200 BRK-100 by Nov 15?" is answered from a live run; releasing a planned order goes through the same confirm gate and creates the document — planning never posts to the GL).
- A full audit trail. Every journal entry explains itself: who posted it, which document it belongs to, why it posted, the complete provenance chain (quote to order to invoice to payments to returns) with reversal links in both directions — and, for agent postings, the verbatim human prompt that proposed it.

The demo company is Cascade Precision Parts, a fictional small Oregon manufacturer making metal brackets.

## More from Meta Global AI Developer Hackathon

- [Rankall.io](https://cerebralvalley.ai/e/meta-ai-developer-hackathon/hackathon/gallery/637)
- [NetOps Copilot](https://cerebralvalley.ai/e/meta-ai-developer-hackathon/hackathon/gallery/638)
- [Team Hades](https://cerebralvalley.ai/e/meta-ai-developer-hackathon/hackathon/gallery/639)
- [MetaMining & Me](https://cerebralvalley.ai/e/meta-ai-developer-hackathon/hackathon/gallery/641)
- [Team Venorse](https://cerebralvalley.ai/e/meta-ai-developer-hackathon/hackathon/gallery/642)
- [Mahi](https://cerebralvalley.ai/e/meta-ai-developer-hackathon/hackathon/gallery/643)

---

Markdown version of https://cerebralvalley.ai/e/meta-ai-developer-hackathon/hackathon/gallery/640. Site index for agents: https://cerebralvalley.ai/llms.txt · full text: https://cerebralvalley.ai/llms-full.txt
