@verax-ai/proxy 0.8.2 → 0.10.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.
@@ -26,6 +26,7 @@ export type ReceiptCheck = {
26
26
  root: string;
27
27
  treeSize: number;
28
28
  leafIndex: number;
29
+ issuedAtSec?: number;
29
30
  } | {
30
31
  ok: false;
31
32
  stage: ReceiptStage;
@@ -36,3 +37,40 @@ export type ReceiptCheck = {
36
37
  * holds. vds is read from the protected header only.
37
38
  */
38
39
  export declare function verifyReceipt(receipt: Uint8Array, leafEntry: Uint8Array, publicKeyPem: string): ReceiptCheck;
40
+ export type CcfReceiptCheck = {
41
+ ok: true;
42
+ root: string;
43
+ commitEvidence: string;
44
+ } | {
45
+ ok: false;
46
+ stage: ReceiptStage;
47
+ reason: string;
48
+ };
49
+ /**
50
+ * Checks one receipt from a CCF ledger (vds 2, CCF_LEDGER_SHA256) for one
51
+ * claims digest under the service key the reader holds. scitt-ccf-ledger
52
+ * commits to the SHA-256 of the Signed Statement it registered.
53
+ *
54
+ * The inclusion proof at 396/-1 is the CBOR map {1: leaf, 2: path}. The leaf
55
+ * is [internal transaction hash, commit evidence, claims digest] and hashes as
56
+ * SHA-256(hash || SHA-256(evidence) || digest); each path step is
57
+ * [left, node], hashed as SHA-256(node || acc) when left and SHA-256(acc ||
58
+ * node) otherwise. The signature is over the root that yields.
59
+ */
60
+ export declare function verifyCcfReceipt(receipt: Uint8Array, claimsDigest: Uint8Array, publicKeyPem: string): CcfReceiptCheck;
61
+ export type CcfReceiptRead = {
62
+ ok: true;
63
+ root: Buffer;
64
+ commitEvidence: string;
65
+ sign1: Sign1;
66
+ } | {
67
+ ok: false;
68
+ stage: ReceiptStage;
69
+ reason: string;
70
+ };
71
+ /**
72
+ * The root a CCF receipt yields for `claimsDigest`, with no key: a receipt
73
+ * that is not for this digest is refused here, and only the signature is left
74
+ * for `verifyCcfReceipt`.
75
+ */
76
+ export declare function readCcfReceipt(receipt: Uint8Array, claimsDigest: Uint8Array): CcfReceiptRead;
@@ -273,5 +273,107 @@ export function verifyReceipt(receipt, leafEntry, publicKeyPem) {
273
273
  }
274
274
  if (!verified)
275
275
  return { ok: false, stage: "receipt-sig", reason: "signature does not verify over the rebuilt root" };
276
- return { ok: true, root: root.toString("hex"), treeSize, leafIndex };
276
+ // Optional CWT Claims (COSE header 15 / RFC 9597) with iat (CWT claim 6).
277
+ let issuedAtSec;
278
+ const cwt = sign1.protectedHeader.get(15);
279
+ if (cwt instanceof Map) {
280
+ const iat = cwt.get(6);
281
+ if (typeof iat === "number" && Number.isSafeInteger(iat))
282
+ issuedAtSec = iat;
283
+ }
284
+ return issuedAtSec === undefined
285
+ ? { ok: true, root: root.toString("hex"), treeSize, leafIndex }
286
+ : { ok: true, root: root.toString("hex"), treeSize, leafIndex, issuedAtSec };
287
+ }
288
+ /**
289
+ * Checks one receipt from a CCF ledger (vds 2, CCF_LEDGER_SHA256) for one
290
+ * claims digest under the service key the reader holds. scitt-ccf-ledger
291
+ * commits to the SHA-256 of the Signed Statement it registered.
292
+ *
293
+ * The inclusion proof at 396/-1 is the CBOR map {1: leaf, 2: path}. The leaf
294
+ * is [internal transaction hash, commit evidence, claims digest] and hashes as
295
+ * SHA-256(hash || SHA-256(evidence) || digest); each path step is
296
+ * [left, node], hashed as SHA-256(node || acc) when left and SHA-256(acc ||
297
+ * node) otherwise. The signature is over the root that yields.
298
+ */
299
+ export function verifyCcfReceipt(receipt, claimsDigest, publicKeyPem) {
300
+ const read = readCcfReceipt(receipt, claimsDigest);
301
+ if (!read.ok)
302
+ return read;
303
+ let verified = false;
304
+ try {
305
+ verified = verifyCoseSignature(read.sign1.protectedHeader.get(1), publicKeyPem, sign1Structure(read.sign1.protectedBytes, read.root), read.sign1.signature);
306
+ }
307
+ catch {
308
+ verified = false;
309
+ }
310
+ if (!verified)
311
+ return { ok: false, stage: "receipt-sig", reason: "signature does not verify over the rebuilt root" };
312
+ return { ok: true, root: read.root.toString("hex"), commitEvidence: read.commitEvidence };
313
+ }
314
+ /**
315
+ * The root a CCF receipt yields for `claimsDigest`, with no key: a receipt
316
+ * that is not for this digest is refused here, and only the signature is left
317
+ * for `verifyCcfReceipt`.
318
+ */
319
+ export function readCcfReceipt(receipt, claimsDigest) {
320
+ if (claimsDigest.length !== 32)
321
+ return { ok: false, stage: "inclusion", reason: "claims digest is not 32 octets" };
322
+ let sign1;
323
+ try {
324
+ sign1 = decodeSign1(receipt);
325
+ }
326
+ catch (err) {
327
+ return { ok: false, stage: "receipt-decode", reason: err instanceof Error ? err.message : String(err) };
328
+ }
329
+ const crit = sign1.protectedHeader.get(2);
330
+ if (crit !== undefined && (!Array.isArray(crit) || crit.length === 0 || !crit.every((l) => UNDERSTOOD.has(l)))) {
331
+ return { ok: false, stage: "receipt-decode", reason: "a critical header this reader does not understand" };
332
+ }
333
+ if (sign1.unprotected.has(2))
334
+ return { ok: false, stage: "receipt-decode", reason: "crit in the unprotected header" };
335
+ const vds = sign1.protectedHeader.get(395);
336
+ if (vds !== 2)
337
+ return { ok: false, stage: "vds-gate", reason: `vds ${String(vds)} is not CCF_LEDGER_SHA256` };
338
+ const vdp = sign1.unprotected.get(396);
339
+ const proofs = vdp instanceof Map ? vdp.get(-1) : undefined;
340
+ if (!Array.isArray(proofs) || proofs.length !== 1 || !(proofs[0] instanceof Uint8Array)) {
341
+ return { ok: false, stage: "receipt-decode", reason: "no single inclusion proof at 396/-1" };
342
+ }
343
+ if (sign1.payload !== null)
344
+ return { ok: false, stage: "receipt-decode", reason: "receipt payload is not detached" };
345
+ let proof;
346
+ try {
347
+ proof = decodeCborItem(proofs[0]);
348
+ }
349
+ catch (err) {
350
+ return { ok: false, stage: "receipt-decode", reason: err instanceof Error ? err.message : String(err) };
351
+ }
352
+ const leaf = proof instanceof Map ? proof.get(1) : undefined;
353
+ const path = proof instanceof Map ? proof.get(2) : undefined;
354
+ if (!Array.isArray(leaf) || leaf.length !== 3 || !Array.isArray(path)) {
355
+ return { ok: false, stage: "receipt-decode", reason: "inclusion proof shape" };
356
+ }
357
+ const [internalHash, evidence, leafDigest] = leaf;
358
+ if (!(internalHash instanceof Uint8Array) ||
359
+ internalHash.length !== 32 ||
360
+ typeof evidence !== "string" ||
361
+ !(leafDigest instanceof Uint8Array) ||
362
+ leafDigest.length !== 32) {
363
+ return { ok: false, stage: "receipt-decode", reason: "inclusion proof leaf members" };
364
+ }
365
+ const steps = [];
366
+ for (const step of path) {
367
+ if (!Array.isArray(step) || step.length !== 2 || typeof step[0] !== "boolean" || !(step[1] instanceof Uint8Array) || step[1].length !== 32) {
368
+ return { ok: false, stage: "receipt-decode", reason: "inclusion proof path members" };
369
+ }
370
+ steps.push([step[0], step[1]]);
371
+ }
372
+ if (!Buffer.from(leafDigest).equals(Buffer.from(claimsDigest))) {
373
+ return { ok: false, stage: "inclusion", reason: "the receipt commits to another claims digest" };
374
+ }
375
+ let root = sha256(internalHash, sha256(Buffer.from(evidence, "utf8")), leafDigest);
376
+ for (const [left, node] of steps)
377
+ root = left ? sha256(node, root) : sha256(root, node);
378
+ return { ok: true, root, commitEvidence: evidence, sign1 };
277
379
  }
package/dist/types.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import type { DecisionKind, SignedDecisionRecord } from "@cedulon/core";
2
2
  import type { EffectRow, SignedEffectExtract } from "@cedulon/effect-extract";
3
+ /** A tool label. `reads-untrusted` taints the session when the call returns. `egress` is held once it is tainted. */
4
+ export type ToolLabelName = "reads-untrusted" | "egress";
3
5
  /** Who asked. G2 fills `brain` from JWT `sub` and `scopes` from `scope`. */
4
6
  export type Principal = {
5
7
  brain: string;
@@ -10,6 +12,11 @@ export type Principal = {
10
12
  tenant?: string;
11
13
  /** Explicit JWT `org` claim, when the issuer sends one and `tenant` is absent. */
12
14
  org?: string;
15
+ /**
16
+ * JWT `jti`. With the tenant key it names the session. Absent on a direct
17
+ * `proxy.call` that is not a token. An egress call with no `jti` is held.
18
+ */
19
+ jti?: string;
13
20
  };
14
21
  /** Same shape as `@cedulon/mcp-guard` so a later wrap can sit on this type. */
15
22
  export type ToolCall = {
@@ -99,6 +106,17 @@ export type Policy = {
99
106
  media?: MediaConfig;
100
107
  /** Document `scanCharCap`. Results read it even when no `dataClasses` key is set. */
101
108
  scanCharCap?: number;
109
+ /** Absent means a canary match halts the body. `deny` records the deny and leaves the switch alone. */
110
+ canary?: "halt" | "deny";
111
+ /**
112
+ * Operator labels. A key that is present replaces the built-in default,
113
+ * including an empty list. Absent keys keep the default.
114
+ */
115
+ toolLabels?: Readonly<Record<string, readonly ToolLabelName[]>>;
116
+ /** What an egress call does in a tainted session. Absent in the file means hold. */
117
+ sessionTaint?: "hold" | "deny";
118
+ /** What an unlabelled downstream tool is. Absent in the file means both labels. */
119
+ unlabelledDownstream?: "both" | "neither";
102
120
  };
103
121
  export type WitnessClass = "self" | "same-org" | "third-party" | "regulated";
104
122
  export type EffectAttestation = {
@@ -111,8 +129,20 @@ export type LedgerEffect = {
111
129
  resultHash?: string;
112
130
  /** One-row extract signed at call time. */
113
131
  receipt?: SignedEffectExtract;
114
- /** Signed { ref, effectHash, witnessClass, resultHash } via COSE Sign1. */
132
+ /**
133
+ * Signed `{ ref, effectHash, witnessClass, resultHash }` via COSE Sign1.
134
+ * When `receivingSession` is present, the payload also carries `session`
135
+ * and `sessionId`. Rows written before that field omit it and still verify.
136
+ */
115
137
  attestation?: EffectAttestation;
138
+ /**
139
+ * The session that ran this effect. Absent on rows written before the field,
140
+ * on `:halted` rows, and on a third-party receipt.
141
+ */
142
+ receivingSession?: {
143
+ jti: string;
144
+ sessionId: string;
145
+ };
116
146
  };
117
147
  export type RecordSigner = {
118
148
  privateKeyPem: string;
@@ -259,6 +289,40 @@ export type DecisionInputs = {
259
289
  withheld: Record<string, number>;
260
290
  returnedHash: string;
261
291
  };
292
+ /** A canary match. The id and the place in the call, never the value. */
293
+ canary?: {
294
+ finding: "canary-exfiltration";
295
+ id: string;
296
+ where: string;
297
+ };
298
+ /**
299
+ * JWT `jti` of the token that made this call. The gate's session key is the
300
+ * SHA-256 of the tenant key and this `jti`. Set only when the tool carries
301
+ * a session label, so an unlabelled call's inputs stay as they were.
302
+ */
303
+ session?: string;
304
+ /** Labels that applied when this call was decided. Replay does not re-read the policy. */
305
+ toolLabels?: {
306
+ readsUntrusted?: true;
307
+ egress?: true;
308
+ };
309
+ /**
310
+ * On an egress decision made while the session was tainted. `sourceRecordId`
311
+ * is `decisionRecordHash` of the call that tainted the session.
312
+ */
313
+ sessionTaint?: {
314
+ sourceRecordId: string;
315
+ sourceRef: string;
316
+ rule: string | null;
317
+ ruleText: string | null;
318
+ };
319
+ /** The operator clear. A tool call cannot write this. */
320
+ taintClear?: {
321
+ session: string;
322
+ by: string;
323
+ via: "cli";
324
+ atMs: number;
325
+ };
262
326
  };
263
327
  /** How an operator's approval reached the ledger: a person at `verax approve`, a non-interactive `--from-script` run, or the body's `/api/approve`. */
264
328
  export type ApprovalChannel = "cli" | "cli-script" | "http";
@@ -286,6 +350,13 @@ export type ProxyDeps = {
286
350
  resolveInput?: (id: string, principal?: Principal) => Promise<ResolvedInput | null>;
287
351
  /** True when the call names another tenant's memory id or decision ref. */
288
352
  checkTenantMismatch?: (call: ToolCall, principal: Principal) => Promise<boolean>;
353
+ /** Prefixed downstream tool names attached for this process. */
354
+ downstreamTools?: ReadonlySet<string>;
355
+ /**
356
+ * Labels from the downstream document, keyed by the prefixed tool name.
357
+ * A key that is present is labelled, including an empty list.
358
+ */
359
+ downstreamLabels?: Readonly<Record<string, readonly ToolLabelName[]>>;
289
360
  };
290
361
  export type ExplainFinding = {
291
362
  code: string | null;
@@ -336,6 +407,16 @@ export type ExplainResult = {
336
407
  guarantee: "unconditional" | "conditional";
337
408
  warnings: ExplainWarning[];
338
409
  trustRoot: ExplainTrustRoot;
410
+ /**
411
+ * Set when this held or denied egress call was decided in a tainted session.
412
+ * `sourceRecordId` names the call that tainted it. `rule` is the egress rule.
413
+ */
414
+ sessionTaint?: {
415
+ sourceRecordId: string;
416
+ sourceRef: string;
417
+ rule: string | null;
418
+ ruleText: string | null;
419
+ };
339
420
  scope?: {
340
421
  accountId: string;
341
422
  railId: string;
@@ -1,3 +1,4 @@
1
+ import { type SignedCheckpoint } from "@cedulon/checkpoint";
1
2
  import type { SignedDecisionRecord } from "@cedulon/core";
2
3
  export type VerifyTrust = {
3
4
  /** `pinned`: the caller supplied the key. `in-ledger`: read from the records. */
@@ -46,6 +47,17 @@ export type VerifyResult = {
46
47
  /** Transparency Service receipts for checkpoints, when the ledger holds any. */
47
48
  anchors: VerifyAnchors;
48
49
  problems: string[];
50
+ /**
51
+ * Decision records whose signatures verified under the key used for this run.
52
+ * Empty when none verified. Added for readers that must count only accepted
53
+ * rows; does not change ok, problems, or any existing field.
54
+ */
55
+ attestedDecisions: SignedDecisionRecord[];
56
+ /**
57
+ * Checkpoint rows whose signatures verified under the key used for this run.
58
+ * Empty when none verified. Same additive contract as attestedDecisions.
59
+ */
60
+ attestedCheckpoints: SignedCheckpoint[];
49
61
  };
50
62
  export type VerifyAnchors = {
51
63
  line: string;
@@ -14,8 +14,9 @@
14
14
  * its recorded `effectHash` equals the row's `effectHash`, and
15
15
  * the row carries an attestation and a witness receipt that both
16
16
  * verify under one effect key. The signed COSE payload is
17
- * `{ ref, effectHash, witnessClass, resultHash }`, compared after
18
- * decode, and the receipt's effect (`body.effects[0]`, every
17
+ * `{ ref, effectHash, witnessClass, resultHash }`, plus `session`
18
+ * and `sessionId` when the row carries `receivingSession`, compared
19
+ * after decode, and the receipt's effect (`body.effects[0]`, every
19
20
  * field the writer put there) must be that same row. A
20
21
  * `third-party` row instead needs a one-row receipt verified
21
22
  * under `thirdPartyPublicKeyPems` supplied by the reader, equal
@@ -90,8 +91,10 @@
90
91
  *
91
92
  * Control records are a further statement. An allow whose subject is
92
93
  * `verax.halt` opens a halt window; an allow whose subject is `verax.resume`
93
- * closes it. An allow whose subject does not start with `verax.` while a
94
- * window is open is `allow-while-halted <ref>` and `ok` is false. A deny
94
+ * closes it. An allow whose subject is `verax.taint-clear` is the operator
95
+ * clearing a session taint: it does not open or close a window, and it is
96
+ * not `allow-while-halted`. Any other allow while a window is open is
97
+ * `allow-while-halted <ref>` and `ok` is false. A deny
95
98
  * whose reason is `halted` and which sits outside every window is the
96
99
  * warning `halted-deny-without-halt-record <ref>` and does not change `ok`.
97
100
  * A ledger with no control record says so, and that sentence is not a violation.
@@ -104,7 +107,7 @@
104
107
  * the answer rather than a footnote, and `publicKeyPem` lets a reader pin a
105
108
  * copy they hold themselves.
106
109
  */
107
- import { createPublicKey } from "node:crypto";
110
+ import { createHash, createPublicKey } from "node:crypto";
108
111
  import { samePublicKey, thirdPartyReceiptCoversRow } from "./third-party.js";
109
112
  import { existsSync, lstatSync, readFileSync } from "node:fs";
110
113
  import { join } from "node:path";
@@ -115,7 +118,8 @@ import { verifyEffectExtract } from "@cedulon/effect-extract";
115
118
  import { anchorEntryHash, readAnchors } from "./anchors.js";
116
119
  import { checkpointsPath, readCheckpointFile } from "./checkpoints.js";
117
120
  import { sha256Canonical } from "./hash.js";
118
- import { verifyReceipt } from "./transparency-receipt.js";
121
+ import { readCheckpointStatement } from "./signed-statement.js";
122
+ import { verifyCcfReceipt, verifyReceipt } from "./transparency-receipt.js";
119
123
  import { ledgerPiecePathProblem, readLedgerManifest, requireLedgerPiecePath, indexPath, manifestPath, parseIndexText, } from "./ledger-manifest.js";
120
124
  /**
121
125
  * A symbolic link is a named problem and is not read. Missing files are not
@@ -276,9 +280,10 @@ function noteEd25519(pem, problems) {
276
280
  }
277
281
  /**
278
282
  * The writer signs `{ ref, effectHash, witnessClass, resultHash }` as COSE
279
- * Sign1 and a one-row extract. A row with either missing is not bound. Both
280
- * must verify under the key the caller settled on for this row's witness
281
- * class — never a key this row brought by itself.
283
+ * Sign1 and a one-row extract. When the row carries `receivingSession`, the
284
+ * payload also has `session` and `sessionId`. A row with either signature
285
+ * missing is not bound. Both must verify under the key the caller settled
286
+ * on for this row's witness class — never a key this row brought by itself.
282
287
  */
283
288
  function effectSignatureCoversRow(effect, effectKey) {
284
289
  const coseHex = effect.attestation?.coseHex;
@@ -294,11 +299,20 @@ function effectSignatureCoversRow(effect, effectKey) {
294
299
  if (typeof ref !== "string" || typeof effectHash !== "string" || typeof witnessClass !== "string") {
295
300
  return false;
296
301
  }
302
+ const receiving = effect.receivingSession;
303
+ const sessionBound = receiving &&
304
+ typeof receiving.jti === "string" &&
305
+ receiving.jti !== "" &&
306
+ typeof receiving.sessionId === "string" &&
307
+ receiving.sessionId !== ""
308
+ ? { session: receiving.jti, sessionId: receiving.sessionId }
309
+ : null;
297
310
  const expected = canonical({
298
311
  ref,
299
312
  effectHash,
300
313
  witnessClass,
301
314
  resultHash: typeof effect.resultHash === "string" ? effect.resultHash : null,
315
+ ...(sessionBound ?? {}),
302
316
  });
303
317
  let decodedPayload;
304
318
  try {
@@ -711,6 +725,7 @@ function tailStatement(dir, records, checkpointPublicKeyPem, attested = records)
711
725
  checkpointTrust: checkpointTrustOf(pinned, null, 0),
712
726
  problems: [checkpointLink],
713
727
  verified: [],
728
+ attestedRows: [],
714
729
  };
715
730
  }
716
731
  const loaded = readCheckpointFile(dir);
@@ -721,12 +736,14 @@ function tailStatement(dir, records, checkpointPublicKeyPem, attested = records)
721
736
  const checkpointTrust = checkpointTrustOf(pinned, taken, rows.length);
722
737
  const problems = [...loaded.problems];
723
738
  const verified = [];
739
+ const attestedRows = [];
724
740
  noteEd25519(key, problems);
725
741
  for (let i = 0; i < rows.length; i += 1) {
726
742
  if (!checkpointRowVerifies(rows[i], key)) {
727
743
  problems.push(`checkpoint signature does not verify: checkpoint ${i}`);
728
744
  continue;
729
745
  }
746
+ attestedRows.push(rows[i]);
730
747
  try {
731
748
  const count = rows[i].claims.receiptCount;
732
749
  const endMs = rows[i].claims.endMs;
@@ -734,6 +751,7 @@ function tailStatement(dir, records, checkpointPublicKeyPem, attested = records)
734
751
  hash: checkpointHash(rows[i]),
735
752
  receiptCount: typeof count === "number" ? count : null,
736
753
  endMs: typeof endMs === "number" ? endMs : null,
754
+ keyPem: key ?? "",
737
755
  });
738
756
  }
739
757
  catch {
@@ -758,7 +776,7 @@ function tailStatement(dir, records, checkpointPublicKeyPem, attested = records)
758
776
  const covered = brk ? rows.slice(0, brk.index) : rows;
759
777
  const newest = covered.length > 0 ? covered[covered.length - 1] : null;
760
778
  if (!newest) {
761
- return { tail: { line: TAIL_NONE, checkpoint: null }, checkpointTrust, problems, verified };
779
+ return { tail: { line: TAIL_NONE, checkpoint: null }, checkpointTrust, problems, verified, attestedRows };
762
780
  }
763
781
  const claims = newest.claims;
764
782
  const receiptCount = typeof claims.receiptCount === "number" ? claims.receiptCount : null;
@@ -789,6 +807,7 @@ function tailStatement(dir, records, checkpointPublicKeyPem, attested = records)
789
807
  checkpointTrust,
790
808
  problems,
791
809
  verified,
810
+ attestedRows,
792
811
  };
793
812
  }
794
813
  /**
@@ -855,26 +874,45 @@ function anchorStatement(dir, checkpoints, keyPem, problems, required = null) {
855
874
  problems.push(`anchor names a checkpoint the ledger does not hold: ${short}`);
856
875
  continue;
857
876
  }
858
- let entry;
859
- try {
860
- entry = anchorEntryHash(row.checkpointHash, row.route);
861
- }
862
- catch {
863
- problems.push(`anchor route is not one this verifier reads: ${short}`);
864
- continue;
865
- }
866
- if (entry !== row.entryHash) {
867
- problems.push(`anchor entry hash is not the checkpoint's: ${short}`);
868
- continue;
869
- }
870
- const check = verifyReceipt(Buffer.from(row.receiptB64, "base64"), Buffer.from(entry, "hex"), keyPem);
871
- if (!check.ok) {
872
- problems.push(`anchor receipt does not verify: ${short} (${check.stage}: ${check.reason})`);
873
- continue;
877
+ if (row.route === "entries") {
878
+ // The receipt commits to the Signed Statement, so the statement is
879
+ // checked first: it must name this checkpoint and be signed by the key
880
+ // the checkpoint verified under.
881
+ const statement = Buffer.from(row.statementB64, "base64");
882
+ const read = readCheckpointStatement(statement, row.checkpointHash, checkpoint.keyPem);
883
+ if (!read.ok) {
884
+ problems.push(`anchor statement is not this checkpoint's: ${short} (${read.reason})`);
885
+ continue;
886
+ }
887
+ const digest = createHash("sha256").update(statement).digest();
888
+ const check = verifyCcfReceipt(Buffer.from(row.receiptB64, "base64"), digest, keyPem);
889
+ if (!check.ok) {
890
+ problems.push(`anchor receipt does not verify: ${short} (${check.stage}: ${check.reason})`);
891
+ continue;
892
+ }
874
893
  }
875
- if (check.treeSize !== row.treeSize || check.leafIndex !== row.leafIndex) {
876
- problems.push(`anchor row disagrees with its receipt: ${short}`);
877
- continue;
894
+ else {
895
+ let entry;
896
+ try {
897
+ entry = anchorEntryHash(row.checkpointHash, row.route);
898
+ }
899
+ catch {
900
+ problems.push(`anchor route is not one this verifier reads: ${short}`);
901
+ continue;
902
+ }
903
+ if (entry !== row.entryHash) {
904
+ problems.push(`anchor entry hash is not the checkpoint's: ${short}`);
905
+ continue;
906
+ }
907
+ const check = verifyReceipt(Buffer.from(row.receiptB64, "base64"), Buffer.from(entry, "hex"), keyPem);
908
+ if (!check.ok) {
909
+ problems.push(`anchor receipt does not verify: ${short} (${check.stage}: ${check.reason})`);
910
+ continue;
911
+ }
912
+ if (check.treeSize !== row.treeSize || check.leafIndex !== row.leafIndex) {
913
+ problems.push(`anchor row disagrees with its receipt: ${short}`);
914
+ continue;
915
+ }
878
916
  }
879
917
  verified += 1;
880
918
  anchoredHashes.add(row.checkpointHash);
@@ -1013,14 +1051,18 @@ function controlStatement(records) {
1013
1051
  const decision = record.claims?.decision;
1014
1052
  const reason = record.claims?.reasonCode;
1015
1053
  const ref = typeof record.claims?.ref === "string" ? record.claims.ref : "?";
1016
- // Only the two control subjects, with the control effect class, open or
1017
- // close a window. Any other allow inside one is a violation, including a
1018
- // downstream tool whose prefix happens to be "verax".
1054
+ // Halt and resume open or close a window. A taint clear is a control
1055
+ // allow and is not a tool that ran during the halt. Any other allow
1056
+ // inside a window is a violation, including a downstream tool whose
1057
+ // prefix happens to be "verax".
1019
1058
  const control = record.claims?.effectClass === "verax.control";
1020
1059
  const halt = control && decision === "allow" && subject === "verax.halt";
1021
1060
  const resume = control && decision === "allow" && subject === "verax.resume";
1022
- if (halt || resume)
1061
+ const taintClear = control && decision === "allow" && subject === "verax.taint-clear";
1062
+ if (halt || resume || taintClear)
1023
1063
  controlRecords += 1;
1064
+ if (taintClear)
1065
+ continue;
1024
1066
  if (halt) {
1025
1067
  if (!open)
1026
1068
  windows += 1;
@@ -1071,6 +1113,8 @@ function unreadableResult(dir, problem) {
1071
1113
  inputs: INPUTS_UNCHECKED,
1072
1114
  anchors: ANCHORS_NONE,
1073
1115
  problems: [problem],
1116
+ attestedDecisions: [],
1117
+ attestedCheckpoints: [],
1074
1118
  };
1075
1119
  }
1076
1120
  function isDecisionRow(row) {
@@ -1154,6 +1198,8 @@ async function verifyLedgerUnchecked(dir, opts = {}) {
1154
1198
  inputs: INPUTS_UNCHECKED,
1155
1199
  anchors: ANCHORS_NONE,
1156
1200
  problems,
1201
+ attestedDecisions: [],
1202
+ attestedCheckpoints: [],
1157
1203
  };
1158
1204
  }
1159
1205
  const pinned = opts.publicKeyPem?.trim();
@@ -1469,5 +1515,7 @@ async function verifyLedgerUnchecked(dir, opts = {}) {
1469
1515
  inputs,
1470
1516
  anchors,
1471
1517
  problems,
1518
+ attestedDecisions: attested,
1519
+ attestedCheckpoints: tailed.attestedRows,
1472
1520
  };
1473
1521
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verax-ai/proxy",
3
- "version": "0.8.2",
3
+ "version": "0.10.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "engines": {
@@ -19,12 +19,12 @@
19
19
  "policy"
20
20
  ],
21
21
  "dependencies": {
22
- "@cedulon/audit": "0.13.1",
23
- "@cedulon/checkpoint": "0.13.1",
24
- "@cedulon/core": "0.13.1",
25
- "@cedulon/cose": "0.13.1",
26
- "@cedulon/effect-extract": "0.13.1",
27
- "@cedulon/x402-adapter": "0.13.1",
22
+ "@cedulon/audit": "0.16.0",
23
+ "@cedulon/checkpoint": "0.16.0",
24
+ "@cedulon/core": "0.16.0",
25
+ "@cedulon/cose": "0.16.0",
26
+ "@cedulon/effect-extract": "0.16.0",
27
+ "@cedulon/x402-adapter": "0.16.0",
28
28
  "@conarium-ai/mask": "0.3.5"
29
29
  },
30
30
  "description": "The decision proxy behind VERAX: policy, signed decision records, and the ledger they live in.",