open-standards/mesh/mesh-rs/crates/mesh-openai
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Transaction Science 81c119cecc
Some checks failed
repository checks / lockfiles, advisories, tests in CI, workflow hygiene, spec and section references, public text (push) Has been cancelled
mesh: a price catalog, and admission on the worst case a call can cost
A backend that bills money declares a catalog entry: currency, rates per
token in billionths of a minor unit (plain input, cache reads, cache
writes, output) per input-length tier, an optional per-call fee, and the
source of the prices. Undeclared is not free. From the request alone the
entry gives an upper bound: every declared input token at the highest
input rate, every allowed output token at the output rate, in the worst
tier a bill of no more than the declared input could land in. A backend
that bills within the declared tokens cannot charge more.

Under a money ceiling the router admits only a free backend or one whose
bound fits, in the ceiling's currency, never converted; among those it
still picks the fewest joules. Under a grant that bounds money the
steward reserves the bound on every link before the work and settles the
bill after it; a request naming no money ceiling under such a grant may
spend none and reaches only a free backend. A grant is debited its
running total rounded up, so hundredth-of-a-cent calls are not debited a
cent each. The journal records the reservation and the bill, and a
restart replays both; a serve in flight stays debited its reservation.
The receipt carries the bound, the bill, the debit and the price as
declared; receipts without money keep their bytes (the published pack
still verifies). The OpenAI-compatible binding reads
metadata.funds_ceiling and, under one, declares input as the text's byte
length, an upper bound, not the chars/4 estimate.

JCP: a priced hold now checks money before it admits the call into its
windows, so a hold refused for money fills no window (it did, for both
the lone and the chained hold). hold_chained_priced_for also checks the
caller's joule ceiling in the same step, which is what Mesh needs.

Falsified, each turns a test red: admitting before the money check
(lone and chained), the declared tier only, rounding each call up,
undeclared as free, an unreported cache split at the plain rate, no
implied zero ceiling under a money grant, a replay that forgets the
running total, and the binding declaring the estimate.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-12 03:21:26 -05:00
..
examples mesh-meter: hw-meter-apple meters a Mac with the SMC's whole-machine power where IOReport is not live 2026-11-04 22:08:37 -05:00
src mesh: a price catalog, and admission on the worst case a call can cost 2026-11-12 03:21:26 -05:00
tests mesh-meter: an estimate of a served span is never 0 µJ nor the meter's waits 2026-10-10 17:58:55 -04:00
Cargo.toml Cargo: no minimum-supported-version floor, because the policy is latest stable 2026-11-03 17:42:20 -05:00