@flyingrobots/parley-emit 0.1.0 → 0.2.4

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 CHANGED
@@ -5,6 +5,301 @@ on its own; the spec and each message schema move separately (spec §4.4).
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [0.2.4] — 2026-11-23
9
+
10
+ No change to the library or the schemas it ships.
11
+
12
+ ### Fixed
13
+
14
+ - The release workflow's `sanity` job installs the pinned Wesley, as the checks workflow does. The
15
+ suite fails under CI without it (flyingrobots/parley#118), so the `parley-emit-v0.2.3` tag
16
+ stopped at `sanity` and nothing was released or staged. This is the first version staged on npm.
17
+
18
+ ## [0.2.3] — 2026-11-23
19
+
20
+ No change to the library or the schemas it ships. This version exists so that a tag carries the
21
+ new release workflow.
22
+
23
+ ### Changed
24
+
25
+ - **Releases are staged, then approved by the owner** (flyingrobots/parley#85). The release
26
+ workflow runs `npm stage publish` in place of `npm publish`: the npm trusted publisher is allowed
27
+ to stage and nothing else, and a version becomes installable only when the owner approves it with
28
+ two-factor authentication. 0.2.0, 0.2.1 and 0.2.2 never reached npm for that reason.
29
+
30
+ ## [0.2.2] — 2026-11-22
31
+
32
+ Retention's rule for a receipt that may still be being written is now the spec's (§5.1,
33
+ flyingrobots/parley#112). The behaviour and the schemas it ships are unchanged.
34
+
35
+ ### Changed
36
+
37
+ - **No lock protocol: an incomplete receipt is exempt from retention until it has gone unmodified
38
+ for 24 hours.** This is the decision on flyingrobots/parley#112. A receipt whose last line is not
39
+ `end` is kept, and a complete receipt is deleted in its place. Past 24 hours with no write, its
40
+ run is treated as crashed. A complete receipt cannot be appended to (§3.3), so deleting it races
41
+ no writer. The window that remains is accepted: a run silent for over a day that appends while
42
+ retention deletes its receipt loses it. New injected-clock tests pin each case (PE-16d to PE-16f).
43
+
44
+ ## [0.2.1] — 2026-11-22
45
+
46
+ Fixes for findings raised on the vendored Python writer in flyingrobots/taskalisk#71 that hold for
47
+ this writer too. The schemas it ships are unchanged.
48
+
49
+ ### Added
50
+
51
+ - **`run.inputUnreadable(path, code?)`** (flyingrobots/parley#110). It records that the program
52
+ could not read a declared input, as `{"path", "error": "input.unreadable"}` with no digest, so
53
+ `inv` is omitted as spec §2.2 requires. Before this, the writer read the path itself at
54
+ finalisation, so a file that appeared after the program failed to read it got a digest and an
55
+ `inv` for bytes the program never saw. It throws for a path that is not a declared input and
56
+ after the inputs are settled; `run.input` after it supplies bytes again.
57
+
58
+ ### Fixed
59
+
60
+ - **A `.parley/.gitignore` negation that can re-include `receipts/` sends the receipt to the state
61
+ directory** (flyingrobots/parley#109, spec §5.2). A file of `*`, `!receipts/` and `!receipts/**`
62
+ used to be accepted, and its receipts were left where `git add` stages them. The
63
+ `receipt.relocated` warning names the negation. A pattern the check cannot evaluate (an inner
64
+ `/`, a backslash) is taken to match, and a negation that cannot match, such as `!keep`, still
65
+ stores in the repository.
66
+ - **`--schema` and `--help` publish schema documents as declared** (flyingrobots/parley#111, spec
67
+ §5.3). A declared secret whose value occurred in a document, such as `object`, used to rewrite it
68
+ (`"type": "[redacted]"`) under the original `id` and `version`. Every other discovery field is
69
+ still scrubbed.
70
+ - **Retention re-reads a receipt's age at the decision** (flyingrobots/parley#112). It used the
71
+ mtime from the directory scan, so a receipt silent for over a day whose run appended after the
72
+ scan could be deleted. The writer now skips the unlink when the receipt's size or mtime moved
73
+ since the decision. This narrows the window without closing it; the issue stays open for a lock.
74
+
75
+ ## [0.2.0] — 2026-11-22
76
+
77
+ The schemas this version ships are the released versions of the repository's first schema release,
78
+ spec `0.2.0` in the root `CHANGELOG.md`, byte for byte (`src/schemas.ts` records the commit and
79
+ each digest); no schema version is released by this package release (spec §4.5).
80
+
81
+ **Upgrading from 0.1.0**, the three changes marked BREAKING below, in brief: the command is now
82
+ the first argument once the writer's flags are set aside, so a flag before the command is
83
+ `startup.unknown_command`; `--` now ends the writer's flags and is removed; and `<command> --help`
84
+ now lists `parley.startup.failed@1.0.0` beside `parley.error@2.0.0`.
85
+
86
+ ### Changed
87
+
88
+ - **BREAKING for a caller that puts a writer flag after `--`: `--` now ends the writer's flags**
89
+ (flyingrobots/parley#103). The writer used to remove every argument equal to one of its own
90
+ flags (`--human`, `--humanize`, `--dry-run`, `--schema`, `--help`, `-h`) wherever it stood, so a
91
+ tool flag whose value had one of those texts lost it and switched the writer's behaviour
92
+ (`edit --note -h` became `--help` discovery and the tool never saw `-h`). Now the writer's flags
93
+ are recognised only before the first `--`; that `--` is removed and every argument after it
94
+ reaches `resolved`, `inputs` and the handler untouched, so `edit -- --note -h` gives the tool
95
+ `["--note", "-h"]`. Before a `--` nothing changes: `edit --note -h` is still discovery, by a
96
+ stated rule. A `--` used to reach the tool; the first one no longer does, and `edit -- --dry-run`
97
+ is no longer a dry run. Nothing after `--` is ever the command. The Python writer follows the
98
+ same rule.
99
+ - **BREAKING for a caller that names a flag before the command: the command is now the first
100
+ argument once the writer's flags are set aside, and only that one argument is removed**
101
+ (flyingrobots/parley#101). The writer used to take the first argument anywhere that named a
102
+ command and remove every argument with the command's text, so a flag value equal to a command
103
+ name was lost (`edit --reason edit` gave the tool `["--reason"]`) or chosen as the command
104
+ (`--reason plan edit` ran `plan`). Now `edit --reason edit` gives `["--reason", "edit"]`, and in
105
+ a tool with more than one command a first argument that names none is
106
+ `startup.unknown_command`, exit 3, so `--verbose edit` must be written `edit --verbose`. The
107
+ writer's own flags are still recognised anywhere before the first `--` (flyingrobots/parley#103).
108
+ A tool with one command may still omit its name. The Python writer follows the same rule.
109
+ - **BREAKING for a consumer that pins its discovery output: `<command> --help` now lists
110
+ `parley.startup.failed@1.0.0` beside `parley.error@2.0.0`** (flyingrobots/parley#92, spec §4.2).
111
+ A command that declares no `errors` now has the default `[parley.error, parley.startup.failed]`,
112
+ so its `command` line's `emits` and its `schema` lines gain one entry each, after
113
+ `parley.error`. Every command can produce a startup failure, and §4.2 asks `--help` for every
114
+ error type a call can produce. The Python writer already did this. `--schema` already listed the
115
+ type and is unchanged. A command that declares `errors` still replaces the default, so name both
116
+ types in that list. No line shape and no schema version moved, but a test that pins the exact
117
+ list of `--help` schemas, as `flyingrobots/footprint`'s OUT-10b does, fails on upgrade until its
118
+ expectation gains the new entry.
119
+ - `examples/count.ts` checks its arguments in `resolved`, before the bootstrap line, so an argument
120
+ it does not take is `startup.arguments_invalid`, exit 3, with no receipt. This is the spec's
121
+ preferred side of the boundary decided on flyingrobots/parley#91 (§3.2), and it is what
122
+ `count.py` does. A call with no arguments resolves exactly as before, so its `inv` is unchanged.
123
+ - `src/schemas.ts` re-synced for a change to the draft `parley.lens` 1.0.0: an optional `runs`
124
+ section, and `code` in place of `outcome` on each named record (flyingrobots/parley#83). The
125
+ writer's behaviour is unchanged and no version moved; discovery serves the updated draft.
126
+ - `src/schemas.ts` re-synced for a change to the draft `parley.lens` 1.0.0: optional `event`, `t`
127
+ and `outcome` on each named record (flyingrobots/parley#77). The writer's behaviour is unchanged
128
+ and no version moved; discovery serves the updated draft.
129
+ - `src/schemas.ts` re-synced for a change to the draft `parley.query` 1.0.0: an optional `records`
130
+ field for a drill-down (flyingrobots/parley#51). The writer's behaviour is unchanged and no
131
+ version moved; discovery serves the updated draft.
132
+
133
+ - The `code` of a diagnostic **the writer itself raises** is no longer scrubbed. It is the
134
+ writer's own stable identifier, like a schema id or a command's name, and replacing part of it
135
+ put a line on the stream that no longer validated against `parley.warning` or `parley.error` —
136
+ which is the one thing redaction must not do. `receipt.relocated`, `human.renderer_failed`,
137
+ `sink.write_failed`, `sink.sidecar_failed` and the two `history.*` warnings are affected; a
138
+ tool's own `run.warning` and `run.error` are not writer-built and their `code` is scrubbed
139
+ exactly as before. `startup.failed` already behaved this way, scrubbing only its `problem`.
140
+ Found by review of flyingrobots/parley#3, where a secret that is a substring of `history`
141
+ reached it. (flyingrobots/parley#3)
142
+
143
+ - `src/schemas.ts` re-synced from the repository drafts: the package now ships sixteen, adding
144
+ `parley.query` 1.0.0 and `parley.lens` 1.0.0 for the reader's query record and result lens
145
+ (flyingrobots/parley#46). `--schema` serves the drafts at the newly pinned commit; this moves no
146
+ schema version and no package version of its own (spec §4.5).
147
+
148
+ ### Fixed
149
+
150
+ - Retention counts and expires only this tool's receipts (flyingrobots/parley#75): a bundle is
151
+ this tool's when its first line is a `receipt.head` naming it. Other tools' receipts, a
152
+ reader's included, are never counted or deleted, and an unreadable or headless file is left
153
+ alone. Behaviour change for a directory shared with a reader: the tool now keeps `count` of its
154
+ own receipts rather than `count` in all. The decision's text says "of this tool's receipts".
155
+
156
+ ### Added
157
+
158
+ - **A built-in that refuses a suspected secret** (flyingrobots/parley#60). `refuseSuspectedSecrets(patterns?)`
159
+ is a history transform that withholds any line whose body matches one of ten documented token
160
+ shapes, and raises one `history.suspected_secret` warning naming the withheld `seq`, the shape
161
+ and a JSON Pointer — never the matched text.
162
+
163
+ ```ts
164
+ await main(tool, argv, handler, { history: { transform: refuseSuspectedSecrets() } });
165
+ ```
166
+
167
+ It refuses; it never rewrites. A false positive costs one withheld stream line and never a
168
+ changed value in the receipt. The shapes ship as data in `src/transforms/secret-patterns.ts`,
169
+ each with a name, a regex source and one line of rationale: AWS access key ids, GitHub tokens of
170
+ six prefixes, GitHub fine-grained PATs, Slack tokens, Google API keys, PEM private-key headers,
171
+ JWTs, `Bearer` values, npm tokens and Stripe live keys. Every one is anchored and length-bounded,
172
+ every one has a positive and a negative sample, and the test walks the shipped list, so a new
173
+ entry without samples fails. String values are scanned recursively; the five envelope fields are
174
+ not, and neither are object keys. The limits are stated in the README: an unlisted shape passes,
175
+ a token split across two values passes, a token used as a key passes, and a legitimate value that
176
+ matches is withheld. The head is not exempt and is the likeliest line to match, because it echoes
177
+ `argv` and `resolved` (§5): an undeclared token on the command line withholds the whole head, so
178
+ that stream copy has no head and the gap is reported like any other. The warning names a JSON
179
+ Pointer only when the pointer does not itself match a shape, since a pointer is built from the
180
+ record's keys and a key can be a token too. The exit status never moves (§6.1).
181
+
182
+ New exports: `refuseSuspectedSecrets`, `findSuspectedSecret`, `SUSPECTED_SECRET_CODE`,
183
+ `SECRET_PATTERNS`, the types `SecretPattern` and `SuspectedSecret`.
184
+
185
+ - **A transform may refuse, not only withhold** (flyingrobots/parley#60). `refuse(code, problem, remedy?)`
186
+ returns a typed refusal: the writer withholds the line and raises one warning carrying that
187
+ `code`, `problem` and `remedy`, on stderr and in the receipt, leaving the exit status alone. The
188
+ four enforcement rules of flyingrobots/parley#57 are unchanged, and the writer still owns the
189
+ namespace: a `code` that is not spec §6's shape, or an empty `problem`, is
190
+ `history.transform_failed`, and a `code` carrying a declared secret value is
191
+ `history.transform_unredacted`, because a diagnostic's `code` is the one string §5.3 does not
192
+ scrub. `HistoryTransform` widens to allow a `HistoryRefusal` return; returning a record or
193
+ nothing behaves exactly as before. New exports: `refuse`, `isHistoryRefusal` and the type
194
+ `HistoryRefusal`.
195
+
196
+ - **A user-defined transform on the history sink** (flyingrobots/parley#57). The stream copy of a
197
+ run can be a projection of the receipt copy rather than the whole of it. Configure it in code:
198
+
199
+ ```ts
200
+ await main(tool, argv, handler, { history: { transform, name: "drop-step-detail" } });
201
+ ```
202
+
203
+ `MainOptions.history` now takes a sink, `null`, or `{ sink?, transform?, name? }`; the two older
204
+ forms behave exactly as before. The transform is handed the parsed record the receipt already
205
+ holds — redacted, as §5.3 left it — and returns a record to put on the stream or nothing to
206
+ withhold the line. There is no environment variable naming a module to execute, deliberately.
207
+
208
+ The writer enforces the contract around it, so nothing the transform does can put an invalid
209
+ line or a changed envelope on the shared timeline: `event`, `t`, `seq`, `run` and `_schema` are
210
+ taken off whatever it returns and the receipt line's are put back (§1.3); the returned body is
211
+ re-validated against the schema for its exact advertised pair (§4.5), this package's drafts plus
212
+ the schema the tool declared on the emitted or error type (§4.2); and four conditions withhold
213
+ the line and raise one warning naming the withheld `seq`, on stderr and in the receipt, without
214
+ touching the exit status (§6.1): `history.transform_failed` (it threw),
215
+ `history.transform_invalid` (the body no longer validates), `history.transform_unredacted` (the
216
+ body carries a declared secret value the writer had already replaced) and
217
+ `history.transform_uncheckable` (no schema document for the exact pair, or one outside the
218
+ subset the checker implements).
219
+
220
+ The stream copy of a projected run opens with a **`parley.history.transform` 1.0.0** line naming
221
+ the transform and the SHA-256 of its source text as the runtime renders it. It reaches the
222
+ stream alone, so it takes a `seq` the receipt has no line at, and the receipt accounts for that
223
+ gap as a `receipt.step`. A run with no transform configured has no opening line, no step and no
224
+ difference in any byte; a transform with no stream configured is equally inert.
225
+
226
+ New: `src/check.ts` with `checkRecord` and `schemaSubsetGap`, a bounded JSON Schema checker — this package has no
227
+ runtime dependencies, so re-validation is implemented here for the constructs the protocol's own
228
+ schemas use, and it reports a keyword it does not implement instead of ignoring it. The subset
229
+ check walks the whole schema document before any record is checked, so a construct nested under
230
+ a property that record happens not to carry cannot slip past; a test asserts every shipped draft
231
+ is inside the subset. New exports from `src/history.ts`:
232
+ `historyProjection`, `transformDigest`, `transformName`, `isHistorySink`, and the types
233
+ `HistoryTransform`, `HistoryConfig`, `HistoryProjection`. `Run` grows `declareProjection`,
234
+ `noteProjection` and `withheldFromHistory`.
235
+
236
+ Three decisions the README states under its own heading so the owner can overrule each: a line
237
+ the writer cannot re-validate is withheld rather than passed through; the receipt records the
238
+ `seq` the opening line took; and a transform may withhold `end`, so a copy on the stream can
239
+ end without one.
240
+
241
+ - `src/schemas.ts` re-synced from the repository drafts: the package now ships seventeen, adding
242
+ `parley.history.transform` 1.0.0, so `--schema` serves it like any other writer-owned type.
243
+
244
+ - **`declaredProjection(values)`, a built-in history transform** (flyingrobots/parley#59): the
245
+ same §5.3 scrubber the receipt's own redaction uses, applied to the stream copy's body with a
246
+ second declared set — longest value first, keys renamed, the envelope never touched, nor the
247
+ writer's own identity scalars (`DIGEST_KEYS`, now exported from `src/run.ts`) on a writer-built
248
+ record it might also be handed — found in self-review: without it, a declared value that
249
+ coincided with the tool's own name would silently rename `tool` on the stream's head, since that
250
+ field carries no pattern a validator would reject a corrupted value by. An empty declared set
251
+ returns `undefined` rather than an identity function, so no `parley.history.transform` line is
252
+ ever written for it; the transform's name on the stream is always the literal
253
+ `declaredProjection` and its digest never discloses what was declared, since the digest is of
254
+ the function's source text and the values only ever reach it as a closed-over variable. New
255
+ export from `src/transforms/declared.ts`, re-exported from `src/index.ts`.
256
+
257
+ - The shared history stream (spec §8, informative): an opt-in second sink that receives the bytes
258
+ of the local receipt, so one timeline spans tools, repositories, agents and people. Opt in with
259
+ `PARLEY_HISTORY` naming a directory, or by creating `$XDG_STATE_HOME/parley/history` once;
260
+ `PARLEY_HISTORY=off` switches it off even then. A run with no stream configured is unchanged in
261
+ every byte: no `paths.history` on the bootstrap line, no history bookkeeping on the head, no
262
+ file, no warning, no difference in exit status. New exports in `src/history.ts`:
263
+ `resolveHistory`, `openHistory`, `isHistoryFailure`, `writeWholeLine`, `retainHistory`,
264
+ `historyBookkeeping`, `segmentName`, `historyDays`, `HISTORY_ENV`, `HISTORY_DAYS_ENV`,
265
+ `HISTORY_DEFAULT_DAYS`; `MainOptions.history` takes a sink or `null` beside `stdout` and
266
+ `stderr`. No message schema moves and no message type is added: `paths` is already open and
267
+ documents that a program may add paths of its own, and segment retention is recorded with
268
+ `parley.receipt.step`. (flyingrobots/parley#3)
269
+
270
+ The two decisions flyingrobots/parley#3 left open, implemented behind a recommendation the
271
+ package README states under its own heading so the owner can overrule either:
272
+
273
+ - **Scope and expiry.** One stream per user per machine, written as dated daily segments
274
+ (`2026-11-22.jsonl`, UTC), keeping `PARLEY_HISTORY_DAYS` of them, today's included, default
275
+ 14. Expiry unlinks whole segments and never rewrites, because an append-only file with
276
+ concurrent writers cannot be rewritten safely; with `days` at least 1 today's segment is
277
+ never a candidate. Recorded as a `receipt.step`, skipped on `--dry-run`.
278
+ - **Redaction.** None of the stream's own. The sink is handed the same string the receipt was
279
+ handed, after §5.3 has replaced every declared secret, so a credential cannot reach the
280
+ stream unless it reached the receipt first. Reach is protected instead of content: the
281
+ directory is `0700`, segments are `0600`, a record stored as a sidecar reaches the stream as
282
+ its `sidecar` event and never as its stored bytes, and nothing is sent anywhere. An
283
+ undeclared secret is as exposed in the stream as in the receipt, for longer, which the README
284
+ says plainly.
285
+
286
+ Appending is `O_APPEND` with one whole line per write, so concurrent writers cannot split each
287
+ other's lines; a write that reports fewer bytes is abandoned rather than continued, since
288
+ continuing would interleave. A stream that cannot be opened is one `history.unavailable`
289
+ warning and a failed append is one `history.write_failed` warning: never an error, never a sink
290
+ failure, never a different exit status, because the dependency runs one way.
291
+
292
+ The stream's own path gets the rule the receipt's path already had: one carrying a declared
293
+ secret value is never chosen, since the bootstrap line prints it. The receipt has nowhere else
294
+ to go and fails startup; the stream yields with one `history.unavailable` warning and the run
295
+ carries on without it. The literal field name `history` is checked the same way, because a
296
+ secret that is a substring of it would rename the key the line prints.
297
+
298
+ `PARLEY_HISTORY_DAYS` is an integer from 1 to `HISTORY_MAX_DAYS` (36,500); anything else falls
299
+ back to 14. A window wide enough that its own start date is not a date would have thrown out of
300
+ `main` after the head was written, where nothing could catch it, and a retention window is not
301
+ worth failing a run over.
302
+
8
303
  ## [0.1.0] — 2026-11-22
9
304
 
10
305
  The schemas this version ships are the repository drafts at the commit recorded in