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