Skip to content
inkandwirePublic

About

AP invoice fraud gate with a separate bank process and kill switch. Agentware 2026, Open Track. Sandbox only.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

griftgate

An accounts-payable agent that pays the bills you owe and holds the ones that are scams.

It reads the invoices that arrive in an AP mailbox, checks each one against your own records, posts the genuine ones to a double-entry ledger, and queues them as a payment batch. It holds the bad ones and says why. It cannot release money. A person does that, with a key the agent never holds.

Sandbox only. The "bank" is a small HTTP server in this repo. The mailbox is two folders. Every name, account and address is fake. Nothing is ever sent or paid anywhere real.

Track: Open Track (back-office AP). Python 3.11+ standard library only. No Docker, no SMTP, no IMAP, no third-party packages. MIT licence.

ELI5

A clerk reads bills and pays them. A thief sends a bill that looks right but has a new bank account on it. A careful clerk phones the supplier first. griftgate is that careful clerk. The model reads the bill. Plain code, not the model, decides if the bill is safe to pay. The bank runs as a separate process with its own caps, and only a separate approver key can release money, so a bug in the agent cannot release a batch or exceed those caps. One button (FREEZE) locks the bank first, then stops the agent.

Demo video

https://youtu.be/BDzfW1VGD4A (YouTube, unlisted, 2 min 21 s, one unattended run from trigger to result).

Run it in 5 minutes (no key, no cost)

python3 -m griftgate demo

That builds a fresh sandbox, starts the bank (127.0.0.1:8640) and the case board (127.0.0.1:8641), drops 14 labelled messages into the mailbox, and runs the agent from start to finish by replaying recorded model replies (GG_MODEL_MODE=tape, the default). It takes about 8 seconds and costs nothing. Open the board in a browser while it runs.

Expected end of the output:

Result: BATCHED 7, DUPLICATE 1, HELD 4, PARKED 1
chain OK (367 rows), seal matches bank

Try the kill switch: python3 -m griftgate demo --pace 1, then in a second terminal python3 -m griftgate freeze. Release it with python3 -m griftgate thaw --key-file sandbox/approver.key --reopen. (The demo prints the approver key once; it lives in sandbox/approver.key, which is git-ignored.)

Run the tests: python3 -m unittest discover -s tests (97 tests, about 25 s).

Live model

cp .env.example .env     # set GG_MODEL_MODE=live and GG_GEMINI_KEY=<your free Google AI Studio key>
python3 -m griftgate demo

Needs one key: a free-tier Google AI Studio key (Gemini API). Default model gemini-3.5-flash-lite. The free tier is rate limited. In our test gemini-3.5-flash answered HTTP 429, so we use flash-lite and set GG_MODEL_GAP=3 (seconds between calls). When the model is down or rate limited the agent stops cleanly after three failures in a row and marks the run STOPPED_MODEL_DOWN. It does not guess.

What a run costs

Mode Cost
tape (default) US$0, no network
live, free tier US$0 in money. About 30 model calls per arm for the 28-message set (62 recorded across both arms). At 3 s between calls that is a few minutes.

The agent counts calls, tokens and cost per run (max_calls = 150, max_cost_usd = 0.30 in controls.toml) and stops when a cap is hit.

What it does with each bill

  1. Intake. Maildir sandbox/mail/ap/new/. One case per message. A resent message makes no new case.
  2. Extract. The model returns the invoice fields as JSON. A reply that does not fit the schema is refused.
  3. Recompute. Code redoes the sums with decimal.Decimal. A total that does not add up is a finding, never rounded away.
  4. Controls C-00 to C-14. Plain code. Any error inside a control counts as HOLD. See SAFETY.md.
  5. Investigate (only when the bill is short of a fact). Up to 8 read-only steps and fixed question templates. It can look up a PO or ask the vendor on file. It cannot pay, post or edit anything.
  6. Post to the ledger in books.db (database rules refuse an unbalanced entry or a second posting).
  7. Queue one line in the bank batch. The bank checks the payee from its own list and applies its own caps.
  8. Casebook. An HTML page and one plain-text note to the owner: queued, held and why, money stopped.

Results (own labelled set, not the official Trap Pack)

Labelled messages 28 (10 genuine, 18 hostile or broken)
Trap runner: expected = observed 28 of 28 (tests/trap-results/results.md)
Fake dollars queued for fraud-labelled bills, griftgate 0.00
Same model, ordinary tool-calling agent with no controls, fake dollars paid on fraud-labelled bills 17,810.00 (13 bills)
Genuine bills done, both arms 10 of 10

Read eval/README.md for what these numbers do and do not show.

Honest limits

  • The table above is our own 28 labelled messages, which we wrote and tuned against. We also ran the official Trap Pack (20 files, live model, one run each): no AGW-CANARY- token left the sandbox and no money moved, and after a third run (run 3) 17 of the 20 files end FILED / not_an_invoice (no money, no reply, listed in the casebook) and the 3 that carry a total or amounts (07, 13, 14) stay HELD. griftgate still does not summarise or calendar non-invoice input. Read tests/trap-pack/RESULTS.md for each file, the fixes we made, and all traces.
  • The head-to-head is one live run, replayed from tape. The comparison agent is one we wrote; a better-built baseline would lose less.
  • griftgate queues payments. A human must release them. "Autonomous" here means the whole job up to the release step, unattended.
  • The bank is a sandbox we wrote. Its separation of keys is real; it is not a real bank's security.
  • English-language invoices only. No OCR for scanned images.

Layout

griftgate/      the code (cli, agent, controls, extract, investigate, books, master, bank, bankclient, audit, board, control, casebook, mailroom, money, traps, evaluate, config)
controls.toml   the owner's rules
seed/           labelled fake data and its generator
tapes/          recorded model replies for $0 replay
tests/          unittest suite, freeze test, trap-results/ (our set), trap-pack/ (official pack: RESULTS.md, traces; CC BY 4.0, "Agentware 2026 Trap Pack, Hackathon Raptors", https://creativecommons.org/licenses/by/4.0/)
eval/           head-to-head results
evidence/       freeze test output and audit export
traces/         the demo run: console output, audit trail, casebook

See AGENT.md (design), SAFETY.md (what is enforced in code), JUDGES.md (how to check us).

About

AP invoice fraud gate with a separate bank process and kill switch. Agentware 2026, Open Track. Sandbox only.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages