@conarium-ai/core 0.2.43 → 0.2.45

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
@@ -1,5 +1,119 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.45 - the rest of an outside report, and a check over the descriptions
4
+
5
+ **Behaviour change in `conarium-verify` and `conarium-coverage`.** Read the two
6
+ rows below before upgrading a script that branches on exit codes.
7
+
8
+ Joel Hillier probed the exit-code defect we disclosed on 22 August and found
9
+ five routes to 20 where we had named three. 0.2.44 closed three of them. This
10
+ closes the other two.
11
+
12
+ **A file that is valid JSON but not JSONL was called "invalid JSON".** The
13
+ loader splits on newlines unless the file opens with `[`, so a pretty-printed
14
+ JSON object has its opening brace handed to `JSON.parse` alone, and the tool
15
+ reported a valid file as invalid. His point was that the false message mattered
16
+ more than the code, and it does: a caller acts on what it is told went wrong.
17
+ The message now names the real fact and says how to fix it. Where a reader
18
+ actually meets this is directory mode - pointed at our own published
19
+ `test-vectors/`, the verifier reached `expected-hashes.json` and stopped. A
20
+ directory is now asked for the receipts in it: a neighbour that is valid JSON
21
+ in the wrong shape is skipped **and named on stderr**, never skipped quietly.
22
+
23
+ **The check ordering.** The key was loaded before the target was resolved, so a
24
+ path that does not exist answered 13 - a verdict about signatures, for a file
25
+ never opened - and answered 2 as soon as an unrelated `--pubkey` was supplied.
26
+ Which wrong answer a caller received was a fact about check order. The target is
27
+ resolved first now, in `conarium-verify` and `conarium-coverage`. Fail-closed is
28
+ untouched: a missing target exits 2, and a target that is present still cannot
29
+ be verified without a key.
30
+
31
+ | Invocation | 0.2.44 | 0.2.45 |
32
+ |---|---|---|
33
+ | valid JSON that is not JSONL | 20, "invalid JSON" | **2**, and the message is true |
34
+ | a directory holding receipts and a metadata file | 20 | **0**, the metadata file named as skipped |
35
+ | a missing target with no `--pubkey` | 13 | **2** |
36
+ | a corrupt receipts file | 20 | 20, unchanged |
37
+ | a missing `--pubkey` on a file that exists | 13 | 13, unchanged |
38
+
39
+ The last two rows are the split, and a property test decided where it fell. The
40
+ first attempt sent every parse failure to 2, and
41
+ `src/invariants.property.test.ts` - which mutates one byte of a signed chain -
42
+ failed. It was right to: a corrupted file is the artefact being examined and
43
+ rejected, which is a verdict, and answering 2 would send an operator to check
44
+ their arguments instead of their evidence. Valid JSON in the wrong shape is 2.
45
+ Anything else is 20, in a directory as well as out of one.
46
+
47
+ **`test/exit_code_descriptions.mjs`** is new, and it is the part worth keeping.
48
+ The same code is described in `docs/RECEIPT-SPEC.md`, in
49
+ `test-vectors/manifest.json` and in `scripts/gen-test-vectors.mjs`. It requires
50
+ the two machine-readable copies to be identical and each manifest description to
51
+ be the leading clause of the specification's row. On its first run it failed on
52
+ two things nothing else could see: the manifest and the specification describing
53
+ code 2 differently in the same release, and the manifest describing 13 as
54
+ "signature invalid or missing while a pubkey was supplied" - false in the one
55
+ case 13 is returned for, since 13 is what you get when no pubkey was supplied.
56
+
57
+ `spec_exitcode_drift.mjs` was green through all of it, because it compares the
58
+ *set* of codes in the binaries with the set in the tables. That is the blindness
59
+ Joel named after hitting the identical shape in his own `ABSENT` verdict the
60
+ same week: a check over the members of a set cannot see a member that means two
61
+ things. The new check does not close it entirely - it establishes that the three
62
+ texts agree with each other, not that any of them is true of the binary.
63
+
64
+ ## 0.2.44 — a verdict code, on all four tools, now means something was read
65
+
66
+ **This is a behaviour change to every command-line tool in the package. Read
67
+ the table before upgrading a script that branches on exit codes.**
68
+
69
+ 0.2.42 moved `conarium-verify`'s usage errors out of the verdict range and said
70
+ the remaining misuse of 20 was the uncaught-exception handler. That was written
71
+ from reading the file. Running it found `conarium-verify missing.jsonl` exiting
72
+ **20** — *Schema invalid* — with no receipt opened, from a `return { code: 20 }`
73
+ inside `loadReceipts`. 0.2.43 documented it. This release fixes it, and finishes
74
+ the job across the three tools that were measured in 0.2.42 and left alone.
75
+
76
+ Two codes now sit outside the verdict range, and mean the same thing on all
77
+ four binaries:
78
+
79
+ | Exit | Meaning |
80
+ |---|---|
81
+ | 1 | The tool failed unexpectedly — no verdict was reached |
82
+ | 2 | The command could not be run as given — an unknown flag, a required argument that was not given, or a target that is not there. Nothing was read. |
83
+
84
+ What moved, measured before and after:
85
+
86
+ | Invocation | 0.2.43 | 0.2.44 |
87
+ |---|---|---|
88
+ | `conarium-verify <missing path>` | 20 | **2** |
89
+ | `conarium-coverage` — unknown flag, missing argument, missing declaration or receipts file | 20 | **2** |
90
+ | `conarium-reconcile` — unknown flag, missing flags, missing snapshot, receipts or profile | 20 | **2** |
91
+ | `conarium-stamp` — unknown flag, missing argument, missing or unreadable target | 20 | **2** |
92
+ | all four — uncaught exception | 20 | **1** |
93
+
94
+ Unchanged, and asserted in the same test run so the release cannot trade one
95
+ wrong answer for another: a valid chain is 0, a schema failure on a receipt that
96
+ was read is 20, a bad signature is 13, and **a missing `--pubkey` is still 13**.
97
+ That last one is a usage mistake by any ordinary reading, and it stays a verdict
98
+ on purpose: 13 is fail-closed, a script that has special-cased it is asserting
99
+ *do not trust this*, and moving it to 2 would turn that assertion off in the
100
+ name of tidiness. `--help` is 0 on all four.
101
+
102
+ **Who breaks.** A script reading 20 as "schema invalid" was already folding
103
+ typos and missing files into that bucket; those now arrive as 2, and genuine
104
+ schema failures are unaffected. A script treating any non-zero as failure sees
105
+ no change. A script that branches on 20 to page a human about a malformed
106
+ receipt will now page correctly — the missing-file case that used to reach it
107
+ was never a malformed receipt.
108
+
109
+ `test/exit_contract.mjs` is new and runs all four binaries: twelve invocations
110
+ that reach no artefact, nine verdicts and `--help` cases that must not move. It
111
+ was written first and failed on eleven of the twelve, which is the record of
112
+ what this release actually changed. The uncaught-exception path is the one line
113
+ here not covered by it — no CLI input reaches that handler, which is why it is
114
+ last-resort, and the change is covered by reading rather than by a run. Said
115
+ plainly rather than implied by an untested green.
116
+
3
117
  ## 0.2.43 — the number watching the Turkish was reporting a third of it
