soma-som-core 0.1.0

Universal soma(som) structural primitives — Quad / Tree / Ring / Genesis / Fingerprint / TemporalLedger / CrossingRecord
Documentation
// 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,
        }
    }
}