kitt_score 0.1.0

Decision engine at the core of Project KITT — in-memory stateful matching with pluggable scoring backends.
Documentation
//! The frozen `Schema` handed around as `Arc<Schema>`.

use crate::schema::builder::ValueInterner;
use crate::schema::interner::Interner;
use crate::schema::layout::SlotLayout;
use crate::{AttrId, KindId};

/// Immutable schema: interners + slot layout.
///
/// Held as `Arc<Schema>` everywhere. Never mutated after `SchemaBuilder::build`.
#[derive(Debug)]
pub struct Schema {
    /// Kind-name interner.
    pub kind_names: Interner<KindId>,
    /// Attribute-name interner.
    pub attr_names: Interner<AttrId>,
    /// Enum value-string interner.
    pub value_interner: ValueInterner,
    /// Byte-layout for every kind's attribute slots.
    pub slot_layout: SlotLayout,
}

impl Schema {
    /// Look up a kind by name.
    #[must_use]
    pub fn kind(&self, name: &str) -> Option<KindId> {
        self.kind_names.get(name)
    }

    /// Look up an attribute by name.
    #[must_use]
    pub fn attr(&self, name: &str) -> Option<AttrId> {
        self.attr_names.get(name)
    }

    /// Resolve a `KindId` back to its name. For tests and debug logging only.
    #[must_use]
    pub fn kind_name(&self, id: KindId) -> &str {
        self.kind_names.lookup(id)
    }

    /// Resolve an `AttrId` back to its name. For tests and debug logging only.
    #[must_use]
    pub fn attr_name(&self, id: AttrId) -> &str {
        self.attr_names.lookup(id)
    }
}