AI SYSTEMS · LLM EVALS · DETERMINISTIC RULE ENGINES

Andrew Xia

The AI drafts. The rules decide.

I build AI systems with a deterministic core. My flagship reads air-cargo paperwork with an LLM, then lets a rule engine — never the model — issue every compliance verdict.

96.3% STRICT FIELD ACCURACY511 FIELDS HAND-CHECKED ACROSS 85 REAL DOCUMENTS57 DETERMINISTIC RULES · SHA-256 SNAPSHOT PER VERDICTSAME RULE IN THREE SYSTEMS ↓

Verdict — shipment pre-check, replayed

An air-cargo compliance engine I am building solo, measured against a Sydney freight forwarder's real document mix. Pick a case and watch the real pipeline's behaviour: an LLM extracts the fields, then 57 deterministic rules issue the verdict. Every flag carries a receipt.

SYNTHETIC DATA · real pipeline, invented documents

Invoice vs packing list disagree999-55667788 · PVGSYD · 40 pcs · 612.5 kg · Ceramic tableware · CIF
  1. Upload
  2. Classify
  3. Extract
  4. Validate
  5. Score
  6. Draft
Verdicts & receipts

Measured on deepseek-v4-flash at temperature 0 · prompt precheck-extract-v3.0 · 1 run (greedy decode, so one pass is the measurement)

View the eval report

Extraction eval — the shipped extractor vs hand-labelled ground truth

measured 2026-06 · corpus v1

Corpus 85 documents · 511 labelled fields · 17 document sets
Strict exact-match accuracy 96.3%
Semantic accuracy (format/granularity tolerant) 99.0%
Extraction failures 0 · True misses: 2 — both reproduced by the harness and reviewed field-by-field
Method Field-by-field diff, strict + lenient matchers; identifiers compared separator-stripped; every mismatch printed for human review
Run conditions deepseek-v4-flash · temperature 0 · prompt precheck-extract-v3.0 · 1 run

Numbers cover clean digital English PDFs from one forwarder’s document mix. Scanned/photographed documents and other layouts are outside this corpus — measured honesty beats round numbers.

How this demo works

This demo replays pre-recorded outputs of the real pipeline run against synthetic shipping documents — same extraction schemas, same rule engine, same verdict logic. Nothing here calls a network: no LLM API, no tracking, no data leaving your browser. Document values are invented; rule IDs and thresholds are simplified for display. The full system is still being built for that client; this replay is the honest public slice of what works today.

Demo recording: 2026-06-12 · rule snapshot b439ef74…

Systems

Verdict Air-cargo compliance pre-check — 57 deterministic rules issue every verdict, each carrying a SHA-256 snapshot of the ruleset that produced it. Demo above Case study
DevLoop Orchestration harness for AI coding agents — an exit code decides whether the work is done, never the model’s own report — and the gate runs from a read-only copy the worker cannot reach. 10k+ lines across 30 modules, 800+ tests, 1 runtime dependency. The incident, in full
Terrarium Procedural ecology simulation — same seed must produce a bit-identical world, cross-checked against an independent numpy reference implementation. private — ask me
This site Astro + one React island, ~3 KB JS on first paint. Release blocks on a stale rule digest, an out-of-date share card, or an unresolved placeholder. Colophon

Only one of these has an accuracy number, because only one has a hand-labelled corpus to measure against.

Case study — Verdict

Air-cargo compliance pre-check, built on my own initiative for the freight-forwarding domain. I put an early prototype in front of a Sydney forwarder’s IT lead; he opened up their real document mix and workflows, and they are now looking at folding it into their own stack. Solo build, still in development.

The constraint that shaped everything

A compliance verdict you can’t reproduce is a liability. So the system is built on one rule: the model never decides. The LLM extracts fields, classifies documents and drafts follow-ups. Every pass / review / blocked verdict comes from a deterministic rule engine. Pure functions over validated fields, versioned with SHA-256 snapshots of the ruleset. Any verdict can be replayed bit-for-bit later.

Architecture

AI PERIPHERY DETERMINISTIC CORE Documents heuristic classifier LLM fallback JSON-mode extraction Zod schema validation deterministic rule engine (57 rules, snapshot-hashed verdicts + risk score drafts & handover package audit log field corrections document versions
AI periphery (left of the validation boundary) proposes; deterministic core (right) disposes.

What decides what

ConcernDeterministic rulesLLMHuman
Compliance verdicts (pass/warn/block)review queue
Field extraction from documentsschema validationcorrections UI
Document classificationkeyword heuristic firstfallback on low confidence
Follow-up emailstemplate enginedrafting assistalways reviewed
Risk scoring

Honest limitations

Synthetic-data demo above; the real system is in development for one client and is not a public product. Accuracy is measured on clean digital English PDFs from that client’s document mix. Not scans, not photos. Rules encode my reading of public regulations, verified by tests, not by a licensed broker. No production-traffic claims.

Roadmap (building · designed)

  • building HS-code classification: deterministic layer running (keyword matcher over a 5,613-code AHECC dataset, plus tariff and FTA lookup, behind three endpoints). The AI-assisted path above it is a stub that returns nothing, and there is no UI
  • designed compliance copilot for explain-why queries (read-only)
  • designed email-thread intake orchestration

Status verified 2026-06-12

The problem it started from, the full spec and the provider trade-off →

How I build with AI

Verdict was built with an AI pair I governed like an untrusted worker. What began as five documents and a set of hooks is now DevLoop, a tool in its own right.

  1. Spec first.

    Five source-of-truth documents and a 17-stage prompt pipeline define every change before the model sees it.

  2. Guard hooks.

    Custom pre-execution hooks block dangerous commands and out-of-contract edits before they happen.

  3. Read-only reviewers.

    Separate subagents audit diffs against spec. They can flag, but they cannot write.

  4. Gates, not vibes.

    Pre-commit runs type-check, tests and build; CI re-runs everything. Green is the only accepted evidence.

  5. Failure-mode dictionary.

    10 documented incident patterns, each mapped to the safeguard that now catches it. One of them is the model reporting an exit code for a command that was not in the hook it named.

Writing

Notes from building under the assumption that the model is lying.

Contact

Questions about how any of this was built? The fastest way to see it working is the demo above; the second fastest is twenty minutes and a screen share.

Email reaches me directly.

Ask for a walkthrough