Skip to main content

DomainAdapter

Trait DomainAdapter 

Source
pub trait DomainAdapter: Send + Sync {
    // Required methods
    fn domain_name(&self) -> &str;
    fn constraint_channels(&self) -> Vec<Box<dyn ConstraintChannel>>;
    fn map_action_to_state(
        &self,
        action: &dyn ProposedAction,
    ) -> KernelResult<Vec<f64>>;
    fn detect_regime_change(&self, current: &[f64], proposed: &[f64]) -> bool;
    fn format_domain_payload(
        &self,
        margins: &BTreeMap<String, f64>,
    ) -> Option<Value>;

    // Provided method
    fn current_state(&self) -> KernelResult<Vec<f64>> { ... }
}
Expand description

Adapter that connects domain-specific knowledge to the safety kernel.

A domain adapter translates domain concepts (e.g., financial positions, robotic actuator states, LLM tool calls) into the kernel’s state-vector representation and provides domain-specific constraint channels.

Required Methods§

Source

fn domain_name(&self) -> &str

Name of the domain (e.g., “finance”, “agentic”, “robotics”).

Source

fn constraint_channels(&self) -> Vec<Box<dyn ConstraintChannel>>

Provide the constraint channels for this domain.

Source

fn map_action_to_state( &self, action: &dyn ProposedAction, ) -> KernelResult<Vec<f64>>

Map a proposed action’s state deltas into a state vector.

Source

fn detect_regime_change(&self, current: &[f64], proposed: &[f64]) -> bool

Detect whether the proposed state change represents a regime change.

Source

fn format_domain_payload( &self, margins: &BTreeMap<String, f64>, ) -> Option<Value>

Format domain-specific payload data from channel margins.

Provided Methods§

Source

fn current_state(&self) -> KernelResult<Vec<f64>>

Return the current (pre-action) state vector.

Used by the certifier to provide accurate current state for regime change detection. Default returns Err, which causes the certifier to fall back to a zero vector of the correct length (safe fallback — regime detection that depends on the delta will see a larger-than-real shift).

Implementors§