pub struct LifecycleManager { /* private fields */ }Implementations§
Source§impl LifecycleManager
impl LifecycleManager
Sourcepub async fn transition(
&self,
session: &mut Session,
to: SessionStatus,
) -> Result<()>
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
impl LifecycleManager
pub fn new( sessions: Arc<SessionManager>, runtime: Arc<dyn Runtime>, agent: Arc<dyn Agent>, ) -> Self
pub fn with_poll_interval(self, interval: Duration) -> Self
Sourcepub fn with_reaction_engine(self, engine: Arc<ReactionEngine>) -> Self
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.
Sourcepub fn with_scm(self, scm: Arc<dyn Scm>) -> Self
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.
Sourcepub fn with_workspace(self, workspace: Arc<dyn Workspace>) -> Self
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.
Sourcepub fn events_sender(&self) -> Sender<OrchestratorEvent>
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.
Sourcepub fn subscribe(&self) -> Receiver<OrchestratorEvent>
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.
Sourcepub fn spawn(self: Arc<Self>) -> LifecycleHandle
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).