@flyingrobots/parley-read 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +272 -0
- package/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +560 -2
- package/package.json +39 -4
- package/src/digest.ts +438 -0
- package/src/fold.ts +166 -0
- package/src/index.ts +10 -0
- package/src/lines.ts +77 -0
- package/src/load.ts +711 -0
- package/src/locate.ts +70 -0
- package/src/open.ts +435 -0
- package/src/query.ts +760 -0
- package/src/rank.ts +309 -0
- package/src/schemas.ts +2042 -0
- package/src/validate.ts +94 -0
package/README.md
CHANGED
|
@@ -1,3 +1,561 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @flyingrobots/parley-read
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A reader for the [Parley output protocol](../../spec/parley-v0.2.md). It opens the receipt bundles
|
|
4
|
+
a repository has accumulated and hands back every run's records, each labelled by how well it is
|
|
5
|
+
established: validated against the schema for its exact pair, partially checked, or passed through
|
|
6
|
+
unvalidated because its type is not ours to validate.
|
|
7
|
+
|
|
8
|
+
A read over those records states who it is for, what shape of answer it wants and how big an
|
|
9
|
+
answer it will accept, is refused when it cannot, and is itself recorded as a run with a receipt
|
|
10
|
+
(§9) — so the next read can see what was asked. The shape it asks for **orders** the answer: §9's
|
|
11
|
+
purpose is the ranking function, and it never removes a record. The size it will accept **bounds**
|
|
12
|
+
the answer, and the read answers with a digest that says what the bound left out, so a later
|
|
13
|
+
reader cannot mistake a digest for the whole. A drill-down opens the records a digest names, by
|
|
14
|
+
`(run, seq)`, in full — a sidecar's contents included — with one outcome per id, and it is recorded
|
|
15
|
+
as a read too.
|
|
16
|
+
|
|
17
|
+
The rules it keeps are the ones the specification binds a *reader* to — §1.4 buffering and
|
|
18
|
+
quarantine, §5.4's unterminated tail, §1.3's `(run, seq)`, §4.5 and §4.6 on exact-pair resolution,
|
|
19
|
+
and §5 on sidecars — because the cases §6 calls unconstrainable will happen, and a reader that
|
|
20
|
+
aborts on the first stray byte is broken by exactly the case the spec admits.
|
|
21
|
+
|
|
22
|
+
Spec version `0.2.0`. The package version moves with this code; each message schema moves on its
|
|
23
|
+
own (spec §4.4). The schemas it ships are the versions released with spec `0.2.0`, copied from
|
|
24
|
+
`schemas/` at the commit recorded in `src/schemas.ts`, byte-identical by test (spec §4.5).
|
|
25
|
+
|
|
26
|
+
This is a library with no command, for Bun 1.2 or later. Version 0.1.0 is released (tag
|
|
27
|
+
`parley-read-v0.1.0`); its first publish to npm is made by hand by the owner
|
|
28
|
+
([docs/workflows/release-parley-read](../../docs/workflows/release-parley-read/README.md)), after
|
|
29
|
+
which `bun add @flyingrobots/parley-read` installs it with `@flyingrobots/parley-emit` `^0.2.0`.
|
|
30
|
+
Inside this repository it is the workspace package `@flyingrobots/parley-read`.
|
|
31
|
+
|
|
32
|
+
## Loading a directory's receipts
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { loadReceipts } from "@flyingrobots/parley-read";
|
|
36
|
+
|
|
37
|
+
const load = loadReceipts({ cwd: "/work/site" });
|
|
38
|
+
|
|
39
|
+
for (const bundle of load.bundles) {
|
|
40
|
+
console.log(bundle.run, bundle.status, bundle.records.length);
|
|
41
|
+
for (const defect of bundle.defects) console.log(defect.code, defect.section, defect.problem);
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
`loadReceipts` looks in both places the writer could have put a receipt for that working
|
|
46
|
+
directory (§5): `.parley/receipts/` under it, and `$XDG_STATE_HOME/parley/<repo-hash>/receipts/`.
|
|
47
|
+
It creates nothing and reports each location present or absent. A single file is read with
|
|
48
|
+
`readReceiptFile(path)`.
|
|
49
|
+
|
|
50
|
+
A receipt file the loader cannot open at all is reported as a `receipt.unreadable` defect in
|
|
51
|
+
`load.defects` rather than losing the rest of the directory; `readReceiptFile`, given one path by
|
|
52
|
+
name, throws instead. Passing `sidecars: false` skips sidecar resolution and reports each sidecar
|
|
53
|
+
`unchecked` — never `intact`, since nothing about its stored bytes was established.
|
|
54
|
+
|
|
55
|
+
A segment of the shared history stream (§8) is read beside the receipts when a caller names one,
|
|
56
|
+
and never looked for otherwise, because the stream is opt-in and the format never requires it:
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
const load = loadReceipts({ cwd: "/work/site", history: ["/var/lib/parley/history/2026-11-22.jsonl"] });
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
A copy of a run on that stream may be a **projection** of the receipt copy, so where two copies of
|
|
63
|
+
one `(run, seq)` differ the loader returns the one from the source that carries no
|
|
64
|
+
`parley.history.transform` line for that run and records the other as a projection — by name, by
|
|
65
|
+
the digest of the transform's source text, and by which `seq` values it superseded or withheld.
|
|
66
|
+
`readHistorySegment(path)` reads one segment on its own. The rule, and the two edges it has, are
|
|
67
|
+
[the living reference](../../docs/topics/parley-read/README.md#the-least-projected-copy).
|
|
68
|
+
|
|
69
|
+
## A captured load
|
|
70
|
+
|
|
71
|
+
Two runs of the writer's own `count` example in one directory, then one `loadReceipts` over it, on
|
|
72
|
+
2026-11-22. The first run's receipt, five lines:
|
|
73
|
+
|
|
74
|
+
```jsonl
|
|
75
|
+
{"event":"receipt.head","t":1795387199029,"seq":1,"run":"01M82PN3HG54ZAZJSXV18T9Y8G","tool":"count","v":"0.1.0","argv":["count","files"],"resolved":{"command":"files","args":[]},"inputs":[{"path":"a.txt"}],"effects":{"reads":["<cwd>/*"],"writes":[],"network":false,"idempotent":true,"bookkeeping":[{"op":"create","scope":"/private/tmp/parley-read-readme.nJpgGP/work/.parley/receipts/"},{"op":"create","scope":"/private/tmp/parley-read-readme.nJpgGP/work/.parley/.gitignore"},{"op":"delete","scope":"/private/tmp/parley-read-readme.nJpgGP/work/.parley/receipts/"},{"op":"create","scope":"/private/tmp/parley-read-readme.nJpgGP/state/parley/07576214773c1613/receipts/"},{"op":"delete","scope":"/private/tmp/parley-read-readme.nJpgGP/state/parley/07576214773c1613/receipts/"}]},"_schema":{"id":"parley.receipt.head","version":"2.0.0"}}
|
|
76
|
+
{"event":"receipt.step","t":1795387199030,"seq":2,"run":"01M82PN3HG54ZAZJSXV18T9Y8G","decision":"counted 2 regular file(s)","because":"only regular files count","detail":{"n":1},"_schema":{"id":"parley.receipt.step","version":"1.0.0"}}
|
|
77
|
+
{"event":"result","t":1795387199030,"seq":3,"run":"01M82PN3HG54ZAZJSXV18T9Y8G","files":2,"_schema":{"id":"count.result","version":"1.0.0"}}
|
|
78
|
+
{"event":"receipt.inputs","t":1795387199030,"seq":4,"run":"01M82PN3HG54ZAZJSXV18T9Y8G","inputs":[{"path":"a.txt","sha256":"2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"}],"inv":"e6b8b0500dd5cf505567fdb26762bfad915e9dd5ac097d5c994814a6ebff4301","_schema":{"id":"parley.receipt.inputs","version":"1.0.0"}}
|
|
79
|
+
{"event":"end","t":1795387199030,"seq":5,"run":"01M82PN3HG54ZAZJSXV18T9Y8G","status":0,"receipt":"/private/tmp/parley-read-readme.nJpgGP/work/.parley/receipts/01M82PN3HG54ZAZJSXV18T9Y8G.jsonl","redacted":false,"_schema":{"id":"parley.end","version":"1.0.0"}}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
What the load returned. These blocks are fragments of a JavaScript value, not protocol messages,
|
|
83
|
+
so they carry no `_schema`; `load.locations` first — the state directory was never needed, so it
|
|
84
|
+
does not exist, and that is reported rather than treated as an error:
|
|
85
|
+
|
|
86
|
+
```json illustrative
|
|
87
|
+
[
|
|
88
|
+
{ "where": "repo", "dir": "/private/tmp/parley-read-readme.nJpgGP/work/.parley/receipts", "present": true },
|
|
89
|
+
{ "where": "state", "dir": "/private/tmp/parley-read-readme.nJpgGP/state/parley/07576214773c1613/receipts", "present": false }
|
|
90
|
+
]
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Then `load.bundles[0]`, with each record projected to its `seq`, `event` and validation state; a
|
|
94
|
+
real record also carries the file and line it was read from, how many copies carried it, whether
|
|
95
|
+
it came from a sidecar, and the record itself:
|
|
96
|
+
|
|
97
|
+
```json illustrative
|
|
98
|
+
{
|
|
99
|
+
"run": "01M82PN3HG54ZAZJSXV18T9Y8G",
|
|
100
|
+
"sources": [{ "where": "repo", "receipt": "/private/tmp/parley-read-readme.nJpgGP/work/.parley/receipts/01M82PN3HG54ZAZJSXV18T9Y8G.jsonl" }],
|
|
101
|
+
"records": [
|
|
102
|
+
{ "seq": 1, "event": "receipt.head", "validation": "validated" },
|
|
103
|
+
{ "seq": 2, "event": "receipt.step", "validation": "validated" },
|
|
104
|
+
{ "seq": 3, "event": "result", "validation": "unvalidated" },
|
|
105
|
+
{ "seq": 4, "event": "receipt.inputs", "validation": "validated" },
|
|
106
|
+
{ "seq": 5, "event": "end", "validation": "validated" }
|
|
107
|
+
],
|
|
108
|
+
"terminated": true,
|
|
109
|
+
"status": 0,
|
|
110
|
+
"redacted": false,
|
|
111
|
+
"replay": { "unavailable": false, "reasons": [] }
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
And `load.counts` over both runs:
|
|
116
|
+
|
|
117
|
+
```json illustrative
|
|
118
|
+
{ "bundles": 2, "records": 10, "validated": 8, "invalid": 0, "partial": 0, "unvalidated": 2, "quarantined": 0, "duplicates": 0 }
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
The `result` at `seq: 3` is `count.result`, a type this reader ships no schema for and must not
|
|
122
|
+
validate against another (§4.6), so it is returned and reported as unvalidated — two of them
|
|
123
|
+
across the two runs, which is where `counts.unvalidated` comes from. The four `parley.*` lines in
|
|
124
|
+
each receipt were validated against the schema for their exact advertised pair.
|
|
125
|
+
|
|
126
|
+
## A captured projection
|
|
127
|
+
|
|
128
|
+
The same `count` example once more, on 2026-11-22, with a transform on its history sink that
|
|
129
|
+
drops a step's `detail` and withholds the `result` altogether: the stream copy carries what ran,
|
|
130
|
+
not what the run looked at. The segment it appended to is named for the UTC day, so the file is
|
|
131
|
+
`2026-11-23.jsonl`. The receipt is untouched, and the stream copy opens by saying what it is:
|
|
132
|
+
|
|
133
|
+
```jsonl
|
|
134
|
+
{"event":"history.transform","t":1795392112424,"seq":1,"run":"01M82VB1S1W9PX56H9N0XZ4RTC","name":"what-ran","sha256":"1e40e80ba99445be0f933b8628c34eeef8883a28037a9998161af8b91dfcc00a","_schema":{"id":"parley.history.transform","version":"1.0.0"}}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
That line's `seq: 1` is the stream's alone, which is why this run's receipt starts at `seq: 2`. The
|
|
138
|
+
step at `seq: 4` is where the two copies part — the receipt's first, then the stream's:
|
|
139
|
+
|
|
140
|
+
```jsonl
|
|
141
|
+
{"event":"receipt.step","t":1795392112425,"seq":4,"run":"01M82VB1S1W9PX56H9N0XZ4RTC","decision":"counted 2 regular file(s)","because":"only regular files count","detail":{"names":["a.txt","b.txt"]},"_schema":{"id":"parley.receipt.step","version":"1.0.0"}}
|
|
142
|
+
{"event":"receipt.step","t":1795392112425,"seq":4,"run":"01M82VB1S1W9PX56H9N0XZ4RTC","decision":"counted 2 regular file(s)","because":"only regular files count","_schema":{"id":"parley.receipt.step","version":"1.0.0"}}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
One `loadReceipts` over the working directory, handed that segment, returns the receipt's bodies
|
|
146
|
+
and one note. A `Projection` is a fragment of a JavaScript value and not a protocol message, so it
|
|
147
|
+
carries no `_schema`:
|
|
148
|
+
|
|
149
|
+
```json illustrative
|
|
150
|
+
{
|
|
151
|
+
"file": "/var/folders/wt/s8clst9955x1l0qblsl4925w0000gn/T/parley-projection-3mcGOu/history/2026-11-23.jsonl",
|
|
152
|
+
"where": "history",
|
|
153
|
+
"name": "what-ran",
|
|
154
|
+
"sha256": "1e40e80ba99445be0f933b8628c34eeef8883a28037a9998161af8b91dfcc00a",
|
|
155
|
+
"seq": 1,
|
|
156
|
+
"superseded": [4],
|
|
157
|
+
"withheld": [5],
|
|
158
|
+
"sole": false
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
The six records it came back with, projected to what this page is about:
|
|
163
|
+
|
|
164
|
+
| `seq` | `event` | `copies` | `projected` | |
|
|
165
|
+
| --- | --- | --- | --- | --- |
|
|
166
|
+
| 1 | `history.transform` | 1 | yes | the stream's opening line, a record of its own, validated against `parley.history.transform` 1.0.0 |
|
|
167
|
+
| 2 | `receipt.head` | 2 | no | identical in both copies |
|
|
168
|
+
| 3 | `receipt.step` | 2 | no | the writer's own note that the stream copy is a projection, and which `seq` its opening line took |
|
|
169
|
+
| 4 | `receipt.step` | 2 | no | **the receipt's body, with its `detail`.** The stream's narrowed copy is superseded |
|
|
170
|
+
| 5 | `result` | 1 | no | withheld from the stream, so the receipt's copy is the only one there was |
|
|
171
|
+
| 6 | `end` | 2 | no | identical in both copies |
|
|
172
|
+
|
|
173
|
+
No defects. `superseded: [4]` and `withheld: [5]` say exactly what the projection did, and nothing
|
|
174
|
+
in the answer is a narrowed body.
|
|
175
|
+
|
|
176
|
+
## Making a read
|
|
177
|
+
|
|
178
|
+
A read states an `asker`, a `view` and a `window`. The first two are never inferred — §2.1 forbids
|
|
179
|
+
inventing an identity and there is no privileged view — so a read that cannot state them is
|
|
180
|
+
refused rather than answered under a guess. The shapes and the vocabulary are
|
|
181
|
+
[the reader representation](../../docs/topics/reader/README.md).
|
|
182
|
+
|
|
183
|
+
```ts
|
|
184
|
+
import { queryReceipts } from "@flyingrobots/parley-read";
|
|
185
|
+
|
|
186
|
+
const now = Date.now();
|
|
187
|
+
const outcome = await queryReceipts({
|
|
188
|
+
asker: { tool: "claude-code", cwd: "/work/site", task: "flyingrobots/parley#48" },
|
|
189
|
+
view: "what-ran",
|
|
190
|
+
window: { from: now - 86_400_000, to: now },
|
|
191
|
+
note: "what has run in this directory today",
|
|
192
|
+
}, { cwd: "/work/site" });
|
|
193
|
+
|
|
194
|
+
if (outcome.refused) for (const r of outcome.refusals) console.error(r.code, r.problem, r.remedy);
|
|
195
|
+
else console.log(outcome.records.length, "of", outcome.counts.inWindow, "—", outcome.digest.loss);
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
`asker.cwd` is inferred from the directory the read was made against when the caller states none,
|
|
199
|
+
and `asker.task` comes from the request; everything else is refused rather than guessed. A `cwd`
|
|
200
|
+
that is not absolute, an empty `task` and an empty `note` are refused too, rather than emitted as
|
|
201
|
+
a line that fails its own schema.
|
|
202
|
+
|
|
203
|
+
An accepted read is a run: it emits `parley.query` through
|
|
204
|
+
[`@flyingrobots/parley-emit`](../parley-emit/README.md) into a receipt beside the ones it read, so
|
|
205
|
+
the loader finds the question on the next read and a result can name the query it answers by
|
|
206
|
+
`(run, seq)`. A **refused** read is not a run and records nothing — no receipt, no `.parley`
|
|
207
|
+
directory, nothing written — because §9 records a question that was asked, and a question nobody
|
|
208
|
+
could state has no asker to attribute it to. Its refusals carry §6's fields, so a caller that is
|
|
209
|
+
itself a parley tool can hand one straight to `run.error`:
|
|
210
|
+
|
|
211
|
+
```json illustrative
|
|
212
|
+
{
|
|
213
|
+
"code": "query.view_missing",
|
|
214
|
+
"field": "view",
|
|
215
|
+
"problem": "the read states no view, and there is no privileged view to fall back on",
|
|
216
|
+
"remedy": "state one of: what-ran, what-failed, what-changed, how-it-decided, everything; a guessed view is a different answer to a different question, and the caller cannot see it",
|
|
217
|
+
"section": "§9"
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### What a read records, and what it applies
|
|
222
|
+
|
|
223
|
+
| Field | Recorded | Applied |
|
|
224
|
+
| --- | --- | --- |
|
|
225
|
+
| `asker` | Verbatim, `tool` required | Nothing branches on it: two askers asking the same thing get the same answer |
|
|
226
|
+
| `view` | Verbatim, one of five tokens | **The order.** It ranks the answer and filters none of it (below) |
|
|
227
|
+
| `budget` | Verbatim, defaulted to `{"records": 20}` and the answer says it defaulted | **The bound.** `records` bounds how many records the answer names; `bytes` bounds the digest's line; `ms` is a deadline for the whole read (below) |
|
|
228
|
+
| `window` | Verbatim, two timestamps inclusive at both ends | Yes: the answer is the records inside it, ordered by the view, with `(t, run, seq)` ascending as the last part of the key |
|
|
229
|
+
| `note` | Verbatim | Never parsed |
|
|
230
|
+
|
|
231
|
+
### The digest, and what it left out
|
|
232
|
+
|
|
233
|
+
The first response is a **`parley.lens` 1.0.0 record** — the message decided in
|
|
234
|
+
[flyingrobots/parley#46](https://github.com/flyingrobots/parley/issues/46), not a new one. It goes
|
|
235
|
+
through the writer onto the read's stream and into the read's receipt, so the digest is evidence
|
|
236
|
+
and the loader reads it back `validated` against that exact pair. It names the query it answers by
|
|
237
|
+
`(run, seq)`, the asker, the view, the window, the budget **actually applied**, the records it
|
|
238
|
+
holds by `(run, seq)` — the way back a drill-down needs — and the loss:
|
|
239
|
+
|
|
240
|
+
| Budget field | What it bounds |
|
|
241
|
+
| --- | --- |
|
|
242
|
+
| `records` (required) | **The count.** At most this many records are named, and `answer.records` holds exactly those |
|
|
243
|
+
| `bytes` (optional) | **The line.** The lens line as written, serialised JSON plus its newline in UTF-8, is at most this many bytes; records are dropped from the tail of the ranking until it fits |
|
|
244
|
+
| `ms` (optional) | **The whole read, as a deadline**, measured on `opts.clock` from the call and checked after the load, after the ranking and before the digest is written (flyingrobots/parley#71) |
|
|
245
|
+
|
|
246
|
+
`loss.excluded` is always there, zero included — an absent count and a count of zero are different
|
|
247
|
+
claims — and `loss.bound` is `none` only beside a count of 0, which the schema refuses to pair any
|
|
248
|
+
other way. So a digest that left something out says so structurally rather than in prose. What it
|
|
249
|
+
excluded is not returned by another route and is named by no id, so it is reached by reading again
|
|
250
|
+
under a wider budget, not by a drill-down. `counts.inWindow` and
|
|
251
|
+
the ranking's tier census still describe the whole window the digest was drawn from, so the caller
|
|
252
|
+
can see it is not the whole without being handed what it cut.
|
|
253
|
+
|
|
254
|
+
### A budget the read cannot meet
|
|
255
|
+
|
|
256
|
+
A read whose deadline passes at a check, or whose `budget.bytes` cannot hold even a digest naming
|
|
257
|
+
no records, **declines** (flyingrobots/parley#71). It is still a recorded run — its `parley.query`
|
|
258
|
+
is in its receipt — but it writes no lens: it never answers from a partial load, and never writes
|
|
259
|
+
a line over a stated bound. It reports one `parley.error`, code `query.over_budget`, whose
|
|
260
|
+
`detail` states the `bound` that declined, the `phase` it stopped at, the budget `given`, what was
|
|
261
|
+
`measured`, a budget that would have been `sufficient` where that is known (exactly, for bytes:
|
|
262
|
+
the size of the smallest digest) and the elapsed time as `at_least` when phases were still to run.
|
|
263
|
+
The run ends with status 2, and `queryReceipts` returns `{refused: false, declined: true, decline,
|
|
264
|
+
…}` rather than throwing:
|
|
265
|
+
|
|
266
|
+
```ts
|
|
267
|
+
const out = await queryReceipts(
|
|
268
|
+
{ asker: { tool: "my-agent" }, view: "what-failed", window: { from: 0, to: Date.now() }, budget: { records: 20, ms: 50 } },
|
|
269
|
+
{ cwd: process.cwd() },
|
|
270
|
+
);
|
|
271
|
+
if (!out.refused && out.declined) console.error(out.decline.problem, out.decline.sufficient, out.decline.atLeast);
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
The deadline is measured on `opts.clock`, monotonic by default and replaceable so a test can script
|
|
275
|
+
it. The full rules, and a captured decline, are in
|
|
276
|
+
[the reader page](../../docs/topics/parley-read/README.md#when-a-read-declines).
|
|
277
|
+
|
|
278
|
+
### The view orders the answer, and filters none of it
|
|
279
|
+
|
|
280
|
+
Spec §9: the purpose shapes the result, and it is the **ranking function** rather than a filter
|
|
281
|
+
applied afterwards. One total order on a key per record, compared left to right:
|
|
282
|
+
|
|
283
|
+
1. **the failure surface of the runs that failed**, when the view is an answer about a change — a
|
|
284
|
+
read made in order to change something is a read made in order not to repeat a failure. A
|
|
285
|
+
`warning` from a run that went on is not a failure (§6.1) and is placed by the view's own
|
|
286
|
+
surface instead;
|
|
287
|
+
2. **the view's own surface** — the records the view is about, above the records it is not;
|
|
288
|
+
3. **`(t, run, seq)` ascending** — so a view whose surface no record touches leaves the answer
|
|
289
|
+
exactly as it was.
|
|
290
|
+
|
|
291
|
+
Under a view that implies a change, a failed run's records also rank above an `undetermined` run's,
|
|
292
|
+
and those above a run known to have succeeded — within a tier, never across one.
|
|
293
|
+
|
|
294
|
+
`rankRecords(query, records)` is that order on its own: a pure function from an accepted query and
|
|
295
|
+
records to the same records, reordered. It reads nothing, writes nothing and records nothing, and
|
|
296
|
+
it **returns every record it was given** — over-filtering is the failure mode §9 warns about, so
|
|
297
|
+
nothing is dropped at any tier. The digest's bound is applied one step later, above the full
|
|
298
|
+
order, which is the only place a cut can state its own loss honestly. `answer.ranking` carries
|
|
299
|
+
each named record's `rank`, `tier`, `outcome` and the `why` behind them, and its per-run outcomes
|
|
300
|
+
and tier counts are over the whole window the digest was drawn from.
|
|
301
|
+
|
|
302
|
+
Which token implies a change is derived from the vocabulary rather than read from a field —
|
|
303
|
+
`parley.query` has none — and the surface each token names, the outcome rules and the whole
|
|
304
|
+
statement of the order are in
|
|
305
|
+
[the living reference](../../docs/topics/parley-read/README.md#how-the-purpose-orders-the-answer).
|
|
306
|
+
|
|
307
|
+
## A captured read
|
|
308
|
+
|
|
309
|
+
Two runs of the writer's own `count` example in one directory, then one `queryReceipts` over it
|
|
310
|
+
asking what ran in the last day, on 2026-11-22. The read's own receipt holds five lines; this is
|
|
311
|
+
the `query` event it recorded at `seq: 2`, as the receipt holds it:
|
|
312
|
+
|
|
313
|
+
```jsonl
|
|
314
|
+
{"event":"query","t":1795388936981,"seq":2,"run":"01M82RA4RCSBF4F4P9NHM8650K","asker":{"tool":"claude-code","cwd":"/tmp/parley-query-readme.4xkfaK/work","task":"flyingrobots/parley#48"},"view":"what-ran","budget":{"records":20},"window":{"from":1795302536970,"to":1795388936970},"note":"what has run in this directory today","_schema":{"id":"parley.query","version":"1.0.0"}}
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
What the read returned, whole. It is a fragment of a JavaScript value and not a protocol message,
|
|
318
|
+
so it carries no `_schema`, and each record is projected to the five fields a timeline reads; a
|
|
319
|
+
real record also carries the file and line it came from, how many copies carried it, whether it
|
|
320
|
+
came from a sidecar, and the record itself:
|
|
321
|
+
|
|
322
|
+
```json illustrative
|
|
323
|
+
{
|
|
324
|
+
"run": "01M82RA4RCSBF4F4P9NHM8650K",
|
|
325
|
+
"query": { "run": "01M82RA4RCSBF4F4P9NHM8650K", "seq": 2 },
|
|
326
|
+
"view": "what-ran",
|
|
327
|
+
"budget": { "records": 20 },
|
|
328
|
+
"budgetDefaulted": true,
|
|
329
|
+
"window": { "from": 1795302536970, "to": 1795388936970 },
|
|
330
|
+
"counts": { "scanned": 11, "inWindow": 8, "undated": 0, "own": 3 },
|
|
331
|
+
"records": [
|
|
332
|
+
{ "run": "01M82RA4PNDJDYZ51K4GFGK06D", "seq": 1, "event": "receipt.head", "t": 1795388936929, "validation": "validated" },
|
|
333
|
+
{ "run": "01M82RA4PNDJDYZ51K4GFGK06D", "seq": 2, "event": "receipt.step", "t": 1795388936929, "validation": "validated" },
|
|
334
|
+
{ "run": "01M82RA4PNDJDYZ51K4GFGK06D", "seq": 3, "event": "result", "t": 1795388936929, "validation": "unvalidated" },
|
|
335
|
+
{ "run": "01M82RA4PNDJDYZ51K4GFGK06D", "seq": 4, "event": "end", "t": 1795388936929, "validation": "validated" },
|
|
336
|
+
{ "run": "01M82RA4QYCB94DVW87TMBDBQE", "seq": 1, "event": "receipt.head", "t": 1795388936967, "validation": "validated" },
|
|
337
|
+
{ "run": "01M82RA4QYCB94DVW87TMBDBQE", "seq": 2, "event": "receipt.step", "t": 1795388936968, "validation": "validated" },
|
|
338
|
+
{ "run": "01M82RA4QYCB94DVW87TMBDBQE", "seq": 3, "event": "result", "t": 1795388936968, "validation": "unvalidated" },
|
|
339
|
+
{ "run": "01M82RA4QYCB94DVW87TMBDBQE", "seq": 4, "event": "end", "t": 1795388936968, "validation": "validated" }
|
|
340
|
+
]
|
|
341
|
+
}
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
Eight records in the window, from the two `count` runs, ascending by `t`. The two `result` lines
|
|
345
|
+
are `count.result`, a type this reader ships no schema for and must not validate against another
|
|
346
|
+
(§4.6), so they come back unvalidated — the same rule the loader follows.
|
|
347
|
+
|
|
348
|
+
`counts.own` is 3: the read's own head, its query and its first step, as they stood when it
|
|
349
|
+
loaded. They are not in the answer, because **a read does not answer itself**. The record of it is
|
|
350
|
+
there for the next read, which loads it as validated against the exact pair:
|
|
351
|
+
|
|
352
|
+
```json illustrative
|
|
353
|
+
{ "run": "01M82RA4RCSBF4F4P9NHM8650K", "seq": 2, "event": "query", "validation": { "state": "validated", "schema": { "id": "parley.query", "version": "1.0.0" } } }
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
## A captured ranking
|
|
357
|
+
|
|
358
|
+
Three runs of the same `count` example in one directory, on 2026-11-22: one that counted a file,
|
|
359
|
+
one that fell over a dangling symlink, and one that counted again after it was removed. Then one
|
|
360
|
+
read with `view: "what-changed"` — a purpose that implies a change — over the day's window. The
|
|
361
|
+
`query` event the read recorded, as its receipt holds it:
|
|
362
|
+
|
|
363
|
+
```jsonl
|
|
364
|
+
{"event":"query","t":1795390386268,"seq":2,"run":"01M82SPC2NKT5APEFXTY9TM1TN","asker":{"tool":"claude-code","cwd":"/tmp/parley-rank-readme.mHfg3V/work","task":"flyingrobots/parley#49"},"view":"what-changed","budget":{"records":20},"window":{"from":1795303986259,"to":1795390386259},"note":"about to change the counter; what has it done here","_schema":{"id":"parley.query","version":"1.0.0"}}
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
What came back, projected to the key each record was placed by. The ranks, runs, events,
|
|
368
|
+
timestamps, tiers and outcomes are that read's real values; the `why` of each record is abridged to
|
|
369
|
+
its first reason, and a real `ranked` entry carries the whole record beside them:
|
|
370
|
+
|
|
371
|
+
```json illustrative
|
|
372
|
+
{
|
|
373
|
+
"view": "what-changed",
|
|
374
|
+
"impliesChange": true,
|
|
375
|
+
"counts": { "scanned": 14, "inWindow": 11, "undated": 0, "own": 3 },
|
|
376
|
+
"tiers": { "failure": 2, "surface": 2, "other": 7, "failedRuns": 1, "undeterminedRuns": 0, "succeededRuns": 2 },
|
|
377
|
+
"ranked": [
|
|
378
|
+
{ "rank": 1, "run": "01M82SPC1B061PYZ3XQ32S7EGB", "seq": 2, "event": "error", "t": 1795390386227, "tier": "failure", "outcome": "failed", "why": "on the failure surface, and what-changed is an answer about a change" },
|
|
379
|
+
{ "rank": 2, "run": "01M82SPC1B061PYZ3XQ32S7EGB", "seq": 3, "event": "end", "t": 1795390386228, "tier": "failure", "outcome": "failed", "why": "on the failure surface, and what-changed is an answer about a change" },
|
|
380
|
+
{ "rank": 3, "run": "01M82SPC0C4E17JV4WMAPKR38Y", "seq": 3, "event": "result", "t": 1795390386196, "tier": "surface", "outcome": "succeeded", "why": "touches the what-changed surface" },
|
|
381
|
+
{ "rank": 4, "run": "01M82SPC2AP8XYAV1ZD8Y3GPSS", "seq": 3, "event": "result", "t": 1795390386258, "tier": "surface", "outcome": "succeeded", "why": "touches the what-changed surface" },
|
|
382
|
+
{ "rank": 5, "run": "01M82SPC1B061PYZ3XQ32S7EGB", "seq": 1, "event": "receipt.head", "t": 1795390386227, "tier": "other", "outcome": "failed", "why": "off the what-changed surface" },
|
|
383
|
+
{ "rank": 6, "run": "01M82SPC0C4E17JV4WMAPKR38Y", "seq": 1, "event": "receipt.head", "t": 1795390386196, "tier": "other", "outcome": "succeeded", "why": "off the what-changed surface" },
|
|
384
|
+
{ "rank": 7, "run": "01M82SPC0C4E17JV4WMAPKR38Y", "seq": 2, "event": "receipt.step", "t": 1795390386196, "tier": "other", "outcome": "succeeded", "why": "off the what-changed surface" },
|
|
385
|
+
{ "rank": 8, "run": "01M82SPC0C4E17JV4WMAPKR38Y", "seq": 4, "event": "end", "t": 1795390386197, "tier": "other", "outcome": "succeeded", "why": "off the what-changed surface" },
|
|
386
|
+
{ "rank": 9, "run": "01M82SPC2AP8XYAV1ZD8Y3GPSS", "seq": 1, "event": "receipt.head", "t": 1795390386257, "tier": "other", "outcome": "succeeded", "why": "off the what-changed surface" },
|
|
387
|
+
{ "rank": 10, "run": "01M82SPC2AP8XYAV1ZD8Y3GPSS", "seq": 2, "event": "receipt.step", "t": 1795390386258, "tier": "other", "outcome": "succeeded", "why": "off the what-changed surface" },
|
|
388
|
+
{ "rank": 11, "run": "01M82SPC2AP8XYAV1ZD8Y3GPSS", "seq": 4, "event": "end", "t": 1795390386258, "tier": "other", "outcome": "succeeded", "why": "off the what-changed surface" }
|
|
389
|
+
]
|
|
390
|
+
}
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
Four things in that order are the whole feature:
|
|
394
|
+
|
|
395
|
+
- **What failed is first.** The failing run's `error` and its status-2 `end` are ranks 1 and 2,
|
|
396
|
+
although two later runs succeeded after it. In time order they would have been buried.
|
|
397
|
+
- **What the view is about is next.** The two `count.result` records are the subject matter this
|
|
398
|
+
tool exists to produce (§7), so they rank above every head, step and `end` — including the heads
|
|
399
|
+
of their own runs.
|
|
400
|
+
- **Within a tier, a failed run still comes first.** Rank 5 is the failing run's head, at
|
|
401
|
+
`t: …386227`, above rank 6 at `t: …386196`, which is 31 ms earlier. Inside a tier the outcome key
|
|
402
|
+
outranks the clock — and only under a view that implies a change.
|
|
403
|
+
- **Nothing is hidden by the order.** Eleven records in the window, eleven ranked. Under
|
|
404
|
+
`view: "everything"` the same eleven come back in `(t, run, seq)` order: the view changed the
|
|
405
|
+
order and nothing else. What a *budget* cuts from that order is the digest's, below, and it says
|
|
406
|
+
so.
|
|
407
|
+
|
|
408
|
+
## A captured digest
|
|
409
|
+
|
|
410
|
+
Three runs of the same kind, made afresh, then one read with `budget: {"records": 4}` over the day's
|
|
411
|
+
window on 2026-11-22. The first and third runs are the same invocation with the same result, so the
|
|
412
|
+
digest names the third for both. Eleven records are in the window and the digest names four of
|
|
413
|
+
them, so it says `excluded: 7`, and `folded: 4` of those are the first run's.
|
|
414
|
+
These are the two lines that read's own receipt holds, byte for byte — `bun run check` validates
|
|
415
|
+
both against the shipped schemas:
|
|
416
|
+
|
|
417
|
+
```jsonl
|
|
418
|
+
{"event":"query","t":1795401942789,"seq":2,"run":"01M834Q1QWPS7W7F2HA0DAG6DA","asker":{"tool":"claude-code","cwd":"/var/folders/wt/s8clst9955x1l0qblsl4925w0000gn/T/parley-digest-readme.vtwlJT/work","task":"flyingrobots/parley#100"},"view":"what-changed","budget":{"records":4},"window":{"from":1795315542778,"to":1795401942778},"note":"about to change the counter; what has it done here","_schema":{"id":"parley.query","version":"1.0.0"}}
|
|
419
|
+
{"event":"lens","t":1795401942844,"seq":6,"run":"01M834Q1QWPS7W7F2HA0DAG6DA","query":{"run":"01M834Q1QWPS7W7F2HA0DAG6DA","seq":2},"asker":{"tool":"claude-code","cwd":"/var/folders/wt/s8clst9955x1l0qblsl4925w0000gn/T/parley-digest-readme.vtwlJT/work","task":"flyingrobots/parley#100"},"view":"what-changed","budget":{"records":4},"window":{"from":1795315542778,"to":1795401942778},"loss":{"bound":"count-only","excluded":7,"folded":4},"runs":[{"run":"01M834Q1KEMCBN373NYE1BV2BG","tool":"count","v":"0.1.0","argv":["count","files"],"resolved":{"command":"files","args":[]},"inv":"638c446f866624d00aed41b516d92549f87b0197871ae5db312b7edaa8051a16","outcome":"failed"},{"run":"01M834Q1QFYZZ3CMXZ0SKE600Z","tool":"count","v":"0.1.0","argv":["count","files"],"resolved":{"command":"files","args":[]},"inv":"638c446f866624d00aed41b516d92549f87b0197871ae5db312b7edaa8051a16","outcome":"succeeded","folded":{"others":1,"records":4}}],"records":[{"run":"01M834Q1KEMCBN373NYE1BV2BG","seq":2,"event":"error","t":1795401942649,"code":"uncaught.exception"},{"run":"01M834Q1KEMCBN373NYE1BV2BG","seq":3,"event":"end","t":1795401942649},{"run":"01M834Q1QFYZZ3CMXZ0SKE600Z","seq":3,"event":"result","t":1795401942776},{"run":"01M834Q1KEMCBN373NYE1BV2BG","seq":1,"event":"receipt.head","t":1795401942647}],"_schema":{"id":"parley.lens","version":"1.0.0"}}
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
That line is 1,336 bytes. Seven things in it are the whole feature:
|
|
423
|
+
|
|
424
|
+
- **It names the four best-ranked records of what it may name**, and nothing else: the failing
|
|
425
|
+
run's `error` and status-2 `end` first, then the successful run's `count.result`, then the
|
|
426
|
+
failing run's head. The bound cut the tail of the order flyingrobots/parley#49 produced, not a
|
|
427
|
+
selection made some other way.
|
|
428
|
+
- **It says what that cost**, as a count: `excluded: 7`. The count is present at zero too, because
|
|
429
|
+
an absent count and a count of zero are different claims.
|
|
430
|
+
- **It cannot read as complete.** `loss.bound` is `count-only`; `none` is only valid beside a
|
|
431
|
+
count of 0, and the schema refuses the other pairing.
|
|
432
|
+
- **It is the way back.** Each named record is a `(run, seq)` pair, so a drill-down fetches records
|
|
433
|
+
rather than re-deriving them from a result — see [opening what a digest names](#opening-what-a-digest-names).
|
|
434
|
+
- **Each name says what it is.** Beside its `(run, seq)`, every entry carries the record's
|
|
435
|
+
`event` and its `t`, and an `error` its `code`, so a reader sees an `uncaught.exception`
|
|
436
|
+
error, an `end`, a `result` and a head without opening any of them (flyingrobots/parley#77). The
|
|
437
|
+
summary is read off the loaded record.
|
|
438
|
+
- **Each run is said once.** `runs` holds one section per run the entries name: the head's
|
|
439
|
+
`tool`, `v`, `argv`, `resolved` and `inv`, and the run's `outcome` over the whole window, so the first
|
|
440
|
+
section reads as `count files` that `failed` and the second as the same invocation that
|
|
441
|
+
`succeeded` (flyingrobots/parley#83). `resolved` is the head's interpretation, whole:
|
|
442
|
+
`{"command":"files","args":[]}` here, and for a tool that resolves `HEAD~1..HEAD` the two
|
|
443
|
+
commits it compared (flyingrobots/parley#90). Like the summary, it counts against `budget.bytes`.
|
|
444
|
+
- **A repeat is said once too.** The two runs that `succeeded` share an `inv` and a result, so the
|
|
445
|
+
second section stands for both: `folded: {"others": 1, "records": 4}`, this run and one other
|
|
446
|
+
like it whose 4 records are not named (flyingrobots/parley#100), and `loss.folded` says 4 of
|
|
447
|
+
the 7 excluded were left out by that fold rather than by the budget (flyingrobots/parley#79). The
|
|
448
|
+
failed run shares the `inv` and not the result, so it is never folded into them. See
|
|
449
|
+
[runs of one invocation](../../docs/topics/parley-read/README.md#runs-of-one-invocation-are-named-once).
|
|
450
|
+
|
|
451
|
+
## Opening what a digest names
|
|
452
|
+
|
|
453
|
+
`openRecords` takes the `(run, seq)` pairs a lens carries and answers with one outcome per id, in
|
|
454
|
+
the order asked:
|
|
455
|
+
|
|
456
|
+
```ts
|
|
457
|
+
const read = await queryReceipts({ asker: { tool: "claude-code" }, view: "what-failed", window }, { cwd });
|
|
458
|
+
if (read.refused) throw new Error(read.refusals.map((r) => r.code).join(", "));
|
|
459
|
+
const opened = await openRecords(
|
|
460
|
+
{ asker: { tool: "claude-code" }, view: read.view, window: read.window, records: read.digest.records },
|
|
461
|
+
{ cwd },
|
|
462
|
+
);
|
|
463
|
+
if (opened.refused) throw new Error(opened.refusals.map((r) => r.code).join(", "));
|
|
464
|
+
for (const o of opened.opened) console.log(o.outcome, o.record?.record, o.bundle?.replay);
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
| Outcome | Means |
|
|
468
|
+
| --- | --- |
|
|
469
|
+
| `opened` | The record, in full. A record stored in a sidecar comes back with its contents, checked against the declared `sha256`; opening the `sidecar` event itself brings the record it holds as `held` |
|
|
470
|
+
| `over_budget` | Only under `budget.bytes`: the record would pass the bound, so its size is named in `bytes` and no part of it is returned |
|
|
471
|
+
| `sidecar_unavailable` | The sidecar's stored bytes are missing, mismatched, unreadable or unchecked: the pointer is returned and the contents are not claimed |
|
|
472
|
+
| `run_not_found`, `seq_not_found` | Which half of the id did not resolve, with a remedy |
|
|
473
|
+
|
|
474
|
+
Every id whose run resolved carries the loader's replay ruling, so the `error` of a failed run
|
|
475
|
+
opens and says its bundle is unavailable for replay. A drill-down is recorded as a `parley.query`
|
|
476
|
+
carrying `records`, so the next reader can see what was opened; it is refused without an asker, a
|
|
477
|
+
view, a window and at least one id, and then writes nothing.
|
|
478
|
+
|
|
479
|
+
A drill-down may state `budget: { bytes }`. Records open whole, in the order asked, while their
|
|
480
|
+
summed size (UTF-8 bytes of each record's JSON as returned, sidecar contents included) stays within
|
|
481
|
+
the bound; each later id is judged against what remains, so a small record after an over-budget one
|
|
482
|
+
may still open. Every id past the bound is `over_budget` with its size and no contents, never a
|
|
483
|
+
truncated record. Not-found and `sidecar_unavailable` outcomes cost nothing. The recorded
|
|
484
|
+
`parley.query` carries the bound applied. The full rules are in
|
|
485
|
+
[the reader page](../../docs/topics/parley-read/README.md#a-byte-bound).
|
|
486
|
+
|
|
487
|
+
It may also state `budget: { ms }`, the same deadline a read has, checked after the load and after
|
|
488
|
+
the ids are opened; a drill-down past it declines as a read does and opens nothing
|
|
489
|
+
([the reader page](../../docs/topics/parley-read/README.md#a-deadline)).
|
|
490
|
+
|
|
491
|
+
## Surface
|
|
492
|
+
|
|
493
|
+
| Export | Job |
|
|
494
|
+
| --- | --- |
|
|
495
|
+
| `loadReceipts(opts)` | Every run in both receipt locations for a working directory, as bundles |
|
|
496
|
+
| `queryReceipts(request, opts)` | A read: refused without an asker, a view and a window, else recorded as a `parley.query` event and answered with a `parley.lens` digest — the window's records ordered by the view, cut at the budget, and the count the cut left out — or declined with `query.over_budget` when the budget cannot be met |
|
|
497
|
+
| `openRecords(request, opts)`, `planOpen(request)`, `openOne(id, bundles)` | The drill-down: records by `(run, seq)`, one outcome per id, recorded as a `parley.query` carrying `records`; its refusal rules as a pure function; one id resolved against loaded bundles |
|
|
498
|
+
| `planQuery(request)`, `queryRecord(query)` | The refusal rules and the recorded payload, without any reading or writing |
|
|
499
|
+
| `rankRecords(query, records)` | The view's order over records, pure: the same records reordered, never a subset |
|
|
500
|
+
| `digestFor(query, answers, ranked, envelope, outcomes?)` | The bound over that order, pure: the digest's payload, the records it names, the count it excluded and how many of those it `folded`, the bytes its line takes and whether it `fits` a stated byte bound at all |
|
|
501
|
+
| `foldRuns(ranked, outcomes?)` | The fold `digestFor` applies first, pure: runs of one invocation with one result named by the most recent of them |
|
|
502
|
+
| `sufficientBytes(query, answers, total, envelope, folded?)` | The smallest `budget.bytes` that holds a digest naming no records, which a byte decline names |
|
|
503
|
+
| `Deadline`, `MONOTONIC`, `OVER_BUDGET`, `declineOnRun(run, budget, phase, last, over)` | The deadline `budget.ms` is checked against, the default clock, the decline code, and the step and error a decline reports on its run |
|
|
504
|
+
| `digestLine`, `digestBytes` | The line the writer will write for a digest, and its length in UTF-8 bytes |
|
|
505
|
+
| `runOutcomes`, `onViewSurface`, `onFailureSurface`, `impliesChange`, `TIERS`, `OUTCOMES`, `CHANGE_VIEWS` | The parts of that order, each answerable on its own |
|
|
506
|
+
| `VIEWS`, `DEFAULT_BUDGET`, `QUERY_SCHEMA`, `LENS_SCHEMA`, `NO_RETENTION` | The five view tokens, the one documented budget default, the two pairs a read emits, and the retention policy a read states |
|
|
507
|
+
| `readReceiptFile(path, opts)` | One receipt file; a file holding more than one run yields one bundle per run |
|
|
508
|
+
| `readHistorySegment(path, opts)` | One segment of the shared stream (§8), the same way; a copy in it may be a projection of the receipt copy |
|
|
509
|
+
| `receiptLocations(opts)`, `repoReceiptDir`, `stateReceiptDir` | Where receipts are, present or absent; creates nothing |
|
|
510
|
+
| `LineBuffer`, `splitLines`, `readFileLines` | Newline buffering: bytes in, complete lines out, the unterminated tail kept apart (§1.4, §5.4) |
|
|
511
|
+
| `validator(schemas?)`, `schemaRef`, `envelopeGaps` | Exact-pair validation and the version-independent core (§4.5, §4.6) |
|
|
512
|
+
| `SCHEMAS`, `SCHEMA_SOURCE` | The seventeen schemas this reader ships, the released versions of spec `0.2.0`'s release, with the commit and digest of each |
|
|
513
|
+
| `QUARANTINE_CODES` | Which defect codes are a kept line rather than a judgement about a record |
|
|
514
|
+
|
|
515
|
+
## What a load says, rule by rule
|
|
516
|
+
|
|
517
|
+
| It reports | Because |
|
|
518
|
+
| --- | --- |
|
|
519
|
+
| Both locations, present or absent | §5: the writer falls back to the state directory, so a reader that looks in one place sees half the history |
|
|
520
|
+
| Records in `seq` order, one per `(run, seq)` | §1.3: a run holds one counter, and copies of one event are one event |
|
|
521
|
+
| A copy's extra fields folded in, a disagreement as a defect | §1.3: a copy may carry fields another omits, but copies must agree on every field they share |
|
|
522
|
+
| The copy from the source with no transform line for the run, and the other as a `Projection` | §8: the receipt copy is the record and a projection is a view of it, so a reader prefers the least-projected copy it can see — and says what the other one was, and which `seq` it withheld |
|
|
523
|
+
| A stray line quarantined, kept, attributed to the run | §1.4: kept and reported, and evidence of nothing but the fact that something wrote it |
|
|
524
|
+
| An unterminated final line ignored, including a parseable `end` | §5.4: it is not a line, so it cannot establish termination |
|
|
525
|
+
| `validated`, `invalid`, `partial`, `unvalidated` per record | §4.5: full validation is against the exact pair, and "the part I recognise passed" is never "the contract passed" |
|
|
526
|
+
| A sidecar's bytes checked against `bytes` and `sha256`, and the record restored | §5: a sidecar stands in a record's place, and its path must not leave the bundle |
|
|
527
|
+
| `replay.unavailable` with its reasons | §5, §5.3, §5.4: a broken sidecar, no terminated `end`, a non-zero status or a redacted receipt each rule replay out |
|
|
528
|
+
|
|
529
|
+
`replay.unavailable: false` means only that nothing in the bundle rules replay out. Eligibility
|
|
530
|
+
under §2.3 and §5.3 for the invocation at hand — whether that invocation supplied a declared
|
|
531
|
+
secret, whether its `inv` matches — is the caller's to decide, and this reader does not know it.
|
|
532
|
+
|
|
533
|
+
## What it does not do
|
|
534
|
+
|
|
535
|
+
- Project. The records a digest names come back whole; no view reduces one to fewer fields
|
|
536
|
+
(flyingrobots/parley#59).
|
|
537
|
+
- Hand back what the bound excluded. The digest states the count and names only what it kept, so
|
|
538
|
+
the drill-down opens those; the excluded tail is a wider read.
|
|
539
|
+
- Interrupt a phase. `budget.ms` is checked between the load, the ranking and the digest, so a
|
|
540
|
+
slow load is discovered when it finishes and the read then declines; it never answers from part
|
|
541
|
+
of the history (flyingrobots/parley#71).
|
|
542
|
+
- Apply a transform at read time. It prefers the least-projected copy it can see and names the
|
|
543
|
+
projection it passed over; re-projecting a record for an asker is
|
|
544
|
+
flyingrobots/parley#59's.
|
|
545
|
+
- Recompute `inv` or any semantic digest (§7.1). It checks a sidecar's stored bytes against the
|
|
546
|
+
digest the receipt declared, and nothing else.
|
|
547
|
+
- Judge conformance. The doctor under `scripts/` names violated rules; this is a loader, and a
|
|
548
|
+
defect it reports is what it could not read or could not validate.
|
|
549
|
+
- Write, create or repair anything. Locating a location does not create it.
|
|
550
|
+
- Windows paths. v0.2 of the spec is POSIX-only.
|
|
551
|
+
|
|
552
|
+
## Checks
|
|
553
|
+
|
|
554
|
+
```bash
|
|
555
|
+
bun test # root: this package's suite runs with the repository's
|
|
556
|
+
bun run typecheck # strict TypeScript over src, scripts and test
|
|
557
|
+
bun run check # every JSON example, this README included
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
The contract ledger is [docs/topics/parley-read/test-plan.md](../../docs/topics/parley-read/test-plan.md);
|
|
561
|
+
the living reference is [docs/topics/parley-read](../../docs/topics/parley-read/README.md).
|
package/package.json
CHANGED
|
@@ -1,6 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flyingrobots/parley-read",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A reader for the Parley output protocol: opens a repository's receipt bundles under the reader rules of the spec.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./src/index.ts",
|
|
8
|
+
"types": "./src/index.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./src/index.ts"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"src",
|
|
14
|
+
"README.md",
|
|
15
|
+
"CHANGELOG.md",
|
|
16
|
+
"LICENSE",
|
|
17
|
+
"NOTICE"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"test": "bun test",
|
|
21
|
+
"sync-schemas": "bun run scripts/sync-schemas.ts"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@flyingrobots/parley-emit": "^0.2.0",
|
|
25
|
+
"ajv": "^8.17.1",
|
|
26
|
+
"ajv-formats": "^3.0.1"
|
|
27
|
+
},
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git+https://github.com/flyingrobots/parley.git",
|
|
31
|
+
"directory": "packages/parley-read"
|
|
32
|
+
},
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public",
|
|
35
|
+
"registry": "https://registry.npmjs.org/"
|
|
36
|
+
},
|
|
37
|
+
"author": "James Ross",
|
|
38
|
+
"engines": {
|
|
39
|
+
"bun": ">=1.2"
|
|
40
|
+
}
|
|
41
|
+
}
|