@conarium-ai/core 0.2.43 → 0.2.44

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,58 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.44 — a verdict code, on all four tools, now means something was read
4
+
5
+ **This is a behaviour change to every command-line tool in the package. Read
6
+ the table before upgrading a script that branches on exit codes.**
7
+
8
+ 0.2.42 moved `conarium-verify`'s usage errors out of the verdict range and said
9
+ the remaining misuse of 20 was the uncaught-exception handler. That was written
10
+ from reading the file. Running it found `conarium-verify missing.jsonl` exiting
11
+ **20** — *Schema invalid* — with no receipt opened, from a `return { code: 20 }`
12
+ inside `loadReceipts`. 0.2.43 documented it. This release fixes it, and finishes
13
+ the job across the three tools that were measured in 0.2.42 and left alone.
14
+
15
+ Two codes now sit outside the verdict range, and mean the same thing on all
16
+ four binaries:
17
+
18
+ | Exit | Meaning |
19
+ |---|---|
20
+ | 1 | The tool failed unexpectedly — no verdict was reached |
21
+ | 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. |
22
+
23
+ What moved, measured before and after:
24
+
25
+ | Invocation | 0.2.43 | 0.2.44 |
26
+ |---|---|---|
27
+ | `conarium-verify <missing path>` | 20 | **2** |
28
+ | `conarium-coverage` — unknown flag, missing argument, missing declaration or receipts file | 20 | **2** |
29
+ | `conarium-reconcile` — unknown flag, missing flags, missing snapshot, receipts or profile | 20 | **2** |
30
+ | `conarium-stamp` — unknown flag, missing argument, missing or unreadable target | 20 | **2** |
31
+ | all four — uncaught exception | 20 | **1** |
32
+
33
+ Unchanged, and asserted in the same test run so the release cannot trade one
34
+ wrong answer for another: a valid chain is 0, a schema failure on a receipt that
35
+ was read is 20, a bad signature is 13, and **a missing `--pubkey` is still 13**.
36
+ That last one is a usage mistake by any ordinary reading, and it stays a verdict
37
+ on purpose: 13 is fail-closed, a script that has special-cased it is asserting
38
+ *do not trust this*, and moving it to 2 would turn that assertion off in the
39
+ name of tidiness. `--help` is 0 on all four.
40
+
41
+ **Who breaks.** A script reading 20 as "schema invalid" was already folding
42
+ typos and missing files into that bucket; those now arrive as 2, and genuine
43
+ schema failures are unaffected. A script treating any non-zero as failure sees
44
+ no change. A script that branches on 20 to page a human about a malformed
45
+ receipt will now page correctly — the missing-file case that used to reach it
46
+ was never a malformed receipt.
47
+
48
+ `test/exit_contract.mjs` is new and runs all four binaries: twelve invocations
49
+ that reach no artefact, nine verdicts and `--help` cases that must not move. It
50
+ was written first and failed on eleven of the twelve, which is the record of
51
+ what this release actually changed. The uncaught-exception path is the one line
52
+ here not covered by it — no CLI input reaches that handler, which is why it is
53
+ last-resort, and the change is covered by reading rather than by a run. Said
54
+ plainly rather than implied by an untested green.
55
+
3
56
  ## 0.2.43 — the number watching the Turkish was reporting a third of it
4
57
 
5
58
  `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,11 +375,11 @@ 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
385
  const keyResult = loadVerifyKeys(opts.pubkeys)
@@ -504,6 +504,6 @@ const isDirect =
504
504
  if (isDirect) {
505
505
  main().catch((err) => {
506
506
  console.error(err)
507
- process.exit(20)
507
+ process.exit(1)
508
508
  })
509
509
  }
@@ -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
  }
@@ -249,7 +249,7 @@ function loadVerifyKeys(paths) {
249
249
 
250
250
  function loadReceipts(target) {
251
251
  if (!existsSync(target)) {
252
- return { error: `path not found: ${target}`, code: 20 }
252
+ return { error: `path not found: ${target}`, code: 2 }
253
253
  }
254
254
  const st = statSync(target)
255
255
  let files = []
@@ -734,6 +734,6 @@ const isDirect =
734
734
  if (isDirect) {
735
735
  main().catch((err) => {
736
736
  console.error(err)
737
- process.exit(20)
737
+ process.exit(1)
738
738
  })
739
739
  }
@@ -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 | The command could not be run as given — a flag that does not exist, a required argument that was not given, or a target that is not there. The artefact under test was never opened, so nothing is being 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 | Schema invalid — a receipt was read and failed the schema |
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 | The command could not be run as given — a flag that does not exist, a required argument that was not given, or a declaration or receipts file that is not there. The artefact under test was never opened, so nothing is being 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 | The command could not be run as given — a flag that does not exist, a required argument that was not given, or a snapshot, receipts file or profile that is not there. The artefact under test was never opened, so nothing is being 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 | The command could not be run as given — a flag that does not exist, a required argument that was not given, or a target that is not there. The artefact under test was never opened, so nothing is being 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.
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.44",
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: 'the command could not be run as given — nothing was read',
188
189
  10: 'hash mismatch — record altered',
189
190
  11: 'prevHash break — deleted or inserted',
190
191
  12: 'seq gap / non-increasing',
191
192
  13: 'signature invalid or missing while a pubkey was supplied',
192
- 20: 'schema invalid',
193
+ 20: 'schema invalid — a receipt was read and failed the schema',
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": "the command could not be run as given — nothing was read",
10
11
  "10": "hash mismatch — record altered",
11
12
  "11": "prevHash break — deleted or inserted",
12
13
  "12": "seq gap / non-increasing",
13
14
  "13": "signature invalid or missing while a pubkey was supplied",
14
- "20": "schema invalid"
15
+ "20": "schema invalid — a receipt was read and failed the schema"
15
16
  },
16
17
  "cases": [
17
18
  {