Skip to main content

RunState

Struct RunState 

Source
pub struct RunState {
Show 26 fields pub schema: u32, pub id: String, pub repo: PathBuf, pub base_branch: String, pub base_commit: String, pub instruction: String, pub created_at: Timestamp, pub updated_at: Timestamp, pub status: RunStatus, pub seed: u64, pub config: Config, pub enabled_worktree_config: bool, pub candidates: Vec<Candidate>, pub judgements: Vec<Judgement>, pub deliberation: Vec<DeliberationRound>, pub votes: Vec<VoteRecord>, pub tally: Option<Tally>, pub reviews: Vec<ReviewRound>, pub gate: Vec<CommandOutcome>, pub merge: Option<MergeOutcome>, pub leaks: Vec<Leak>, pub quota: Vec<QuotaLoss>, pub parked: bool, pub seats: BTreeMap<String, SeatState>, pub pr: Option<PrRecord>, pub events: Vec<Event>,
}
Expand description

The whole run.

Fields§

§schema: u32

On-disk format version.

§id: String

Run id, e.g. 20260830-153012-a1b2.

§repo: PathBuf

Repository the run operates on.

§base_branch: String

Branch the run started from.

§base_commit: String

Commit the run started from.

§instruction: String

The task, verbatim.

§created_at: Timestamp

When the run was created.

§updated_at: Timestamp

Last state flush.

§status: RunStatus

Current status.

§seed: u64

Seed for labels and session ids.

§config: Config

Config snapshot, so a resumed run behaves like the original.

§enabled_worktree_config: bool

Did magi enable extensions.worktreeConfig? If so, cleanup turns it off.

§candidates: Vec<Candidate>

Candidates.

§judgements: Vec<Judgement>

Initial blind rankings.

§deliberation: Vec<DeliberationRound>

Deliberation, if it happened.

§votes: Vec<VoteRecord>

Private final votes.

§tally: Option<Tally>

The count.

§reviews: Vec<ReviewRound>

Review rounds.

§gate: Vec<CommandOutcome>

Final gate.

§merge: Option<MergeOutcome>

Merge outcome.

§leaks: Vec<Leak>

Vendor tokens seen in judged material.

§quota: Vec<QuotaLoss>

Seats lost to a CLI rate limit / quota, in the order they hit.

§parked: bool

Parked at a node boundary, waiting to be resumed.

A run that is neither finished nor being worked on is otherwise indistinguishable from one whose daemon was killed, and the two want opposite things from an operator: the first is expected to be resumed, the second is a leftover. Cleared by the resume that carries it on.

§seats: BTreeMap<String, SeatState>

Per-seat conversation state.

§pr: Option<PrRecord>

Last observation of the winner’s pull request, when a land loop ran.

Persisted rather than derived from the event log because the phone asks two questions about a run that has opened a PR - how are its checks and which round is it on - and parsing prose out of events to answer them would break the first time an event message was reworded.

§events: Vec<Event>

Node log.

Implementations§

Source§

impl RunState

Source

pub fn new( repo: PathBuf, base_branch: String, base_commit: String, instruction: String, config: Config, ) -> Self

A fresh run.

Source

pub fn dir(&self) -> PathBuf

Directory holding this run’s state and artifacts.

Source

pub fn short(&self) -> &str

Short form used in branch names and reports.

Source

pub fn branch_for(&self, label: char) -> String

Branch name for a label.

Source

pub fn worktree_root(&self) -> PathBuf

Root of this run’s worktrees.

Source

pub fn event(&mut self, node: &str, message: impl Into<String>)

Note something in the run log and on the tracing stream.

Source

pub fn save(&mut self) -> Result<()>

Flush to run.json, atomically.

Source

pub fn load(id: &str) -> Result<Self>

Load a run by id or unambiguous id prefix.

Source

pub fn winner(&self) -> Option<&Candidate>

The winning candidate, once the tally has run.

Source

pub fn viable(&self) -> Vec<&Candidate>

Candidates eligible for judging.

Source

pub fn created_local(&self) -> String

Local-time creation stamp for reports.

Source

pub fn ensure_can_delete(&self, in_flight: bool) -> Result<()>

Assert that this run is safe to delete.

Refuses a run a live daemon is working on, and refuses any run whose candidate worktrees and branches have not been folded away with magi fold. The fold requirement is the real protection: it is what makes “delete” mean “remove a record” rather than “throw away a worktree somebody may still be editing”.

in_flight has to come from the caller, because a run’s own status cannot answer the question. A daemon killed mid-run leaves its status at implementing forever, and a guard that trusted that would make every interrupted run permanently undeletable - the operator’s only recourse being to edit run.json by hand, which is exactly the sort of thing this command exists to avoid. The queue already treats an orphaned .lock from a SIGKILLed daemon the same way; this is that rule for runs.

Trait Implementations§

Source§

impl Clone for RunState

Source§

fn clone(&self) -> RunState

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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