pub struct KernelEventLog<'conn> { /* private fields */ }Expand description
Append-only writer for the kernel_events table.
Maintains a monotone seq counter per KernelEventLog instance
(per-session / per-sidecar lifetime). The counter is not persisted
across restarts; callers that need stable cross-restart ordering should
use the SQLite id column (autoincrement) instead.
Implementations§
Source§impl<'conn> KernelEventLog<'conn>
impl<'conn> KernelEventLog<'conn>
Sourcepub fn new(db: &'conn Connection) -> Self
pub fn new(db: &'conn Connection) -> Self
Create a writer that shares the given (already-migrated) connection.
Call ensure_kernel_events_table before constructing this.
Starts seq at 0 — suitable for empty in-memory test DBs. Production
callers should prefer Self::with_next_seq after [peek_next_seq].
Sourcepub fn with_next_seq(db: &'conn Connection, next_seq: u64) -> Self
pub fn with_next_seq(db: &'conn Connection, next_seq: u64) -> Self
Resume appending after restart using the next free sequence number.
Sourcepub fn peek_next_seq(db: &Connection) -> Result<u64>
pub fn peek_next_seq(db: &Connection) -> Result<u64>
Next seq value to assign (max existing + 1, or 0 when empty).
Sourcepub fn append(&mut self, event: KernelEvent) -> Result<()>
pub fn append(&mut self, event: KernelEvent) -> Result<()>
Append one event. The ts_ms is the Unix time in milliseconds at
call time.
Sourcepub fn append_batch(
&mut self,
events: impl IntoIterator<Item = KernelEvent>,
) -> Result<()>
pub fn append_batch( &mut self, events: impl IntoIterator<Item = KernelEvent>, ) -> Result<()>
Append multiple events in a single transaction.
Sourcepub fn load_turn_events(
&self,
turn_id: &str,
) -> Result<Vec<KernelEventEnvelope>>
pub fn load_turn_events( &self, turn_id: &str, ) -> Result<Vec<KernelEventEnvelope>>
Load all events for a given turn_id in sequence order.
Used by Phase 3b replay and completeness verification tests.