Paid, hosted product at menivor.com, now retired as a company project. Fresh squashed history of the cleaned working tree (secret-scanned, no .env, no customer data, no outreach logs). Built on MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
28 KiB
Abacus — per-agent spend attribution + hard real-time budget kill-switch
Status: planning doc (no code yet). App slug:
abacus· Dir:apps/abacus· Unit: AIT (µ$ integer, ADR-0001). Product family: ReelForge (video) · Relay (inference gateway) · Mint (AIT settlement + AITP-402) · Abacus (this — spend governance + enforcement rail).
One-liner: An inline reverse proxy that gives every autonomous agent a hard, cryptographically-receipted spend budget — and kills the request the microsecond it would breach it, so a looping agent can never burn $40k overnight again.
1. Problem & thesis
Autonomous agents have become unsupervised spenders. They call LLMs, tools, compute, and other agents in loops, and today the money controls are all after-the-fact dashboards: Helicone, Langfuse, and Portkey show you what an agent already spent. When a planning loop or a retry storm goes pathological at 2am, the dashboard is a beautiful record of the $40k you just lost. Cloud FinOps tools (CloudZero, Vantage, Kubecost) have the same shape one layer down: visibility, tagging, alerts — no enforcement in the request path.
The thesis: as agents autonomously spend, "control" stops being a nice-to-have report and becomes a board-level, mandatory, inline requirement — the same way network firewalls and IAM are mandatory. The durable value is being the enforcement point that sits in the request path, holds the budget, and can refuse to let money leave. Enforcement + a tamper-evident receipt trail is the system of record for agent spend, which is far stickier than a read-only dashboard you can rip out on renewal day.
Abacus is that enforcement point. It is a thin reverse proxy in front of every
paid call an agent makes (LLM, tool, sub-agent, compute), backed by Mint
allowances and holds, so the budget is reserved before the call and captured
only on success — and a breach is a 4xx/kill, not a Slack alert an hour later.
Why this is the buyer-side wedge into the platform thesis: every enforced request settles as a Mint hold→capture with a hash-linked receipt. Governance is the reason a CFO mandates the proxy; the proxy is the on-ramp that routes agent spend onto the Mint rail. Control grows the rail.
2. Why now
- Agents actually spend autonomously now. 2025-2026 agent frameworks run multi-step, self-directed loops with tool and sub-agent budgets. The failure mode (runaway spend) is common enough to be a recurring post-mortem, not a hypothetical.
- The pain is bought into after a specific incident. "We burned $X overnight" is a concrete, dated, painful event with a named owner. That is the sharpest possible sales trigger.
- Reverse-proxy adoption is already normalized. Teams already put Helicone / Portkey / a gateway in front of their LLM calls by changing a base URL. Adding an enforcing proxy is a one-line change, not an architecture project.
- We already own the rails. Relay is an OpenAI-compatible inline gateway; Mint already specifies allowances, holds→capture, AITP-402, and hash-linked receipts. The enforcement primitives exist as plans; Abacus is the governance product that makes them a must-have.
- Regulatory/audit tailwind. SOC2/ISO auditors and finance teams increasingly ask "how do you prevent and prove agent spend controls?" A cryptographic receipt trail answers it directly.
3. The narrowest wedge + first customer
Wedge (one feature, one sentence): "Set a hard dollar ceiling per agent / per run / per key; when the next call would breach it, we block the call and page you — before the money leaves."
Not analytics. Not multi-cloud FinOps. One kill-switch, sold into a post-mortem.
First customer: a Series-A/B startup running customer-facing or internal autonomous agents (support agent, coding agent, research agent, data-pipeline agent) on OpenAI/Anthropic/OpenRouter, spending $20k-$500k/mo on LLM+tools, whose eng or finance lead just lived through a runaway-spend incident (or fears one because they have no ceiling). Buyer = eng lead + finance/FinOps, champion = the on-call engineer who got paged.
First integration (day-1 value, zero new SDK): they change one base URL. Their agents keep using the OpenAI SDK; requests now flow through Abacus. We attribute spend per agent/key/run and enforce a ceiling. That is the entire first sale.
Land → expand: kill-switch → per-agent budgets & policies → tool/sub-agent spend (not just LLM) → cryptographic receipts as system-of-record → org treasury & allowances on Mint → agents that pay per-call via AITP-402.
4. How it reuses ReelForge / Relay / Mint (concrete)
Abacus is ~80% assembly of existing primitives plus a governance/policy layer
and a hard enforcement gate. It is a standalone Rust workspace (axum/tokio),
excluded from the root Cargo workspace exactly like apps/relay and
apps/mint, so it never triggers the apps/desktop GPUI/Metal build. It inherits
ADR-0001 (integer microdollar) and ADR-0002 (success-only billing).
4.1 Reuse from Relay (apps/relay/crates/*) — the proxy body
relay-server— the axum HTTP surface + tower middleware stack is the exact reverse-proxy shape Abacus needs; Abacus is a middleware layer + policy engine in front of it (or a thin fork of the server binary configured as enforce-only).relay-router/relay-normalize/relay-providers— reuse the OpenAI-compatible request parsing, provider manifests, and streaming normalization so Abacus can meter any provider (OpenAI, Anthropic, Google, Groq, DeepSeek, xAI, OpenRouter passthrough, local vLLM/Ollama) with no per-provider code.relay-tokenize— exact pre-flight token counting to estimate the cost of the call about to happen (critical: we must price before we allow).relay-billing— microdollar metering + markup accounting; Abacus reuses the metering path but adds the pre-authorization gate in front of it.relay-keys— provisioning/management keys with scopes + per-key spend/rate limits are exactly the identity anchor Abacus attributes and budgets against.relay-guardrails— extend the middleware slot: a budget guardrail joins moderation/PII/context-cap as first-class inline middleware.relay-analytics— usage rollups feed the attribution views (spend by agent/key/run/model/tool).
4.2 Reuse from Mint (apps/mint) — the enforcement + receipt rail
This is the moat layer. Abacus does not re-implement money; it drives Mint:
- Allowance (
allowance.grant/allowance.spend) — the native per-agent / per-key / per-run budget. GrantlimitAIT overwindowwithscope. Every agent call is anallowance.spendthat Mint rejects withallowance_exceededwhen the ceiling is hit. The budget lives in the ledger, not in app memory — so it survives restarts, races, and multi-instance proxies. - Hold → capture/release (
hold.create/hold.capture/hold.release) — the pre-authorization gate. Before forwarding a call, Abacus creates a hold for the estimated max cost (drops spendable balance immediately → no double-spend across concurrent calls). On success it captures actual usage; on failure it releases (ADR-0002 success-only for agents). This is what makes the kill-switch hard and race-free rather than a best-effort counter. - AITP-402 (
aitp-holdscheme) — for agents that pay per call with no pre-funded session: Abacus returns402with anAITP-Challenge, the agent signs an authorization, Mint verifies + holds, the call proceeds, capture on completion. This turns Abacus into the standard toll booth for the agent economy. - Receipts (hash-linked, ed25519-signed, merkle root) — every enforced
decision (allowed, captured, blocked) emits a tamper-evident receipt. This is
the system-of-record claim: an auditor or a dispute can independently verify
the full spend history offline, and
GET /v1/receipts/auditgives a merkle root. A read-only dashboard cannot produce this; that is the durable differentiator. - Reserve / conservation invariant — org treasury balances and agent budgets
are all AIT accounts;
Σ balances + Σ active holds == reservegives finance a solvency/"money can't have leaked" proof. - Accounts & addresses — each agent gets a Mint
agentaccount/address (ait1<2>…); orgs get atreasuryaccount. Attribution = ledger identity, not a tag string.
4.3 Reuse from ReelForge (apps/api/app/domains/*) — governance patterns & first dogfood
domains/spend(policy.py,roles.py,service.py) — existing spend-policy + role model is the conceptual seed for Abacus's policy engine (who can raise a ceiling, role-scoped budgets); port the policy shape.domains/gateway(provisioning.py,media_usage.py, markup) — the provisioning-key + usage-metering + markup pattern is the same shape Abacus applies to any agent call.media_usageshows the metered-usage ledger pattern to mirror.domains/routing(policy.py,license_class.py) — the license/cost policy engine is a template for Abacus's per-provider cost policy.domains/observability&domains/compliance— reuse the dashboards and compliance surfaces for the attribution UI and audit/export.domains/wallet(integer-microdollar ledger) — becomes a Mint client (mirrors the Mint PLAN §2 "wrap then unify"); ReelForge's own render/agent spend is the first internal dogfood of Abacus enforcement.webapp — reuse the existing dashboard shell for the Abacus console (budgets, live spend, kill-switch, receipts).
4.4 Shared infra
Neon/Postgres (ledger + policy + receipts), Cloudflare (edge proxy termination,
the natural place to run an inline enforcement layer near the caller), OTel via
*-telemetry crates.
5. Architecture sketch
Abacus is an inline enforcing reverse proxy with a policy engine and a Mint-backed budget/receipt core. The critical design property: the money decision happens in the request path, synchronously, before bytes are forwarded.
┌──────────────────────────────────────────────────────────┐
Agent / SDK │ A B A C U S │
(base_url swap) │ │
│ request │ ┌──────────┐ ┌───────────┐ ┌────────────────────┐ │
├──────────▶│ │ ingress │─▶ │ identity │─▶ │ POLICY ENGINE │ │
│ │ │ (relay- │ │ resolve │ │ budget? scope? │ │
│ │ │ server) │ │ (relay- │ │ who/agent/run/key │ │
│ │ └──────────┘ │ keys) │ └─────────┬──────────┘ │
│ │ │ └───────────┘ │ │
│ │ ▼ ▼ │
│ │ ┌──────────────┐ ┌───────────────┐ │
│ │ │ pre-flight │ │ ENFORCEMENT │ │
│ │ │ cost estimate│─── est. max ───▶│ GATE (Mint) │ │
│ │ │ (relay- │ │ hold.create / │ │
│ │ │ tokenize) │ │ allowance.spend│ │
│ │ └──────────────┘ └──────┬────────┘ │
│ │ │ allow / DENY │
│ │ DENY → 402 (AITP) or 429/403 kill ◀────┤ │
│ │ ▼ allow │
│ │ ┌────────────────────────────────────────────────┐ │
│ response │ │ forward (relay-router/normalize/providers) │ │
│◀──────────┤ │ → provider (OpenAI/Anthropic/…/tool/sub-agent) │ │
│ (stream) │ └───────────────────┬────────────────────────────┘ │
│ │ ▼ on complete │
│ │ hold.capture(actual) | hold.release(fail) │
│ │ ▼ │
│ │ emit hash-linked RECEIPT (mint-receipts) │
│ └──────────────────────┼───────────────────────────────────┘
│ ▼
│ ┌───────────────────┐ ┌───────────────────┐
└───────────────────────▶│ Mint (AIT ledger │ │ Neon/Postgres │
async: analytics, │ allowances/holds │ │ policy + rollups │
alerts, receipts feed │ receipts/reserve)│ │ attribution │
└───────────────────┘ └───────────────────┘
Request lifecycle (the hot path):
- Ingress (reuse
relay-server): agent sends an OpenAI-compatible (or tool/HTTP) request through Abacus. - Identity resolve (reuse
relay-keys): map key/header → agent account, run id, org/treasury, and applicable policy. Attribution is a ledger account, not a tag. - Pre-flight cost estimate (reuse
relay-tokenize+ provider pricing): compute the maximum this call could cost. - Enforcement gate (Mint):
hold.create(estimated_max)against the agent's allowance/balance.- Mint returns
allowance_exceeded/insufficient_funds→ kill: respond402(AITP challenge, if pay-per-call) or403/429with a structuredbudget_exceededbody, page the on-call, log a blocked receipt. No bytes forwarded, no money spent. - Hold succeeds → proceed.
- Mint returns
- Forward (reuse
relay-router/normalize/providers): stream from the real provider/tool/sub-agent. - Settle: on success
hold.capture(actual_usage); on failure/timeouthold.release(ADR-0002). Emit a hash-linked signed receipt. - Async fan-out: attribution rollups, budget-burn alerts (e.g. 80% warn), and the receipts audit feed.
Why a hold, not a counter: concurrent agent calls racing the same budget can each pass a naive "current_spend < ceiling" check and collectively overshoot. A Mint hold reserves the money synchronously and atomically (per-account serialized apply, AITP-402 §8), so N concurrent calls can never breach the ceiling. This is the technical reason enforcement must sit on the ledger, and the reason a dashboard can't do it.
Policy engine (Postgres, ported from domains/spend + domains/routing):
budgets and rules keyed by org / team / agent / run / key / model / provider / tool,
with windows (per-run, per-hour, per-day, per-month), soft (warn) and hard (kill)
thresholds, allow/deny scopes, and role-gated overrides ("who can raise a ceiling").
Latency budget: the gate adds one Mint round-trip. Target p99 added overhead < 5ms (mirrors Relay's SLO) via same-region Mint, connection pooling, and an optional local allowance lease (Abacus leases a slice of the allowance from Mint and enforces locally, reconciling asynchronously) for ultra-low-latency tenants — the lease is itself a Mint hold, so it stays race-safe.
6. Monetization (everything settles on Mint)
Abacus is a governance SaaS with a usage-metered rail underneath, and every enforced request is a Mint settlement — so revenue is legible and on-rail.
- Platform seat / tier (primary, fast cash). Per-org subscription by number of
governed agents / spend under management:
- Team (kill-switch + per-agent budgets + receipts) — flat monthly.
- Business (policy engine, RBAC overrides, tool/sub-agent enforcement, SSO, audit export) — higher flat + per-seat.
- Enterprise (self-host/edge, custom compliance, solvency proofs, SLA).
- Governed-spend bps (the rail take-rate). A small basis-point fee on spend under enforcement (e.g. 15-50 bps of AIT flowing through holds), because we sit inline and provide the guarantee. This scales with agent spend — the thing the thesis says grows unboundedly — and lands directly on Mint as captured holds.
- AITP-402 toll (agent economy). For pay-per-call agents paying via AITP-402, Abacus takes a markup on the hold→capture, exactly like Relay's gateway markup / BYOK fee. Every such call mints a receipt on Mint.
- Overage / burst alerts + auto-top-up (Mint mint/redeem). When a treasury
nears empty, Abacus triggers Mint auto-top-up (Stripe/crypto on-ramp via
relay-web3→POST /v1/mint), earning the standard on-ramp spread. - Compliance/audit add-on. Cryptographic receipt export + solvency proof + SOC2 evidence pack as a paid enterprise module.
All of (2)-(4) settle as Mint transfers/captures with receipts — Abacus grows the rail as a function of governed spend. Money math is integer µ$ (ADR-0001), billing is success-only (ADR-0002).
7. Moat & network effects
- Inline > read-only (structural). Because Abacus is in the request path and holds the money, it is the enforcement point, not an observer. Ripping it out means removing your spend guarantee — a security/compliance regression, not a tooling swap. Dashboards (Helicone/Langfuse) are trivially removable at renewal; an enforcement gate is not.
- Cryptographic receipts as system-of-record (data gravity). Once an org's audit trail, disputes, and finance reconciliation depend on Abacus's hash-linked merkle-verifiable receipts, Abacus is the book of record for agent spend. Migrating means abandoning your verifiable history.
- Ledger identity for agents. Every agent becomes a Mint account with a budget and a receipt history. That identity graph (agent → runs → spend → receipts) compounds and isn't portable to a competitor.
- Rail flywheel (platform thesis). More enforced spend → more settlement on Mint → more AITP-402 payees/payers → the agent-economy payments rail others build on. Governance is the reason buyers adopt; the rail is the durable asset they end up standing on.
- Two-sided toll booth. As agents pay other agents/tools via AITP-402 through Abacus, both payer and payee are on the rail — classic marketplace network effect.
Incumbent risk (honest): Helicone/Langfuse/Portkey/OpenRouter can add enforcement — Portkey already has guardrails/budgets. Our defensibility is (a) the ledger-backed hold (hard, race-free, not a soft counter) tied to a real settlement layer, (b) cryptographic receipts as system-of-record, and (c) being part of a settlement rail (Mint) + gateway (Relay) they'd have to rebuild. Speed to the ledger-hold semantics + receipts is the race.
8. GTM — first 100 users
- Post-mortem inbound. Content + outreach aimed at the exact incident: "the looping agent that burned $40k." Teardown blog posts, an incident playbook, and a free "runaway-spend risk audit" (point Abacus at their logs read-only, show where they had no ceiling). The audit is the wedge conversation.
- One-line drop-in. Free tier: swap base URL, get per-agent attribution + one free hard budget/kill-switch. Time-to-first-value = minutes. This mirrors how Helicone/Portkey got adopted, but with enforcement as the hook.
- Dogfood first (credibility). Put ReelForge's own agent/render spend
(
domains/wallet, gateway, series/clipfarm fan-out) behind Abacus and publish the numbers. "We govern our own agents with it." - Land the champion, sell the mandate. Champion = the paged on-call engineer; economic buyer = finance/FinOps who now wants provable control. The receipt trail is the finance/audit close.
- Relay + agent-framework distribution. Offer Abacus as the default budget guardrail inside Relay, and as a drop-in for popular agent frameworks (a middleware/proxy config, not an SDK rewrite).
- First 100: ~10 design partners from post-mortem inbound + warm YC-network agent startups; convert via the free audit + free kill-switch; expand the ones with real spend into paid policy/receipts tiers.
9. Key risks + kill-criteria
| Risk | Mitigation | Kill-criteria |
|---|---|---|
| Latency in the hot path (the gate must be fast). | Same-region Mint, pooling, local allowance-lease mode; publish p99 overhead. | If p99 added overhead can't get < 15ms in real deployments, the inline thesis fails — pivot to near-line (fail-open with fast async kill). |
| Fail-open vs fail-closed — if Mint/Abacus is down, do agents stop working? | Configurable: fail-open with a locally-leased allowance (bounded risk) or fail-closed for high-risk tenants. Leases cap worst-case exposure. | If enterprises won't accept either posture, enforcement-in-path is unsellable. |
| Incumbents add enforcement (Portkey budgets, etc.). | Ledger-hold + cryptographic receipts + rail integration as the differentiator; move fast to system-of-record. | If a top-3 incumbent ships ledger-backed holds + verifiable receipts before our GA, re-evaluate. |
| Cost-estimate accuracy — we hold on estimated max; bad estimates over-reserve or under-protect. | Reuse relay-tokenize for exact pre-count; hold the provider-priced max; capture actuals. Tune per-provider. |
If we can't bound estimate error enough to make holds trustworthy, kill-switch precision suffers. |
| Attribution correctness — mis-attributed spend erodes trust instantly. | Ledger-identity (Mint accounts) not tag strings; property tests on conservation. | Persistent mis-attribution in pilots = no trust = no sale. |
| Compliance posture of AIT/holds. | Inherit Mint's closed-loop, fiat-backed, reserve-segregated design; KYC/AML on mint/redeem only. | Regulatory blocker on internal-credit holds. |
| Buyers want visibility, not enforcement (yet). | Ship attribution first as the wedge; enforcement as the upgrade. | If <20% of attribution users ever turn on a hard budget after a pilot quarter, the "enforcement is mandatory" thesis is wrong for this segment. |
10. Phased roadmap (Ax0 → Ax4) with acceptance gates
Own multi-agent workflow chain (recon → design → build → review → fix), TDD, same shape as ReelForge waves / Relay RP / Mint AP. Standalone workspace, disjoint from running workflows. Depends on Mint AP1 (holds) + AP3 (allowances/AITP-402).
-
Ax0 — Attribution proxy (the free wedge). Standalone
apps/abacusworkspace; inline reverse proxy on top ofrelay-server/relay-router/relay-normalize; identity resolve viarelay-keys; per-agent/run/key spend metering viarelay-tokenize+relay-billing; write-through to Neon. Gate: a real agent's OpenAI-compatible traffic flows through Abacus and every request is attributed to an agent/run/key with microdollar-exact spend, zero added correctness drift vs direct calls. -
Ax1 — Hard kill-switch (the sale). Wire the enforcement gate to Mint
hold.create → capture/release+allowance.grant/spend; pre-flight cost estimate; structuredbudget_exceededkill (403/429) + on-call alert. Policy engine v0 (per-agent/run/key ceilings) ported fromdomains/spend. Gate: under a concurrent runaway-loop simulation, spend is capped at the ceiling with zero overshoot (N racing calls cannot breach), failed/blocked calls never capture (ADR-0002), and the offending call is killed before forwarding. -
Ax2 — Receipts as system-of-record. Every allow/capture/block emits a
mint-receiptshash-linked, ed25519-signed receipt; attribution UI (reusewebshell +domains/observability) shows spend-by-agent/run/model/tool + live budget burn; audit export +receipts/auditmerkle root. Gate: an auditor can independently verify a full agent's spend history offline and any tamper is detected; finance reconciles a month of spend to the receipt trail exactly. -
Ax3 — Policy engine + org treasury + AITP-402 toll. Full policy engine (org/team/agent/run/model/provider/tool scopes, windows, soft/hard thresholds, RBAC overrides); org treasuries + delegated allowances on Mint; AITP-402 pay-per-call toll for sessionless agents; tool/sub-agent spend enforcement (not just LLM); local allowance-lease low-latency mode. Gate: an agent with no pre-funded session completes a paid call via AITP-402 through Abacus with a hold, capture, and receipt; a cross-team budget policy is enforced with role-gated overrides; p99 added overhead < 5ms in lease mode.
-
Ax4 — GA / rail + governed-spend billing. Governed-spend bps + AITP-402 markup + auto-top-up (Mint mint/redeem via
relay-web3) all settling on Mint; fail-open/closed postures; self-host/edge (Cloudflare) deploy; SOC2 evidence pack; solvency proof; OTel dashboards; blue-green. Dogfood: ReelForge's own agent spend fully governed. Gate: a paying design-partner org runs production agent traffic under Abacus enforcement for 30 days with zero missed kills, zero billing/conservation violations under chaos, and reconciled Mint settlement.
11. Success metrics
- Wedge/value: time-to-first-kill-switch (minutes from base-URL swap); # runaway incidents prevented (blocked-before-breach events) per org; $ of would-be overspend blocked.
- Correctness (non-negotiable): zero budget overshoot under concurrent-loop chaos; zero success-only (ADR-0002) violations; zero conservation violations on Mint; 100% attribution accuracy vs ground truth.
- Performance: p99 added gateway overhead (< 5ms lease mode, < 15ms inline target); fail-over/fail-open behavior within SLO.
- Rail (thesis): AIT governed-spend GMV under enforcement; bps revenue; # agent accounts with active budgets; # AITP-402 payees/payers on the rail; receipts emitted / audited.
- Business: free-audit → paid conversion; attribution-user → enforcement-on conversion (validates the "enforcement is mandatory" thesis); net revenue retention as governed spend grows; logos with Abacus as system-of-record.
12. The billion-dollar thesis (crisp)
As agents become the primary autonomous spenders of money, the mandatory, board-level control point is an inline enforcement layer that holds the budget and can refuse to let money leave — and the enforced, cryptographically-receipted record becomes the system-of-record for agent spend. Abacus wins that control point with a sharp kill-switch wedge, then compounds because it is ripped-out-proof (enforcement + verifiable receipts, not a removable dashboard). Critically, every enforced request settles on Mint, so buyer-side governance is also the on-ramp that routes the entire agent economy's spend onto the AITP-402 payments rail — Abacus is the sharpest buyer-side wedge into the durable platform: the payments rail for the agent economy.