Skip to main content

combs_mesh/blocks/
lifecycle.rs

1//! `lfc` — an agent lifecycle state machine.
2
3use serde::{Deserialize, Serialize};
4
5/// Lifecycle block: states + event-driven transitions.
6#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7pub struct LifecycleBlock {
8    /// The states (exactly one should have `initial: true`).
9    #[serde(default)]
10    pub states: Vec<LifecycleState>,
11    /// The transitions.
12    #[serde(default)]
13    pub transitions: Vec<LifecycleTransition>,
14}
15
16/// A lifecycle state.
17#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
18pub struct LifecycleState {
19    /// State name.
20    pub name: String,
21    /// Whether this is the entry state.
22    #[serde(default)]
23    pub initial: bool,
24}
25
26/// An event-driven transition between states.
27#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
28pub struct LifecycleTransition {
29    /// Source state name.
30    pub from: String,
31    /// Target state name.
32    pub to: String,
33    /// Event that triggers the transition.
34    pub event: String,
35}