kitt_score 0.1.0

Decision engine at the core of Project KITT — in-memory stateful matching with pluggable scoring backends.
Documentation
//! Action registration event — binds a scorer + payload + validity window to a location. See spec §3.2, §3.3.

use crate::event::kind_ref::KindRef;
use crate::location::state::LocationView;
use crate::scoring::ScorerSpec;
use crate::{ActionId, LocId, UnixTime};
use std::sync::Arc;

/// Spec §3.2, §3.3: register an action with start/end window + a scorer + a
/// generic payload `T` + an optional post-processing closure.
#[derive(Clone)]
pub struct ActionIngest<'a, T> {
    /// The location at which this action is registered.
    pub location: LocId,
    /// Caller-assigned stable identifier for this action.
    pub action_id: ActionId,
    /// Unix timestamp (seconds) from which this action is eligible.
    pub start: UnixTime,
    /// Unix timestamp (seconds) after which this action is no longer eligible.
    pub end: UnixTime,
    /// Tie-breaking priority; higher wins.
    pub priority: u8,
    /// The event kind that can trigger scoring of this action.
    pub kind: KindRef<'a>,
    /// Scorer configuration used to evaluate this action.
    pub scorer: ScorerSpec<'a>,
    /// Caller-supplied payload returned to the caller when this action wins.
    pub payload: T,
    /// Applied to the winning action's payload at decision time.
    /// `None` → payload is returned verbatim (the common ad-tech case).
    #[allow(clippy::type_complexity)]
    pub post: Option<Arc<dyn Fn(&T, &LocationView<'_>) -> T + Send + Sync>>,
}