pub struct GoalTracker { /* private fields */ }Expand description
Pure state machine for goal tracking.
Implementations§
Source§impl GoalTracker
impl GoalTracker
Sourcepub fn has_goal(&self) -> bool
pub fn has_goal(&self) -> bool
true when a goal snapshot exists, regardless of lifecycle status.
Sourcepub fn pause_message(&self) -> Option<&str>
pub fn pause_message(&self) -> Option<&str>
User-facing pause message, if the goal paused with one.
Sourcepub fn elapsed_ms(&self) -> u64
pub fn elapsed_ms(&self) -> u64
Total elapsed wall-clock time in milliseconds, including the live portion when the goal is currently active.
Sourcepub fn tokens_used(&self) -> i64
pub fn tokens_used(&self) -> i64
High-water mark of tokens spent on the goal (session total minus the start baseline, floored at zero). Zero when no goal exists.
Sourcepub fn auto_continue_turns(&self) -> u8
pub fn auto_continue_turns(&self) -> u8
Consumed auto-continue turns this episode. Zero without a goal.
Sourcepub fn claim_auto_continue_turn(&mut self, max_turns: u8) -> Option<u8>
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.
Sourcepub fn record_token_observation(&mut self, session_total: i64)
pub fn record_token_observation(&mut self, session_total: i64)
Fold a session token-total observation into the high-water mark. Monotonic, and a no-op without a goal.
Sourcepub fn set_token_budget(&mut self, budget: Option<i64>) -> bool
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.
Sourcepub fn enforce_budget(&mut self) -> bool
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.
Sourcepub fn set_objective(&mut self, objective: &str) -> bool
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.
Sourcepub fn persist(&self) -> Result<(), SessionStoreError>
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.
Sourcepub fn restore(session_dir: PathBuf) -> Result<Self, SessionStoreError>
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.
Sourcepub fn goal_snapshot(&self) -> Option<GoalSnapshot>
pub fn goal_snapshot(&self) -> Option<GoalSnapshot>
Current snapshot for event and RPC payloads; None without a goal.
Sourcepub fn to_goal_updated_event(&self) -> ThreadEvent
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
impl GoalTracker
Sourcepub fn from_snapshot(session_dir: PathBuf, snapshot: GoalOrchestration) -> Self
pub fn from_snapshot(session_dir: PathBuf, snapshot: GoalOrchestration) -> Self
Restore tracker state from a persisted snapshot.
Sourcepub fn snapshot_mut(&mut self) -> Option<&mut GoalOrchestration>
pub fn snapshot_mut(&mut self) -> Option<&mut GoalOrchestration>
Return a mutable reference to the current orchestration snapshot.
Sourcepub fn status(&self) -> Option<GoalStatus>
pub fn status(&self) -> Option<GoalStatus>
Current lifecycle status, if a goal is active.
Sourcepub fn token_budget(&self) -> Option<i64>
pub fn token_budget(&self) -> Option<i64>
Token budget cap, if set.
Sourcepub fn create_goal(
&mut self,
goal_id: String,
objective: String,
token_budget: Option<i64>,
token_baseline: i64,
created_at: String,
baseline_commit: Option<String>,
)
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.
Sourcepub fn pause(&mut self, reason: GoalPauseReason) -> bool
pub fn pause(&mut self, reason: GoalPauseReason) -> bool
Pause the goal with a specific reason. Only transitions from Active.
Sourcepub fn pause_with_message(
&mut self,
reason: GoalPauseReason,
message: String,
) -> bool
pub fn pause_with_message( &mut self, reason: GoalPauseReason, message: String, ) -> bool
Like Self::pause but also stores a human-readable message.
Sourcepub fn resume(&mut self) -> bool
pub fn resume(&mut self) -> bool
Resume a paused goal (any paused variant). Returns true if applied.
Sourcepub fn complete(&mut self) -> bool
pub fn complete(&mut self) -> bool
Mark the goal as complete. Accepts Active or any paused variant.
Sourcepub fn budget_limit(&mut self) -> bool
pub fn budget_limit(&mut self) -> bool
Mark the goal as budget-limited. Accepts Active or any paused variant.
Sourcepub fn account_elapsed(&mut self)
pub fn account_elapsed(&mut self)
Flush elapsed wall-clock time into elapsed_ms.
Sourcepub fn rollback_classifier_attempt(&mut self)
pub fn rollback_classifier_attempt(&mut self)
Undo the most recent attempt-slot reservation.
Sourcepub fn claim_strategist_fire(
&mut self,
should_fire: impl Fn(u32, u32) -> bool,
) -> Option<u32>
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.
Sourcepub fn revoke_strategist_cap_bonus(&mut self)
pub fn revoke_strategist_cap_bonus(&mut self)
Revoke the cap bonus granted by Self::claim_strategist_fire.