Skip to main content

GoalTracker

Struct GoalTracker 

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

Pure state machine for goal tracking.

Implementations§

Source§

impl GoalTracker

Source

pub fn active_activation_id(&self) -> Option<Uuid>

Runtime identity of the current active interval. Paused and restored goals cannot authorize work until the user resumes them.

Source

pub fn commit(&mut self, staged: Self) -> Result<(), SessionStoreError>

Replace the live tracker only after the proposed snapshot is persisted.

Source

pub fn has_goal(&self) -> bool

true when a goal snapshot exists, regardless of lifecycle status.

Source

pub fn goal_id(&self) -> Option<&str>

Stable goal id, if a goal exists.

Source

pub fn pause_message(&self) -> Option<&str>

User-facing pause message, if the goal paused with one.

Source

pub fn elapsed_ms(&self) -> u64

Total elapsed wall-clock time in milliseconds, including the live portion when the goal is currently active.

Source

pub fn tokens_used(&self) -> i64

Tokens charged while the goal was active. Zero when no goal exists.

Source

pub fn auto_continue_turns(&self) -> u8

Consumed auto-continue turns this episode. Zero without a goal.

Source

pub fn claim_auto_continue_turn(&mut self, max_turns: u8) -> Option<u8>

Atomically reserve one auto-continue turn when budget remains, returning the 1-based turn number. None leaves state untouched.

Source

pub fn record_token_observation(&mut self, session_total: i64)

Charge the increase in this runloop’s cumulative token total to an active goal. Observations while paused only advance the cursor. Observe before changing status so usage is attributed to the interval that just ended.

Source

pub fn set_token_budget(&mut self, budget: Option<i64>) -> bool

Replace the token budget in place (None clears it). Returns false when no goal exists.

Source

pub fn enforce_budget(&mut self) -> bool

Mark an Active goal budget-limited when usage reached its cap. Paused goals keep the user’s explicit state. Returns true if applied.

Source

pub fn set_objective(&mut self, objective: &str) -> bool

Replace the objective in place, preserving elapsed time and history. Returns false when no goal exists.

Source

pub fn persist(&self) -> Result<(), SessionStoreError>

Persist the snapshot to <session_dir>/goal/goal.json, creating the directory if needed. With no goal, removes a stale snapshot instead so a cleared goal never resurrects on restart.

Source

pub fn restore(session_dir: PathBuf) -> Result<Self, SessionStoreError>

Restore a tracker from <session_dir>/goal/goal.json, or return an empty tracker when no snapshot exists. In-flight goals restore paused.

Source

pub fn goal_snapshot(&self) -> Option<GoalSnapshot>

Current snapshot for event and RPC payloads; None without a goal.

Source

pub fn to_goal_updated_event(&self) -> ThreadEvent

Build the goal.updated payload for the current state; goal: None when no goal exists.

Source§

impl GoalTracker

Source

pub fn new(session_dir: PathBuf) -> Self

Create a new tracker with no active goal.

Source

pub fn from_snapshot(session_dir: PathBuf, snapshot: GoalOrchestration) -> Self

Restore tracker state from a persisted snapshot.

Source

pub fn snapshot_mut(&mut self) -> Option<&mut GoalOrchestration>

Return a mutable reference to the current orchestration snapshot.

Source

pub fn is_active(&self) -> bool

true if a goal is currently active.

Source

pub fn phase(&self) -> Option<GoalPhase>

Current execution phase, if a goal is active.

Source

pub fn status(&self) -> Option<GoalStatus>

Current lifecycle status, if a goal is active.

Source

pub fn objective(&self) -> Option<&str>

Human-readable objective, if a goal is active.

Source

pub fn token_budget(&self) -> Option<i64>

Token budget cap, if set.

Source

pub fn create_goal( &mut self, goal_id: String, objective: String, token_budget: Option<i64>, token_baseline: i64, created_at: String, baseline_commit: Option<String>, )

Create a new goal. Replaces any existing orchestration.

Source

pub fn pause(&mut self, reason: GoalPauseReason) -> bool

Pause the goal with a specific reason. Only transitions from Active.

Source

pub fn pause_with_message( &mut self, reason: GoalPauseReason, message: String, ) -> bool

Like Self::pause but also stores a human-readable message.

Source

pub fn resume(&mut self) -> bool

Resume a paused goal (any paused variant). Returns true if applied.

Source

pub fn complete(&mut self) -> bool

Mark the goal as complete. Accepts Active or any paused variant.

Source

pub fn budget_limit(&mut self) -> bool

Mark the goal as budget-limited. Accepts Active or any paused variant.

Source

pub fn clear(&mut self)

Clear the goal entirely.

Source

pub fn account_elapsed(&mut self)

Flush elapsed wall-clock time into elapsed_ms.

Source

pub fn rollback_classifier_attempt(&mut self)

Undo the most recent attempt-slot reservation.

Source

pub fn claim_strategist_fire( &mut self, should_fire: impl Fn(u32, u32) -> bool, ) -> Option<u32>

Atomically evaluate the strategist trigger and claim a fire.

Source

pub fn revoke_strategist_cap_bonus(&mut self)

Revoke the cap bonus granted by Self::claim_strategist_fire.

Trait Implementations§

Source§

impl Clone for GoalTracker

Source§

fn clone(&self) -> Self

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 GoalTracker

Source§

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

Formats the value using the given formatter. 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> 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> 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> 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 = !

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