soma-som-ring 0.1.0

Standalone ring execution engine for soma(som): cycle lifecycle, extension registration, boundary mediation
Documentation
// SPDX-License-Identifier: LGPL-3.0-only
//! Neutral default unit processor.
//!
//! Per the ring-foundation-purity contract, soma-som-ring exports the
//! [`UnitProcessor`] trait (at soma-som-core) and a **neutral default processor**
//! that "applies no application-specific logic". This file is that default.
//!
//! Concrete unit processors live in the application tier and register via the
//! orchestrator's extension API at startup.

use soma_som_core::processor::{UnitProcessor, UnitProcessorError};
use soma_som_core::quad::{Quad, Tree};
use soma_som_core::types::UnitId;

/// Neutral default unit processor.
///
/// Pass-through: forwards input Tree unchanged with a single
/// `processor.name` marker. Unit-agnostic — usable as the default for
/// any unit (FU/MU/CU/OU/SU/HU).
#[derive(Debug, Default)]
pub struct PassthroughProcessor;

impl PassthroughProcessor {
    /// Create a new passthrough processor.
    pub fn new() -> Self {
        Self
    }
}

impl UnitProcessor for PassthroughProcessor {
    fn process(
        &mut self,
        _unit_id: UnitId,
        _cycle_index: u64,
        input: &Quad,
        _data: &Quad,
    ) -> Result<Quad, UnitProcessorError> {
        let mut tree: Tree = input.tree.clone();
        tree.insert("processor.name".into(), b"PassthroughProcessor".to_vec());
        Ok(Quad::new(input.root, input.pointer, tree))
    }

    fn name(&self) -> &str {
        "PassthroughProcessor"
    }
}