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 skill;
61mod tool;
62mod turn;
63
64pub use adviser::{
65    AdviserAnswer, AdviserAnswered, AdviserAsk, AdviserAsked, AdviserFailure, AdviserFellBack,
66};
67pub use checkpoint::{CheckpointCommitted, Commit, CommitAttribution};
68pub use collaboration::{
69    ConflictLevel, GoalConflict, Landing, Lane, PursuitChanged, PursuitMove, SignalConsumed,
70    SignalEnqueued, SignalId, SignalKind, SignalLanded, SignalWaitEnded, SignalWaitStarted,
71    WaitEnd, WorktreeOpened,
72};
73pub use control::{
74    BuildingConfigured, BuildingCreated, CancelReceived, CityInitialized, FiredAction, GateChecked,
75    HandoffWritten, PolicyChanged, WatchdogFired,
76};
77pub use credential::{SecretCaptured, ToolkitLinkOpened};
78pub use discard::{AssetArchived, DiscardRestored, FileDiscarded};
79pub use document::{
80    DocumentWritten, ProposalDecided, ProposalOffered, ProposalWithdrawn, SliceVerdict, Verdict,
81};
82pub use endpoint::{AttachedTuning, EndpointAttached, EndpointLost, InputKinds, ModelSelected};
83pub use governance::{
84    Admittance, ApprovalResolved, AutonomyChanged, CityHalted, GovernedDocumentWritten,
85    GoverningDocument, RulesChanged, SpineDocumentWritten, autonomy_word,
86};
87pub use harness::{
88    HarnessAnswered, HarnessPermit, HarnessPermitKind, HarnessReported, HarnessStop,
89};
90pub use history::{FileRestored, WentBack};
91pub use log::LogTruncated;
92pub use modality::{EmbeddingCalled, RerankCalled};
93pub use probe::{EndpointProbed, ModelFacts, ProbeFailure};
94pub use provider::{
95    ProviderAccount, ProviderAccountBinding, ProviderDegraded, VaultFellBack,
96    validate_provider_accounts,
97};
98pub use remote::{
99    DevicePaired, DeviceRevoked, RemoteClosed, RemoteClosing, RemoteOpened, RemoteSessionStarted,
100};
101pub use renewal::CacheRenewed;
102pub use roadmap::{RoadmapMoved, RoadmapStep};
103pub use run::{
104    EvalRun, EvidenceCite, FreezeCause, Opening, RunForked, RunFrozen, RunPolicyChanged,
105    RunStarted, SessionNamed, SessionOpened, SkillPin,
106};
107pub use skill::{AuditSource, AuditVerdict, ShelvedFrom, SkillAudited, SkillShelved};
108pub use tool::{ToolAnswer, ToolCalled, ToolResult};
109pub use turn::{
110    ModelCalled, ModelReturned, PartChange, PromptAssembled, PromptSegment, PromptShapeCompared,
111    PromptSkip, PromptSource, ShapeChanged, ShapePart, SkipReason, SteerReceived,
112};