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
//! What a record's parts **are**, said without saying anything about rows.
//!
//! A summary is a headline and a [`Body`] is what was said. Between the two and
//! the raw JSON tree there is a level that reads a record the way a person would
//! describe it — the whole message, then its tool calls listed *as tool calls*
//! (SPEC.md §Lenses, the open level). This module is the vocabulary a dialect
//! uses to say what is in there, and it is deliberately row-free: no widths, no
//! indents, no fold markers, no order on the screen. `src/source/record/parts.rs`
//! turns a `Vec<Part>` into rows, and it is the only thing that does.
//!
//! # What a part may hold
//!
//! The same ceiling a [`Body`] has, for the same reason. [`Lens::detail`] is
//! called **on demand, for the record the reader opened** — never once per
//! record and never stored on a [`Summary`] — so parts do not cost anything per
//! document. But one *record* can carry five calls whose outputs are fifteen
//! kilobytes apiece, and a level that read them into memory to count its rows
//! would make opening one step cost what the step cost. So every stretch of
//! text in a `Part` is a [`Body`]: a bounded head, the true byte and line
//! counts, and the path back into the record.
//!
//! Two of those paths are real and one is not, and the difference is stated
//! rather than hidden:
//!
//! * a **result** sits at a path of static keys and one index
//! (`observation.results[3].content`), so opening it reads the whole of it
//! back out of the record being painted;
//! * an **argument** sits under a key whose name is the argument's own
//! (`arguments.command`), and [`Step::Key`] is `&'static str` — a path there
//! would have to allocate the key. An argument is therefore a `Body` with an
//! **empty path**, which [`Body::text_in`] resolves to the head. That is not a
//! silent clip: the head carries the true `bytes` and `lines`, so the row
//! under it says `⋯ +N more` exactly as a clipped message does, and every byte
//! is still one `r` away in the record's own tree.
//!
//! A lens never hides anything (SPEC.md §Lenses). A part may be clipped; it may
//! not be quiet about it.
use Body;
use crateValue;
/// The name an argument list gets when it is not an object at all.
///
/// A dialect reads a call's `arguments` as the object the schema says it is,
/// but a real file writes an array, a bare string, or a JSON-encoded string
/// that streaming cut in half. Dropping those left the open level saying the
/// call had **no** arguments, which is the one thing a clip may never do
/// (SPEC.md §Lenses) — so they become one argument under this name, holding
/// exactly what the file said.
pub const RAW_ARGS: &str = "arguments";
/// A call's `arguments` as the list the open level lists, whatever shape they
/// arrived in.
///
/// An object is its members, in the record's own order. Anything else is one
/// entry named [`RAW_ARGS`]: a string as itself, and any other value as the
/// JSON it is — which is what the record's tree would show, and what `r` is
/// one press away from.
///
/// Every value is a [`Body`] with an **empty path**: an argument lives under a
/// key that is its own name and a [`Step::Key`](super::Step::Key) is
/// `&'static str`, so the value is a bounded head that states its true size
/// rather than a path back into the record.
/// One value as the text an argument row shows: a string as itself, anything
/// else as its own JSON.
/// One thing a record turns out to contain, once you read it as what it is.
///
/// Deliberately two variants and not more: text someone (or something) wrote,
/// and a call to a tool. A dialect that finds a third kind of thing in a record
/// says so here, once, and every dialect gets the rows for free.