1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//! 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:
//!
//! 1. A field is added, removed, or renamed in any `serde`-serialized struct
//! that crosses the persistence boundary (sqlite columns, JSONL log,
//! context-pack JSON).
//! 2. The semantic meaning of a field changes (e.g. `confidence` switches
//! range or distribution), even if the JSON shape is unchanged.
//! 3. The wire string of any `EventType` (or other tagged enum that carries
//! a `cortex.<entity>.<name>.v<N>` identifier) is renamed.
//! 4. 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.
/// Returns the `CARGO_PKG_VERSION` of `cortex-core`.
/// Returns the current schema version (re-export of [`crate::SCHEMA_VERSION`]).
///
/// Provided so downstream code can write `cortex_core::version::schema()`
/// without a `use` of the constant.
pub const