pub struct ReactionEngine { /* private fields */ }Expand description
The reaction dispatcher. Holds config, attempt trackers, and the Runtime handle needed to actually talk to the agent process.
Arc<ReactionEngine> is what gets wired into LifecycleManager.
Implementations§
Source§impl ReactionEngine
impl ReactionEngine
Sourcepub fn new(
config: HashMap<String, ReactionConfig>,
runtime: Arc<dyn Runtime>,
events_tx: Sender<OrchestratorEvent>,
) -> Self
pub fn new( config: HashMap<String, ReactionConfig>, runtime: Arc<dyn Runtime>, events_tx: Sender<OrchestratorEvent>, ) -> Self
Build an engine from a loaded config. The caller owns the runtime
and the broadcast channel — typically LifecycleManager hands its
own events_tx in via clone() so engine events share the channel.
Sourcepub fn new_with_config(
ao_config: Arc<AoConfig>,
runtime: Arc<dyn Runtime>,
events_tx: Sender<OrchestratorEvent>,
) -> Self
pub fn new_with_config( ao_config: Arc<AoConfig>, runtime: Arc<dyn Runtime>, events_tx: Sender<OrchestratorEvent>, ) -> Self
Build an engine with access to per-project reactions overrides.
Global rules come from ao_config.reactions; for each session,
Self::resolve_reaction_config merges in
ao_config.projects[session.project_id].reactions when present.
Sourcepub fn resolve_reaction_config(
&self,
session: &Session,
key: &str,
) -> Option<ReactionConfig>
pub fn resolve_reaction_config( &self, session: &Session, key: &str, ) -> Option<ReactionConfig>
Effective reaction config for key in session’s project context.
- Both global and project define
key: start from global, overlay project — booleans andactionalways from project; eachOptionfield uses project whenSome, otherwise keeps global. - Only project: return the project entry.
- Only global: return the global entry.
Sourcepub fn with_scm(self, scm: Arc<dyn Scm>) -> Self
pub fn with_scm(self, scm: Arc<dyn Scm>) -> Self
Attach an SCM plugin so auto-merge can actually merge.
Builder form to match LifecycleManager::with_scm. When unset,
dispatch_auto_merge falls back to Phase D’s “log and emit intent
only” behaviour so existing callers that don’t know about SCM
keep working.
Sourcepub fn with_notifier_registry(self, registry: NotifierRegistry) -> Self
pub fn with_notifier_registry(self, registry: NotifierRegistry) -> Self
Attach a notifier registry so dispatch_notify can fan out to
real notifier plugins. Without a registry the engine falls back
to Phase D behaviour (emit event, return success).
Sourcepub async fn dispatch(
&self,
session: &Session,
reaction_key: &str,
) -> Result<Option<ReactionOutcome>>
pub async fn dispatch( &self, session: &Session, reaction_key: &str, ) -> Result<Option<ReactionOutcome>>
Fire the reaction configured for reaction_key against session,
if any. Returns None when there’s no matching config — the
caller (usually LifecycleManager::transition) treats that as
“silently do nothing” rather than an error.
session is borrowed (not cloned) because dispatch only needs
the ID and runtime handle; nothing is persisted back.
Sourcepub async fn dispatch_with_message(
&self,
session: &Session,
reaction_key: &str,
message_override: String,
) -> Result<Option<ReactionOutcome>>
pub async fn dispatch_with_message( &self, session: &Session, reaction_key: &str, message_override: String, ) -> Result<Option<ReactionOutcome>>
Like Self::dispatch but overrides the configured message with
message_override. Used by call sites that build dynamic message
bodies (e.g. CI-failed formatting check names/URLs from live data)
without needing a static config entry.
Returns None when no reaction is configured for the key (same
contract as dispatch).
Sourcepub fn clear_tracker(&self, session_id: &SessionId, reaction_key: &str)
pub fn clear_tracker(&self, session_id: &SessionId, reaction_key: &str)
Forget any tracker state for (session, reaction_key). Called by
LifecycleManager on the tick that leaves a triggering status,
so the next time the session re-enters it, retries start from zero.
A lingering tracker would mean a session that failed CI, was fixed,
and failed again would start already half-way through the retry
budget — not what anyone wants.
Sourcepub fn clear_all_for_session(&self, session_id: &SessionId)
pub fn clear_all_for_session(&self, session_id: &SessionId)
Drop every tracker entry for session_id. Called by
LifecycleManager::terminate — without this, the map would grow
monotonically over a long-running ao-rs watch as terminated
sessions leave orphan entries behind. Cheap: one full-map walk
per termination, and the N is small (reaction-key count).