pub struct AgentState {
pub files: HashMap<PathBuf, FileState>,
pub errors: Vec<ErrorInfo>,
pub occupied_files: HashMap<PathBuf, u32>,
pub investigated: HashMap<PathBuf, u32>,
pub metrics: HashMap<String, f64>,
pub last_progress_tick: u64,
pub total_changes: usize,
}Expand description
State of the agent’s world
Fields§
§files: HashMap<PathBuf, FileState>Files that have been loaded/modified
errors: Vec<ErrorInfo>Current errors (compile, lint, etc.)
occupied_files: HashMap<PathBuf, u32>Files currently being investigated by other agents
investigated: HashMap<PathBuf, u32>Completed investigation targets
metrics: HashMap<String, f64>Custom metrics
last_progress_tick: u64Last progress tick (for stall detection)
total_changes: usizeTotal changes made
Implementations§
Source§impl AgentState
impl AgentState
Sourcepub fn update_file(&mut self, path: PathBuf, state: FileState)
pub fn update_file(&mut self, path: PathBuf, state: FileState)
Add or update a file’s state
Sourcepub fn clear_errors(&mut self)
pub fn clear_errors(&mut self)
Clear all errors
Sourcepub fn has_errors(&self) -> bool
pub fn has_errors(&self) -> bool
Check if there are any errors
Sourcepub fn error_count(&self) -> usize
pub fn error_count(&self) -> usize
Get the number of errors
Sourcepub fn most_errored_file(&self) -> Option<&PathBuf>
pub fn most_errored_file(&self) -> Option<&PathBuf>
Get the file with the most errors
Sourcepub fn occupy_file(&mut self, path: PathBuf, agent_id: u32)
pub fn occupy_file(&mut self, path: PathBuf, agent_id: u32)
Mark a file as occupied by an agent
Sourcepub fn release_file(&mut self, path: &PathBuf)
pub fn release_file(&mut self, path: &PathBuf)
Release a file
Sourcepub fn is_occupied(&self, path: &PathBuf, exclude_agent: u32) -> bool
pub fn is_occupied(&self, path: &PathBuf, exclude_agent: u32) -> bool
Check if a file is occupied (by another agent)
Sourcepub fn mark_investigated(&mut self, path: PathBuf, agent_id: u32)
pub fn mark_investigated(&mut self, path: PathBuf, agent_id: u32)
Mark a file as investigated
Sourcepub fn is_investigated(&self, path: &PathBuf) -> bool
pub fn is_investigated(&self, path: &PathBuf) -> bool
Check if a file has been investigated
Sourcepub fn uninvestigated_files(&self) -> Vec<&PathBuf>
pub fn uninvestigated_files(&self) -> Vec<&PathBuf>
Get uninvestigated files
Sourcepub fn available_files(&self, agent_id: u32) -> Vec<&PathBuf>
pub fn available_files(&self, agent_id: u32) -> Vec<&PathBuf>
Get available files for an agent (not occupied, not investigated)
Sourcepub fn set_metric(&mut self, key: impl Into<String>, value: f64)
pub fn set_metric(&mut self, key: impl Into<String>, value: f64)
Set a metric
Sourcepub fn get_metric(&self, key: &str) -> Option<f64>
pub fn get_metric(&self, key: &str) -> Option<f64>
Get a metric
Sourcepub fn record_progress(&mut self, tick: u64, changes: usize)
pub fn record_progress(&mut self, tick: u64, changes: usize)
Record progress at current tick
Sourcepub fn is_stalled(&self, current_tick: u64, threshold: u64) -> bool
pub fn is_stalled(&self, current_tick: u64, threshold: u64) -> bool
Check if progress is stalled
Trait Implementations§
Source§impl Clone for AgentState
impl Clone for AgentState
Source§fn clone(&self) -> AgentState
fn clone(&self) -> AgentState
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for AgentState
impl Debug for AgentState
Source§impl Default for AgentState
impl Default for AgentState
Source§fn default() -> AgentState
fn default() -> AgentState
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for AgentState
impl<'de> Deserialize<'de> for AgentState
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for AgentState
impl RefUnwindSafe for AgentState
impl Send for AgentState
impl Sync for AgentState
impl Unpin for AgentState
impl UnsafeUnpin for AgentState
impl UnwindSafe for AgentState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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