Skip to main content

GoalSlots

Struct GoalSlots 

Source
pub struct GoalSlots { /* private fields */ }
Expand description

Exactly GOAL_SLOT_COUNT fixed, privileged goal slots (#2347).

Why: See module docs — this is the in-memory state agent_loop::transcript::Transcript renders fresh on every to_messages() call and tools::goals::{SetGoalTool, ClearGoalTool} mutate on the model’s behalf. What: A fixed-size array of Option<GoalSlot>; Default is all-empty. Test: goals_tests::*.

Implementations§

Source§

impl GoalSlots

Source

pub fn new() -> Self

Construct an all-empty GoalSlots.

Why: Explicit constructor mirrors this crate’s Tool::new() convention even though Default would do the same. Test: goals_tests::new_is_all_empty.

Source

pub fn set( &mut self, slot: usize, text: impl Into<String>, source: GoalSource, ) -> Result<(), GoalSlotError>

Write (or overwrite) a 1-based slot with text from source.

Why: The model-facing set_goal tool and the future operator RPC (#2350) both need one shared, validated write path rather than reaching into the array directly. What: Validates slot via Self::validate, then replaces (does NOT append to) that slot with a fresh GoalSlot { text, source, updated_at: Utc::now() }. Overwriting an occupied slot discards its previous content — slots hold the CURRENT goal only, not a history. Test: goals_tests::set_then_get_round_trips_all_fields, goals_tests::set_overwrites_existing_slot, goals_tests::set_out_of_range_slot_errors.

Source

pub fn clear(&mut self, slot: usize) -> Result<(), GoalSlotError>

Clear a 1-based slot, leaving it empty.

Why: The model-facing clear_goal tool needs a validated way to retire a completed/obsolete goal without disturbing the other four slots. What: Validates slot via Self::validate, then sets it to None. Clearing an already-empty slot is a no-op success, not an error — idempotent clearing is simpler for the model to reason about than a “nothing to clear” failure. Test: goals_tests::clear_empties_slot, goals_tests::clear_already_empty_slot_is_ok, goals_tests::clear_out_of_range_slot_errors.

Source

pub fn get(&self, slot: usize) -> Option<&GoalSlot>

Read the current content of a 1-based slot, if occupied.

Why: Test/observability accessor; also lets a future operator view (#2350) inspect one slot without re-deriving the whole rendered block. What: Returns None for an out-of-range slot OR an empty one — the two cases are intentionally not distinguished here (callers that need to distinguish “invalid” from “empty” use set/clear’s Result instead). Test: goals_tests::set_then_get_round_trips_all_fields.

Source

pub fn occupied(&self) -> Vec<(usize, GoalSlot)>

Snapshot every currently-occupied slot as (1-based slot, GoalSlot) pairs, in slot order (#2350).

Why: session.get_goals and TranscriptRecord.goals (session::transcript) both need a serialisable view of every occupied slot together with its 1-based index — cloning here (rather than returning references) lets the caller build its own DTO without holding this GoalSlots’s lock any longer than the snapshot itself. What: Filters out empty slots, cloning each occupied GoalSlot paired with its 1-based slot number. Test: goals_tests::occupied_skips_empty_slots_and_preserves_index, goals_tests::occupied_empty_when_all_slots_empty.

Source

pub fn render(&self) -> Option<String>

Render the privileged-goals prompt block, or None if every slot is empty.

Why: This is what Transcript::to_messages injects at position [1] on every call — computed fresh from live state rather than stored, so it can never drift from what set/clear last wrote. Returning None when nothing is set means an all-empty GoalSlots injects NOTHING, matching the acceptance criterion that the goals message is absent (not an empty stub) when no goal has ever been set. What: Numbers each occupied slot by its 1-based position, skipping empty slots entirely (so slot 3 alone renders as "3. <text>", not "1. <text>"), joined under [GOALS_PREAMBLE]. Test: goals_tests::render_none_when_all_empty, goals_tests::render_numbers_by_slot_skipping_empty, goals_tests::render_includes_preamble.

Trait Implementations§

Source§

impl Clone for GoalSlots

Source§

fn clone(&self) -> GoalSlots

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GoalSlots

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for GoalSlots

Source§

fn default() -> GoalSlots

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

impl PartialEq for GoalSlots

Source§

fn eq(&self, other: &GoalSlots) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for GoalSlots

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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