Skip to content
Fossa

Orders

Matching, reservations, generations, and expiry.

Activate list routing

The council selects the market’s routing mode. Shared-provider mode uses canonical provider indices and counter pages, list/model offer books, and wallet counters. New reservations require a compatible book and complete state for matching.

Read the market’s mode before building a transaction. Existing bookings retain their original settlement bindings. Use the SDK to choose the correct path from validated state. A program deployment does not itself activate a market.

Initialize reusable booking storage

initialize_receipt creates a Booking account. Despite its name, this instruction creates reservation storage, not a completed receipt. The owner, payer, and fresh booking account sign. The user must belong to that owner and market.

Initialization records owner, market, user, and rent payer. It sets status to available (5) and generation to zero. Reserve only initialized, available storage with the same bindings.

For a reusable order, pass Some(next_generation). It must exceed the booking’s previous generation and equal User.generation + 1. Both counters use u64; arithmetic overflow fails. A one-shot order passes None and requires a booking whose generation is still zero. Initialization and reservation can share a transaction.

Submit an order

reserve_list_booking accepts a ReserveRequest, optional generation, and optional minimum_wallet_concurrency. The owner signs. Generated accounts bind the market, model, selected list and books, user, owner, booking, recorded payer, routing registry, provider counters, wallet ledger, and assigned model group.

Supply canonical counter pages needed by the complete selected list/model book. The winner’s page must be writable. Missing state that could change the winner causes rejection; omitting competitors cannot force a shortlist.

Request fieldsMeaning
model_idExact model identifier.
input_rate_cap, cached_rate_cap, output_rate_capMaximum payment atoms per million tokens.
min_speed, privateMinimum declared speed and required privacy flag.
max_input, max_outputPositive token bounds within offer and context limits.
checkpointExact nonzero checkpoint hash.
input_modalities, output_modalitiesRequired nonzero modality masks.
min_context, limits_configuredMinimum context and manual-limit declaration. A positive minimum requires the declaration.
spendMaximum reserve including surcharge.
estimated_input, estimated_cached, estimated_outputEstimated usage within booked bounds.
cache_providerProvider eligible for a positive cached-input estimate.
minimum_wallet_concurrencyMinimum advertised global and wallet concurrency. Omitted means 1.

Each call books one slot. A concurrency requirement does not reserve a batch or require that many idle slots. The reserve cannot exceed free funds. Include the assigned group even when its backing route is disabled. See SDK builders.

Matching and price selection

The list matcher scans populated offers in the selected list/model book. Unrelated registered providers and offers in other lists are outside this scan. Admission and provider consent are both required.

It checks activation, checkpoint, modalities, token bounds, all rate caps, privacy, speed, global and wallet concurrency, both quotas, concurrency requirement, and funds. The program skips a full or quota-limited provider and can choose the next eligible offer. If no offer qualifies, it returns Unavailable without a partial reservation. A provider’s later HTTP rejection does not automatically reroute the existing booking. A new attempt requires a separate booking. Release or expire an unused reservation to recover its reserved funds.

The score sums separately rounded input, cached-input, and output charges. Only cache_provider uses the cached estimate. Lowest score wins; equal scores retain the earlier insertion order. Context must fit both min_context and max_input + max_output. The speed minimum also keeps the claim window within one day.

The base reserve covers maximum input, maximum output, and one rounding atom. The surcharge is included in both reserve and estimated score.

token_charge(tokens, rate) = ceil(tokens × rate / 1_000_000)

base_reserve = token_charge(max_input, input_rate) + token_charge(max_output, output_rate) + 1

total_reserve = base_reserve + ceil(base_reserve × fee_bps / 10_000)

Read the matched booking

A successful reservation reduces free balance and increments the selected provider’s global and wallet active-booking counts and both quotas atomically. Booking stores the provider, payout, rates, request token limits, exact checkpoint, requested and offered modality masks, selected offer’s token capacities, list, stable provider limit ID, reserve, estimated score, and deadline. It also stores list fee terms and their destination authorities.

Later changes to offers, list membership, model assignment, backing routes, or council authority do not replace those stored payment terms. A catalog preview is not the resulting booking.

Status 0 means reserved. The normal claim deadline is execution time plus 300 + ceil(max_output / selected_speed) seconds. Matching excludes offers whose calculated claim duration would exceed 86,400 seconds. Test builds can use another base interval. Read the stored claim_end.

The booking’s cache flag permits cached usage when its selected provider equals the request’s cache_provider. The provider still reports whether cached usage occurred.

Release or expire a reservation

The selected provider signs release_list_booking to return a reserve without charging. Anyone can submit expire_list_booking after the claim deadline. Supply the booking’s stored counter bindings and provider-wallet ledger. Reusable storage requires its current generation.

Both actions return the full reserve and decrement provider and wallet active bookings atomically. They do not refund quota. Reusable storage becomes available; one-shot storage becomes released.

Use the settlement path recorded in the booking. Current offers or membership do not replace it. At the exact claim deadline, a valid claim is still permitted and expiry fails. Time alone does not restore funds; expiry must execute.