Skip to main content

kernel/
event.rs

1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4// Copyright (c) 2026 2youg1 and the sprawling contributors
5
6//! EventRecord and the closed EventKind set: the value
7//! layer of "the Ledger is the only history".
8//!
9//! Invariants owned here:
10//! - every kind belongs to exactly one window class; the single criterion
11//!   is "does its payload decide model-request bytes". The authority is
12//!   [`EventKind::window_class`] — an exhaustive match, no catch-all, so a
13//!   new variant forces an explicit classification.
14//! - canonical bytes have one producer: [`EventRecord::canonical_line`].
15//!   Struct key order = declaration order; payload keys sort (BTreeMap);
16//!   `addr: None` and `ig: false` are omitted; no line terminator. The
17//!   chain hashes exactly these bytes (ledger module).
18//! - Ledger payloads never carry floats (determinism rule 6): [`Payload`]
19//!   rejects them at construction and again on deserialize.
20//! - [`EventRef`] has private fields and no public constructor; minting
21//!   requires holding a whole record (append path or replay after chain
22//!   verification, 15.3-1).
23//! - kernel neither samples clocks nor generates ids: [`TimeMs`] and
24//!   [`RunId`] arrive as parameters. uuid v7 is human-readable identity
25//!   only; [`RunId::CITY`] (nil) marks city-level records.
26
27mod identity;
28mod kind;
29mod moment;
30mod payload;
31pub mod record;
32mod scope;
33mod who;
34
35pub use identity::{RunId, Seq, TimeMs};
36pub use kind::{EventKind, WindowClass};
37pub use payload::{EventDraft, EventRecord, EventRef, Payload};
38pub use scope::Scope;
39pub use who::Who;