1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// SPDX-FileCopyrightText: 2026 Andrei G <bug-ops>
// SPDX-License-Identifier: MIT OR Apache-2.0
//! State types shared between the autonomous goal subsystem and command handlers.
use serde::{Deserialize, Serialize};
/// FSM states for an autonomous goal session.
///
/// Valid transitions:
/// - `Running` → `Verifying` (supervisor check triggered)
/// - `Verifying` → `Running` (supervisor: not yet achieved)
/// - `Verifying` → `Achieved` (supervisor: goal met)
/// - `Running` / `Verifying` → `Stuck` (stuck counter exhausted or supervisor failures)
/// - `Running` / `Verifying` → `Aborted` (user cancel or turn limit reached)
/// - `Running` / `Verifying` → `Failed` (unrecoverable error)
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum AutonomousState {
/// The agent is actively running multi-turn execution.
Running,
/// The supervisor is verifying whether the goal condition is satisfied.
Verifying,
/// Goal achieved and confirmed by the supervisor.
Achieved,
/// No progress detected across the configured number of consecutive turns.
Stuck,
/// Session aborted by the user or turn limit reached.
Aborted,
/// Unrecoverable error during execution.
Failed,
}
impl std::fmt::Display for AutonomousState {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Running => f.write_str("running"),
Self::Verifying => f.write_str("verifying"),
Self::Achieved => f.write_str("achieved"),
Self::Stuck => f.write_str("stuck"),
Self::Aborted => f.write_str("aborted"),
Self::Failed => f.write_str("failed"),
}
}
}