Skip to main content

Module kernel_event_log

Module kernel_event_log 

Source
Expand description

Append-only SQLite log for KernelEvent records — Phase 3a double-write.

§Purpose

Written by the double-write adapter during Phase 3a; not yet read by any production code path. Phase 3b will add the projection/replay consumer.

§Schema (additive, backward-compatible)

CREATE TABLE IF NOT EXISTS kernel_events (
    id      INTEGER PRIMARY KEY AUTOINCREMENT,
    seq     INTEGER NOT NULL,
    ts_ms   INTEGER NOT NULL,
    kind    TEXT    NOT NULL,
    turn_id TEXT,           -- NULL only for schema_version sentinel
    payload TEXT    NOT NULL -- JSON-serialised KernelEvent
);

Adding columns in future schema versions: ALTER TABLE ADD COLUMN … DEFAULT …. Removing columns: increment schema_version and provide an upcast script.

§WAL / performance

Inherits the WAL-mode connection from open_sqlite_session_db. Each KernelEventLog::append call is a single INSERT; callers may batch via append_batch to amortise transaction overhead.

Structs§

KernelEventLog
Append-only writer for the kernel_events table.

Functions§

ensure_kernel_events_table
Ensure the kernel_events table and index exist. Safe to call on every startup — uses CREATE … IF NOT EXISTS.