Skip to main content

ModelPolicyBuilderState

Struct ModelPolicyBuilderState 

Source
pub struct ModelPolicyBuilderState {
    pub scope: ModelScope,
    pub harness_index: usize,
    pub model: String,
    pub model_choices: Vec<ModelChoice>,
    pub model_choice_index: Option<usize>,
    pub reasoning_index: usize,
    pub reasoning_cycle: Vec<String>,
    pub dry_run: bool,
    pub refresh_integrity: bool,
    pub focused_field: usize,
}
Expand description

State for the model policy builder UI.

Fields§

§scope: ModelScope§harness_index: usize

Index into CAPABLE_HARNESSES.

§model: String

Model name or “auto”; empty leaves the model field of the rule untouched. Free text is still accepted — open registry namespaces (Ollama tags, OpenRouter slugs) are too large to enumerate, so the picker offers the verified and example values and typing covers everything else.

§model_choices: Vec<ModelChoice>

Registry-verified models selectable for the current harness, refreshed by Self::refresh_choices. Empty when no registry is loaded.

§model_choice_index: Option<usize>

Position within model_choices; None means the model field holds a free-typed value (or is empty) rather than a picked entry.

§reasoning_index: usize

Index into reasoning_cycle.

§reasoning_cycle: Vec<String>

Live reasoning cycle for the current (harness, model) pair. Index 0 is always [MODEL_POLICY_REASONING_UNCHANGED]; when the pair supports an effort at all, “auto” and the verified values follow. A single-entry cycle therefore means “this pair has no projectable reasoning field”.

§dry_run: bool§refresh_integrity: bool

Chain npm run asset-integrity:write after a successful apply.

§focused_field: usize

Implementations§

Source§

impl ModelPolicyBuilderState

Source

pub fn new() -> Self

Source

pub fn harness(&self) -> &'static str

The harness id currently selected.

Source

pub fn refresh_choices(&mut self, registry: Option<&ModelRegistry>)

Recompute both pickers from the registry for the current harness and model. Called whenever the harness or the model text changes.

The narrowing is the registry’s, not ours: a model that declares its own reasoning_efforts gets exactly those, otherwise its namespace’s, otherwise the harness vocabulary. A free-typed model the registry does not enumerate keeps the full harness vocabulary and is left for scripts/model-policy.mjs to accept or reject — the TUI never decides legality itself.

registry: None (missing or unparsable catalog file) restores the pre-registry behaviour: free-text model entry and the static union, codex only.

Source

pub fn reasoning_supported(&self) -> bool

Whether the reasoning field can be cycled at all — true when the harness has a reasoning field, even if the selected model accepts no concrete effort (auto is still reachable to clear it).

Source

pub fn reasoning_clear_only(&self) -> bool

True when the harness has a reasoning field but the selected model accepts no concrete effort — the cycle holds only “(unchanged)” and “auto”.

Source

pub fn reasoning_display(&self) -> &str

The reasoning value currently shown for the focused field.

Source

pub fn cycle_model(&mut self)

Step to the next verified model for this harness, wrapping through a free-text slot so the picker never traps the operator inside the list.

Source

pub fn selected_choice(&self) -> Option<&ModelChoice>

The picked registry entry, when the model field holds one.

Source

pub fn command(&self) -> ModelPolicyCommand

Build the subprocess command from the current form state.

Trait Implementations§

Source§

impl Default for ModelPolicyBuilderState

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more