kernel/event/kind/window.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//! The window partition: which kinds decide model-request bytes.
7
8use super::EventKind;
9
10/// The two-way partition; the sole criterion is "does the payload decide
11/// model-request bytes" (C16). There is no third class.
12#[derive(Debug, Clone, Copy, PartialEq, Eq)]
13pub enum WindowClass {
14 InWindow,
15 RecordOnly,
16}
17
18impl EventKind {
19 /// The partition authority. Exhaustive on purpose: adding a variant
20 /// without deciding its class is a compile error, not a default.
21 pub fn window_class(&self) -> WindowClass {
22 match self {
23 EventKind::PromptAssembled
24 | EventKind::ModelCalled
25 | EventKind::ModelReturned
26 | EventKind::ToolCalled
27 | EventKind::ToolResult
28 | EventKind::ResultOffloaded
29 | EventKind::SteerReceived
30 | EventKind::SignalConsumed
31 | EventKind::AdviserAnswered => WindowClass::InWindow,
32 EventKind::CityInitialized
33 | EventKind::BuildingCreated
34 | EventKind::BuildingConfigured
35 | EventKind::BuildingRemoved
36 | EventKind::RunStarted
37 // Starting a session decides what the next run is given, and
38 // the bytes it is given are recorded by `prompt_assembled`;
39 // nothing here belongs to a window already on the wire.
40 | EventKind::SessionOpened
41 // The cache shape measures what a request carries; it never
42 // decides any of those bytes.
43 | EventKind::PromptShapeCompared
44 | EventKind::RunForked
45 | EventKind::GateChecked
46 | EventKind::GateDenied
47 | EventKind::CheckpointCommitted
48 | EventKind::HandoffWritten
49 | EventKind::CancelReceived
50 | EventKind::WatchdogFired
51 | EventKind::BudgetLimit
52 | EventKind::RunFrozen
53 | EventKind::LogTruncated
54 | EventKind::SignalEnqueued
55 | EventKind::DraftHeld
56 | EventKind::DraftResolved
57 | EventKind::GoalRegistered
58 | EventKind::GoalConflict
59 | EventKind::ArbitrationVerdict
60 | EventKind::RepairStarted
61 | EventKind::RepairReused
62 | EventKind::WorktreeOpened
63 | EventKind::PrOpened
64 | EventKind::PrMerged
65 | EventKind::PrRejected
66 | EventKind::RoadmapClaimed
67 | EventKind::RoadmapFinished
68 | EventKind::RoadmapReleased
69 | EventKind::RoadmapSplit
70 | EventKind::RoadmapBlocked
71 | EventKind::PursuitChanged
72 | EventKind::ApprovalRequested
73 | EventKind::ApprovalResolved
74 | EventKind::PolicyCreated
75 | EventKind::PolicyRevoked
76 | EventKind::TaintPromoted
77 | EventKind::CrossBuildingTransfer
78 | EventKind::CityHalted
79 | EventKind::BackpressureShed
80 | EventKind::DigestInvalidated
81 | EventKind::EndpointAttached
82 | EventKind::EndpointProbed
83 | EventKind::EndpointLost
84 | EventKind::ModelSelected
85 | EventKind::ProviderDegraded
86 | EventKind::LoginStarted
87 | EventKind::EvalRun
88 | EventKind::AssetArchived
89 | EventKind::CredentialLent
90 | EventKind::SecretCaptured
91 | EventKind::SecretEgressBlocked
92 | EventKind::FileDiscarded
93 | EventKind::DiscardRestored
94 | EventKind::AutonomyChanged
95 | EventKind::WentBack
96 | EventKind::FileRestored
97 // Connecting an application changes which tools a later run
98 // is offered, and the tool table is assembled from the
99 // configuration rather than from this line, so nothing here
100 // decides model-request bytes.
101 | EventKind::ToolkitLinkOpened
102 // An embedding or a rerank is a call for a derived value,
103 // not a turn of the conversation: the window's bytes are
104 // recorded by `prompt_assembled`, and the answer here is
105 // recorded so a cost can be read off the history.
106 | EventKind::EmbeddingCalled
107 | EventKind::RerankCalled
108 | EventKind::AdviserAsked
109 // The fallback records that the city's own policy answered
110 // instead; the move it made is already written where the
111 // move itself is written.
112 | EventKind::AdviserFellBack
113 | EventKind::GovernedDocumentWritten
114 | EventKind::SpineDocumentWritten
115 | EventKind::RulesChanged
116 // A renewal resends a prefix already on the wire and changes
117 // no byte of any later request; the line records its cost.
118 | EventKind::CacheRenewed
119 // What a harness said or answered never decides a request
120 // this city sends.
121 | EventKind::HarnessReported
122 | EventKind::HarnessAnswered
123 // Who may reach the city from outside its machine decides no
124 // byte a model is sent.
125 | EventKind::RemoteOpened
126 | EventKind::RemoteClosed
127 | EventKind::DevicePaired
128 | EventKind::DeviceRevoked
129 | EventKind::RemoteSessionStarted
130 // A save, and a person's verdicts on a suggestion, change a
131 // file on disk; a later run reads that file, never this line.
132 | EventKind::DocumentWritten
133 | EventKind::ProposalOffered
134 | EventKind::ProposalDecided
135 | EventKind::ProposalWithdrawn => WindowClass::RecordOnly,
136 }
137 }
138}