Expand description
Schema and crate version helpers.
§Schema version policy
crate::SCHEMA_VERSION tags every persisted Cortex record (events,
traces, memories, principles, doctrine, context packs, audit records).
It governs on-disk and wire compatibility, NOT the crate’s
semver.
§Bump rules
Bump SCHEMA_VERSION and open an ADR in docs/adr/ whenever any of
the following changes:
- A field is added, removed, or renamed in any
serde-serialized struct that crosses the persistence boundary (sqlite columns, JSONL log, context-pack JSON). - The semantic meaning of a field changes (e.g.
confidenceswitches range or distribution), even if the JSON shape is unchanged. - The wire string of any
EventType(or other tagged enum that carries acortex.<entity>.<name>.v<N>identifier) is renamed. - Hash framing changes (payload hash, event hash, chain framing) — these invalidate previously-recorded chains and force a migration.
§What does NOT require a bump
- Adding a brand-new variant to an open enum that ships with
serde(other)handling AND already-deployed readers that quarantine unknown variants. - Internal refactors that preserve the on-disk JSON byte-for-byte.
- Adding new tables / files that older readers can ignore.
When in doubt: bump and write the ADR. The cost of a one-line schema bump is orders of magnitude less than the cost of a silent shape drift in the ledger.
Functions§
- crate_
version - Returns the
CARGO_PKG_VERSIONofcortex-core. - schema
- Returns the current schema version (re-export of
crate::SCHEMA_VERSION).