Skip to main content

LifecycleManager

Struct LifecycleManager 

Source
pub struct LifecycleManager { /* private fields */ }

Implementations§

Source§

impl LifecycleManager

Source

pub async fn transition( &self, session: &mut Session, to: SessionStatus, ) -> Result<()>

Transition status, persist, emit StatusChanged, and (if a reaction engine is attached) dispatch any reaction associated with the new status.

Ordering matters: normally we save + emit StatusChanged before calling the engine, so subscribers see the transition event in the right order and so a panicking engine doesn’t lose the state change.

Phase G parking hook. When the reaction is auto-merge and the engine reports a non-escalated failure, transition persists the session as MergeFailed (instead of Mergeable) so the next SCM tick’s derive_scm_status can decide whether to retry (still-ready observation re-promotes to Mergeable) or abandon (flake / closed PR drops off the PR track). Escalated outcomes are left in Mergeable so the retry loop stops and the human notification stands — see the doc on should_park_in_merge_failed.

Source§

impl LifecycleManager

Source

pub fn new( sessions: Arc<SessionManager>, runtime: Arc<dyn Runtime>, agent: Arc<dyn Agent>, ) -> Self

Source

pub fn with_poll_interval(self, interval: Duration) -> Self

Source

pub fn with_reaction_engine(self, engine: Arc<ReactionEngine>) -> Self

Attach a reaction engine. ReactionEngine::new should be given this LifecycleManager’s events_tx (via events_sender()) so reaction events land on the same broadcast channel as lifecycle events. Builder form for test ergonomics.

Source

pub fn with_scm(self, scm: Arc<dyn Scm>) -> Self

Attach an SCM plugin. When present, poll_one fans out a detect_pr + four parallel pr_state/ci_status/review_decision/ mergeability probes per session per tick, then routes the result through derive_scm_status for PR-driven status transitions.

Builder form mirrors with_reaction_engine — call sites that don’t care about SCM polling leave it unset and get Phase C/D behaviour.

Source

pub fn with_workspace(self, workspace: Arc<dyn Workspace>) -> Self

Attach a workspace plugin. When present, sessions that transition to Merged automatically have their worktree destroyed within the same poll cycle. Sessions with workspace_path: None are unaffected.

Source

pub fn events_sender(&self) -> Sender<OrchestratorEvent>

Borrow the underlying broadcast sender so a ReactionEngine constructed separately can publish events on the same channel LifecycleManager uses. Cheap clone — broadcast::Sender is internally ref-counted.

Source

pub fn subscribe(&self) -> Receiver<OrchestratorEvent>

Get a fresh subscriber. Each recv() call sees events from the point of subscription onward — history is not replayed.

Source

pub fn spawn(self: Arc<Self>) -> LifecycleHandle

Spawn the background polling loop. Returns a handle that can be used to stop it cleanly.

We use tokio_util::sync::CancellationToken rather than a oneshot because cancellation tokens are cheap to clone and can be passed into future sub-tasks (e.g. a reaction engine that shares this manager’s shutdown signal).

Source

pub async fn tick(&self, seen: &mut HashSet<SessionId>) -> Result<()>

One pass over every non-terminal session. Public so tests can drive the state machine deterministically without sleeping.

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