Skip to main content

nexo_driver_loop/memory/
trait_def.rs

1use async_trait::async_trait;
2use nexo_driver_claude::ClaudeError;
3use nexo_driver_permission::PermissionRequest;
4use nexo_driver_types::{Decision, GoalId};
5
6#[async_trait]
7pub trait DecisionMemory: Send + Sync + 'static {
8    /// Up to `k` past decisions semantically similar to `req`.
9    async fn recall(&self, req: &PermissionRequest, k: usize) -> Vec<Decision>;
10
11    /// Persist a decision so it can be recalled later. Best-effort —
12    /// implementors that fail to record should log and return Ok so
13    /// the decider's hot path doesn't surface storage errors.
14    async fn record(&self, _decision: &Decision) -> Result<(), ClaudeError> {
15        Ok(())
16    }
17}
18
19#[derive(Clone, Debug, Eq, PartialEq)]
20pub enum Namespace {
21    /// Restrict recall to a specific goal.
22    PerGoal(GoalId),
23    /// Recall against every decision in the store.
24    Global,
25}