agora.fleet.cast
Cast loader + validator (roles-and-casting Stage 1).
A CAST binds each ROLE to a model profile for one hardware envelope, with
evidence citations. This module loads a casts/<envelope>.yaml file into a
validated Cast and checks it against the four rules from
docs/design/roles-and-casting.md:
Every
profilereference resolves inprofiles.yaml.Sum of resident model sizes ≤
vram_budget_gb(sizes from the local manifest store — Ollama/api/show— not hand-entered).Every binding either cites
evidenceor carries awaiver…… UNLESS it is
binding: human, which is always valid and needs neither.
Loading (resolve_cast()) produces the role→profile table the orchestrator
would consume; the resident/keep_alive fields are advisory to the
eviction protocol. Deliberately small: schema + four rules + loud failures.
Model-size lookup is injected so the validator stays pure and testable — the
CLI supplies the live Ollama probe, tests supply a static map.
Finding: rule 3’s evidence requirement is where F12 lands — a binding’s
evidence key is per-(model × TOOL SURFACE), not per-model alone. A model measured
reliable on one tool family has not been shown reliable casting onto a seat that
uses a different, unmeasured one (the run-1.3 add_function wall). So “cite
evidence” means cite a row for the seat’s actual tools, not a generic 9/9.
Module Attributes
The sentinel value for a role deliberately bound to a human, not a model. |
Functions
|
Load and schema-validate a cast YAML file. |
|
Best-effort: query the local Ollama manifest store for resident sizes. |
|
Build the role table a loader would hand the orchestrator. |
|
Check a cast against the four casting rules; return a list of problems. |
Classes
A full cast: hardware envelope + role bindings. |
|
One role→profile binding inside a cast. |
|
The hardware envelope a cast targets. |
|
One entry of the role table produced by |
- class agora.fleet.cast.Cast[source]
Bases:
BaseModelA full cast: hardware envelope + role bindings.
- model_config = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- hardware: CastHardware
- bindings: dict[str, CastBinding]
- class agora.fleet.cast.CastBinding[source]
Bases:
BaseModelOne role→profile binding inside a cast.
Exactly one of
profileorbinding: humanshould be set (checked invalidate_cast(), not here, so the error is reported not raised).- model_config = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class agora.fleet.cast.CastHardware[source]
Bases:
BaseModelThe hardware envelope a cast targets.
- model_config = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- agora.fleet.cast.HUMAN_BINDING = 'human'
The sentinel value for a role deliberately bound to a human, not a model.
- class agora.fleet.cast.ResolvedBinding[source]
Bases:
BaseModelOne entry of the role table produced by
resolve_cast().profileis None for a human-bound role.modelis the concrete model id (e.g.ollama/gemma4:e4b) for a profile binding, else “”.- model_config = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- profile: ModelProfile | None
- agora.fleet.cast.load_cast(path)[source]
Load and schema-validate a cast YAML file.
YAML parse errors and pydantic validation failures both surface as
AgoraErrorwith the offending path attached — mirrorsagora.fleet.profiles.load_profiles().
- async agora.fleet.cast.ollama_sizes_gb(cast, profiles, base_url)[source]
Best-effort: query the local Ollama manifest store for resident sizes.
Returns
{model_id: size_gb}for every RESIDENT profile binding whose profile resolves. Used by the CLI to feedvalidate_cast()’s residency rule; kept out of the pure validator so tests need no daemon.
- agora.fleet.cast.resolve_cast(cast, profiles)[source]
Build the role table a loader would hand the orchestrator.
Resolves each profile binding to its
ModelProfile; leaves human bindings profile-less. RaisesAgoraErrorif the cast does not validate structurally (unknown profile / malformed binding) — load refuses an invalid cast. Residency-budget failures do NOT block load (residency is advisory to the eviction protocol), so this ignoressizes_gb.
- agora.fleet.cast.validate_cast(cast, profiles, *, sizes_gb=None)[source]
Check a cast against the four casting rules; return a list of problems.
An empty list means the cast is valid.
sizes_gbmaps a concrete model id (profile.model) → its on-disk size in GB; supply it (from the local manifest store) to enable the residency-budget rule. When it is None, the residency sum is not checkable and is reported as a single skip note rather than silently passing.