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
//! AutomationKind / AutomationTrigger -- the task-notification pulse model.
/// The TRUE class of a `<task-notification>` automation trigger, parsed from the leading
/// classifier of its `<summary>` (verified against real sessions: the summary opens with
/// `Background command "…"`, `Dynamic workflow "…"`, or `Agent …`). This is the attribution
/// the P2 turn-segmentation lens demands - the old code hardcoded the literal `workflow` for
/// EVERY trigger, mislabeling background-command + agent pulses (81% on a captured session).
/// True when a `Background command "<name>" …` summary's QUOTED command name names a
/// monitor / cron cadence - so the pulse is attributed to [`AutomationKind::Monitor`] rather
/// than the generic [`AutomationKind::BackgroundCommand`]. Extracts the substring between the
/// FIRST pair of double quotes (the command name) and matches a conservative set of
/// monitor-cadence tokens against it (case-insensitive): the standalone word `monitor`, or
/// `re-arm`, `relaunch monitor`, `liveness`. The match is restricted to the quoted NAME (never
/// the whole summary) so a background command that merely mentions "monitor" in trailing prose
/// is not over-captured; absent quotes, nothing matches (stays `BackgroundCommand`). Tokens
/// chosen to be strongly monitor-specific - `tick`/`cadence` alone are too broad and excluded.
pub
/// A parsed `<task-notification>` automation trigger - the stable inner tags of a
/// machine-injected background-command / workflow / spawned-task completion notice. Every
/// field is `Option` because a malformed / partial notification must degrade gracefully
/// (the label still renders with `?`/`completed` fallbacks) rather than be dropped.
/// Extract the text between `<tag>` and `</tag>` in `s`, trimmed, or `None` when the tag
/// is absent or empty. Codepoint-safe: `str::find` returns ASCII byte offsets of the
/// (ASCII) tag delimiters, and the slice is taken on those offsets only - never inside the
/// (possibly CJK) body. A missing close tag yields `None` (never a runaway slice).
pub
/// Collapse all runs of ASCII whitespace (incl. newlines/tabs) to single spaces
/// and trim the ends, so an excerpt renders on one line. Does NOT truncate -
/// length capping with an explicit `… (+N chars)` marker is the caller's job.
pub
// ============================================================================
// role.class.sub classification engine (GOLD plan §2–§6) - ADDITIVE, P1.
//
// This is the NEW taxonomy core, testable in isolation. It is NOT yet wired into any
// consumer (the legacy `cli::Category` + `-t` selector still drive output); P2 cuts the
// surfaces over to [`Record::classify`] and removes the old enum. Until then the new
// items carry a targeted `#[allow(dead_code)]` (the binary never calls them yet).
//
// GOLD GAPS surfaced during P1 (reported upstream, not silently absorbed):
// - `harness.schedule.wakeup`: the FIRED autonomous-loop / `ScheduleWakeup` timer tick is
// detected via its fixed markers ([`SCHEDULE_WAKEUP_MARKER`] sentinel +
// [`SCHEDULE_WAKEUP_LOOP_CHECK_PREFIX`] / [`SCHEDULE_WAKEUP_TIMER_MARKER`], P1c M2a). A
// GENERIC cron/monitor tick's injected prompt is still operator-authored free text with no
// universal marker; such an isMeta tick that matches no marker is EXCLUDED (P1c M2b: an
// isMeta record is never `user.message`), not mislabeled. The `ScheduleWakeup` *tool_use*
// (the agent ARMING a wakeup) is classified `agent.tool.use`, not the harness tick.
// - `agent.thinking` covers BOTH [`Block::Thinking`] and [`Block::RedactedThinking`] (the
// encrypted/opaque thinking form). The latter is UNATTESTED in the current corpus (oracle
// B3/G7) so it is exercised by a SYNTHETIC fixture; it carries no readable text, so the
// render surfaces a `[redacted thinking]` placeholder while still classifying `agent.thinking`.
// ============================================================================