Inspiration

An AI agent can now pick items and pay for them alone. When one of those charges is disputed, nobody can prove what the agent was allowed to do or why it chose the item. The money gets stuck in an argument. Sentry is a receipt layer for agentic payments.

What it does

Sentry gives the agent a signed permission slip (a mandate): a monthly cap, allowed categories, an approval line, and an optional "ask me when unsure" clause. The agent shops through the PayPal sandbox. Plain code (not a model) checks every choice against the mandate.

  • Evidence: every decision writes a hash-chained evidence record: the mandate version, the options and prices the agent saw, what it chose and why, and the budget before and after. Editing a record breaks the chain, and /api/evidence/verify finds it.
  • Holds: a purchase above the approval line becomes a PayPal authorization (a hold). A person approves it and Sentry captures it. A rejection voids the hold. Nothing is charged before approval.
  • Disputes: when a purchase is disputed, the evidence becomes a dispute response. Code computes the verdict. DEFENSIBLE means provide evidence, with a PDF evidence packet. MANDATE_BREACH means accept the claim and refund through PayPal. A model only writes the narrative.
  • Merchant view: shows "Ship it" or "Do not ship" for a purchase, from the same proof.

How we built it (PayPal + AI)

PayPal: Orders v2 (create, approve, capture), card checkout with the PayPal sandbox test card, Authorizations (hold, capture, void, expiry), Refunds (full and partial), Payouts (fallback when a refund is not possible), signed webhooks (verified, idempotent) plus a reconciler as a safety net, the PayPal JS SDK button, and the Disputes API list call. One module, the gate, is the only code that can mint a ticket for a PayPal mutation.

AI: the shopping agent runs in one of three modes. live uses Claude for tool calls and dispute narratives. engine is an on-server semantic engine (MiniLM-L6 embeddings via ONNX, no API key). It reads intent, asks a clarifying question when unsure, substitutes within budget, and flags prompt injection. mock is for tests. The agent only proposes. The checker decides.

Stack: Node 24 TypeScript, SQLite, Next.js static export, AG Grid, hosted on Render. 87 unit tests and 4 end-to-end tests pass.

Challenges

  • PayPal would not open a sandbox dispute on our payments (TRANSACTION_NOT_ELIGIBLE), so disputes are labelled SIMULATED.
  • The Payout path is denied with SELF_PAY_NOT_ALLOWED on our sandbox accounts (same sender and receiver).
  • Keeping the model out of every decision that moves money.

Accomplishments

Real sandbox runs (2026-11-11): hold then capture, a $299 rogue purchase refunded through PayPal after a MANDATE_BREACH verdict, a partial refund, and verified signed webhooks.

What we learned

Signed-mandate protocols prove what was authorised. They do not prove the agent read the right price or that budget remained. That evidence must be captured at decision time.

What is real and what is simulated

The README table lists exactly what ran against the PayPal sandbox. We do NOT claim AP2/FIDO conformance, real liability shift, card-network integration or production readiness. PayPal SANDBOX only.

Built during the submission period

The project was built during the submission period (first commit 2026-11-08).

Testing instructions

Open https://mandate-ledger.onrender.com. No login. The first load can take about 30 s (Render free tier). Sandbox only; no real money.

  1. Landing page, then "Open the console".
  2. Mandates: verify the signature and seal.
  3. Ask the agent: "restock the pantry basics". The $42 bundle waits for approval (the approval line is $40). Approve and capture.
  4. Run the rogue demo ($299), then open Disputes and accept the claim: a MANDATE_BREACH refund is issued.
  5. Evidence: verify the chain. Merchant view: "Do not ship" / "Ship it". Download the packet PDF.

To run locally, see the README "Quick start" (mock mode needs no credentials).

AI tools disclosure

  • In the product: claude-sonnet-5-5 (Anthropic API) for the live shopping agent's tool calls and dispute narratives. Xenova/all-MiniLM-L6-v2 (open source, local, through Transformers.js and ONNX) for the no-key engine. No external AI service is used in engine mode.
  • Demo video voice-over: Microsoft Edge TTS "Andrew" (synthetic voice).
  • While building: Claude Code and Codex as coding assistants. They are separate from the product's AI.

What is next

A real PayPal dispute round trip, persistent storage and a stable signing key, recurring mandates.

Built With

  • ag-grid
  • claude
  • next.js
  • node.js
  • onnx
  • paypal-orders-api
  • paypal-refunds-api
  • paypal-sandbox
  • paypal-webhooks
  • render
  • sqlite
  • transformers.js
  • typescript
Share this project:

Updates

Submission history