bamboo_engine/runtime/execution/child_completion.rs
1//! Child-session completion notification primitives.
2//!
3//! The engine owns child runner lifecycle, but parent resume policy lives in the
4//! server/application layer. This module defines the small callback boundary
5//! between them so child completion is event-driven without making the engine
6//! depend on `AppState`.
7
8use async_trait::async_trait;
9use chrono::{DateTime, Utc};
10
11/// Terminal child-session completion recorded by the child runner lifecycle.
12#[derive(Debug, Clone)]
13pub struct ChildCompletion {
14 pub parent_session_id: String,
15 pub child_session_id: String,
16 /// One of: completed | cancelled | error | skipped | timeout.
17 pub status: String,
18 pub error: Option<String>,
19 pub completed_at: DateTime<Utc>,
20}
21
22/// Application-layer callback invoked when a child session reaches a terminal
23/// state. Implementations must be idempotent: duplicate completion events for
24/// the same child can occur when watchdog timeout races normal runner teardown.
25#[async_trait]
26pub trait ChildCompletionHandler: Send + Sync {
27 async fn on_child_completed(&self, completion: ChildCompletion);
28}