Skip to main content

State

Struct State 

Source
pub struct State {
Show 27 fields pub current_round: u32, pub max_iterations: u32, pub codex_model: String, pub codex_effort: String, pub codex_timeout: u64, pub push_every_round: bool, pub full_review_round: u32, pub plan_file: String, pub plan_tracked: bool, pub start_branch: String, pub base_branch: String, pub base_commit: String, pub review_started: bool, pub ask_codex_question: bool, pub session_id: Option<String>, pub agent_teams: bool, pub started_at: Option<String>, pub pr_number: Option<u32>, pub configured_bots: Option<Vec<String>>, pub active_bots: Option<Vec<String>>, pub poll_interval: Option<u64>, pub poll_timeout: Option<u64>, pub startup_case: Option<String>, pub latest_commit_sha: Option<String>, pub latest_commit_at: Option<String>, pub last_trigger_at: Option<String>, pub trigger_comment_id: Option<String>,
}
Expand description

Represents the state of an RLCR or PR loop.

Schema matches setup-rlcr-loop.sh exactly: All field names use snake_case as per YAML convention.

Fields§

§current_round: u32

Current round number (0-indexed).

§max_iterations: u32

Maximum number of iterations allowed.

§codex_model: String

Codex model name (e.g., “gpt-5.4”).

§codex_effort: String

Codex reasoning effort (e.g., “high”, “xhigh”).

§codex_timeout: u64

Codex timeout in seconds.

§push_every_round: bool

Whether to push after each round.

§full_review_round: u32

Interval for full alignment checks (round N-1 for N, 2N-1, etc.).

§plan_file: String

Path to the plan file (relative to project root).

§plan_tracked: bool

Whether the plan file is tracked in git.

§start_branch: String

Branch where the loop started.

§base_branch: String

Base branch for code review.

§base_commit: String

Base commit SHA.

§review_started: bool

Whether review phase has started.

§ask_codex_question: bool

Whether to ask Codex for clarification.

§session_id: Option<String>

Session identifier for this loop. Always serialized as empty string when None (shell contract).

§agent_teams: bool

Whether agent teams mode is enabled.

§started_at: Option<String>

Timestamp when the loop was created (ISO 8601).

§pr_number: Option<u32>

PR number for PR loops.

§configured_bots: Option<Vec<String>>

List of configured bots for PR review.

§active_bots: Option<Vec<String>>

List of active bots for PR review.

§poll_interval: Option<u64>

Polling interval for PR state checks (seconds).

§poll_timeout: Option<u64>

Timeout for PR polling (seconds).

§startup_case: Option<String>

Startup case for PR loop (e.g., “new_pr”, “existing_pr”).

§latest_commit_sha: Option<String>

Latest commit SHA for PR.

§latest_commit_at: Option<String>

Timestamp of latest commit.

§last_trigger_at: Option<String>

Timestamp of last trigger.

§trigger_comment_id: Option<String>

ID of trigger comment.

Implementations§

Source§

impl State

Source

pub fn from_file<P: AsRef<Path>>(path: P) -> Result<Self, StateError>

Parse state from a file containing YAML frontmatter.

Source

pub fn from_markdown(content: &str) -> Result<Self, StateError>

Parse state from markdown content with YAML frontmatter.

Source

pub fn from_markdown_strict(content: &str) -> Result<Self, StateError>

Parse state from markdown with strict validation of required fields.

This matches the shell behavior in loop-common.sh parse_state_file_strict() which rejects missing required fields: current_round, max_iterations, review_started, and base_branch.

Source

pub fn to_markdown(&self) -> Result<String, StateError>

Serialize state to markdown with YAML frontmatter.

Source

pub fn save<P: AsRef<Path>>(&self, path: P) -> Result<(), StateError>

Save state to a file.

Source

pub fn new_rlcr( plan_file: String, plan_tracked: bool, start_branch: String, base_branch: String, base_commit: String, max_iterations: Option<u32>, codex_model: Option<String>, codex_effort: Option<String>, codex_timeout: Option<u64>, push_every_round: bool, full_review_round: Option<u32>, ask_codex_question: bool, agent_teams: bool, review_started: bool, ) -> Self

Create a new RLCR state with the given parameters.

Source

pub fn increment_round(&mut self)

Increment the round counter.

Source

pub fn is_max_iterations_reached(&self) -> bool

Check if max iterations have been reached.

Source

pub fn is_terminal_state_file(filename: &str) -> bool

Check if this is a terminal state filename.

Source

pub fn is_valid_terminal_reason(reason: &str) -> bool

Check if a reason is a valid terminal state reason.

Source

pub fn terminal_state_filename(reason: &str) -> Option<&'static str>

Get the terminal state filename for a given exit reason.

Returns None if the reason is not a valid terminal reason. Shell contract: invalid reasons should error, not silently map to unexpected.

Source

pub fn rename_to_terminal<P: AsRef<Path>>( state_path: P, reason: &str, ) -> Result<PathBuf, StateError>

Rename state file to terminal state file.

This implements the end-loop rename behavior from loop-common.sh: After determining the exit reason, rename state.md to -state.md

Returns error if reason is not valid (matching shell end_loop behavior).

Trait Implementations§

Source§

impl Clone for State

Source§

fn clone(&self) -> State

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 State

Source§

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

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

impl Default for State

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for State

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 PartialEq for State

Source§

fn eq(&self, other: &State) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for State

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

impl StructuralPartialEq for State

Auto Trait Implementations§

§

impl Freeze for State

§

impl RefUnwindSafe for State

§

impl Send for State

§

impl Sync for State

§

impl Unpin for State

§

impl UnsafeUnpin for State

§

impl UnwindSafe for State

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, 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> 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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,