Skip to main content

kernel/event/
record.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//! One serde struct per [`EventKind`](super::EventKind): the single
7//! authority for what a kind's payload is called and what it holds.
8//!
9//! Writers reach a payload through [`Payload::of`](super::Payload::of)
10//! and readers through [`Payload::read`](super::Payload::read). Those
11//! two doors plus these structs replace the hand-written
12//! `insert("key")` at the writer and `get("key")` at each reader, which
13//! is how one key came to be spelled two ways in two crates.
14//!
15//! Three rules hold for every struct here, because a ledger already
16//! written cannot be re-spelled:
17//!
18//! 1. **The bytes do not move.** Field names are the keys the previous
19//!    hand-written writer used, an absent key is spelled
20//!    `#[serde(skip_serializing_if = ...)]` exactly where the previous
21//!    writer omitted it, and a key that writer emitted unconditionally
22//!    stays unconditional even when it is empty. Keys sort on the way
23//!    out (serde_json's `Map` is a `BTreeMap`), so declaration order
24//!    here changes nothing.
25//! 2. **Reading is tolerant, writing is not.** Every field a record
26//!    written by an older build may lack carries `#[serde(default)]`,
27//!    because the fixtures hold a `run_started` whose payload is `{}`.
28//!    Unknown keys are ignored rather than refused, so a newer writer
29//!    never breaks an older reader.
30//! 3. **Values keep their kernel types.** A run is a [`RunId`](super::RunId) and not
31//!    a `String`, so the display form and the parse live where they
32//!    already lived. Types with a hand-written `Serialize` carry
33//!    `schemars(with = "String")`, which states on the schema what
34//!    their wire form has always been.
35//!
36//! A kind whose struct is not here yet is still read by hand at its
37//! call sites; the migration moves one family at a time, and each
38//! family's closing condition is that a replay produces identical
39//! bytes.
40
41mod adviser;
42mod checkpoint;
43mod collaboration;
44mod control;
45mod credential;
46mod discard;
47mod document;
48mod endpoint;
49mod governance;
50mod harness;
51mod history;
52mod log;
53mod modality;
54mod probe;
55mod provider;
56mod remote;
57mod renewal;
58mod roadmap;
59mod run;
60mod tool;
61mod turn;
62
63pub use adviser::{
64    AdviserAnswer, AdviserAnswered, AdviserAsk, AdviserAsked, AdviserFailure, AdviserFellBack,
65};
66pub use checkpoint::{CheckpointCommitted, Commit, CommitAttribution};
67pub use collaboration::{
68    ConflictLevel, GoalConflict, Lane, PursuitChanged, PursuitMove, SignalConsumed, SignalEnqueued,
69    SignalId, SignalKind, WorktreeOpened,
70};
71pub use control::{
72    BuildingConfigured, BuildingCreated, CancelReceived, CityInitialized, FiredAction, GateChecked,
73    HandoffWritten, PolicyChanged, WatchdogFired,
74};
75pub use credential::{SecretCaptured, ToolkitLinkOpened};
76pub use discard::{AssetArchived, DiscardRestored, FileDiscarded};
77pub use document::{
78    DocumentWritten, ProposalDecided, ProposalOffered, ProposalWithdrawn, SliceVerdict, Verdict,
79};
80pub use endpoint::{AttachedTuning, EndpointAttached, EndpointLost, InputKinds, ModelSelected};
81pub use governance::{
82    Admittance, ApprovalResolved, AutonomyChanged, CityHalted, GovernedDocumentWritten,
83    GoverningDocument, RulesChanged, SpineDocumentWritten, autonomy_word,
84};
85pub use harness::{
86    HarnessAnswered, HarnessPermit, HarnessPermitKind, HarnessReported, HarnessStop,
87};
88pub use history::{FileRestored, WentBack};
89pub use log::LogTruncated;
90pub use modality::{EmbeddingCalled, RerankCalled};
91pub use probe::{EndpointProbed, ModelFacts, ProbeFailure};
92pub use provider::{ProviderDegraded, VaultFellBack};
93pub use remote::{
94    DevicePaired, DeviceRevoked, RemoteClosed, RemoteClosing, RemoteOpened, RemoteSessionStarted,
95};
96pub use renewal::CacheRenewed;
97pub use roadmap::{RoadmapMoved, RoadmapStep};
98pub use run::{
99    EvalRun, EvidenceCite, FreezeCause, Opening, RunForked, RunFrozen, RunStarted, SessionOpened,
100    SkillPin,
101};
102pub use tool::{ToolAnswer, ToolCalled, ToolResult};
103pub use turn::{
104    ModelCalled, ModelReturned, PartChange, PromptAssembled, PromptSegment, PromptShapeCompared,
105    PromptSkip, PromptSource, ShapeChanged, ShapePart, SkipReason, SteerReceived,
106};