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

11 KiB

apps/mint — AI Token settlement layer (unit: AIT · protocol: AITP-402)

A new infra module / app: treat AI credits as a first-class, transferable AI Token (AIT) — sendable, receivable, deliverable between accounts, agents, providers, and models — with web3 mechanics and zero crypto.

Addresses, signed transfers, conservation-of-supply, and verifiable hash-linked receipts give it the "web3 feel." But it is fiat-backed, centrally settled, off-chain — no blockchain, no gas, no volatility. It is the canonical settlement layer that ReelForge (apps/api), apps/relay, and desktop all spend on. Payment protocol is x402-shaped, denominated in AIT, not crypto.

Product family: ReelForge (video) · Relay (inference gateway) · Mint (this — AI-token settlement). App dir apps/mint; token unit AIT; machine payment protocol AITP-402.


1. The core idea

  • AI Token (AIT) = the platform credit unit. 1 AIT = 1 USD of credit, tracked internally in integer microdollars (1 AIT = 1,000,000 µ$) — mirrors ADR-0001. No floats, ever.
  • AIT is a fully reserve-backed internal stable-token: every AIT outstanding is backed 1:1 by purchased credit (Stripe fiat + crypto on-ramp via relay-web3). Total AIT supply == reserve. This conservation invariant is what makes it feel like a coin without being one.
  • AIT is transferable: account→account, agent→agent, user→model/provider (creator payouts, tips), org treasury→member. Send / receive / deliver, atomic and idempotent.
  • AIT is programmable: holds/escrow (success-only billing generalized), streaming/metered payments, delegated allowances, and an x402-style machine-payment protocol (AITP-402) so agents pay per call with no pre-funded session.
  • AIT is verifiable: every movement emits a signed, hash-linked receipt (a private, append-only merkle log) — auditable like a chain, without a chain.

Why "web3 but not crypto": you get addresses, signed transactions, a tamper-evident ledger, and conservation-of-supply — the properties people want from web3 — while settlement stays instant, free, fiat-backed, and compliant.


2. Where it sits (unifies the wallets)

Today there are three overlapping money surfaces:

  • apps/api microdollar wallet ledger (ReelForge).
  • apps/api/domains/gateway provisioning keys + markup.
  • apps/relay relay-billing credits ledger.

