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
// SPDX-License-Identifier: LGPL-3.0-only
#![allow(missing_docs)]
//! Pluggable autonomy evaluation.
//!
//! The ring delegates the "how autonomous can the worker be on this command?"
//! decision to a provider supplied by the application. The trait carries only
//! primitive types at the boundary: the effective autonomy level is a `u8`
//! (0 = most restricted, 255 = fully autonomous) and the limiting factor is
//! a lexicon-coordinate string. Application code defines what coordinates
//! exist and how the level range maps to its semantic levels.
use crate::quad::Tree;
/// The outcome of one autonomy evaluation.
pub struct AutonomyDecision {
/// 0 = most restricted, 255 = fully autonomous.
pub effective_level: u8,
/// Lexicon-coordinate string identifying the limiting factor (empty when none).
pub limiting_factor: String,
/// Whether the decision was escalated from a lower floor.
pub escalated: bool,
}
/// Pluggable autonomy decision for ring commands.
pub trait AutonomyEvaluator: Send + Sync {
fn evaluate(&self, tree: &Tree) -> AutonomyDecision;
}
/// No-op default — full autonomy with no constraints.
pub struct FullAutonomy;
impl AutonomyEvaluator for FullAutonomy {
fn evaluate(&self, _tree: &Tree) -> AutonomyDecision {
AutonomyDecision {
effective_level: 255,
limiting_factor: String::new(),
escalated: false,
}
}
}