Skip to main content

sim_lib_agent_runner_core/
card.rs

1use sim_citizen_derive::Citizen;
2use sim_kernel::{Expr, Symbol};
3
4/// Metadata describing one runner/model candidate for routing and inspection.
5#[derive(Clone, Debug, PartialEq, Citizen)]
6#[citizen(symbol = "agent-runner/ModelCard", version = 1)]
7pub struct ModelCard {
8    /// Registered runner symbol.
9    pub runner: Symbol,
10    /// Model name advertised by the runner.
11    pub model: String,
12    /// Provider identity, such as `openai-compatible` or `process`.
13    pub provider: Symbol,
14    /// Locality hint such as local, remote, or agent-backed.
15    pub locality: Symbol,
16    /// Open extension fields preserved for policy and browse surfaces.
17    pub extra: Vec<(Expr, Expr)>,
18}
19
20impl ModelCard {
21    /// Constructs a card with explicit runner, provider, and locality metadata.
22    pub fn new(
23        runner: Symbol,
24        model: impl Into<String>,
25        provider: Symbol,
26        locality: Symbol,
27    ) -> Self {
28        Self {
29            runner,
30            model: model.into(),
31            provider,
32            locality,
33            extra: Vec::new(),
34        }
35    }
36}
37
38impl Default for ModelCard {
39    fn default() -> Self {
40        Self::new(
41            Symbol::qualified("runner", "fixture"),
42            "fixture-model",
43            Symbol::new("fixture-provider"),
44            Symbol::new("local"),
45        )
46    }
47}
48
49/// One availability/score proposal produced for market-style runner selection.
50#[derive(Clone, Debug, PartialEq, Default, Citizen)]
51#[citizen(symbol = "agent-runner/ModelBid", version = 1)]
52pub struct ModelBid {
53    /// Whether the runner can currently satisfy the request.
54    pub available: bool,
55    /// Optional explanation when unavailable or for diagnostics.
56    pub reason: Option<String>,
57    /// Preference score when the runner is available.
58    pub score: Option<f64>,
59    /// Optional model override or chosen concrete model name.
60    pub model: Option<String>,
61    /// Open extension fields preserved for policy-specific metadata.
62    pub extra: Vec<(Expr, Expr)>,
63}
64
65impl ModelBid {
66    /// Constructs an unavailable bid with an explanatory reason.
67    pub fn unavailable(reason: impl Into<String>) -> Self {
68        Self {
69            available: false,
70            reason: Some(reason.into()),
71            score: None,
72            model: None,
73            extra: Vec::new(),
74        }
75    }
76}
77
78/// Returns the citizen class symbol for [`ModelCard`].
79pub fn model_card_class_symbol() -> Symbol {
80    Symbol::qualified("agent-runner", "ModelCard")
81}
82
83/// Returns the citizen class symbol for [`ModelBid`].
84pub fn model_bid_class_symbol() -> Symbol {
85    Symbol::qualified("agent-runner", "ModelBid")
86}