Skip to main content

wire/answer/
model_figures.rs

1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4// Copyright (c) 2026 2youg1 and the sprawling contributors
5
6//! The window and the ceiling the city would register for each row of a
7//! model table the person left empty, each with the rung that answered
8//! (`crates/wire/spec/Answer/ModelFigures.lean` ยง8-97, wire D58).
9//!
10//! Read shapes only: the ladder is `gateway::Figures::resolve`, the one
11//! the pick point calls, so a page that draws these draws what a pick
12//! with empty boxes registers rather than a second guess at it.
13
14use kernel::{Ceiling, ModelTag, Window};
15use serde::{Deserialize, Serialize};
16
17/// One row of the table, as the page asks about it.
18#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
19#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
20pub struct FiguresAsked {
21    pub id: String,
22    /// The window the provider's own list stated for this row; absent
23    /// for a row the person named and the list did not carry.
24    pub context_tokens: Option<Window>,
25    /// The ceiling the provider's own list stated for this row.
26    pub max_output_tokens: Option<Ceiling>,
27    /// The role this row is to fill: the earlier registration of the
28    /// same model under this tag is a rung of its own.
29    pub tag: Option<ModelTag>,
30}
31
32/// Every row asked about, in the order asked.
33#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
34#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
35pub struct ModelFiguresAnswer {
36    pub models: Vec<FiguresLine>,
37}
38
39/// What one row would be registered with.
40#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
41#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
42pub struct FiguresLine {
43    pub id: String,
44    /// Absent when no rung states a window: the window is unknown and
45    /// the context reminder stays silent.
46    pub window: Option<WindowLine>,
47    /// Absent only when the policy default itself is zero, a state the
48    /// policy module's own test forbids.
49    pub ceiling: Option<CeilingLine>,
50}
51
52/// A window and the rung that stated it.
53#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
54#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
55pub struct WindowLine {
56    pub tokens: Window,
57    pub from: FigureFrom,
58}
59
60/// The ceiling a call would be made with.
61#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
62#[serde(rename_all = "snake_case")]
63#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
64pub enum CeilingLine {
65    /// A figure every request states, and who stated it.
66    Sent { tokens: Ceiling, from: FigureFrom },
67    /// Nobody stated one on a face that takes none: the request leaves
68    /// the field out and the provider applies its own default.
69    ProviderDefault,
70}
71
72/// Who stated a figure, spelled as `model_selected` records it
73/// (`window_from`, `ceiling_from`).
74#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
75#[serde(rename_all = "snake_case")]
76#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
77pub enum FigureFrom {
78    /// A figure the person entered.
79    Person,
80    /// The provider's own model list.
81    Upstream,
82    /// What this tag was registered with when it last pointed at this
83    /// same model.
84    Registered,
85    /// The pinned catalogue or the preset table.
86    Preset,
87    /// The city's policy default; never the source of a window.
88    Policy,
89}