videogen/docs/apps-vision/ledgerline.md
caelum0x d56639a594
Some checks are pending
build-images / api (push) Waiting to run
build-images / worker-gpu (push) Waiting to run
build-images / web (push) Waiting to run
codeql / Analyze (javascript-typescript) (push) Waiting to run
codeql / Analyze (python) (push) Waiting to run
perf / API hot-path micro-smoke (budgeted) (push) Waiting to run
perf / Desktop engine crates (release build check) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Waiting to run
vision2026-ci / API phase modules (ruff + pytest) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Waiting to run
vision2026-ci / Python SDK resource tests (push) Waiting to run
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Waiting to run
vision2026-ci / Alembic upgrade + drift check (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Waiting to run
Menivor — open source release (MIT), free to use and fork
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.
2026-12-04 02:10:26 +03:00

527 lines
32 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Ledgerline — AI usage-metering + billing with COGS reconciliation
> **One-liner:** The billing system of record for AI companies that puts
> **revenue and true provider COGS on the same ledger** — so a GPT-wrapper knows
> its real gross margin per customer, per feature, per model, in real time — built
> natively on Mint streams/holds/allowances/receipts and Relay's provider
> cost-capture.
>
> **Status:** Sx0 first product slice implemented. Authenticated event ingest,
> real Mint settlement, Postgres persistence, and request-level margin queries
> are runnable; the one-million-event/durable-workflow Sx0 gate remains open.
> See `apps/ledgerline/README.md` for the current surface and run contract.
> **Slug:** `ledgerline`. App dir: `apps/ledgerline`.
> Product family: **ReelForge** (video) · **Relay** (inference gateway) ·
> **Mint** (AIT settlement) · **Ledgerline** (this — metering + billing +
> margin).
---
## 1. Problem & thesis
Usage-based billing (UBB) infrastructure — Metronome, Orb, Lago, Stripe Billing —
is already a multi-billion-dollar category, and **AI is its fastest-growing
segment**. Every AI company that charges per token, per generation, per seat +
overage, or per "credit" needs three hard things:
1. **Meter** raw usage events reliably (idempotent, late-arriving, high-volume).
2. **Rate** those events into money (tiers, prepaid credits, commitments,
minimums, discounts) and **invoice** correctly.
3. **Recognize** the money (revenue schedules, prepaid draw-down, ASC-606).
The incumbents do (1)–(3) well. But they were built for SaaS, where **cost of
goods sold (COGS) is roughly fixed** (servers you already own). They treat the
*revenue* side as the whole world.
**AI billing is different: COGS is variable, per-request, and often the majority
of the bill.** Every user prompt hits an LLM/GPU/image provider that charges the
AI company money *at the moment of use*. So the number every AI founder actually
loses sleep over is not "what did I invoice?" — it's **"am I making money on this
customer, on this feature, on this model, this week — or am I subsidizing a power
user into bankruptcy?"**
Today that answer lives in a **spreadsheet reconciliation nightmare**: export
Stripe/Metronome revenue, export OpenAI + Anthropic + Replicate + AWS invoices,
try to join them on some fuzzy key that doesn't exist, and produce a
gross-margin estimate that is weeks stale and customer-blind.
**Ledgerline's thesis:** the billing system of record for AI companies should
capture **revenue and provider COGS on one double-entry ledger, keyed to the same
request**, so **true gross margin is a first-class, real-time, drill-downable
metric** — not a quarterly reconciliation project. Because our platform already
*is* the payment rail that pays the providers (Relay + Mint), we can capture exact
COGS at the moment of settlement — an angle **no pure billing tool can match
without integrating a rail they don't own.**
### Why this is a company and not just a feature (the honest tension)
The scoring note is right to flag it: "COGS reconciliation reads more as a feature
than a company." The defensible framing is **not** "we add a margin column to
Metronome." It is:
- **The system of record is the moat.** Once Ledgerline is the meter → rate →
invoice → revenue-recognition system for a company, it is famously sticky
(multi-quarter rip-and-replace). We earn that position with a *sharper wedge*
(margin, not just invoices) and *lower integration cost* (the meter and the
cost feed can be the same event when they run through Relay/Mint).
- **The COGS+revenue-on-one-rail data compounds.** Every settled request writes a
paired (revenue, provider-cost) receipt to Mint's hash-linked log. Over time
Ledgerline holds the **only clean, per-request, cross-provider margin dataset**
for its customers — which powers margin analytics, alerting, provider-arbitrage
routing recommendations, and eventually price optimization. That dataset is the
compounding asset; billing is the beachhead that produces it.
- **It is capital-light.** It is buildable almost entirely on primitives that
already exist in Mint and Relay. Low cost to keep in the portfolio; high option
value if AI-native billing becomes the standard.
**Kill/demote criterion up front (honoring the note):** if the portfolio is
already billing-heavy, or if within Sx2 we cannot show a design partner a margin
number they could not previously see *and* that changed a decision they made,
Ledgerline should be demoted to a **margin-analytics feature of Relay/Mint**
rather than a standalone company. The go/no-go is in §11.
---
## 2. Why now
- **AI COGS is now the dominant line item** for a huge class of "GPT-wrapper" and
agent startups — 40–90% of revenue, and *variable*. Finance tooling built for
~80% software gross margins simply doesn't model this.
- **Provider price volatility is constant** (model deprecations, new cheaper
tiers, per-provider price cuts weekly). Companies that cannot see per-model
margin cannot exploit these — they leave money on the table every week.
- **Agentic usage is spiky and unbounded.** A single autonomous agent can 100x a
customer's provider cost overnight. Founders need *live* margin + spend alerting,
not a month-end invoice.
- **UBB is standardizing.** Metronome/Orb/Lago proved the meter→rate→invoice
pattern and educated the market; buyers now expect usage billing. The greenfield
is the **margin-aware** layer on top.
- **We already own the rail.** Relay is an OpenRouter-shaped gateway that sees
exact per-request provider cost; Mint is a double-entry, success-only,
hash-linked settlement ledger with holds/streams/allowances. The two hardest
parts of AI-native billing — reliable metering and exact COGS capture — fall out
of infrastructure we are already building. **The window is the 12–24 months
before an incumbent bolts a credible COGS feed onto their billing product; our
edge is that we settle the provider payment, so our COGS is ground truth, not an
imported estimate.**
---
## 3. The narrowest wedge + first customer
**Wedge (one sentence):** *"Point your existing OpenAI/Anthropic/etc. traffic at
Relay (or drop in our meter SDK), and within a day see real-time gross margin per
customer and per feature, with automatic alerts when a customer goes
margin-negative — no billing migration required."*
We deliberately **do not** lead with "replace your billing system." That is a
6-month enterprise sale against entrenched incumbents. We lead with a **read-only,
side-car margin lens** that requires zero rip-and-replace, produces a number the
founder has never had, and *earns the right* to become the biller later.
### First customer profile (ICP for the first 10)
- **Seed / Series-A AI product company** ("GPT-wrapper," AI agent, AI-copilot,
AI-media tool) doing **$10k–$500k MRR**, billing usage-based or credit-based.
- Routes the majority of spend to **2–5 external providers** (OpenAI, Anthropic,
Google, Replicate/fal, an image/video model, GPU on RunPod).
- Has a **founder or first finance hire** who currently maintains a
margin spreadsheet and hates it.
- **Trigger:** "we just found out our top 3 customers are unprofitable and we
didn't know for two months," or "we're raising and the investor asked for
gross margin by cohort and we can't produce it."
**Design partner #0 is internal:** **ReelForge itself.** ReelForge already has
the exact pain — the `routing` domain calls 11 real model adapters each with a
license/cost policy, `gateway` resells provisioning keys with markup, `wallet`
is an integer-microdollar ledger, and `clipmarket` pays creators. Ledgerline's
first production deployment is reconciling ReelForge's own revenue (wallet debits
for renders/clips) against its own COGS (routing adapter provider spend + RunPod
GPU minutes) to answer "what is our true margin per render template, per model,
per creator?" This is a real, dogfooded first customer with real money moving —
not a lab screen. It also de-risks the product before a single external sale.
---
## 4. How it reuses ReelForge / Relay / Mint (concrete)
Ledgerline is **thin by design** — it is an orchestration + rating + reporting
layer over primitives that already exist. Almost nothing here is net-new
infrastructure.
### 4.1 Mint (the settlement + receipt substrate) — the core reuse
Ledgerline stores **every billable event as a paired ledger movement on Mint**, so
revenue and COGS are the same double-entry system, not two systems to reconcile.
| Mint primitive (from `docs/mint`) | How Ledgerline uses it |
|---|---|
| **Hold → capture/release** (`hold.create`/`capture`/`release`, ADR-0002) | The customer-facing charge for a metered request is a *hold* opened at request start and *captured on success* for the actual rated amount (metered inference = `aitp-hold`). Failures release — never invoice a failed generation. |
| **Stream** (`stream.open/tick/close`) | Long/agentic/token-metered jobs bill as a stream with a **cap**; each `tick` settles usage incrementally. The cap *is* the spend guardrail that stops a runaway agent. |
| **Allowance** (`allowance.grant/spend`, `window`, `scope`) | Prepaid credit balances, per-customer/per-key spend budgets, and free-tier limits are allowances. "Credit draw-down" billing = allowance spend. |
| **Transfer** | Provider payouts and creator/reseller revenue splits are transfers to `provider`/`model`/`creator` addresses. This is where **COGS is captured as a real ledger entry**, not an imported invoice line. |
| **Receipt** (hash-linked, signed, merkle-rooted) | Every invoice line and every COGS line is a tamper-evident receipt. **Auditable billing + auditable margin** — an enterprise-grade differentiator (disputes, SOC2, revenue audit) that pure billing tools bolt on separately. |
| **AITP-402** | Agent/machine customers pay per call with no pre-funded session; the 402 `aitp-hold` handshake *is* usage billing for the agent economy. |
| **Reserve / conservation invariant** | Solvency + "did every dollar of revenue and every dollar of COGS reconcile to zero?" is enforced by Mint's `Σ balances + Σ holds == reserve`. Reconciliation is an *invariant*, not a monthly job. |
**Key architectural claim:** in Ledgerline, a single billable AI request produces
**one linked pair of Mint receipts** — a *revenue* movement (customer hold→capture)
and a *COGS* movement (transfer to the provider address, sourced from Relay's exact
cost) — sharing a `request_id`. Margin = revenue receipt − COGS receipt, per
request, queryable directly off the hash-linked log. **That linkage is the whole
product.**
### 4.2 Relay (the exact-COGS capture point)
Relay is an OpenAI-compatible gateway that already computes **exact per-request
provider cost** (`GET /generation?id=` returns exact spend; `relay-billing` is a
microdollar credits ledger; provider manifests hold per-endpoint pricing for 300+
models). Ledgerline consumes this as the **ground-truth COGS feed**:
- When a customer's traffic flows **through Relay**, every completion already emits
a normalized usage record (model, prompt/completion tokens, image/request units)
and the **exact provider cost**. Ledgerline subscribes to that stream → writes
the COGS leg to Mint automatically. **Zero extra instrumentation** — this is the
"point your traffic at Relay and see margin tomorrow" wedge.
- Relay's **BYOK-with-%-fee** and **markup** logic already separate "what the
provider charged" from "what we charge the customer" — that spread *is* margin,
and Ledgerline surfaces it per customer/model.
- Relay's `provider-manifests` give Ledgerline a **pricing catalog** to rate usage
even for traffic that *doesn't* go through Relay (SDK-only mode, §4.4).
### 4.3 ReelForge (first customer + domain reuse)
- **`wallet`** (integer-microdollar ledger, ADR-0001) → becomes a Ledgerline/Mint
client account; render/clip debits are metered revenue events.
- **`routing`** (11 adapters + license/cost policy) → emits COGS events per model
call; the license/cost policy is a ready-made cost source for non-Relay
providers (local ComfyUI/Wan, RunPod GPU minutes).
- **`gateway`** (provisioning keys + markup + reseller) → each reseller key is a
Ledgerline customer; markup is the margin Ledgerline reports; this is a real
multi-tenant billing surface on day one.
- **`clipmarket`** (CPM creator payouts + fraud) → creator payouts are COGS-side
transfers; Ledgerline reports "net margin after creator revenue share."
- **`web`/`desktop`/`mobile`** frontends → Ledgerline ships a **real dashboard**
(margin explorer, invoices, alerts) wired to live data, reusing the existing web
app shell — per MEMORY, a real backend-wired feature, not a read-only inspector.
### 4.4 The two integration modes (both reuse the above)
1. **Gateway mode (best data, zero instrumentation):** customer routes inference
through Relay. COGS is captured exactly and automatically; revenue is rated by
Ledgerline. This is the highest-fidelity, lowest-effort path and the one we push.
2. **SDK / ingest mode (meet them where they are):** customer keeps calling
providers directly and sends **usage events** to Ledgerline's ingest API (thin
meter SDK, or a webhook/log-drain from their existing setup). Ledgerline rates
revenue and **estimates COGS** using Relay's provider-manifest pricing catalog
+ the customer's actual provider invoices (uploaded/API-synced) for true-up.
Lower fidelity, but zero migration — the on-ramp that converts to gateway mode.
---
## 5. Architecture sketch (prose + text diagram)
Ledgerline is a **standalone Rust service** (axum/tokio), a sibling to `apps/relay`
and `apps/mint`, **excluded from the root Cargo workspace** so it never triggers
the `apps/desktop` GPUI/Metal build (same constraint as relay/mint, per MEMORY:
desktop-gpui-metal-constraint). It is a *client* of Mint (settlement) and a
*subscriber* of Relay (COGS feed). It owns metering, rating, invoicing, and
reporting; it delegates all money movement and receipts to Mint.
### 5.1 Target crate decomposition
| Crate (planned) | Role |
|---|---|
| `ledgerline-server` (bin) | axum HTTP: event ingest, invoices, margin API, webhooks, dashboard BFF |
| `ledgerline-core` | shared types: `MeterEvent`, `RatedLine`, `MarginRecord`, microdollar reuse (ADR-0001) |
| `ledgerline-ingest` | high-volume idempotent event intake (dedup keys, late/out-of-order, backpressure) |
| `ledgerline-meter` | aggregation: group raw events into billable quantities per meter/customer/window |
| `ledgerline-rating` | rate cards, tiers, prepaid credits, commitments, minimums, discounts → money |
| `ledgerline-cogs` | COGS capture: Relay cost-feed subscriber + provider-invoice import/true-up + manifest-based estimation |
| `ledgerline-margin` | joins revenue + COGS per `request_id`/customer/feature/model → real-time margin + alerts |
| `ledgerline-invoicing` | invoice generation, revenue schedules, prepaid draw-down, ASC-606 hooks |
| `ledgerline-mint-client` | wraps Mint SDK: opens holds/streams/allowances, writes paired revenue+COGS receipts |
| `ledgerline-connectors` | provider-invoice adapters (OpenAI/Anthropic/AWS/Replicate billing APIs), Stripe payout |
| `ledgerline-store` | `sqlx` Postgres (Neon): event store, rate cards, invoices, margin projections |
| `ledgerline-report` | dashboard/query API: margin explorer, cohort/feature/model breakdowns, exports |
| `ledgerline-telemetry` | `tracing` → OpenTelemetry |
| `ledgerline-testkit` | property tests: rating correctness, reconciliation-to-zero, idempotency |
(The runnable first slice is intentionally one standalone `ledgerline` crate with
domain, Mint transport, Postgres store, and server modules. Split these target
crates only when scale or ownership boundaries make that useful.)
### 5.2 Text diagram
```
CUSTOMER'S AI TRAFFIC
│
┌─────────────────────────┼─────────────────────────┐
│ (gateway mode) │ (SDK/ingest mode)│
▼ │ ▼
┌───────────┐ exact per-req │ ┌──────────────┐
│ RELAY │ provider cost │ │ meter SDK / │
│ (gateway) ├───────────────┐ │ │ log-drain │
└─────┬─────┘ usage record │ │ └──────┬───────┘
│ pays provider │ │ raw usage events │
▼ (COGS = real $) ▼ ▼ ▼
┌──────────────────────────────────────────────────────────────────┐
│ LEDGERLINE │
│ ingest → meter → rating(revenue) + cogs(cost) → margin → invoice │
│ │ │ │
│ │ writes PAIRED movements (same request_id): │
│ ▼ │
│ revenue leg: customer HOLD→CAPTURE (success-only) │
│ cogs leg: TRANSFER → provider/model/creator address │
└───────────────────────────────┬──────────────────────────────────┘
▼
┌──────────────────────────────┐
│ MINT │
│ double-entry AIT ledger · │
│ holds/streams/allowances · │
│ hash-linked signed receipts·│
│ reserve conservation invariant│
└──────────────┬───────────────┘
▼
Neon/Postgres (authoritative)
│
margin explorer / invoices / alerts (ReelForge web/desktop/mobile shell)
▲
│ provider-invoice true-up
┌───────────┴────────────┐
│ OpenAI/Anthropic/AWS/ │ (ledgerline-connectors)
│ Replicate billing APIs │
└────────────────────────┘
```
### 5.3 Correctness stance (reuse Mint's invariants)
- **Success-only revenue:** every metered charge is a hold captured only on
success (ADR-0002) — inherited, not reimplemented.
- **Reconciliation-as-invariant:** because revenue and COGS are movements on the
*same* Mint ledger, "revenue − COGS − retained = 0" is checkable against Mint's
conservation invariant, not a spreadsheet.
- **Microdollar-exact** everywhere (ADR-0001). No floats, ever.
- **Idempotent ingest:** every usage event carries a dedup key; replays are no-ops
(mirrors Mint's idempotency-key discipline).
- **Auditable:** every invoice line + COGS line is a hash-linked receipt; a customer
or auditor can independently verify the full chain.
---
## 6. Monetization (fees / take-rate settling on Mint)
Ledgerline monetizes three ways, all settling as Mint transfers:
1. **Billing-platform SaaS (primary, predictable):** seat/volume-tier subscription
for the metering + invoicing + revenue-recognition system of record (mirrors how
Metronome/Orb/Lago price). Tiered by billable-event volume and active customer
count. This is the durable ARR.
2. **Margin-lens usage fee (the wedge, land motion):** a small **per-metered-event
or bps-of-tracked-COGS** fee for the read-only margin lens in SDK/ingest mode —
cheap, self-serve, no migration; converts to (1) and (3).
3. **Rail take-rate (the compounding upside):** when the customer runs revenue
*and* provider payments **through Relay/Mint** (gateway mode), Ledgerline shares
in the existing Relay markup / BYOK % fee — i.e. we earn on the *spread we help
them see and improve*. This is the "same rail also pays providers" differentiator
turned into revenue: we are not just reporting margin, we are in the flow of
funds on both legs, and we take a few bps of each settled request.
All fees are Mint transfers to the Ledgerline treasury account → unified,
auditable, microdollar-exact. Pricing guardrail: the margin-lens fee must always
be a rounding error against the margin leak it surfaces (charge < 1% of the money
we help them find/keep).
---
## 7. Moat & network effects
- **System-of-record stickiness:** once Ledgerline meters, rates, invoices, and
recognizes revenue, replacing it is a multi-quarter finance project. Standard UBB
moat — we just reach it via a sharper wedge.
- **The paired-ledger data moat (unique):** Ledgerline accumulates the **only
clean, per-request, cross-provider, revenue-linked COGS dataset** for each
customer. That powers margin analytics, anomaly/runaway alerts, and eventually
**provider-arbitrage routing recommendations** ("route model X's traffic to
provider Y and save 18% at equal quality") — recommendations we can *execute*
because Relay is the router. No pure billing tool can do this; no pure gateway has
the revenue side. The intersection is the defensible ground.
- **Rail lock-in compounds:** as customers move both revenue and provider payments
onto Relay/Mint, switching means re-plumbing money on both sides. The "same rail
pays providers" angle is not just a feature — it is a second lock-in surface.
- **Cross-product flywheel:** every ReelForge/Relay/Mint customer is a warm
Ledgerline lead and vice-versa; the shared Mint ledger means onboarding one
product pre-populates the others' accounts/addresses.
- **Benchmark network effect (later):** anonymized, aggregated margin benchmarks
("your $/1k-tokens COGS is in the 80th percentile for your model mix") get more
valuable as more customers join — a data moat that widens with scale.
**Honest moat limits:** Metronome/Orb/Lago/Stripe are entrenched and well-funded;
they can add a COGS import. Our durable edge is (a) owning the settlement rail so
our COGS is ground-truth not imported, and (b) the compounding paired dataset +
execution loop via Relay. If we cannot keep those two ahead, this collapses to a
feature — see kill-criteria (§11).
---
## 8. GTM — first 100 users
- **0 (internal dogfood):** ReelForge is customer #0 (§3). Ship the margin explorer
against real ReelForge revenue/COGS; produce a "margin per render template / per
model / per creator" report that changes an actual routing or pricing decision.
This is the reference story and the demo.
- **1–10 (hand-served design partners):** target seed/Series-A AI product companies
in the founder's network + Relay's early users. Offer the **free read-only margin
lens** (SDK/ingest mode) — "send us your usage, we'll show you margin by customer
in 48h, no migration." The hook is a number they've never had. Convert the ones
who gasp.
- **11–40 (Relay pull-through):** every Relay gateway customer gets margin
reporting **for free, on by default** — gateway mode means COGS is already
captured. Relay becomes the top of Ledgerline's funnel; "you're already paying
providers through us, here's your margin" is a zero-friction upsell.
- **41–100 (content + self-serve):** publish the thing founders keep asking for —
"true gross margin for AI companies" teardowns, an open **AI margin calculator**,
benchmark reports ("median GPT-wrapper gross margin is X%"). Self-serve signup for
the margin lens; sales-assist for the full billing system-of-record conversion.
- **Wedge trigger messaging:** lead with **"stop subsidizing power users"** and
**"know your margin before the board asks,"** not "reconcile COGS" (too abstract).
The runaway-agent + unprofitable-whale story is the sharpest emotional hook the
category allows.
---
## 9. Key risks
1. **"Feature, not a company."** (Highest.) The margin lens alone is demo-able but
thin. Mitigation: the lens is only the *wedge*; the plan is explicitly to earn
the billing-system-of-record position (the real company) and the paired-data +
Relay-execution moat. If we can't convert lens → SoR, we demote (see §11).
2. **Incumbent copies the COGS feed.** Metronome/Orb add a cost-import. Mitigation:
our COGS is *settled ground truth* via Relay/Mint, not an imported estimate, and
we can *act* on it (routing). Race to own the rail before they credibly do.
3. **Portfolio is billing-heavy / cannibalizes Mint.** Mitigation: Ledgerline is a
*client* of Mint, not a competitor; if it's redundant, fold it in as a Mint/Relay
feature (that's the demote path, cheap because it's the same primitives).
4. **Metering reliability at scale** (late/duplicate/out-of-order events, financial
correctness). Mitigation: reuse Mint's idempotency + double-entry discipline;
property-test rating and reconciliation-to-zero from day one (TDD, 80%+).
5. **SDK-mode COGS fidelity** (estimation vs. reality). Mitigation: provider-invoice
connectors for true-up; be transparent that gateway mode is exact and estimate
error is bounded and shown. Push customers to gateway mode.
6. **Compliance/rev-rec scope creep** (ASC-606, tax, dunning). Mitigation: don't
boil the ocean in Sx0–Sx2; margin + usage invoicing first, formal rev-rec later;
partner/passthrough for tax.
7. **Slow displacement of entrenched billers.** Mitigation: don't try to displace
at first contact; land side-car, expand to SoR over quarters.
## 10. Kill-criteria (explicit)
Demote Ledgerline to "a margin-analytics feature of Relay/Mint" (not a standalone
app) if **any** of these is true at its gate:
- By end of **Sx2**: no design partner can point to a **margin number they could
not previously produce** that **changed a decision** (pricing, routing, firing a
customer). *(The single most important gate.)*
- By end of **Sx3**: zero design partners willing to route real revenue+COGS
through gateway mode (the rail take-rate is the only defensible upside; if nobody
adopts it, there is no company beyond a report).
- The portfolio review concludes billing is over-invested and Mint/Relay already
cover 80% of the value — fold in rather than staff standalone.
- Incumbent ships an equivalent ground-truth COGS feed *and* we have no rail
advantage (i.e. Relay adoption stalled) — the differentiator is gone.
---
## 11. Phased roadmap (Sx0 → Sx4, with acceptance gates)
> Built on the same recon → design → build → review → fix multi-agent harness as
> the ReelForge waves / Relay RP0 / Mint AP0, TDD throughout, 80%+ coverage. Each
> phase is disjoint and parallel-safe; nothing here touches the desktop Metal build.
- **Sx0 — Meter + paired-ledger spine (internal).**
`ledgerline-core` + `ingest` + `meter` + `mint-client`. Idempotent event intake;
emit a *paired* revenue-hold + COGS-transfer to Mint per event, sharing
`request_id`. Wire ReelForge `wallet`/`routing` as the first source.
**Gate:** 1M synthetic billable events ingest idempotently and reconcile to zero
against Mint's conservation invariant; a per-request margin row is queryable.
**Current:** the executable service, idempotent API contract, real Mint
hold/capture + COGS transfer, Postgres projection, and per-request/filterable
margin APIs are implemented. Durable outbox progress and the 1M-event scale
proof remain before this gate can be called complete.
- **Sx1 — Rating + real COGS from Relay.**
`ledgerline-rating` (tiers/credits/minimums) + `ledgerline-cogs` subscribing to
Relay's exact cost feed; provider-manifest pricing catalog for estimation.
**Gate:** ReelForge's real revenue vs. real COGS produces a correct
"margin per template / per model / per creator" report; rating matches a
hand-computed oracle to the microdollar; margin ties out to Relay's
`GET /generation` costs within 0 error in gateway mode.
- **Sx2 — Margin explorer + alerts (the wedge, first external partners).**
`ledgerline-margin` + `ledgerline-report` + real dashboard on the web shell:
margin by customer/feature/model/cohort, and **margin-negative / runaway-spend
alerts**. SDK/ingest mode live for zero-migration onboarding.
**Gate (the go/no-go):** ≥3 external design partners onboarded in SDK mode; ≥1
points to a margin insight that **changed a real decision**. (Fail → demote per
§10.)
- **Sx3 — Invoicing + rail take-rate (become the biller).**
`ledgerline-invoicing` (invoices, prepaid draw-down via allowances, revenue
schedules) + gateway-mode revenue *and* provider payment through Relay/Mint with
Ledgerline take-rate. `ledgerline-connectors` for provider-invoice true-up.
**Gate:** ≥1 customer runs their **actual customer billing** through Ledgerline
(real invoices sent, real money collected) *and* ≥1 routes revenue+COGS through
gateway mode paying the rail take-rate; reconciliation-to-zero holds in
production.
- **Sx4 — System-of-record + margin intelligence (the company).**
Rev-rec (ASC-606 hooks), commitments/discounts, multi-tenant hardening,
provider-arbitrage routing recommendations (execute via Relay), anonymized
margin benchmarks, SOC2-path via receipt auditability, blue-green.
**Gate:** ≥5 paying customers on the billing system-of-record; ≥1
provider-arbitrage recommendation adopted and measurably saving money;
net revenue retention trend positive.
---
## 12. Success metrics
- **Wedge:** time-to-first-margin-number (target < 48h SDK mode, < 1 day gateway).
- **Aha:** % of design partners who report a margin insight that changed a decision
(target ≥ 60% of Sx2 partners) — this is the north-star for "company vs feature."
- **Adoption depth:** % of customers in gateway mode (exact COGS) vs SDK mode; #
routing revenue+COGS through the rail (take-rate adoption).
- **System-of-record:** # customers whose *actual* customer invoicing runs through
Ledgerline; billable-event volume; NRR.
- **Correctness:** reconciliation-to-zero holds 100% (invariant); rating vs oracle
error = 0 µ$; COGS vs Relay ground-truth error = 0 in gateway mode.
- **Margin impact (the value proof):** aggregate $ of margin leak surfaced, and $
of provider spend saved via arbitrage recommendations.
- **Rail economics:** take-rate revenue as % of Ledgerline revenue (the compounding
differentiator materializing).
---
## 13. Strategic note — pressure-testing the billion-dollar wedge
The portfolio thesis is that the durable platform value is the **payments rail for
the agent economy (Mint + AITP-402) plus marketplaces settling on it.** Ledgerline
is **not** the rail — it is a **demand-generation and lock-in layer that drives
volume onto the rail.** Its billion-dollar contribution is indirect but real:
- Billing is the **stickiest** enterprise surface; whoever is the AI-billing SoR
sits closest to the money and has the strongest reason to route both revenue and
provider payments through one rail. Ledgerline is how Mint/Relay become the
*default* rail for a company's entire money flow, not just its inference spend.
- The **paired revenue+COGS dataset** is a moat the pure-rail play doesn't
automatically get — and it is exactly the data that makes marketplace/routing
recommendations credible ("we know your true margin, so we can route you to the
cheaper provider"). That closes the loop between billing (Ledgerline), routing
(Relay), and settlement (Mint).
- **Verdict consistent with the score (67, "weakest of five"):** keep it
capital-light, ride Relay/Mint primitives, treat the margin lens as a wedge whose
job is to feed the rail. If it can't earn the SoR position or drive rail volume,
demote it into Relay/Mint — cheaply, because it was built on their primitives all
along. The billion-dollar outcome is **"the billing brain that makes Mint the
system of record for AI money,"** not a standalone reconciliation tool.