Skip to main content

RunState

Struct RunState 

Source
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: u32

Tracks 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: ProjectKnowledge

Cumulative 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

Source

pub fn new(spec_json_path: PathBuf, branch: String) -> Self

Source

pub fn new_with_config( spec_json_path: PathBuf, branch: String, config: Config, ) -> Self

Create a new RunState with a config snapshot.

Source

pub fn new_with_session( spec_json_path: PathBuf, branch: String, session_id: String, ) -> Self

Create a new RunState with a session ID.

Source

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.

Source

pub fn from_spec(spec_md_path: PathBuf, spec_json_path: PathBuf) -> Self

Source

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.

Source

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.

Source

pub fn effective_config(&self) -> Config

Get the effective config for this run. Returns the stored config if available, otherwise the default.

Source

pub fn transition_to(&mut self, state: MachineState)

Source

pub fn start_iteration(&mut self, story_id: &str)

Source

pub fn finish_iteration( &mut self, status: IterationStatus, output_snippet: String, )

Source

pub fn set_work_summary(&mut self, summary: Option<String>)

Set the work summary on the current (last) iteration

Source

pub fn current_iteration_duration(&self) -> u64

Source

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).

Source

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).

Source

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:

  1. Captures the git diff since pre_story_commit
  2. Creates a StoryChanges record
  3. 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 implemented
  • commit_hash - Optional commit hash if the changes were committed
Source

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:

  1. Git diff data for empirical knowledge of what files were created/modified
  2. 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 StoryChanges record combining both sources
  • Merges file info into the knowledge.files registry
  • 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 implemented
  • agent_output - The full output from the Claude agent
  • commit_hash - Optional commit hash if the changes were committed
Source

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:

  1. Adds the usage to the specified phase in phase_usage
  2. 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
Source

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 Clone for RunState

Source§

fn clone(&self) -> RunState

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for RunState

Source§

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

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

impl<'de> Deserialize<'de> for RunState

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for RunState

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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> 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<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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> SerializableAny for T
where T: 'static + Any + Clone + for<'a> Send + Sync,