Skip to main content

Module baseline

Module baseline 

Source
Expand description

System baseline + drift detection — the executor behind brain baseline capture/diff/list and the baseline.capture/diff/list native capabilities.

A baseline is a deterministic, offline snapshot of the brain’s stable system facts — version, platform, the effective LLM/embedding wiring, adapter exposure, action toggles, the live native-capability inventory, and the security surface. Each snapshot is a flat key → value map: every entry is one fact, so a later diff can report precisely which facts were added, removed, or changed since the baseline was taken.

Storage. Snapshots are persisted as versioned JSON files under ~/.brain/baselines/baseline-<NNNN>.json, where <NNNN> is a monotonically increasing version number. This is local-first and inspectable, and — unlike writing into the semantic fact store — it never opens SQLite/RuVector, so it can’t contend with a running daemon (the same reason brain status avoids opening the DB directly).

Truthful by construction. Capture reads only the loaded config, the process environment, and the capability inventory it is handed. There is no LLM and no network: the snapshot is exactly what the running config declares, and a diff is a literal set comparison of two such snapshots.

Capability inventory is injected. The native-capability descriptors live in the binary crate; rather than reach back into it (a layering inversion), the caller passes the inventory in as a CapabilitySummary slice — the composition root assembles it from the descriptor list. Keeps this core a pure function of its inputs.

Structs§

BaselineProvider
The cortex::actions::BaselineBackend implementation. Holds a snapshot of the config and the capability inventory taken at boot, and runs the deterministic capture/diff/list on each dispatch. The chat tool-loop dispatches baseline.* through this; the CLI calls the free functions directly (assembling the inventory itself).
CapabilitySummary
One native capability, flattened for the baseline snapshot. The composition root builds these from the registered descriptors and hands them to capture / diff, so this core never depends on the descriptor source.

Functions§

capabilities
The capabilities this backend declares: baseline capture/diff/list. Always wired — local snapshot files, no network. capture is a local write; diff/list are read-only.
capture
Capture a new baseline snapshot and store it as the next version. Returns the rendered confirmation (version, fact count, and the file path).
diff
Compare two baselines and render the drift. With no versions, compares the latest stored baseline against the current live state; from picks the stored baseline to compare from; to compares against another stored baseline instead of live state.
list
Render the stored baseline snapshots, newest first.