ATP becomes the canonical ledger underneath all three. They become ATP clients: a ReelForge render debit or a relay inference charge is an ATP hold → capture-on-success. Additive, not a rewrite — ATP first wraps existing balances (each product's wallet = an ATP account), then unifies over time.

   apps/api (ReelForge)  ─┐
   apps/relay (LLM gw)   ─┼──▶  apps/mint  (canonical AIT ledger + transfer + AITP-402)
   apps/desktop          ─┘        │  reserve-backed, verifiable, success-only
                                   └──▶ Neon/Postgres (authoritative) + receipts log

Standalone Rust workspace (axum/tokio), excluded from the root Cargo workspace like apps/relay, so it never triggers the apps/desktop GPUI/Metal build. Inherits ADR-0001 (microdollar) and ADR-0002 (success-only billing) — success-only becomes the native hold→capture primitive.


3. Primitives

Primitive What it does Backs
Account An addressable balance owner (user, org, agent, provider, model, treasury). Has one or more AIT addresses. everything
Address ait1<...> — a stable, shareable handle to receive AIT. Per account/agent/model/provider. send/receive, payouts, tips
Transfer Atomic, idempotent debit→credit between two accounts. Signed request, hash-linked receipt. send/deliver, payouts, gifting
Hold (escrow) Reserve AIT for a job; capture on success, release on failure. success-only billing (render, inference)
Stream Continuous metered debit (per token / per second) with a cap; settle incrementally. live inference, long jobs
Allowance Delegated spend: key/agent may spend ≤ N AIT within a window (provisioning keys generalized). sub-keys, agent budgets
AITP-402 HTTP 402 challenge → authorize AIT transfer → verified → request proceeds. machine-native agent payments
Receipt Signed, hash-linked (prev-hash) log entry per movement. audit, dispute, verifiable history
Reserve Ledger of fiat/crypto backing; supply-conservation check. trust, solvency proof

Every movement is double-entry and append-only. Balances are derived projections; the log is truth.


4. API surface (used by relay + apps/api + agents)

Accounts & addresses

  • POST /v1/accounts · GET /v1/accounts/:id · GET /v1/accounts/:id/balance
  • POST /v1/accounts/:id/addresses → ait1… · GET /v1/addresses/:addr

Move AIT

  • POST /v1/transfers { from, to, amount_micros, memo, idempotency_key } → signed receipt
  • POST /v1/holds (reserve) · POST /v1/holds/:id/capture · POST /v1/holds/:id/release
  • POST /v1/streams (open) · POST /v1/streams/:id/tick · POST /v1/streams/:id/close
  • POST /v1/allowances · POST /v1/allowances/:id/spend

Machine payments (AITP-402)

  • Any protected endpoint may reply 402 Payment Required + AITP-Challenge header; caller responds with AITP-Authorization (a signed transfer intent); server verifies via POST /v1/aitp/verify and proceeds. Denominated in AIT.

Verify & reserve

  • GET /v1/receipts/:id · GET /v1/accounts/:id/receipts (hash-linked history)
  • GET /v1/reserve (supply == backing proof) · GET /v1/receipts/audit (merkle root)

On/off-ramp (delegates to relay-web3 / Stripe)

  • POST /v1/mint (fiat/crypto deposit confirmed → mint AIT) — reserve-gated
  • POST /v1/redeem (burn AIT → fiat/crypto payout) — KYC/limits enforced

Mirror OpenAI-style ergonomics; SDKs generated for Rust (relay) and Python (apps/api).


5. Rust workspace (apps/mint/crates/*)

Crate Role
mint-server (bin) axum HTTP + optional gRPC: accounts, transfers, holds, streams, AITP-402, receipts
mint-core Ait amount (microdollar newtype), Address, AccountId, error model
mint-ledger double-entry append-only ledger; transfers; hold→capture/release; balance projections; supply-conservation invariant
mint-receipts signed, hash-linked (prev-hash → merkle root) receipt log; verification
mint-protocol AITP-402 challenge/authorize/verify (x402-shaped, AIT scheme)
mint-accounts accounts, addresses, orgs/treasuries, allowances/delegated spend
mint-stream streaming/metered payment channels (internal, off-chain) with caps
mint-reserve reserve ledger + mint/redeem gating; solvency proof; on/off-ramp bridge
mint-store sqlx Postgres (Neon) + migrations; append-only guarantees
mint-sdk client libs (Rust + generated Python) for relay & apps/api
mint-telemetry tracing → OpenTelemetry
mint-testkit fake clocks/signers, property-test harness for conservation

Stack: tokio · axum · tower · serde · sqlx(Postgres) · ed25519-dalek (receipt signing) · blake3/sha2 (hash-linking) · jsonwebtoken · figment. Injectable clock + signer seams (deterministic in tests).


6. Invariants (property-tested, non-negotiable)

  1. Conservation: Σ balances + Σ active holds == reserve at all times.
  2. Double-entry: every entry sums to zero across accounts (+ reserve).
  3. Success-only: a hold captures only on success; failure releases in full (ADR-0002).
  4. Idempotency: replaying a transfer/hold with the same key is a no-op.
  5. Tamper-evidence: receipt n.prev_hash == hash(receipt n-1); merkle root verifiable; any edit breaks the chain.
  6. Non-negative: no account goes negative (allowances/holds gate spend).
  7. Microdollar-exact: all math integer µ$; no float; no rounding drift.

These become the RP-style acceptance gates and a continuous chaos/property suite.


7. Phased build

  • AP0 — Ledger core: mint-core + mint-ledger + mint-store; accounts, addresses, transfer (send/receive), balance projections, conservation + double-entry invariants (property tests). Gate: 1M random transfers conserve.
  • AP1 — Holds & success-only: hold → capture/release; idempotency; the success-only primitive. Gate: failure injection never captures.
  • AP2 — Receipts & verifiability: mint-receipts hash-linked signed log + merkle root + /receipts/audit. Gate: any tamper detected.
  • AP3 — AITP-402 + allowances: mint-protocol machine payments + delegated spend; agent pays per call in AIT. Gate: agent→model paid call, no session.
  • AP4 — Streams + reserve/mint/redeem: metered streaming; mint-reserve on/off-ramp bridge to Stripe + relay-web3. Gate: supply == backing after mint/redeem/stream storms.
  • AP5 — Clients & unify: mint-sdk; wire apps/relay relay-billing and apps/api wallet to settle on ATP (holds/captures). Gate: a ReelForge render and a relay completion both settle through ATP.
  • AP6 — Governance/GA: orgs/treasuries, org budgets, dispute/refund flows, OTel dashboards, solvency status page, blue-green.

8. Product surfaces it unlocks

  • Send AI tokens to anyone — user→user gifting, org→member allocation.
  • Creator/model payouts — usage revenue splits settle to a model/provider address automatically (the ReelForge clipmarket CPM + relay model-author share become ATP transfers).
  • Agent economy — autonomous agents hold budgets, pay each other and pay models via AITP-402, all in AIT.
  • Verifiable spend — every user can audit a tamper-evident receipt trail; enterprises get a solvency/reserve proof.
  • One balance, every product — buy AIT once, spend on ReelForge renders, relay inference, marketplace, desktop — the "credit usable in anything" promise made literal and portable.

9. Compliance & safety (design-in, not bolt-on)

Closed-loop, fiat-backed internal credit — not a security, not a cryptocurrency (no public chain, no trading, redeemable 1:1). Still: KYC/AML thresholds on mint/redeem, sanctions screening on payout addresses, per-account/keys velocity limits, clear ToS that AIT is a prepaid credit, and reserve segregation. Ledger is authoritative; ramps (fiat/crypto) never bypass conservation or success-only.


10. Build harness

Own multi-agent workflow chain (AP0 → AP6), TDD, same recon → design → build → review → fix shape as the ReelForge waves and relay RP0. Greenfield and disjoint from the running Wave 1 / RP0 workflows — safe to launch in parallel on request.