Skip to main content

Module model

Module model 

Source
Expand description

The model seam (seam registry ARCHITECTURE 3). Every provider call carries a BuildingPolicy value; the policy is defined here (kernel cannot name outer crates) and evaluated by city::policy — dependency inversion, same as the ledger seam. The part crates/kernel/spec/Model.lean specifies this module.

Structs§

AccountRoster
The accounts an adapter can call as, in priority order, and the one its next request goes out on. Answered once before a round opens (crates/kernel/spec/AccountRecovery.lean §8-86), never per attempt.
BuildingPolicy
Building-level constraints riding along the call. It carries the one load-bearing bit; further fields only grow, and each one is added at every construction site the compiler names.
Ceiling
The most a model may emit in one response, thinking included.
ChatMessage
ChatRequest
The canonical request conversation (city dialect = Anthropic Messages). Both production dialects and the scripted model consume this one shape — the seam carries it so replay, citysim and the real gateway argue about the same object.
ChatResponse
The canonical response: dialect output, endpoint input.
ImageRef
One picture, as everything except the wire refers to it.
ModelRequest
What the adapter needs to make one call. segments are the frozen prefix hashes (same source as prompt_assembled); chat is the full canonical conversation the dialect puts on the wire.
ModelReturn
One assistant turn. message is the in-window content; calls is the requested tool wave — empty means the turn loop may conclude the run. usage/stop/billed_usd_micros ride along from real dialects and stay None for scripted adapters that predate cost accounting.
ModelUsage
Provider-reported token counts.
RosterEntry
One account of a roster, and whether its reference can be redeemed right now (kernel D55). Neither the key nor the reference is here.
RunPolicy
The four values one run works under, chosen when it is dispatched and written into its run_started line.
SystemBlock
One frozen-prefix block on the wire. cache marks an explicit prompt cache breakpoint (breakpoints sit on segment edges).
ToolDef
A tool as the provider sees it; sourced from catalog tool_defs only.
Window
The most tokens one model reads in a single call, prompt and reply together.

Enums§

AdmissionRequirement
The evidence a run’s work must carry before a merge lets it into the building.
CacheCount
One cache count as a provider reported it: a number, or nothing at all.
ContentBlock
Canonical content block. Tool inputs are Payload — the float ban holds here because these bytes become ledger payloads verbatim.
DialectKind
Which wire the far side speaks. Closed: a fourth dialect is a compile error at every entrance of gateway::dialect, which is how it is kept from being approximated with the nearest of the three already written.
Effort
How hard the provider should think, least to most, in the upstreams’ words. Which levels one (Endpoint, model) offers is the upstream’s statement, answered by the gateway’s thinking ladder and never by a table here (crates/kernel/spec/Model.lean D56); a level outside the offer is refused, never moved to a neighbour. Check the vendors before changing the ladder: https://platform.claude.com/docs/en/build-with-claude/effort, https://developers.openai.com/api/docs/guides/reasoning.
ImageType
The picture formats this city carries.
Increment
One piece of what a model is producing, before the call it belongs to has settled.
LandingPolicy
Whether a run’s work takes the ordinary road or stays in an experiment that never lands.
MessageBreakpoint
Which message of a request carries an explicit prompt-cache breakpoint.
Mode
Whether a run is talking with the person or carrying out work.
ModelTag
What a chosen model is for. Exhaustive rather than a free label: a tag exists because some code asks for a model by it, so a tag with no asker is a setting the person can fill in and never see used. It grows when a caller appears, not when a name is imagined.
Role
Message author on the canonical (Anthropic-shaped) conversation.
StopReason
Why the provider stopped. Wire-borne and closed: a fourth reason has to be answered by every dialect that maps one (14.3).

Traits§

Model
The model port. Production adapter: gateway::endpoint; second adapter: citysim scripted model. Implementations never sample clocks or read global state.

Functions§

content_from_message
The inverse of message_payload for window folding and rebuild.
message_payload
The account-side form of assistant content: the single authority for how content blocks enter model_returned payloads (and thus how the window is rebuilt offline, C16).

Type Aliases§

EarlyCalls
A tool call handed over the moment its block is complete, before the call it belongs to has settled.
Increments
Text arriving from a provider before the call has finished.