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
//! What a record *spent*, said without naming a format.
//!
//! The half the two usage dialects share: the counters a record can carry, the
//! exact total that becomes [`crate::lens::Summary::tokens`], and the one
//! spelling of the numeric block a row shows them in. `usage_agent.rs` reads a
//! Claude Code session log into it and `usage_atif.rs` reads an ATIF trajectory
//! into it; neither spells a number, and neither decides a row — that is still
//! `src/source/record/`'s.
//!
//! # Three different things a cell can say
//!
//! This is the whole design, and it is why every counter is an [`Option`]
//! rather than a `u64` that defaults to zero:
//!
//! * **a number** — the format recorded that value, and `0` means zero tokens
//! were spent, which is a real and observable thing;
//! * **`-`** — this *record* did not record a field its format has. The column
//! stays, because other records in the same file fill it;
//! * **no column at all** — the *format* has no such field. ATIF-v1.7 records no
//! cache-creation counter of any kind, so a `usage-atif` row has three fields
//! and never a fourth. A `0` there would read as "this agent wrote nothing to
//! cache" when the truth is "this format does not record cache writes", and a
//! `-` on every row of every file would be a column of nothing.
//!
//! The rule stated once and applied twice: a *format*-level absence removes the
//! column for the whole file, because alignment is what a number column is for
//! and alignment is per file; a *record*-level absence inside a format that has
//! the field prints `-`.
//!
//! # Why the block is a constant width
//!
//! A reader of this lens is scanning down one column. Four fields are
//! `4×8 + 3×2 = 38` columns and three are `3×8 + 2×2 = 28`, always, whatever
//! the numbers are — which is what [`crate::lens::tokens`] flooring to four
//! columns buys. The row is never wrapped (it scrolls), so a narrow terminal
//! pans across it rather than losing the action off the end.
use crateValue;
use crate;
/// Columns a field's label gets, left-justified.
const LABEL: usize = 4;
/// Columns a field's number gets, right-aligned. [`crate::lens::tokens`]
/// promises never to exceed it.
const NUMBER: usize = 4;
/// Columns one field occupies: its label then its number, no separator, because
/// the label is short and the number is right-aligned into the gap.
pub const FIELD: usize = LABEL + NUMBER;
/// Columns between two fields.
const GAP: &str = " ";
/// Between the numbers and what the record did.
const TURN: &str = " \u{b7} ";
/// What a record with no numbers at all shows in the number cell of a field its
/// format does have. Never `0`: a recorded zero and an unrecorded field are
/// different claims, and this lens exists to keep them apart.
const ABSENT: &str = "-";
/// The counters a record recorded, exactly as the file recorded them.
///
/// `None` is "this record did not say", not "zero" — see the module docs.
/// One column of the numeric block: which counter, under which label.
///
/// A dialect names the set its format actually has, once, and a counter that is
/// not in the set never reaches a row — that is the "absent column" of the
/// three-way distinction above.
/// The row a usage-bearing record shows: the numbers, then what it did.
///
/// Every field is [`FIELD`] columns whatever it holds, so the block is
/// `fields.len() * FIELD + (fields.len() - 1) * 2` columns for every record in
/// the file and the column reads straight down.
/// One field: its label left-justified, its number right-aligned into what is
/// left. ASCII throughout — the labels are this module's own and
/// [`crate::lens::tokens`] emits digits and one suffix letter — so columns and
/// bytes agree here and the padding is exact.
/// Adjacent entries that read the same collapsed to `Read ×3`.
///
/// A turn that read three files made one kind of move, and spelling it three
/// times pushes what happened next off the row. The same rule `atif` applies to
/// its own row, for the same reason.
// -- the open level -------------------------------------------------------------
//
// Where the row's floored four columns become exact, and where everything the
// row had no column for lands. Nothing a record holds is unreachable, which is
// the seam's rule — and this level is built from `Part::Text` alone, because
// this lens is not re-telling the conversation.
/// One `name value` line of an open level, aligned so a column of numbers
/// still reads as a column when it is exact.
/// A `name value` line for an integer field, when the record has one.
///
/// The **exact** integer, not [`tokens`]: the row above is floored to four
/// columns and this is the rung a reader descends to when they need the real
/// number — `1999` on the row is `1.9k`, and here it is `1999`.
/// A `name value` line for a string field, when the record has one.
/// The lines gathered under `label` as one part, or nothing when there were
/// none — an empty part is a row that says a name and shows nothing under it.
///
/// The body has an **empty path**: it is a summary this module composed, not a
/// string node of the record, so there is nothing to walk back to. Every byte
/// of it is short, and the record's own tree is one `r` away regardless.