Clearing Primitives

Settlement

The money movement that closes the Work — charge, credit, and claw-back — on a ledger, reversible inside a warranty window.

Settlement is the money movement that closes the Work — a charge, a credit, or a claw-back. Today it reads as ledger transactions plus returns-driven reversals (Settlement (ledger transactions)); new work also settles on the dedicated balanced-entry work-settlement journal.

Wallets support prepay with auto-top-up; postpay accumulates into invoices. Usage is metered across everything — routing decisions, connector actions, workflow steps, tool calls, tokens in and out — denominated to the micro-unit. Because work can be bad, settlement is reversible by contract: within a Warranty window the buyer can return the work, triggering an automatic credit and optional re-routing.

Status

shipping — the ledger, wallets, usage invoicing, and returns exist today; the balanced-entry journal in integer micro-units co-writes alongside them, enabled per deployment behind a settlement flag.

Settlement states

A market settlement moves through MarketSettlementStatus:

MarketSettlementStatus
pending → held

Funds are reserved when a winner is committed.

MarketSettlementStatus
held → committed

Captured once the work completes successfully.

MarketSettlementStatus
failed · cancelled

Released without capture when the work does not clear.

Why a separate journal

New work settles on a balanced-entry journal in integer micro-units, where every committed transaction nets to zero per currency. The existing float-based lead ledger and the Stripe tables become payment adapters — money integrity is a property of the journal, not a convention.

What the journal enforces

Zero-sum is enforced by the database itself at commit, entries are append-only, and corrections are always new compensating transactions. Each settlement is identified per unit of work and party, transitions under optimistic locking, and every posting carries an idempotency fingerprint — a replay converges on the original, and a reused key with different money fails loudly. Committed journal transactions flow into the work's Receipt as its settlement evidence.

Where to go deeper