1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
//! The `ActionEvent` taxonomy carried by `HarnessPayload::Action` (DOC-73 §3.2).
//!
//! Why: The dashboard's list and tree views (DOC-73 §5) need one typed vehicle
//! for "something happened" that names its object by reference rather
//! than by value, so an event stays small no matter how large the thing
//! it describes (§3.2 "Required fields"). `HarnessPayload::Hook`'s
//! untyped `{kind, data}` shape cannot serve this: the tree assembler
//! needs to pattern-match on a closed, typed set of phases to know what
//! each node means, and an open-ended `Value` gives it nothing to match
//! on.
//! What: Six `ActionEvent` variants — `Workflow`, `Agent`, `File`, `Tool`,
//! `Session`, `Inference` — each carrying the fields every kind needs
//! (via the flattened [`ActionMeta`]) plus its own phase and payload.
//! `Actor`, `ObjectRef`, `ObjectType`, and `PathRef` are the supporting
//! types §3.2 and §6 name. Every new enum here is `#[non_exhaustive]`:
//! the taxonomy is expected to grow phases and object types as more
//! harnesses adapt (§3.4), and §3.3 requires that growth be additive
//! rather than a breaking rename.
//! Test: `super::tests::action_event_round_trips_all_six_kinds`,
//! `super::tests::action_event_wire_shape_matches_kind_tag`,
//! `super::tests::action_event_kind_matches_serde_tag`,
//! `super::tests::action_meta_schema_version_defaults_to_one`,
//! `super::tests::harness_payload_action_round_trips`,
//! `super::tests::harness_payload_pre_action_payload_still_deserializes`.
// #6847: added alongside `control_bus::PushClient` to close out the two items
// DOC-73 §3.2/§4 still owed after #7150 landed the envelope's `id`/`parent_id`.
// Fields and phases are transcribed from the spec's code sample and its
// "Required fields on every ActionEvent" table; nothing here is speculative
// beyond what those two sections already specify.
use ;
use ;
use EventId;
use HarnessSource;
/// Fields every `ActionEvent` variant carries, regardless of `kind`.
///
/// Why: §3.2's "Required fields on every ActionEvent" table lists seven fields
/// the view needs on every kind. Four of them (`id`, `at`, `source`,
/// `parent_id`) already exist on the enclosing [`super::HarnessEvent`]
/// envelope; carrying them here too is what let an object viewer, a log
/// exporter, or a future non-envelope transport read one `ActionEvent`
/// value and answer "who, when, from where, caused by what" without
/// needing the outer envelope in hand. Collecting them in one struct and
/// flattening it into each variant is what keeps six variants from
/// repeating seven field declarations apiece.
/// What: `id`/`at`/`source`/`session`/`parent_id` mirror the envelope fields
/// of the same name; `actor` and `objects` are §3.2's own additions.
/// `schema_version` is §3.3's versioning field, defaulting to `1` so a
/// payload serialized before this field existed still deserializes.
/// Test: `super::tests::action_meta_schema_version_defaults_to_one`, plus the
/// round-trip tests, which cover every field through a real variant.
/// Who performed an action.
///
/// Why: §3.2 — "an agent name plus its stable `agent_id`, or `Operator`, or
/// `System`". The tree view colors and labels a node by actor, so the
/// three cases need to stay structurally distinct rather than collapsing
/// into a display string at emit time.
/// What: `Agent` carries both the display name and the stable id the object
/// viewer links through; `Operator` and `System` are unit variants.
/// Test: `super::tests::action_event_round_trips_all_six_kinds` covers `Agent`
/// through a real event; `Operator`/`System` via
/// `super::tests::actor_operator_and_system_round_trip`.
/// The nine object types DOC-73 §6's object viewer routes on.
///
/// Why: `ObjectRef.type` is "a discriminated type tag" (§3.2); modelling it as
/// a closed enum rather than a bare `String` gives the tree/list views a
/// type the compiler checks, while still matching the exact nine
/// `/ui/object/<type>/<id>` routes §6 enumerates.
/// What: One variant per §6 table row. `#[non_exhaustive]` because §6 already
/// reserves the shape for more object types than it lists as MVP.
/// Test: `super::tests::object_type_round_trips_every_variant`.
/// A link target: "what the action acted on" (§3.2), rendered by the object
/// viewer (§6).
///
/// Why: Events stay small no matter how large the object they reference — the
/// view renders `label` and links on `(type, id)` rather than inlining
/// object content (§3.2, §6 "Reached by link only").
/// What: `object_type` is the discriminated tag; `id` is opaque to the view
/// (whatever the owning harness uses to look the object up); `label` is
/// the short display string.
/// Test: `super::tests::action_event_round_trips_all_six_kinds`.
/// A `File` action's target: a repo-relative path and, for a write, a diff
/// reference.
///
/// Why: §6 — a `File::Written` row shows "the unified diff"; the object
/// viewer needs a reference to that diff, not the diff itself, for the
/// same reason `ObjectRef` never inlines content.
/// What: `path` is repo-relative; `diff_ref` is opaque to the view and absent
/// for every phase but `Written`.
///
/// Security: both fields are rendered verbatim by the object viewer (§6). A
/// producer MUST pass any user- or file-derived free text through
/// `crate::credentials::scrub_secrets` before setting either one.
/// Test: `super::tests::action_event_round_trips_all_six_kinds`.
/// Phases of `ActionEvent::Workflow` (DOC-73 §3.2 table, verbatim).
/// Phases of `ActionEvent::Agent` — maps 1:1 onto `LifecycleEvent`'s
/// `AgentSpawned`/`AgentMessage`/`AgentDone`/`AgentFailed` (DOC-73 §3.2).
/// Phases of `ActionEvent::File` (DOC-73 §3.2 table, verbatim).
/// Phases shared by `ActionEvent::Tool` and `ActionEvent::Inference` — both
/// rows in DOC-73 §3.2's table list the identical `Started`/`Finished`/
/// `Errored` set, so one enum serves both kinds.
/// Phases of `ActionEvent::Session` (DOC-73 §3.2 table, verbatim).
/// The typed action taxonomy carried by `HarnessPayload::Action` (DOC-73
/// §3.2).
///
/// Why: See module docs. Each variant "names its object by reference rather
/// than by value" — `object`/`agent_id`/`path`/`tool`+`call_id`/`model`
/// are identifiers and short labels, never the object's content.
/// What: `#[serde(tag = "kind", rename_all = "snake_case")]` produces
/// `{"kind":"workflow", ...flattened ActionMeta fields..., "phase":...,
/// "object":...}` and the equivalent shape for the other five kinds.
/// [`ActionMeta`] is flattened into every variant rather than
/// duplicated field-by-field.
/// Test: `super::tests::action_event_round_trips_all_six_kinds`,
/// `super::tests::action_event_wire_shape_matches_kind_tag`,
/// `super::tests::action_event_kind_matches_serde_tag`.