Skip to main content

khive_pack_session/
lib.rs

1//! khive-pack-session — session storage pack for the khive runtime.
2//!
3//! Registers the `session` note kind and three internal subhandlers:
4//! `session.store`, `session.list`, `session.get`
5//! (operator-only this milestone — see `vocab::SESSION_HANDLERS`).
6//! Serialization (`handlers::export::handle_export`) is an in-process helper,
7//! not a dispatchable verb.
8//!
9//! The pack's active feature is a background mirror service (`warm` hook) that
10//! live-tails Claude Code session JSONL transcripts into the pack's auxiliary
11//! SQL tables.
12
13pub mod handlers;
14pub mod mirror;
15mod pack;
16pub mod vocab;
17
18use khive_runtime::KhiveRuntime;
19use khive_types::{HandlerDef, Pack, PackSchemaPlan};
20
21pub(crate) use vocab::{SESSION_HANDLERS, SESSION_SCHEMA_PLAN_STMTS};
22
23/// Session pack — registers the `session` note kind and session lifecycle verbs.
24pub struct SessionPack {
25    runtime: KhiveRuntime,
26}
27
28impl Pack for SessionPack {
29    const NAME: &'static str = "session";
30    const NOTE_KINDS: &'static [&'static str] = &["session"];
31    const ENTITY_KINDS: &'static [&'static str] = &[];
32    const HANDLERS: &'static [HandlerDef] = &SESSION_HANDLERS;
33    const REQUIRES: &'static [&'static str] = &["kg"];
34    const SCHEMA_PLAN: Option<PackSchemaPlan> = Some(PackSchemaPlan {
35        pack: "session",
36        statements: &SESSION_SCHEMA_PLAN_STMTS,
37    });
38}
39
40impl SessionPack {
41    /// Create a new `SessionPack` bound to the given runtime.
42    pub fn new(runtime: KhiveRuntime) -> Self {
43        Self { runtime }
44    }
45
46    pub(crate) fn runtime(&self) -> &KhiveRuntime {
47        &self.runtime
48    }
49}