4
118
 
5
119
  `test/pack_locale.mjs` has always ended with a line naming what it does *not*
@@ -164,7 +164,7 @@ function loadVerifyKeys(paths) {
164
164
 
165
165
  function loadDeclaration(path) {
166
166
  if (!existsSync(path)) {
167
- return { error: `declaration not found: ${path}`, code: 20 }
167
+ return { error: `declaration not found: ${path}`, code: 2 }
168
168
  }
169
169
  let obj
170
170
  try {
@@ -177,7 +177,7 @@ function loadDeclaration(path) {
177
177
 
178
178
  function loadReceipts(path) {
179
179
  if (!existsSync(path)) {
180
- return { error: `receipts file not found: ${path}`, code: 20 }
180
+ return { error: `receipts file not found: ${path}`, code: 2 }
181
181
  }
182
182
  const raw = readFileSync(path, 'utf-8').trim()
183
183
  if (!raw) return { receipts: [] }
@@ -375,25 +375,32 @@ async function main(argv = process.argv.slice(2)) {
375
375
  opts = parseArgs(argv)
376
376
  } catch (err) {
377
377
  usage(err.message)
378
- process.exit(20)
378
+ process.exit(2)
379
379
  }
380
380
  if (!opts.target) {
381
381
  usage('missing <declaration.json>')
382
- process.exit(20)
382
+ process.exit(2)
383
383
  }
384
384
 
385
- const keyResult = loadVerifyKeys(opts.pubkeys)
386
- if (keyResult.error) {
387
- fail(keyResult.code, keyResult.error, opts.json)
388
- }
389
- const { keys } = keyResult
390
-
385
+ /**
386
+ * Target before key, for the reason set out in conarium-verify: with the key
387
+ * first, a declaration that is not there answered 13 — a signature verdict
388
+ * about a file nobody opened — and answered 2 as soon as an unrelated
389
+ * --pubkey was supplied. Fail-closed is unaffected: a missing declaration
390
+ * exits 2, and one that is present still needs a key.
391
+ */
391
392
  const declResult = loadDeclaration(opts.target)
392
393
  if (declResult.error) {
393
394
  fail(declResult.code, declResult.error, opts.json)
394
395
  }
395
396
  const d = declResult.declaration
396
397
 
398
+ const keyResult = loadVerifyKeys(opts.pubkeys)
399
+ if (keyResult.error) {
400
+ fail(keyResult.code, keyResult.error, opts.json)
401
+ }
402
+ const { keys } = keyResult
403
+
397
404
  const schemaErr = schemaOk(d)
398
405
  if (schemaErr) {
399
406
  fail(20, `schema invalid: ${schemaErr}`, opts.json)
@@ -504,6 +511,6 @@ const isDirect =
504
511
  if (isDirect) {
505
512
  main().catch((err) => {
506
513
  console.error(err)
507
- process.exit(20)
514
+ process.exit(1)
508
515
  })
509
516
  }
@@ -90,7 +90,7 @@ const PROFILE_V = 'conarium-mapping-profile/0.1'
90
90
 
91
91
  function loadSnapshot(path, label) {
92
92
  if (!existsSync(path)) {
93
- return { error: `${label} snapshot not found: ${path}` }
93
+ return { error: `${label} snapshot not found: ${path}`, code: 2 }
94
94
  }
95
95
  let obj
96
96
  try {
@@ -192,7 +192,7 @@ export function classifyPattern(query) {
192
192
  // ─── receipts ────────────────────────────────────────────────────────────────
193
193
 
194
194
  function loadReceipts(path) {
195
- if (!existsSync(path)) return { error: `receipts file not found: ${path}` }
195
+ if (!existsSync(path)) return { error: `receipts file not found: ${path}`, code: 2 }
196
196
  const raw = readFileSync(path, 'utf-8').trim()
197
197
  if (!raw) return { receipts: [] }
198
198
  const receipts = []
@@ -471,7 +471,7 @@ function patternDigest(query) {
471
471
  * indeterminate — this function does not invent a bound of one.
472
472
  */
473
473
  export function loadMappingProfile(path) {
474
- if (!existsSync(path)) return { error: `profile not found: ${path}` }
474
+ if (!existsSync(path)) return { error: `profile not found: ${path}`, code: 2 }
475
475
  const raw = readFileSync(path)
476
476
  let obj
477
477
  try {
@@ -784,25 +784,25 @@ async function main(argv = process.argv.slice(2)) {
784
784
  opts = parseArgs(argv)
785
785
  } catch (err) {
786
786
  usage(err.message)
787
- process.exit(20)
787
+ process.exit(2)
788
788
  }
789
789
  if (!opts.before || !opts.after || !opts.receiptsPath) {
790
790
  usage('missing required flag (--before, --after and --receipts are all required)')
791
- process.exit(20)
791
+ process.exit(2)
792
792
  }
793
793
 
794
794
  const b = loadSnapshot(opts.before, 'before')
795
- if (b.error) fail(20, b.error, opts.json)
795
+ if (b.error) fail(b.code ?? 20, b.error, opts.json)
796
796
  const a = loadSnapshot(opts.after, 'after')
797
- if (a.error) fail(20, a.error, opts.json)
797
+ if (a.error) fail(a.code ?? 20, a.error, opts.json)
798
798
  const rec = loadReceipts(opts.receiptsPath)
799
- if (rec.error) fail(20, rec.error, opts.json)
799
+ if (rec.error) fail(rec.code ?? 20, rec.error, opts.json)
800
800
 
801
801
  let profile = null
802
802
  let profileRaw = Buffer.from('')
803
803
  if (opts.profilePath) {
804
804
  const loaded = loadMappingProfile(opts.profilePath)
805
- if (loaded.error) fail(20, loaded.error, opts.json)
805
+ if (loaded.error) fail(loaded.code ?? 20, loaded.error, opts.json)
806
806
  profile = loaded.profile
807
807
  profileRaw = loaded.raw
808
808
  }
@@ -955,6 +955,6 @@ const isDirect =
955
955
  if (isDirect) {
956
956
  main().catch((err) => {
957
957
  console.error(err)
958
- process.exit(20)
958
+ process.exit(1)
959
959
  })
960
960
  }
@@ -65,15 +65,15 @@ async function main(argv = process.argv.slice(2)) {
65
65
  opts = parseArgs(argv)
66
66
  } catch (err) {
67
67
  usage(err.message)
68
- process.exit(20)
68
+ process.exit(2)
69
69
  }
70
70
  if (!opts.target) {
71
71
  usage('missing <file>')
72
- process.exit(20)
72
+ process.exit(2)
73
73
  }
74
74
  if (!existsSync(opts.target)) {
75
75
  console.error(`file not found: ${opts.target}`)
76
- process.exit(20)
76
+ process.exit(2)
77
77
  }
78
78
 
79
79
  let content
@@ -81,7 +81,7 @@ async function main(argv = process.argv.slice(2)) {
81
81
  content = readFileSync(opts.target)
82
82
  } catch (err) {
83
83
  console.error(`cannot read ${opts.target}: ${err.message}`)
84
- process.exit(20)
84
+ process.exit(2)
85
85
  }
86
86
 
87
87
  const digest = createHash('sha256').update(content).digest()
@@ -147,6 +147,6 @@ const isDirect =
147
147
  if (isDirect) {
148
148
  main().catch((err) => {
149
149
  console.error(err)
150
- process.exit(20)
150
+ process.exit(1)
151
151
  })
152
152
  }
@@ -247,43 +247,124 @@ function loadVerifyKeys(paths) {
247
247
  return { keys }
248
248
  }
249
249
 
250
+ function isWholeJson(raw) {
251
+ try {
252
+ JSON.parse(raw)
253
+ return true
254
+ } catch {
255
+ return false
256
+ }
257
+ }
258
+
259
+ /**
260
+ * Read one file as receipts, or say truthfully why it could not be.
261
+ *
262
+ * The message used to be `invalid JSON in <file>:1` for any line that failed
263
+ * to parse, and for the commonest case that sentence was false. Receipts are
264
+ * one per line, so a pretty-printed JSON document has its opening brace handed
265
+ * to JSON.parse on its own — and the file it was read from is perfectly valid
266
+ * JSON. An outside reader hit it and said the message mattered more than the
267
+ * code, which is right: a caller acts on what it is told went wrong, and being
268
+ * told a valid file is invalid sends them to look at the wrong thing.
269
+ *
270
+ * So the file is asked the second question before the tool answers the first.
271
+ * Valid JSON that is not JSONL is a format mismatch and says so; anything else
272
+ * is genuinely malformed and says that instead.
273
+ */
274
+ function parseReceiptFile(file, raw) {
275
+ const lines =
276
+ raw.includes('\n') && !raw.trimStart().startsWith('[')
277
+ ? raw.split('\n').filter(Boolean)
278
+ : [raw]
279
+ const out = []
280
+ for (let i = 0; i < lines.length; i++) {
281
+ let obj
282
+ try {
283
+ obj = JSON.parse(lines[i])
284
+ } catch (err) {
285
+ /**
286
+ * Two different answers, and the split decides whether this is a verdict.
287
+ *
288
+ * If the whole file is valid JSON, nothing is wrong with the bytes — the
289
+ * caller handed a shape this tool does not read, and no judgement about
290
+ * the content has been made. That is 2.
291
+ *
292
+ * If it is not valid JSON either, the artefact was examined and rejected,
293
+ * and that is a verdict whatever the caller intended. It stays in the
294
+ * verdict range, because a one-byte mutation of a signed chain lands
295
+ * here — `src/invariants.property.test.ts` mutates a valid chain and
296
+ * caught this file answering 2 when it first split them. Telling a
297
+ * caller "your command could not be run" about a tampered file sends
298
+ * them to check their arguments instead of their evidence.
299
+ */
300
+ if (isWholeJson(raw)) {
301
+ return {
302
+ code: 2,
303
+ error:
304
+ `${file} is JSON but not JSONL: this reads one receipt per line, ` +
305
+ `and line ${i + 1} is not a complete JSON document on its own. ` +
306
+ 'Convert it with `jq -c .`, or pass a file that already has one receipt per line.',
307
+ }
308
+ }
309
+ return { code: 20, error: `${file}:${i + 1} is not valid JSON: ${err.message}` }
310
+ }
311
+ if (Array.isArray(obj)) {
312
+ for (const item of obj) out.push(item)
313
+ } else {
314
+ out.push(obj)
315
+ }
316
+ }
317
+ return { receipts: out }
318
+ }
319
+
250
320
  function loadReceipts(target) {
251
321
  if (!existsSync(target)) {
252
- return { error: `path not found: ${target}`, code: 20 }
322
+ return { error: `path not found: ${target}`, code: 2 }
253
323
  }
254
324
  const st = statSync(target)
255
- let files = []
256
- if (st.isDirectory()) {
257
- files = readdirSync(target)
258
- .filter((f) => ['.json', '.jsonl', '.receipt'].includes(extname(f)))
259
- .map((f) => join(target, f))
260
- .sort()
261
- } else {
262
- files = [target]
263
- }
325
+ const isDir = st.isDirectory()
326
+ const files = isDir
327
+ ? readdirSync(target)
328
+ .filter((f) => ['.json', '.jsonl', '.receipt'].includes(extname(f)))
329
+ .map((f) => join(target, f))
330
+ .sort()
331
+ : [target]
264
332
 
265
333
  const receipts = []
334
+ const skipped = []
266
335
  for (const file of files) {
267
336
  const raw = readFileSync(file, 'utf-8').trim()
268
337
  if (!raw) continue
269
- const lines = raw.includes('\n') && !raw.trimStart().startsWith('[')
270
- ? raw.split('\n').filter(Boolean)
271
- : [raw]
272
- for (let i = 0; i < lines.length; i++) {
273
- let obj
274
- try {
275
- obj = JSON.parse(lines[i])
276
- } catch (err) {
277
- return { error: `invalid JSON in ${file}:${i + 1}: ${err.message}`, code: 20 }
278
- }
279
- if (Array.isArray(obj)) {
280
- for (const item of obj) receipts.push({ file, receipt: item })
281
- } else {
282
- receipts.push({ file, receipt: obj })
338
+ const parsed = parseReceiptFile(file, raw)
339
+ if (parsed.error) {
340
+ /**
341
+ * Naming a file asserts that it is receipts, so failing to read it is
342
+ * the answer. Naming a directory asks about the receipts in it, and a
343
+ * neighbour that is not receipts is not a verdict about the ones that
344
+ * are — this is what happens to anyone who points the verifier at our
345
+ * own published `test-vectors/`, where `expected-hashes.json` sits
346
+ * beside the vectors and used to stop the run.
347
+ *
348
+ * Skipped, and named. Skipping quietly would report success over
349
+ * something that was never examined, which is the defect this codebase
350
+ * keeps finding in itself and in other people's checkers.
351
+ */
352
+ if (isDir && parsed.code === 2) {
353
+ skipped.push(parsed.error)
354
+ continue
283
355
  }
356
+ /**
357
+ * A neighbour that is not valid JSON at all is never skipped, in a
358
+ * directory or out of it. A corrupt file sitting among receipts is
359
+ * exactly what a tampered receipt looks like, and skipping it because
360
+ * the caller named a directory rather than a file would decide, on a
361
+ * detail of the invocation, not to report evidence.
362
+ */
363
+ return { error: parsed.error, code: parsed.code }
284
364
  }
365
+ for (const receipt of parsed.receipts) receipts.push({ file, receipt })
285
366
  }
286
- return { receipts }
367
+ return { receipts, skipped }
287
368
  }
288
369
 
289
370
  function schemaOk(r) {
@@ -444,17 +525,34 @@ async function main(argv = process.argv.slice(2)) {
444
525
  )
445
526
  }
446
527
 
447
- const keyResult = loadVerifyKeys(opts.pubkeys)
448
- if (keyResult.error) {
449
- fail(keyResult.code, keyResult.error, opts.json)
450
- }
451
- const { keys } = keyResult
452
-
528
+ /**
529
+ * The target is resolved before the key is loaded, and the order is the
530
+ * point. Both checks are refusals, but they answer different questions, and
531
+ * whichever runs first decides what a caller is told about an invocation
532
+ * that is wrong in two ways. With the key first, a path that does not exist
533
+ * came back as 13 — a verdict about signatures, for a file that was never
534
+ * opened — and the same missing path came back as 2 the moment an unrelated
535
+ * --pubkey was added. Which answer you got was a fact about this ordering
536
+ * rather than about your run.
537
+ *
538
+ * Fail-closed is untouched by the swap: a target that is missing exits 2,
539
+ * which is not success, and a target that is present still cannot be
540
+ * verified without a key.
541
+ */
453
542
  const loaded = loadReceipts(opts.target)
454
543
  if (loaded.error) {
455
544
  fail(loaded.code, loaded.error, opts.json)
456
545
  }
457
546
  const { receipts } = loaded
547
+ for (const note of loaded.skipped ?? []) {
548
+ console.error(`skipped, not receipts: ${note}`)
549
+ }
550
+
551
+ const keyResult = loadVerifyKeys(opts.pubkeys)
552
+ if (keyResult.error) {
553
+ fail(keyResult.code, keyResult.error, opts.json)
554
+ }
555
+ const { keys } = keyResult
458
556
 
459
557
  let anchorRows = []
460
558
  if (opts.anchorCheck) {
@@ -734,6 +832,6 @@ const isDirect =
734
832
  if (isDirect) {
735
833
  main().catch((err) => {
736
834
  console.error(err)
737
- process.exit(20)
835
+ process.exit(1)
738
836
  })
739
837
  }
@@ -191,14 +191,15 @@ are unchanged.
191
191
  | Exit | Meaning |
192
192
  |---|---|
193
193
  | 0 | Chain intact, signatures valid |
194
- | 2 | Usage error — no receipt was read |
194
+ | 1 | The tool failed unexpectedly — no verdict was reached |
195
+ | 2 | No verdict was reached because the run could not begin — a flag that does not exist, a required argument that was not given, a target that is not there, or an input that could not be read as receipts. No receipt was judged. |
195
196
  | 10 | Hash mismatch — record altered |
196
197
  | 11 | `prevHash` break — deleted or inserted; also `--expect-count` / `--expect-last-hash` mismatch |
197
198
  | 12 | `seq` gap / non-increasing — missing or reordered |
198
199
  | 13 | Signature invalid / pubkey missing (fail-closed) |
199
200
  | 14 | Claimed anchor invalid under `--anchor-check`, or `--require-head-anchor` when the head is unanchored. An individual `anchor:null` receipt is skipped, not failed — periodic anchoring leaves most of them null. |
200
201
  | 15 | Anchor **could not be checked** — calendar unreachable, the OpenTimestamps verifier is not installed, or `--anchor-check` reached no anchor at all because every receipt in the chain is unanchored. Deliberately distinct from 14: "I could not verify this" is not "this is invalid". The digest comparison is performed offline and still holds; only the timestamp attestation is unconfirmed. A verifier that collapsed the two would be asserting something it did not measure. |
201
- | 20 | Schema invalid — a receipt was read and failed the schema. ⚠️ Also returned when the target path does not exist (`path not found`) and on an uncaught exception, neither of which reads a receipt. Both are known and unfixed; `CHANGELOG.md` 0.2.42 says why. |
202
+ | 20 | The input was read as receipts and rejected — a receipt that failed the schema, or a file that is not valid JSON. A one-byte mutation of a signed chain lands here rather than on 2: the bytes were examined. |
202
203
 
203
204
  Fail-closed: if the verifier is unsure, it does not exit 0.
204
205
 
@@ -482,9 +483,11 @@ occurred"** — an absent record is ambiguous by nature.
482
483
  | Exit | Meaning |
483
484
  |---|---|
484
485
  | 0 | Declaration signature valid (+ consistent with receipts if given), chain contiguous. Unpinned window start is printed, not a silent complete. |
486
+ | 1 | The tool failed unexpectedly — no verdict was reached |
487
+ | 2 | No verdict was reached because the run could not begin — a flag that does not exist, a required argument that was not given, or a declaration or receipts file that is not there. Nothing was judged. |
485
488
  | 12 | Chain has gaps — coverage incomplete (`--allow-gaps` verifies authenticity only); also `--expect-seq-from` miss |
486
489
  | 13 | Signature invalid / pubkey missing (fail-closed); also a receipt Ed25519 failure under `--receipts` |
487
- | 20 | Schema invalid |
490
+ | 20 | Schema invalid — the declaration was read and failed the schema |
488
491
  | 30 | Inconsistent with the receipts file |
489
492
 
490
493
  ## Reconciliation (two-sided, v0.1)
@@ -554,7 +557,9 @@ Rules that keep the verdict honest:
554
557
  | Exit | Meaning |
555
558
  |---|---|
556
559
  | 0 | Every DB query pattern in the window is attributable to receipt(s) for the same table — object attribution, not per-statement coverage |
557
- | 20 | Input invalid or window unreliable (schema error, counter regression) |
560
+ | 1 | The tool failed unexpectedly — no verdict was reached |
561
+ | 2 | No verdict was reached because the run could not begin — a flag that does not exist, a required argument that was not given, or a snapshot, receipts file or profile that is not there. Nothing was judged. |
562
+ | 20 | Input was read and is invalid, or the window is unreliable (schema error, counter regression) |
558
563
  | 40 | Unreconciled DB activity — recorded by the database, not receipted |
559
564
  | 41 | Indeterminate — a pattern is uncovered only by the window boundary, and two clocks decide that boundary |
560
565
 
@@ -695,6 +700,8 @@ conarium-stamp <file> [--sidecar <path>] [--json]
695
700
  | Exit | Meaning |
696
701
  |---|---|
697
702
  | 0 | Stamped; sidecar written (`pending` until upgraded) |
703
+ | 1 | The tool failed unexpectedly — no verdict was reached |
704
+ | 2 | No verdict was reached because the run could not begin — a flag that does not exist, a required argument that was not given, or a target that is not there or unreadable. Nothing was judged. |
698
705
  | 50 | Stamping failed — calendars unreachable or timed out |
699
706
 
700
707
  Receipts are not anchored by the write path. An operator stamps a document
@@ -0,0 +1,84 @@
1
+ # Claims review — 0.2.44
2
+
3
+ - base: v0.2.43
4
+ - head: 150f134
5
+ - surface: sha256:9383a93c1e38d7031c88b62995af3d03222a7f650c29d4f9f75180f9d42e3c14
6
+ - verdict: pass
7
+ - reviewer: maintainer, running the four binaries against the four tables. The
8
+ previous review of this defect was done by reading and missed half of it.
9
+
10
+ One surface changed: the four exit-code tables in `docs/RECEIPT-SPEC.md`. Two
11
+ rows added to each, three rows reworded to say what was read before a verdict
12
+ was given.
13
+
14
+ ## Findings
15
+
16
+ ### 1. docs/RECEIPT-SPEC.md — exit 1 is published on four tables and observed on none
17
+
18
+ - Claim: "| 1 | The tool failed unexpectedly — no verdict was reached |", now in
19
+ the verifier, coverage, reconciliation and stamping tables.
20
+ - Mechanism: `process.exit(1)` in the `main().catch` handler at the foot of each
21
+ of the four binaries, replacing `process.exit(20)`.
22
+ - Why it falls short: no CLI input reaches that handler. Four candidate triggers
23
+ were tried against `conarium-verify` — a directory passed to `--anchors`,
24
+ `/dev/null` passed to `--anchors`, a non-numeric `--expect-count`, a malformed
25
+ `--expect-last-hash` — and every one was caught by the code that owns it and
26
+ answered with its own exit code. That is the right result for a last-resort
27
+ handler and it is also the reason the row is unmeasured: `exit_contract.mjs`
28
+ runs twenty-one invocations and none of them produces a 1. The evidence for
29
+ this row is that the line is short and reads correctly. **That is reading
30
+ substituted for running, which is the substitution this release exists to
31
+ correct** — 0.2.42 named the remaining misuse of 20 by reading the file, and
32
+ the half it missed was found by executing it.
33
+ - Disposition: shipping, and said plainly rather than left to look measured. The
34
+ changelog states that this one line is covered by reading rather than by a
35
+ run. The alternative — an environment variable or hidden flag that forces a
36
+ throw so a test can observe it — puts a deliberate crash path into a security
37
+ tool to satisfy a checkbox, and that trade is worse than the gap.
38
+ - Second-order, recorded because it is the more useful half: **the drift guard
39
+ went green through all of this.** `test/spec_exitcode_drift.mjs` compares the
40
+ *set* of literal codes in the binaries against the set in the tables. `1` was
41
+ added on both sides, so the sets matched. It was equally blind when `20` named
42
+ two different events, which is how that survived to 0.2.42. A set comparison
43
+ cannot see meaning, and nothing in the tree can — `exit_contract.mjs` narrows
44
+ the gap by asserting what specific invocations return, but it asserts the
45
+ cases someone thought of.
46
+
47
+ ### 2. docs/RECEIPT-SPEC.md — "Nothing was read" was read as literally as it was written
48
+
49
+ - Claim, as first written in this release: "| 2 | The command could not be run
50
+ as given — … Nothing was read, so nothing is being judged. |"
51
+ - Mechanism: the paths that now exit 2 are a `parseArgs` throw, a missing
52
+ required argument, and a target that is absent or unreadable.
53
+ - Why it falls short: on several of those paths a file *has* been read. In
54
+ `conarium-verify` and `conarium-coverage` the public key is loaded before the
55
+ target is looked for, so `conarium-verify <missing> --pubkey <key>` opens and
56
+ parses a key file and then exits 2. In `conarium-stamp` the "cannot read"
57
+ branch has opened the target and failed partway. What is true — and what the
58
+ code actually establishes — is narrower: the artefact under test was never
59
+ opened. "Nothing" claimed the whole filesystem.
60
+ - Disposition: reworded in `150f134`, in all four tables. The row now says "The
61
+ artefact under test was never opened".
62
+
63
+ ## Not a finding, recorded so the next reader does not re-derive it
64
+
65
+ **`conarium-coverage <missing declaration>` with no `--pubkey` is 13, and 13 is
66
+ a verdict code.** `loadVerifyKeys` runs before the declaration path is checked,
67
+ so a file that does not exist is answered with *signature invalid / pubkey
68
+ missing*. It is the same shape as the defect this release fixes, one argument
69
+ over, and `exit_contract.mjs` asserts it deliberately rather than by omission.
70
+
71
+ It stays for the reason 0.2.42 gave for the verifier: 13 is fail-closed. A
72
+ caller that has special-cased it is asserting *do not trust this result*, and
73
+ moving a missing key to 2 would switch that assertion off in the name of a
74
+ tidier table. The ordering is the fixable part — checking the target before the
75
+ key would answer the more specific question first — and it is not fixed here,
76
+ because reordering the fail-closed check is a change to the safety posture and
77
+ belongs in a release that is about the safety posture.
78
+
79
+ **Three tests had written the old answer down.** `test/reconcile_cli.test.mjs`
80
+ asserted 20 for an unparseable `--skew`, for no arguments at all, and for
81
+ `--json --json-v2` together. All three are `parseArgs` throws — no snapshot is
82
+ opened in any of them — so all three were asserting the defect. Their
83
+ expectations moved to 2 with the reason written beside each one, rather than in
84
+ a commit message nobody reads at the line where the question comes up.
@@ -0,0 +1,96 @@
1
+ # Claims review — 0.2.45
2
+
3
+ - base: v0.2.44
4
+ - head: e67cac8
5
+ - surface: sha256:e9d01e4e6f99670242922cf7c7d960d85adb9ca786d238d8a5f4279bc1c3eb43
6
+ - verdict: pass
7
+ - reviewer: maintainer, correcting a disposition written in the previous review
8
+ against an objection it had not read carefully enough
9
+
10
+ One surface changed: the four exit-code tables in `docs/RECEIPT-SPEC.md`. Every
11
+ `2` row was rewritten, the verifier's `20` row was widened, and both changes
12
+ came from measuring rather than from taste.
13
+
14
+ ## Findings
15
+
16
+ ### 1. The previous review answered an objection the reporter had not made
17
+
18
+ - Claim, in `docs/claims/reviews/0.2.44.md`: that a missing `--pubkey` returning
19
+ 13 "stays for the reason 0.2.42 gave for the verifier: 13 is fail-closed. A
20
+ caller that has special-cased it is asserting *do not trust this result*, and
21
+ moving a missing key to 2 would switch that assertion off."
22
+ - Mechanism: the report being answered. Joel Hillier's message of 22 August
23
+ 01:56 says, of the same behaviour, *"The refusal itself is right and I'd keep
24
+ it, and the message says plainly what happened."*
25
+ - Why it falls short: the objection was never that the refusal should go. It was
26
+ that the published description is false — `test-vectors/manifest.json`
27
+ described 13 as *"signature invalid or missing while a pubkey was supplied"*,
28
+ and 13 is what is returned when no pubkey was supplied — and that the check
29
+ ordering decided which of two wrong answers a caller received. A disposition
30
+ that defends a position the reporter already granted looks like an answer and
31
+ settles nothing. Rejecting a finding is legitimate; rejecting a finding one
32
+ has misread is not, and the second is harder to notice because it produces
33
+ the same paragraph.
34
+ - Disposition: both halves are fixed in this release. The description now
35
+ matches the specification's row, and the target is resolved before the key is
36
+ loaded. The previous review's second reason — that reordering "belongs in a
37
+ release that is about the fail-closed posture" — does not survive being
38
+ checked either: fail-closed means never reporting success without verifying
39
+ signatures, a missing target now exits 2, and a target that is present still
40
+ requires a key. Nothing about the posture moved. It was a harmless reorder
41
+ classified as a safety change, which is how work gets deferred for a reason
42
+ that reads well and is not true.
43
+
44
+ ### 2. docs/RECEIPT-SPEC.md — the `2` row has now been rewritten in three consecutive releases
45
+
46
+ - Claim, before this release: "The artefact under test was never opened, so
47
+ nothing is being judged."
48
+ - Mechanism: the paths that reach 2. In 0.2.44 they were argument errors and
49
+ absent targets, and the sentence held. This release adds a file that is valid
50
+ JSON in the wrong shape, and reaching that verdict requires opening the file
51
+ and reading all of it.
52
+ - Why it falls short: the sentence was true when written and was made false by
53
+ the next commit that widened the code. This is the third wording — 0.2.42
54
+ shipped "Usage error", 0.2.44 narrowed it to "the artefact under test was
55
+ never opened" after that overclaimed, and 0.2.45 has now falsified that one.
56
+ A row that has to be re-examined every time a path is added to its code is a
57
+ row whose text is doing work the code should be doing.
58
+ - Disposition: reworded to what is true of every path — "No verdict was reached
59
+ because the run could not begin" — and, more usefully, `test/exit_contract.mjs`
60
+ now asserts the behaviour of each path rather than leaving the row to carry
61
+ it alone. The pattern is recorded because the next widening of code 2 should
62
+ start by asking whether the row survives it.
63
+
64
+ ### 3. docs/RECEIPT-SPEC.md — the `20` row moved because a property test disagreed with the split
65
+
66
+ - Claim: "| 20 | The input was read as receipts and rejected — a receipt that
67
+ failed the schema, or a file that is not valid JSON. A one-byte mutation of a
68
+ signed chain lands here rather than on 2: the bytes were examined. |"
69
+ - Mechanism: `src/invariants.property.test.ts` mutates one byte of a valid
70
+ signed chain and asserts the result is never 0, over a set of verdict codes.
71
+ - Why it falls short — of the first attempt, not the shipped text: the first
72
+ version of this change sent *every* parse failure to 2, on the reasoning that
73
+ no receipt had been read. The property test failed, and it was right to. A
74
+ corrupted receipts file is not a caller who mistyped a command; it is the
75
+ artefact being examined and rejected, which is a verdict, and answering 2
76
+ would send an operator to check their arguments instead of their evidence.
77
+ The distinction that decides it was already in the code — whether the file is
78
+ valid JSON at all — and it had been wired to the wrong branch.
79
+ - Disposition: valid JSON in the wrong shape is 2; anything else stays 20, in a
80
+ directory as well as out of one, because skipping a corrupt neighbour would
81
+ make reporting evidence depend on whether the caller named a file or a folder.
82
+
83
+ ## Not a finding, recorded so the next reader does not re-derive it
84
+
85
+ `test/exit_code_descriptions.mjs` is the mechanism this class has been missing,
86
+ and what it caught on its first run is the argument for it: code 2 described
87
+ differently by the manifest and the specification in the same release, and code
88
+ 13 described by the manifest as something that is false in the one case it is
89
+ returned for. Neither was visible to `spec_exitcode_drift.mjs`, which compares
90
+ the *set* of codes in the binaries with the set in the tables — the same
91
+ blindness that let 20 name two events until 0.2.42.
92
+
93
+ Its own limit, stated: it checks that the three texts agree with each other. It
94
+ does not check that any of them is true of the binary. `exit_contract.mjs` asks
95
+ that question of the codes and cannot ask it of the sentences, and a run that is
96
+ green here means the descriptions are consistent, not that they are correct.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@conarium-ai/core",
3
- "version": "0.2.43",
3
+ "version": "0.2.45",
4
4
  "mcpName": "io.github.dogrucanemek-alt/conarium",
5
5
  "//files-artefakt": "Generated files under examples/ (private key, receipt/audit JSONL) are EXCLUDED. .gitignore does not bind npm: because the allow-list contained 'examples', `npm publish` on a machine that had run the demo was shipping _keys/audit-ed25519.pem (PRIVATE KEY) and the receipts. test/pack_artefakt.mjs locks this. The exclusions are LIMITED to examples/: receipts.jsonl and .pub.pem under test-vectors/ MUST ship, or a third party cannot run the conformance vectors.",
6
6
  "//files": "Allow-list of what enters the package. Without it npm sent everything: 296 files / 1.5 MB — CI workflows, gitleaks config, a 137 KB marketing image, the site's api/chat.js. A bank security team opens the tarball and sees those. scripts/ is here ON PURPOSE: conarium-reconcile references scripts/pg-snapshot.sql at runtime; without it the user files a support mail.",
@@ -184,12 +184,13 @@ writeFileSync(
184
184
  note: 'Frozen conformance vectors. Run each case through your verifier and compare the exit code. KEYS/ in args resolves to the keys/ directory at the root of test-vectors.',
185
185
  exitCodes: {
186
186
  0: 'chain intact, signatures valid',
187
- 2: 'Usage error — no receipt was read',
187
+ 1: 'the tool failed unexpectedly — no verdict was reached',
188
+ 2: 'no verdict was reached because the run could not begin',
188
189
  10: 'hash mismatch — record altered',
189
190
  11: 'prevHash break — deleted or inserted',
190
191
  12: 'seq gap / non-increasing',
191
- 13: 'signature invalid or missing while a pubkey was supplied',
192
- 20: 'schema invalid',
192
+ 13: 'signature invalid / pubkey missing (fail-closed)',
193
+ 20: 'the input was read as receipts and rejected',
193
194
  },
194
195
  cases,
195
196
  },
@@ -6,12 +6,13 @@
6
6
  "note": "Frozen conformance vectors. Run each case through your verifier and compare the exit code. KEYS/ in args resolves to the keys/ directory at the root of test-vectors.",
7
7
  "exitCodes": {
8
8
  "0": "chain intact, signatures valid",
9
- "2": "Usage error — no receipt was read",
9
+ "1": "the tool failed unexpectedly — no verdict was reached",
10
+ "2": "no verdict was reached because the run could not begin",
10
11
  "10": "hash mismatch — record altered",
11
12
  "11": "prevHash break — deleted or inserted",
12
13
  "12": "seq gap / non-increasing",
13
- "13": "signature invalid or missing while a pubkey was supplied",
14
- "20": "schema invalid"
14
+ "13": "signature invalid / pubkey missing (fail-closed)",
15
+ "20": "the input was read as receipts and rejected"
15
16
  },
16
17
  "cases": [
17
18
  {