pub struct RunState {Show 18 fields
pub run_id: String,
pub status: RunStatus,
pub machine_state: MachineState,
pub spec_json_path: PathBuf,
pub spec_md_path: Option<PathBuf>,
pub branch: String,
pub current_story: Option<String>,
pub iteration: u32,
pub review_iteration: u32,
pub started_at: DateTime<Utc>,
pub finished_at: Option<DateTime<Utc>>,
pub iterations: Vec<IterationRecord>,
pub config: Option<Config>,
pub knowledge: ProjectKnowledge,
pub pre_story_commit: Option<String>,
pub session_id: Option<String>,
pub total_usage: Option<ClaudeUsage>,
pub phase_usage: HashMap<String, ClaudeUsage>,
}Fields§
§run_id: String§status: RunStatus§machine_state: MachineState§spec_json_path: PathBuf§spec_md_path: Option<PathBuf>§branch: String§current_story: Option<String>§iteration: u32§review_iteration: u32Tracks the current review cycle (1, 2, or 3) during the review loop
started_at: DateTime<Utc>§finished_at: Option<DateTime<Utc>>§iterations: Vec<IterationRecord>§config: Option<Config>Configuration snapshot taken at run start. This ensures resumed runs use the same config they started with.
knowledge: ProjectKnowledgeCumulative project knowledge tracked across agent runs. Contains file info, decisions, patterns, and story changes.
pre_story_commit: Option<String>Git commit hash captured before starting each story. Used to calculate diffs for what changed during the story.
session_id: Option<String>Session identifier for worktree-based parallel execution. Deterministic ID derived from worktree path (or “main” for main repo).
total_usage: Option<ClaudeUsage>Total accumulated token usage across all phases of the run.
phase_usage: HashMap<String, ClaudeUsage>Token usage broken down by phase. Keys are story IDs (e.g., “US-001”) or pseudo-phase names:
- “Planning”: spec generation
- “US-001”, “US-002”, etc.: user story implementation
- “Final Review”: review iterations + corrections
- “PR & Commit”: commit generation + PR creation
Implementations§
Source§impl RunState
impl RunState
pub fn new(spec_json_path: PathBuf, branch: String) -> Self
Sourcepub fn new_with_config(
spec_json_path: PathBuf,
branch: String,
config: Config,
) -> Self
pub fn new_with_config( spec_json_path: PathBuf, branch: String, config: Config, ) -> Self
Create a new RunState with a config snapshot.
Sourcepub fn new_with_session(
spec_json_path: PathBuf,
branch: String,
session_id: String,
) -> Self
pub fn new_with_session( spec_json_path: PathBuf, branch: String, session_id: String, ) -> Self
Create a new RunState with a session ID.
Sourcepub fn new_with_config_and_session(
spec_json_path: PathBuf,
branch: String,
config: Config,
session_id: String,
) -> Self
pub fn new_with_config_and_session( spec_json_path: PathBuf, branch: String, config: Config, session_id: String, ) -> Self
Create a new RunState with config and session ID.
pub fn from_spec(spec_md_path: PathBuf, spec_json_path: PathBuf) -> Self
Sourcepub fn from_spec_with_config(
spec_md_path: PathBuf,
spec_json_path: PathBuf,
config: Config,
) -> Self
pub fn from_spec_with_config( spec_md_path: PathBuf, spec_json_path: PathBuf, config: Config, ) -> Self
Create a RunState from spec with a config snapshot.
Sourcepub fn from_spec_with_config_and_session(
spec_md_path: PathBuf,
spec_json_path: PathBuf,
config: Config,
session_id: String,
) -> Self
pub fn from_spec_with_config_and_session( spec_md_path: PathBuf, spec_json_path: PathBuf, config: Config, session_id: String, ) -> Self
Create a RunState from spec with config and session ID.
Sourcepub fn effective_config(&self) -> Config
pub fn effective_config(&self) -> Config
Get the effective config for this run. Returns the stored config if available, otherwise the default.
pub fn transition_to(&mut self, state: MachineState)
pub fn start_iteration(&mut self, story_id: &str)
pub fn finish_iteration( &mut self, status: IterationStatus, output_snippet: String, )
Sourcepub fn set_work_summary(&mut self, summary: Option<String>)
pub fn set_work_summary(&mut self, summary: Option<String>)
Set the work summary on the current (last) iteration
pub fn current_iteration_duration(&self) -> u64
Sourcepub fn run_duration_secs(&self) -> u64
pub fn run_duration_secs(&self) -> u64
Get the total run duration in seconds.
Returns the time between started_at and finished_at (or now if not finished).
Sourcepub fn capture_pre_story_state(&mut self)
pub fn capture_pre_story_state(&mut self)
Capture the current HEAD commit before starting a story.
This stores the commit hash so we can later calculate what changed during the story implementation. For non-git projects, this is a no-op.
On the first call (when baseline_commit is not set), this also captures
the baseline commit for the entire run. This is used to track which files
autom8 touched vs external changes (US-010).
Sourcepub fn record_story_changes(
&mut self,
story_id: &str,
commit_hash: Option<String>,
)
pub fn record_story_changes( &mut self, story_id: &str, commit_hash: Option<String>, )
Record changes made during a story and update project knowledge.
This method:
- Captures the git diff since
pre_story_commit - Creates a
StoryChangesrecord - Adds it to the project knowledge
For non-git projects or if pre_story_commit is not set, this creates
an empty StoryChanges record.
§Arguments
story_id- The ID of the story that was just implementedcommit_hash- Optional commit hash if the changes were committed
Sourcepub fn capture_story_knowledge(
&mut self,
story_id: &str,
agent_output: &str,
commit_hash: Option<String>,
)
pub fn capture_story_knowledge( &mut self, story_id: &str, agent_output: &str, commit_hash: Option<String>, )
Capture story knowledge after agent completion.
This method combines two sources of truth:
- Git diff data for empirical knowledge of what files were created/modified
- Agent-provided semantic information (files context, decisions, patterns)
The method:
- Gets git diff since
pre_story_commit(if available) - Filters changes to only include files autom8 touched (see US-010)
- Extracts structured context from the agent’s output
- Creates a
StoryChangesrecord combining both sources - Merges file info into the
knowledge.filesregistry - Appends decisions and patterns to knowledge
For non-git projects, only agent-provided context is used.
§Arguments
story_id- The ID of the story that was just implementedagent_output- The full output from the Claude agentcommit_hash- Optional commit hash if the changes were committed
Sourcepub fn capture_usage(&mut self, phase_key: &str, usage: Option<ClaudeUsage>)
pub fn capture_usage(&mut self, phase_key: &str, usage: Option<ClaudeUsage>)
Capture usage from a Claude call and add it to the appropriate phase.
This method:
- Adds the usage to the specified phase in
phase_usage - Accumulates the usage into
total_usage
If usage is None, this is a no-op.
§Arguments
phase_key- The phase identifier (e.g., “Planning”, “US-001”, “Final Review”, “PR & Commit”)usage- The usage data from the Claude call, or None if not available
Sourcepub fn set_iteration_usage(&mut self, usage: Option<ClaudeUsage>)
pub fn set_iteration_usage(&mut self, usage: Option<ClaudeUsage>)
Set usage on the current (last) iteration.
This stores the usage data in the IterationRecord for per-story tracking.
If usage is None, this is a no-op.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for RunState
impl<'de> Deserialize<'de> for RunState
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>,
Auto Trait Implementations§
impl Freeze for RunState
impl RefUnwindSafe for RunState
impl Send for RunState
impl Sync for RunState
impl Unpin for RunState
impl UnwindSafe for RunState
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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>
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>
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