@action-state-group/capsule-viewer 0.8.0 → 0.9.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.
@@ -3232,14 +3232,14 @@ var EvidenceGraph = (() => {
3232
3232
  throw new Error("expected non-negative bigint, got " + n);
3233
3233
  return n === _0n ? 0 : n.toString(2).length;
3234
3234
  }
3235
- function validateObject(object13, fields2 = {}, optFields = {}, title = "object") {
3236
- aobject2(object13, title);
3235
+ function validateObject(object14, fields2 = {}, optFields = {}, title = "object") {
3236
+ aobject2(object14, title);
3237
3237
  aobject2(fields2, "fields");
3238
3238
  aobject2(optFields, "optFields");
3239
3239
  function checkField(fieldName, expectedType, isOpt) {
3240
3240
  const label = title === "object" ? `param "${String(fieldName)}"` : `"${title}.${String(fieldName)}"`;
3241
- const val = object13[fieldName];
3242
- if (!Object.hasOwn(object13, fieldName) && (isOpt ? val !== void 0 : expectedType !== "function")) {
3241
+ const val = object14[fieldName];
3242
+ if (!Object.hasOwn(object14, fieldName) && (isOpt ? val !== void 0 : expectedType !== "function")) {
3243
3243
  throw new TypeError(`${label} is invalid: expected own property`);
3244
3244
  }
3245
3245
  if (isOpt && val === void 0)
@@ -4807,10 +4807,10 @@ var EvidenceGraph = (() => {
4807
4807
  ...claims.has("cadence") ? { cadence: claims.get("cadence") } : {}
4808
4808
  };
4809
4809
  }
4810
- function verifyEd25519(publicKey, message, signature) {
4811
- if (publicKey.length !== 32 || signature.length !== 64) return false;
4812
- const r = signature.subarray(0, 32);
4813
- const s = littleEndian(signature.subarray(32));
4810
+ function verifyEd25519(publicKey, message, signature2) {
4811
+ if (publicKey.length !== 32 || signature2.length !== 64) return false;
4812
+ const r = signature2.subarray(0, 32);
4813
+ const s = littleEndian(signature2.subarray(32));
4814
4814
  if (s >= Point.Fn.ORDER) return false;
4815
4815
  let a;
4816
4816
  let rPoint;
@@ -5047,7 +5047,7 @@ var EvidenceGraph = (() => {
5047
5047
  verifyRange2 = (root, size, fromIndex, toIndex, bodyDigests, proof) => verifyRange(hash, root, size, fromIndex, toIndex, bodyDigests, proof);
5048
5048
  checkpointCrypto = {
5049
5049
  hash,
5050
- verifyEd25519: async (publicKey, message, signature) => verifyEd25519(publicKey, message, signature)
5050
+ verifyEd25519: async (publicKey, message, signature2) => verifyEd25519(publicKey, message, signature2)
5051
5051
  };
5052
5052
  verifyCheckpoint = (cose) => verifyCheckpointWith(checkpointCrypto, cose);
5053
5053
  checkpointMetadata = (cose) => checkpointMetadataWith(checkpointCrypto, cose);
@@ -5089,6 +5089,8 @@ var EvidenceGraph = (() => {
5089
5089
  obligationStatus: () => obligationStatus,
5090
5090
  placeholders: () => placeholders,
5091
5091
  readWordingPack: () => readWordingPack,
5092
+ readerAnchorWitness: () => readerAnchorWitness,
5093
+ readerWitnessPolicy: () => readerWitnessPolicy,
5092
5094
  registerPresentation: () => registerPresentation,
5093
5095
  renderChecking: () => renderChecking,
5094
5096
  renderCompliancePage: () => renderCompliancePage,
@@ -5098,6 +5100,7 @@ var EvidenceGraph = (() => {
5098
5100
  renderUnableToVerify: () => renderUnableToVerify,
5099
5101
  resolvePresentation: () => resolvePresentation,
5100
5102
  rowStatus: () => rowStatus,
5103
+ setReaderWitnessPolicy: () => setReaderWitnessPolicy,
5101
5104
  tierReader: () => tierReader,
5102
5105
  verifiedPayload: () => verifiedPayload,
5103
5106
  verifyDisclosureEnvelope: () => verifyDisclosureEnvelope,
@@ -5160,6 +5163,63 @@ var EvidenceGraph = (() => {
5160
5163
  return concat(spkiPrefix, publicKey);
5161
5164
  }
5162
5165
 
5166
+ // node_modules/@action-state-group/agent-action-capsule/dist/ed25519-strict.js
5167
+ var SMALL_ORDER_Y = [
5168
+ "0000000000000000000000000000000000000000000000000000000000000000",
5169
+ "0100000000000000000000000000000000000000000000000000000000000000",
5170
+ "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f",
5171
+ "c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a",
5172
+ "26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05"
5173
+ ];
5174
+ var ED25519_L = hexToBytes("edd3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010");
5175
+ function strictPoint(encoded) {
5176
+ const y = Uint8Array.from(encoded);
5177
+ y[31] &= 127;
5178
+ const canonical = !(y[0] >= 237 && y.subarray(1, 31).every((b) => b === 255) && y[31] === 127);
5179
+ const hex5 = Array.from(y, (b) => b.toString(16).padStart(2, "0")).join("");
5180
+ return canonical && !SMALL_ORDER_Y.includes(hex5);
5181
+ }
5182
+ function strictEd25519(publicKey, signature2) {
5183
+ if (publicKey.length !== 32 || signature2.length !== 64)
5184
+ return false;
5185
+ if (!strictPoint(publicKey) || !strictPoint(signature2.subarray(0, 32)))
5186
+ return false;
5187
+ for (let i = 31; i >= 0; i--) {
5188
+ const s = signature2[32 + i];
5189
+ if (s !== ED25519_L[i])
5190
+ return s < ED25519_L[i];
5191
+ }
5192
+ return false;
5193
+ }
5194
+ async function verifyEd25519Strict(publicKey, signature2, message) {
5195
+ if (!strictEd25519(publicKey, signature2))
5196
+ return false;
5197
+ const subtle = globalThis.crypto.subtle;
5198
+ const key = await subtle.importKey("raw", publicKey, { name: "Ed25519" }, false, ["verify"]);
5199
+ return await subtle.verify({ name: "Ed25519" }, key, signature2, message);
5200
+ }
5201
+
5202
+ // node_modules/@action-state-group/agent-action-capsule/dist/nesting.js
5203
+ var MAX_NESTING_DEPTH = 128;
5204
+ function nestedTooDeep(value) {
5205
+ const stack = [[value, 0]];
5206
+ while (stack.length !== 0) {
5207
+ const [node, depth] = stack.pop();
5208
+ let children;
5209
+ if (Array.isArray(node))
5210
+ children = node;
5211
+ else if (node !== null && typeof node === "object" && !(node instanceof JsonNumber))
5212
+ children = Object.values(node);
5213
+ else
5214
+ continue;
5215
+ if (depth >= MAX_NESTING_DEPTH)
5216
+ return true;
5217
+ for (const child of children)
5218
+ stack.push([child, depth + 1]);
5219
+ }
5220
+ return false;
5221
+ }
5222
+
5163
5223
  // node_modules/@action-state-group/agent-action-capsule/dist/sha256.js
5164
5224
  var K = new Uint32Array([
5165
5225
  1116352408,
@@ -5294,7 +5354,6 @@ var EvidenceGraph = (() => {
5294
5354
  // node_modules/@action-state-group/agent-action-capsule/dist/json.js
5295
5355
  var utf8 = new TextDecoder("utf-8", { fatal: true });
5296
5356
  var encoder2 = new TextEncoder();
5297
- var MAX_DEPTH = 1e3;
5298
5357
  var numberToken = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/;
5299
5358
  var JsonNumber = class {
5300
5359
  raw;
@@ -5345,12 +5404,12 @@ var EvidenceGraph = (() => {
5345
5404
  offset += 1;
5346
5405
  };
5347
5406
  const parse = (depth) => {
5348
- if (depth > MAX_DEPTH)
5349
- throw new SyntaxError(`JSON nesting exceeds ${MAX_DEPTH}`);
5350
5407
  ws();
5351
5408
  const c = text2[offset];
5352
5409
  if (c === '"')
5353
5410
  return parseString();
5411
+ if ((c === "{" || c === "[") && depth >= MAX_NESTING_DEPTH)
5412
+ throw new SyntaxError(`JSON nesting exceeds ${MAX_NESTING_DEPTH}`);
5354
5413
  if (c === "{") {
5355
5414
  offset += 1;
5356
5415
  const value2 = {};
@@ -5471,8 +5530,6 @@ var EvidenceGraph = (() => {
5471
5530
  return JSON.stringify(value);
5472
5531
  }
5473
5532
  function render(value, path2, seen, depth) {
5474
- if (depth > MAX_DEPTH)
5475
- throw new TypeError(`JSON nesting exceeds ${MAX_DEPTH}`);
5476
5533
  if (value === null)
5477
5534
  return "null";
5478
5535
  if (typeof value === "boolean")
@@ -5496,6 +5553,8 @@ var EvidenceGraph = (() => {
5496
5553
  }
5497
5554
  if (typeof value !== "object" || value === void 0)
5498
5555
  throw new TypeError(`unsupported JSON value at ${path2}`);
5556
+ if (depth >= MAX_NESTING_DEPTH)
5557
+ throw new TypeError(`JSON nesting exceeds ${MAX_NESTING_DEPTH}`);
5499
5558
  if (seen.has(value))
5500
5559
  throw new TypeError(`cyclic JSON value at ${path2}`);
5501
5560
  seen.add(value);
@@ -5665,8 +5724,11 @@ var EvidenceGraph = (() => {
5665
5724
  } catch (error) {
5666
5725
  return error?.name === "NotSupportedError" ? void 0 : false;
5667
5726
  }
5727
+ const signature2 = hexToBytes(signatureHex);
5728
+ if (!strictEd25519(hexToBytes(keyId), signature2))
5729
+ return false;
5668
5730
  try {
5669
- return await globalThis.crypto.subtle.verify({ name: "Ed25519" }, key, hexToBytes(signatureHex), countersignV1SigningInput(entry));
5731
+ return await globalThis.crypto.subtle.verify({ name: "Ed25519" }, key, signature2, countersignV1SigningInput(entry));
5670
5732
  } catch {
5671
5733
  return false;
5672
5734
  }
@@ -6059,6 +6121,18 @@ var EvidenceGraph = (() => {
6059
6121
  const add2 = (code2, detail, check, severity = "error") => {
6060
6122
  findings.push(check === void 0 ? { code: code2, detail, severity } : { code: code2, detail, severity, check });
6061
6123
  };
6124
+ if (nestedTooDeep(capsule))
6125
+ return {
6126
+ ok: false,
6127
+ findings: [
6128
+ {
6129
+ code: "verifier_internal_error",
6130
+ detail: "Capsule is nested too deeply or contains itself",
6131
+ severity: "error"
6132
+ }
6133
+ ],
6134
+ assurance: {}
6135
+ };
6062
6136
  const top = object2(capsule);
6063
6137
  if (top === void 0)
6064
6138
  return {
@@ -7198,7 +7272,7 @@ var EvidenceGraph = (() => {
7198
7272
  if (reader.byte() !== 160)
7199
7273
  throw new SyntaxError("unprotected header MUST be an empty map");
7200
7274
  const payload = reader.bytes();
7201
- const signature = reader.bytes();
7275
+ const signature2 = reader.bytes();
7202
7276
  if (reader.offset !== data.length)
7203
7277
  throw new SyntaxError("trailing CBOR data");
7204
7278
  const protectedHeaders = protectedHeaderMap(protectedBytes);
@@ -7214,10 +7288,10 @@ var EvidenceGraph = (() => {
7214
7288
  return fail2("envelope_protected_headers_invalid", "protected header MUST contain exactly alg, content type, and kid");
7215
7289
  if (!equalBytes(payload, hexToBytes(capsuleId)))
7216
7290
  return fail2("envelope_payload_mismatch", "attached payload MUST equal the raw 32-byte Capsule ID");
7217
- if (signature.length !== 64)
7291
+ if (signature2.length !== 64)
7218
7292
  return fail2("envelope_signature_invalid", "Ed25519 signature MUST be 64 bytes");
7219
7293
  const key = await globalThis.crypto.subtle.importKey("spki", producerPublicKeySpki(publicKey), { name: "Ed25519" }, false, ["verify"]);
7220
- if (!await globalThis.crypto.subtle.verify({ name: "Ed25519" }, key, signature, producerEnvelopeSigningBytes(protectedBytes, payload)))
7294
+ if (!await globalThis.crypto.subtle.verify({ name: "Ed25519" }, key, signature2, producerEnvelopeSigningBytes(protectedBytes, payload)))
7221
7295
  return fail2("envelope_signature_invalid", "Ed25519 signature verification failed");
7222
7296
  return {
7223
7297
  ok: true,
@@ -7294,6 +7368,8 @@ var EvidenceGraph = (() => {
7294
7368
  async function gradeRecordSignature(record) {
7295
7369
  if (!plainObject(record))
7296
7370
  return { verdict: "invalid", messages: ["not a JSON object"] };
7371
+ if (nestedTooDeep(record))
7372
+ return { verdict: "invalid", messages: ["record is nested too deeply"] };
7297
7373
  const id = idText(record);
7298
7374
  const hasSignature = Object.hasOwn(record, "signature"), hasKeyId = Object.hasOwn(record, "key_id");
7299
7375
  if (!hasSignature && !hasKeyId)
@@ -7306,8 +7382,8 @@ var EvidenceGraph = (() => {
7306
7382
  ]
7307
7383
  };
7308
7384
  try {
7309
- const signature = digitPairs(record.signature, "signature"), keyId = digitPairs(record.key_id, "key_id");
7310
- const result = await verifyProducerEnvelope(await recordCapsuleId(record), signature);
7385
+ const signature2 = digitPairs(record.signature, "signature"), keyId = digitPairs(record.key_id, "key_id");
7386
+ const result = await verifyProducerEnvelope(await recordCapsuleId(record), signature2);
7311
7387
  if (result.ok && result.publicKey !== void 0 && equalBytes(result.publicKey, keyId))
7312
7388
  return { verdict: "authored", messages: [] };
7313
7389
  } catch (error) {
@@ -7326,6 +7402,156 @@ var EvidenceGraph = (() => {
7326
7402
  };
7327
7403
  }
7328
7404
 
7405
+ // node_modules/@action-state-group/agent-action-capsule/dist/category-coverage.js
7406
+ var CATEGORY_STATUSES = [
7407
+ "AVAILABLE",
7408
+ "PARTIAL",
7409
+ "WITHHELD",
7410
+ "DELETED",
7411
+ "ABSENT",
7412
+ "UNDISCLOSED"
7413
+ ];
7414
+ var CATEGORY_COVERAGE_GATING = [
7415
+ "category_coverage_form",
7416
+ "category_coverage_signature",
7417
+ "category_coverage_consistency"
7418
+ ];
7419
+ var object6 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) && !(value instanceof JsonNumber);
7420
+ var HEX128 = /^[0-9a-f]{128}$/u;
7421
+ var ABSOLUTE_URI = /^[A-Za-z][A-Za-z0-9+.-]*:(?:[A-Za-z0-9._~!$&'()*+,;=:@/?-]|%[0-9A-Fa-f]{2})*$/u;
7422
+ var PRIVATE_SET = "x-";
7423
+ var CONTRADICTED_BY_A_RECORD = ["ABSENT", "WITHHELD"];
7424
+ function categoryCoverageSigningInput(member, root) {
7425
+ const unsigned = {};
7426
+ for (const [name, value] of Object.entries(member))
7427
+ if (name !== "signature")
7428
+ Object.defineProperty(unsigned, name, {
7429
+ value,
7430
+ enumerable: true,
7431
+ writable: true,
7432
+ configurable: true
7433
+ });
7434
+ return jcs({ category_coverage: unsigned, root });
7435
+ }
7436
+ function wellFormed(member) {
7437
+ if (!object6(member))
7438
+ return false;
7439
+ if (typeof member.set !== "string" || member.set === "")
7440
+ return false;
7441
+ const categories = member.categories;
7442
+ if (!object6(categories) || Object.keys(categories).length === 0)
7443
+ return false;
7444
+ for (const [name, entry] of Object.entries(categories)) {
7445
+ if (name === "" || !object6(entry) || !CATEGORY_STATUSES.includes(entry.status))
7446
+ return false;
7447
+ const hasUri = Object.hasOwn(entry, "policy_uri");
7448
+ if (hasUri && !(typeof entry.policy_uri === "string" && ABSOLUTE_URI.test(entry.policy_uri)))
7449
+ return false;
7450
+ if (entry.status === "UNDISCLOSED" && !hasUri)
7451
+ return false;
7452
+ }
7453
+ if (Object.hasOwn(member, "request_digest") && !isHex64(member.request_digest))
7454
+ return false;
7455
+ const hasSigner = Object.hasOwn(member, "signer");
7456
+ if (hasSigner !== Object.hasOwn(member, "signature"))
7457
+ return false;
7458
+ if (hasSigner) {
7459
+ const signer = member.signer;
7460
+ if (!object6(signer) || !isHex64(signer.key_id))
7461
+ return false;
7462
+ if (typeof member.signature !== "string" || !HEX128.test(member.signature))
7463
+ return false;
7464
+ }
7465
+ return true;
7466
+ }
7467
+ async function signature(member, root) {
7468
+ if (!Object.hasOwn(member, "signature"))
7469
+ return "NOT_PRESENT";
7470
+ let signingInput;
7471
+ try {
7472
+ signingInput = categoryCoverageSigningInput(member, root);
7473
+ } catch {
7474
+ return "FAIL";
7475
+ }
7476
+ const key = hexToBytes(member.signer.key_id);
7477
+ const sig = hexToBytes(member.signature);
7478
+ if (!strictEd25519(key, sig))
7479
+ return "FAIL";
7480
+ if (!await probeEd25519())
7481
+ return "NOT_CHECKED";
7482
+ try {
7483
+ return await verifyEd25519Strict(key, sig, signingInput) ? "PASS" : "FAIL";
7484
+ } catch {
7485
+ return "FAIL";
7486
+ }
7487
+ }
7488
+ function setRegistered(member, categorySets) {
7489
+ const set = member.set;
7490
+ if (set.startsWith(PRIVATE_SET))
7491
+ return "NOT_PRESENT";
7492
+ const known = categorySets && Object.hasOwn(categorySets, set) ? categorySets[set] : void 0;
7493
+ if (known === void 0 || known === null)
7494
+ return "INCONCLUSIVE";
7495
+ return Object.keys(member.categories).every((name) => known.includes(name)) ? "PASS" : "FAIL";
7496
+ }
7497
+ async function request(member, octets) {
7498
+ if (octets === null || octets === void 0)
7499
+ return "NOT_CHECKED";
7500
+ if (Object.hasOwn(member, "request_digest") && member.request_digest !== await sha256Hex(octets))
7501
+ return "FAIL";
7502
+ let parsed;
7503
+ try {
7504
+ if (octets[0] === 239 && octets[1] === 187 && octets[2] === 191)
7505
+ return "NOT_CHECKED";
7506
+ parsed = decodeStrictJson(octets);
7507
+ } catch {
7508
+ return "NOT_CHECKED";
7509
+ }
7510
+ if (!object6(parsed))
7511
+ return "NOT_CHECKED";
7512
+ if (!Object.hasOwn(parsed, "categories"))
7513
+ return "NOT_PRESENT";
7514
+ const asked = parsed.categories;
7515
+ const names2 = object6(asked) ? asked.names : void 0;
7516
+ if (!object6(asked) || typeof asked.set !== "string" || !Array.isArray(names2) || names2.length === 0 || !names2.every((name) => typeof name === "string") || new Set(names2).size !== names2.length)
7517
+ return "NOT_CHECKED";
7518
+ if (asked.set !== member.set)
7519
+ return "FAIL";
7520
+ const categories = member.categories;
7521
+ return names2.every((name) => Object.hasOwn(categories, name)) ? "PASS" : "FAIL";
7522
+ }
7523
+ function consistency(member, recordIds, recordCategories) {
7524
+ if (recordCategories === null || recordCategories === void 0 || recordIds.some((id) => !Object.hasOwn(recordCategories, id)))
7525
+ return "NOT_CHECKED";
7526
+ const carried = new Set(recordIds.map((id) => recordCategories[id]));
7527
+ return Object.entries(member.categories).some(([name, entry]) => CONTRADICTED_BY_A_RECORD.includes(entry.status) && carried.has(name)) ? "FAIL" : "PASS";
7528
+ }
7529
+ async function checkCategoryCoverage(bundle, inputs = {}) {
7530
+ if (!Object.hasOwn(bundle, "category_coverage"))
7531
+ return null;
7532
+ const member = bundle.category_coverage;
7533
+ if (!wellFormed(member))
7534
+ return {
7535
+ category_coverage_form: "FAIL",
7536
+ category_coverage_signature: "NOT_CHECKED",
7537
+ category_coverage_set_registered: "NOT_CHECKED",
7538
+ category_coverage_request: "NOT_CHECKED",
7539
+ category_coverage_consistency: "NOT_CHECKED"
7540
+ };
7541
+ const records = Array.isArray(bundle.records) ? bundle.records : [];
7542
+ const recordIds = records.filter(object6).map((record) => record.capsule_id).filter((id) => typeof id === "string");
7543
+ return {
7544
+ category_coverage_form: "PASS",
7545
+ category_coverage_signature: await signature(member, Object.hasOwn(bundle, "root") ? bundle.root : null),
7546
+ category_coverage_set_registered: setRegistered(member, inputs.categorySets),
7547
+ category_coverage_request: await request(member, inputs.categoryRequest),
7548
+ category_coverage_consistency: consistency(member, recordIds, inputs.recordCategories)
7549
+ };
7550
+ }
7551
+ function categoryCoverageFails(result) {
7552
+ return result !== null && CATEGORY_COVERAGE_GATING.some((name) => result[name] === "FAIL");
7553
+ }
7554
+
7329
7555
  // node_modules/@action-state-group/agent-action-capsule/dist/cose-receipt.js
7330
7556
  var COSE_SIGN1_TAG = 18n;
7331
7557
  var HDR_ALG = 1n;
@@ -7343,7 +7569,7 @@ var EvidenceGraph = (() => {
7343
7569
  var MAX_INCLUSION_PROOFS = 16;
7344
7570
  var MAX_AUDIT_PATH = 64;
7345
7571
  var MAX_TREE_SIZE = 1n << 62n;
7346
- var MAX_DEPTH2 = 32;
7572
+ var MAX_RECEIPT_DEPTH = 16;
7347
7573
  var CborMap = class {
7348
7574
  entries;
7349
7575
  constructor(entries) {
@@ -7371,10 +7597,32 @@ var EvidenceGraph = (() => {
7371
7597
  }
7372
7598
  };
7373
7599
  var utf84 = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
7374
- function decodeStrictCbor(data) {
7375
- return decodeCbor(data, true);
7600
+ function decodeReceiptItem(data, topTag) {
7601
+ const value = decodeCbor(data);
7602
+ const walk = (item, depth) => {
7603
+ if (typeof item === "bigint" && item < -(1n << 63n))
7604
+ throw new SyntaxError("an integer below -2^63");
7605
+ if (item instanceof CborTag) {
7606
+ if (!(depth === 0 && topTag && item.tag === COSE_SIGN1_TAG))
7607
+ throw new SyntaxError("a tag other than the outer tag 18");
7608
+ walk(item.value, depth + 1);
7609
+ } else if (Array.isArray(item)) {
7610
+ for (const inner of item)
7611
+ walk(inner, depth + 1);
7612
+ } else if (item instanceof CborMap) {
7613
+ for (const [key, inner] of item.entries) {
7614
+ if (typeof key !== "bigint" && typeof key !== "string")
7615
+ throw new SyntaxError("a map key that is not an integer or text");
7616
+ walk(key, depth + 1);
7617
+ walk(inner, depth + 1);
7618
+ }
7619
+ } else if (!(item === null || typeof item === "boolean" || typeof item === "bigint" || typeof item === "string" || item instanceof Uint8Array))
7620
+ throw new SyntaxError("a float or a simple value");
7621
+ };
7622
+ walk(value, 0);
7623
+ return value;
7376
7624
  }
7377
- function decodeCbor(data, shortest) {
7625
+ function decodeCbor(data) {
7378
7626
  let offset = 0;
7379
7627
  const byte = () => {
7380
7628
  const value2 = data[offset++];
@@ -7398,12 +7646,12 @@ var EvidenceGraph = (() => {
7398
7646
  let value2 = 0n;
7399
7647
  for (let i = 0; i < width; i += 1)
7400
7648
  value2 = value2 << 8n | BigInt(byte());
7401
- if (shortest && value2 < [24n, 1n << 8n, 1n << 16n, 1n << 32n][add2 - 24])
7649
+ if (value2 < [24n, 1n << 8n, 1n << 16n, 1n << 32n][add2 - 24])
7402
7650
  throw new SyntaxError("CBOR argument is not in its shortest form");
7403
7651
  return value2;
7404
7652
  };
7405
7653
  const item = (depth) => {
7406
- if (depth > MAX_DEPTH2)
7654
+ if (depth > MAX_RECEIPT_DEPTH)
7407
7655
  throw new SyntaxError("CBOR nesting too deep");
7408
7656
  const first = byte(), major = first >>> 5, add2 = first & 31;
7409
7657
  if (major === 7) {
@@ -7430,51 +7678,10 @@ var EvidenceGraph = (() => {
7430
7678
  if (add2 === 25)
7431
7679
  return halfFloat(view.getUint16(0));
7432
7680
  const value2 = add2 === 26 ? view.getFloat32(0) : view.getFloat64(0);
7433
- if (shortest && (Number.isNaN(value2) || fitsHalf2(value2) || add2 === 27 && Math.fround(value2) === value2))
7681
+ if (Number.isNaN(value2) || fitsHalf2(value2) || add2 === 27 && Math.fround(value2) === value2)
7434
7682
  throw new SyntaxError("CBOR float is not in its shortest form");
7435
7683
  return value2;
7436
7684
  }
7437
- if (!shortest && add2 === 31 && major >= 2 && major <= 5) {
7438
- const atBreak = () => {
7439
- if (data[offset] !== 255)
7440
- return false;
7441
- offset += 1;
7442
- return true;
7443
- };
7444
- if (major === 2 || major === 3) {
7445
- const chunks = [];
7446
- while (!atBreak()) {
7447
- const head2 = byte();
7448
- if (head2 >>> 5 !== major || (head2 & 31) === 31)
7449
- throw new SyntaxError("invalid indefinite-length string chunk");
7450
- chunks.push(take(argument(head2 & 31)));
7451
- }
7452
- const joined = new Uint8Array(chunks.reduce((sum, chunk) => sum + chunk.length, 0));
7453
- let at = 0;
7454
- for (const chunk of chunks) {
7455
- if (major === 3)
7456
- utf84.decode(chunk);
7457
- joined.set(chunk, at);
7458
- at += chunk.length;
7459
- }
7460
- return major === 2 ? joined : utf84.decode(joined);
7461
- }
7462
- if (major === 4) {
7463
- const out = [];
7464
- while (!atBreak())
7465
- out.push(item(depth + 1));
7466
- return out;
7467
- }
7468
- const entries2 = [], keys2 = /* @__PURE__ */ new Set();
7469
- while (!atBreak()) {
7470
- const key = item(depth + 1), identity2 = identityOf(key);
7471
- if (keys2.has(identity2))
7472
- throw new SyntaxError("duplicate CBOR map key");
7473
- keys2.add(identity2);
7474
- entries2.push([key, item(depth + 1)]);
7475
- }
7476
- return new CborMap(entries2);
7477
- }
7478
7685
  const length = argument(add2);
7479
7686
  if (major === 0)
7480
7687
  return length;
@@ -7576,7 +7783,7 @@ var EvidenceGraph = (() => {
7576
7783
  return fold(size, index);
7577
7784
  }
7578
7785
  function inclusionProof2(blob) {
7579
- const value = decodeCbor(blob, false);
7786
+ const value = decodeReceiptItem(blob, false);
7580
7787
  if (!Array.isArray(value) || value.length !== 3)
7581
7788
  throw new SyntaxError("inclusion proof must be [tree_size, leaf_index, [path]]");
7582
7789
  const [size, index, path2] = value;
@@ -7622,15 +7829,15 @@ var EvidenceGraph = (() => {
7622
7829
  try {
7623
7830
  if (receipt.length > MAX_MESSAGE_BYTES)
7624
7831
  return fail2("receipt too large");
7625
- const outer = decodeStrictCbor(receipt);
7832
+ const outer = decodeReceiptItem(receipt, true);
7626
7833
  if (!(outer instanceof CborTag) || outer.tag !== COSE_SIGN1_TAG || !Array.isArray(outer.value) || outer.value.length !== 4)
7627
7834
  return fail2("receipt is not a COSE_Sign1 message");
7628
- const [protectedBytes, unprotected, payload, signature] = outer.value;
7835
+ const [protectedBytes, unprotected, payload, signature2] = outer.value;
7629
7836
  if (!(protectedBytes instanceof Uint8Array))
7630
7837
  return fail2("receipt is not a COSE_Sign1 message");
7631
7838
  if (payload !== null)
7632
7839
  return fail2("receipt payload is attached; a receipt's payload must be detached");
7633
- const headers = protectedBytes.length ? decodeStrictCbor(protectedBytes) : new CborMap([]);
7840
+ const headers = protectedBytes.length ? decodeReceiptItem(protectedBytes, false) : new CborMap([]);
7634
7841
  if (!(headers instanceof CborMap))
7635
7842
  return fail2("protected header is not a map");
7636
7843
  if (headers.get(HDR_VDS) !== VDS_RFC9162_SHA256)
@@ -7661,11 +7868,11 @@ var EvidenceGraph = (() => {
7661
7868
  throw new SyntaxError("inclusion proof entry is not a byte string");
7662
7869
  return inclusionProof2(proof);
7663
7870
  });
7664
- if (!(signature instanceof Uint8Array))
7871
+ if (!(signature2 instanceof Uint8Array))
7665
7872
  return fail2("signature is not a byte string");
7666
7873
  for (const { size, index, path: path2 } of candidates) {
7667
7874
  const root = await rootFromInclusion(leaf, index, size, path2);
7668
- const verified = await verifySignature(alg, publicKeySpki, signature, producerEnvelopeSigningBytes(protectedBytes, root));
7875
+ const verified = await verifySignature(alg, publicKeySpki, signature2, producerEnvelopeSigningBytes(protectedBytes, root));
7669
7876
  if (verified === "unavailable")
7670
7877
  return {
7671
7878
  ok: false,
@@ -7680,40 +7887,13 @@ var EvidenceGraph = (() => {
7680
7887
  return fail2(`unreadable receipt: ${String(error)}`);
7681
7888
  }
7682
7889
  }
7683
- var SMALL_ORDER_Y = [
7684
- "0000000000000000000000000000000000000000000000000000000000000000",
7685
- "0100000000000000000000000000000000000000000000000000000000000000",
7686
- "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f",
7687
- "c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a",
7688
- "26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05"
7689
- ];
7690
- var ED25519_L = hexToBytes("edd3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010");
7691
- function strictPoint(encoded) {
7692
- const y = Uint8Array.from(encoded);
7693
- y[31] &= 127;
7694
- const canonical = !(y[0] >= 237 && y.subarray(1, 31).every((b) => b === 255) && y[31] === 127);
7695
- const hex5 = Array.from(y, (b) => b.toString(16).padStart(2, "0")).join("");
7696
- return canonical && !SMALL_ORDER_Y.includes(hex5);
7697
- }
7698
- function strictEd25519(publicKey, signature) {
7699
- if (publicKey.length !== 32 || signature.length !== 64)
7700
- return false;
7701
- if (!strictPoint(publicKey) || !strictPoint(signature.subarray(0, 32)))
7702
- return false;
7703
- for (let i = 31; i >= 0; i--) {
7704
- const s = signature[32 + i];
7705
- if (s !== ED25519_L[i])
7706
- return s < ED25519_L[i];
7707
- }
7708
- return false;
7709
- }
7710
- async function verifySignature(alg, spki, signature, signed) {
7711
- if (alg === ALG_EDDSA && !strictEd25519(spki.subarray(-32), signature))
7890
+ async function verifySignature(alg, spki, signature2, signed) {
7891
+ if (alg === ALG_EDDSA && !strictEd25519(spki.subarray(-32), signature2))
7712
7892
  return false;
7713
7893
  const subtle = globalThis.crypto?.subtle;
7714
7894
  if (subtle === void 0)
7715
7895
  return "unavailable";
7716
- const [importAlgorithm, verifyAlgorithm] = alg === ALG_EDDSA ? [{ name: "Ed25519" }, { name: "Ed25519" }] : alg === ALG_ES256 && signature.length === 64 ? [
7896
+ const [importAlgorithm, verifyAlgorithm] = alg === ALG_EDDSA ? [{ name: "Ed25519" }, { name: "Ed25519" }] : alg === ALG_ES256 && signature2.length === 64 ? [
7717
7897
  { name: "ECDSA", namedCurve: "P-256" },
7718
7898
  { name: "ECDSA", hash: "SHA-256" }
7719
7899
  ] : [];
@@ -7726,7 +7906,7 @@ var EvidenceGraph = (() => {
7726
7906
  return await canImport(subtle, alg, importAlgorithm) ? false : "unavailable";
7727
7907
  }
7728
7908
  try {
7729
- return await subtle.verify(verifyAlgorithm, key, signature, signed);
7909
+ return await subtle.verify(verifyAlgorithm, key, signature2, signed);
7730
7910
  } catch {
7731
7911
  return false;
7732
7912
  }
@@ -7840,7 +8020,7 @@ var EvidenceGraph = (() => {
7840
8020
  "leaf_index",
7841
8021
  "tree_size"
7842
8022
  ];
7843
- var object6 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
8023
+ var object7 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
7844
8024
  function bindingOf(url) {
7845
8025
  const separator = url.indexOf("://");
7846
8026
  const scheme = separator < 0 ? "" : url.slice(0, separator).toLowerCase();
@@ -7855,11 +8035,11 @@ var EvidenceGraph = (() => {
7855
8035
  return base.replace(/\/+$/u, "");
7856
8036
  }
7857
8037
  function witnessRowFor(directory, tsUrl) {
7858
- const rows = object6(directory) ? directory.witnesses : directory;
8038
+ const rows = object7(directory) ? directory.witnesses : directory;
7859
8039
  if (!Array.isArray(rows))
7860
8040
  return void 0;
7861
8041
  const binding = bindingOf(tsUrl), endpoint = endpointOf(tsUrl);
7862
- return rows.find((row2) => object6(row2) && (Object.hasOwn(row2, "binding") ? row2.binding : BINDING_CLL) === binding && endpointMatches(Object.hasOwn(row2, "endpoint") ? row2.endpoint : "", endpoint));
8042
+ return rows.find((row2) => object7(row2) && (Object.hasOwn(row2, "binding") ? row2.binding : BINDING_CLL) === binding && endpointMatches(Object.hasOwn(row2, "endpoint") ? row2.endpoint : "", endpoint));
7863
8043
  }
7864
8044
  var endpointMatches = (value, endpoint) => typeof value === "string" && value.replace(/\/+$/u, "") === endpoint;
7865
8045
  function base64Canonical(value) {
@@ -7883,7 +8063,7 @@ var EvidenceGraph = (() => {
7883
8063
  return value;
7884
8064
  if (typeof value === "string")
7885
8065
  return [...value];
7886
- if (object6(value))
8066
+ if (object7(value))
7887
8067
  return Object.keys(value);
7888
8068
  if (value === null || value === void 0 || value === false || value === 0)
7889
8069
  return [];
@@ -8067,12 +8247,12 @@ ${body}
8067
8247
  return fail2("the Rekor key is not an ECDSA P-256 key");
8068
8248
  }
8069
8249
  try {
8070
- if (!object6(receipt))
8250
+ if (!object7(receipt))
8071
8251
  return fail2("receipt is not an object");
8072
8252
  if (receipt.logID !== await sha256Hex(key))
8073
8253
  return fail2("logID is not the pinned Rekor key");
8074
8254
  const verification = receipt.verification;
8075
- const timestamp = object6(verification) ? verification.signedEntryTimestamp : void 0;
8255
+ const timestamp = object7(verification) ? verification.signedEntryTimestamp : void 0;
8076
8256
  if (!timestamp)
8077
8257
  return fail2("no signedEntryTimestamp");
8078
8258
  const integratedTime = jsonInteger(receipt.integratedTime), logIndex = jsonInteger(receipt.logIndex);
@@ -8084,19 +8264,21 @@ ${body}
8084
8264
  if (!await subtle.verify({ name: "ECDSA", hash: "SHA-256" }, rekorKey, p1363(base64Canonical(timestamp)), signed))
8085
8265
  return fail2("signedEntryTimestamp does not verify under the Rekor key");
8086
8266
  const entry = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(base64Canonical(receipt.body)));
8087
- if (!object6(entry) || entry.kind !== "dsse")
8267
+ if (nestedTooDeep(entry))
8268
+ return fail2("unreadable receipt: body nested too deeply");
8269
+ if (!object7(entry) || entry.kind !== "dsse")
8088
8270
  return fail2("entry kind is not dsse");
8089
8271
  const spec = entry.spec || {};
8090
- if (!object6(spec))
8272
+ if (!object7(spec))
8091
8273
  return fail2("entry spec is not an object");
8092
8274
  const payloadHash = spec.payloadHash || {};
8093
- if (!object6(payloadHash) || payloadHash.algorithm !== "sha256" || payloadHash.value !== await sha256Hex(cose))
8275
+ if (!object7(payloadHash) || payloadHash.algorithm !== "sha256" || payloadHash.value !== await sha256Hex(cose))
8094
8276
  return fail2("entry payloadHash is not this checkpoint's bytes");
8095
8277
  const verifiers = /* @__PURE__ */ new Set();
8096
- for (const signature of pyIterate(spec.signatures)) {
8097
- if (!object6(signature))
8278
+ for (const signature2 of pyIterate(spec.signatures)) {
8279
+ if (!object7(signature2))
8098
8280
  return fail2("entry signature is not an object");
8099
- const verifier = Object.hasOwn(signature, "verifier") ? signature.verifier : "";
8281
+ const verifier = Object.hasOwn(signature2, "verifier") ? signature2.verifier : "";
8100
8282
  verifiers.add(pyStrip(latin1(base64Canonical(verifier)).replaceAll("\r", "")));
8101
8283
  }
8102
8284
  const raw = fromHex(options.checkpointKeyId);
@@ -8148,7 +8330,7 @@ ${body}
8148
8330
  });
8149
8331
  }
8150
8332
  var isRecord = (entry) => {
8151
- if (!object6(entry) || !RECORD_FIELDS.every((name) => Object.hasOwn(entry, name)))
8333
+ if (!object7(entry) || !RECORD_FIELDS.every((name) => Object.hasOwn(entry, name)))
8152
8334
  return false;
8153
8335
  if (!["ts_url", "entry_hash", "receipt_b64"].every((name) => typeof entry[name] === "string" && entry[name] !== ""))
8154
8336
  return false;
@@ -8251,6 +8433,153 @@ ${body}
8251
8433
  receipts: results
8252
8434
  };
8253
8435
  }
8436
+ var ANCHOR_DIGEST = /^[0-9a-f]{64}$/u;
8437
+ var LOWER_HEX = /^(?:[0-9a-f]{2})*$/u;
8438
+ var ANCHOR_ED25519_PREFIX = "302a300506032b6570032100";
8439
+ var P256_SPKI_PREFIX = "3059301306072a8648ce3d020106082a8648ce3d03010703420004";
8440
+ var MAX_ANCHOR_RECEIPT_OCTETS = 10 * 1024 * 1024;
8441
+ var MAX_ANCHOR_PROOFS = 16;
8442
+ var MAX_ANCHOR_TREE_SIZE = 1n << 62n;
8443
+ var PRIVATE_LABEL = -65536n;
8444
+ function anchorPathLength(size, index) {
8445
+ let count2 = 0;
8446
+ while (size > 1n) {
8447
+ let k = 1n;
8448
+ while (k * 2n < size)
8449
+ k *= 2n;
8450
+ if (index < k)
8451
+ size = k;
8452
+ else
8453
+ [size, index] = [size - k, index - k];
8454
+ count2 += 1;
8455
+ }
8456
+ return count2;
8457
+ }
8458
+ function parseAnchorReceipt(receipt) {
8459
+ try {
8460
+ if (receipt.length === 0 || receipt.length > MAX_ANCHOR_RECEIPT_OCTETS)
8461
+ return null;
8462
+ const outer = decodeReceiptItem(receipt, true);
8463
+ if (!(outer instanceof CborTag) || outer.tag !== 18n || !Array.isArray(outer.value) || outer.value.length !== 4)
8464
+ return null;
8465
+ const [protectedBytes, unprotected, payload, signature2] = outer.value;
8466
+ if (!(protectedBytes instanceof Uint8Array) || protectedBytes.length === 0 || payload !== null || !(signature2 instanceof Uint8Array) || signature2.length !== 64)
8467
+ return null;
8468
+ const headers = decodeReceiptItem(protectedBytes, false);
8469
+ if (!(headers instanceof CborMap))
8470
+ return null;
8471
+ let time = null;
8472
+ for (const [label, value] of headers.entries) {
8473
+ if (label === 1n) {
8474
+ if (value !== -8n && value !== -7n)
8475
+ return null;
8476
+ } else if (label === 395n) {
8477
+ if (value !== 1n)
8478
+ return null;
8479
+ } else if (label === 4n) {
8480
+ if (!(value instanceof Uint8Array))
8481
+ return null;
8482
+ } else if (label === HDR_CWT_CLAIMS) {
8483
+ if (!(value instanceof CborMap))
8484
+ return null;
8485
+ const iat = value.get(CWT_IAT);
8486
+ if (typeof iat === "bigint" && iat >= 0n && iat <= MAX_IAT)
8487
+ time = Number(iat);
8488
+ } else if (!(typeof label === "bigint" && label < PRIVATE_LABEL))
8489
+ return null;
8490
+ }
8491
+ const alg = headers.get(1n);
8492
+ if (alg === void 0 || !headers.has(395n))
8493
+ return null;
8494
+ if (!(unprotected instanceof CborMap) || unprotected.entries.length !== 1)
8495
+ return null;
8496
+ const vdp = unprotected.get(396n);
8497
+ if (!(vdp instanceof CborMap) || vdp.entries.length !== 1)
8498
+ return null;
8499
+ const raw = vdp.get(-1n);
8500
+ if (!Array.isArray(raw) || raw.length === 0 || raw.length > MAX_ANCHOR_PROOFS)
8501
+ return null;
8502
+ const proofs = [];
8503
+ for (const blob of raw) {
8504
+ if (!(blob instanceof Uint8Array))
8505
+ return null;
8506
+ const proof = decodeReceiptItem(blob, false);
8507
+ if (!Array.isArray(proof) || proof.length !== 3)
8508
+ return null;
8509
+ const [size, index, path2] = proof;
8510
+ if (typeof size !== "bigint" || typeof index !== "bigint" || index < 0n || index >= size || size > MAX_ANCHOR_TREE_SIZE || !Array.isArray(path2) || path2.length !== anchorPathLength(size, index) || !path2.every((node) => node instanceof Uint8Array && node.length === 32))
8511
+ return null;
8512
+ proofs.push({ size, index, path: path2 });
8513
+ }
8514
+ return { alg: alg === -8n ? "ed25519" : "p256", proofs, time };
8515
+ } catch {
8516
+ return null;
8517
+ }
8518
+ }
8519
+ function anchorPolicyKeys(policy) {
8520
+ const rows = typeof policy === "object" && policy !== null ? policy.witnesses : void 0;
8521
+ const out = [];
8522
+ for (const row2 of Array.isArray(rows) ? rows : []) {
8523
+ if (typeof row2 !== "object" || row2 === null)
8524
+ continue;
8525
+ const { name, keys } = row2;
8526
+ if (typeof name !== "string" || !Array.isArray(keys))
8527
+ continue;
8528
+ for (const key of keys) {
8529
+ if (typeof key !== "string" || !LOWER_HEX.test(key))
8530
+ continue;
8531
+ const type = key.length === 88 && key.startsWith(ANCHOR_ED25519_PREFIX) ? "ed25519" : key.length === 182 && key.startsWith(P256_SPKI_PREFIX) ? "p256" : null;
8532
+ if (type !== null)
8533
+ out.push({ name, type, spki: hexToBytes(key) });
8534
+ }
8535
+ }
8536
+ return out;
8537
+ }
8538
+ async function checkAnchorReceipt(anchorDigest, receipt, policy) {
8539
+ const report = (status2, witness = null, time = null) => ({
8540
+ status: status2,
8541
+ witness,
8542
+ registration_time: time
8543
+ });
8544
+ if (!ANCHOR_DIGEST.test(anchorDigest) || !(receipt instanceof Uint8Array))
8545
+ return report("FAIL");
8546
+ const parsed = parseAnchorReceipt(receipt);
8547
+ if (parsed === null)
8548
+ return report("FAIL");
8549
+ const keys = anchorPolicyKeys(policy).filter(({ type }) => type === parsed.alg);
8550
+ if (keys.length === 0)
8551
+ return report("NOT_CHECKED");
8552
+ const leaf = hexToBytes(anchorDigest);
8553
+ let unavailable = false;
8554
+ for (const { name, spki } of keys) {
8555
+ const result = await verifyCoseReceipt(receipt, leaf, spki);
8556
+ if (result.ok)
8557
+ return report("PASS", name, parsed.time);
8558
+ if (result.unavailable)
8559
+ unavailable = true;
8560
+ }
8561
+ return report(unavailable ? "NOT_CHECKED" : "FAIL");
8562
+ }
8563
+ async function checkAnchorWitnessed(anchorDigest, receipts2, policy) {
8564
+ const reports = [];
8565
+ for (const receipt of receipts2)
8566
+ reports.push(await checkAnchorReceipt(anchorDigest, receipt, policy));
8567
+ const statuses = new Set(reports.map((r) => r.status));
8568
+ const status2 = reports.length === 0 ? "NOT_PRESENT" : statuses.has("PASS") ? "PASS" : statuses.has("FAIL") ? "FAIL" : "NOT_CHECKED";
8569
+ let chosen;
8570
+ for (const r of reports) {
8571
+ if (r.status !== "PASS")
8572
+ continue;
8573
+ if (chosen === void 0 || r.registration_time !== null && (chosen.registration_time === null || r.registration_time < chosen.registration_time))
8574
+ chosen = r;
8575
+ }
8576
+ return {
8577
+ status: status2,
8578
+ receipts: reports,
8579
+ witness: chosen?.witness ?? null,
8580
+ witnessed_time: chosen?.registration_time ?? null
8581
+ };
8582
+ }
8254
8583
 
8255
8584
  // node_modules/@action-state-group/agent-action-capsule/dist/bundle.js
8256
8585
  var Ed25519UnavailableError = class extends Error {
@@ -8264,7 +8593,7 @@ ${body}
8264
8593
  status: "fail",
8265
8594
  findings
8266
8595
  });
8267
- var object7 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) && !(value instanceof JsonNumber);
8596
+ var object8 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) && !(value instanceof JsonNumber);
8268
8597
  var integer = (value) => typeof value === "number" && Number.isSafeInteger(value);
8269
8598
  var hex4 = (value) => Uint8Array.from(value.match(/../gu), (byte) => Number.parseInt(byte, 16));
8270
8599
  function base64UrlDecode(value) {
@@ -8314,10 +8643,12 @@ ${body}
8314
8643
  }
8315
8644
  async function verifyPlainAndStrict(bundle, options) {
8316
8645
  try {
8317
- const plain2 = await verifyPlain(bundle);
8646
+ if (nestedTooDeep(bundle))
8647
+ throw new RangeError(`Bundle nests more than ${MAX_NESTING_DEPTH} levels`);
8648
+ const plain2 = await verifyPlain(bundle, options);
8318
8649
  return options.strict === true ? {
8319
8650
  plain: plain2,
8320
- strict: await strict(plain2, object7(bundle) ? bundle : void 0, options)
8651
+ strict: await strict(plain2, object8(bundle) ? bundle : void 0, options)
8321
8652
  } : { plain: plain2 };
8322
8653
  } catch (error) {
8323
8654
  if (!(error instanceof RangeError))
@@ -8349,11 +8680,12 @@ ${body}
8349
8680
  disclosures: [],
8350
8681
  extensions: [],
8351
8682
  countersignatures: [],
8352
- capsuleResults: {}
8683
+ capsuleResults: {},
8684
+ categoryCoverage: null
8353
8685
  };
8354
8686
  }
8355
- async function verifyPlain(bundle) {
8356
- if (!object7(bundle))
8687
+ async function verifyPlain(bundle, options) {
8688
+ if (!object8(bundle))
8357
8689
  return malformedBundle();
8358
8690
  let digest;
8359
8691
  try {
@@ -8379,7 +8711,8 @@ ${body}
8379
8711
  status: "producer_self_report"
8380
8712
  }
8381
8713
  } : {},
8382
- capsuleResults: collected.results
8714
+ capsuleResults: collected.results,
8715
+ categoryCoverage: await checkCategoryCoverage(bundle, options)
8383
8716
  };
8384
8717
  }
8385
8718
  var SIGNED_CHECKPOINT_FIELDS = [
@@ -8393,6 +8726,7 @@ ${body}
8393
8726
  ];
8394
8727
  var SELECTION_PRODUCER_SELECTED = "producer-selected";
8395
8728
  var SELECTION_NOT_CHECKABLE = "selection_not_checkable";
8729
+ var CERTIFICATE_MODE_UNSUPPORTED = "certificate_mode_unsupported";
8396
8730
  async function strict(plain2, bundle, options) {
8397
8731
  if (bundle === void 0 || bundle.bundle_kind !== "evidence-bundle/v2" || bundle.bundle_version !== "2")
8398
8732
  return {
@@ -8411,7 +8745,7 @@ ${body}
8411
8745
  const records = [];
8412
8746
  const seen = /* @__PURE__ */ new Set();
8413
8747
  for (const record of Array.isArray(bundle.records) ? bundle.records : []) {
8414
- if (!object7(record))
8748
+ if (!object8(record))
8415
8749
  continue;
8416
8750
  const id = capsuleIdOf(record);
8417
8751
  const { verdict: verdict2, messages } = await verifyRecordSignature(record);
@@ -8437,16 +8771,19 @@ ${body}
8437
8771
  status: unclaimed.length ? "withheld" : "pass",
8438
8772
  findings: signatureFindings
8439
8773
  };
8440
- const stated = object7(bundle.checkpoint) ? bundle.checkpoint : {};
8441
- const checkpoint = await strictCheckpoint(stated, object7(bundle.completeness_certificate) ? bundle.completeness_certificate : {});
8774
+ const stated = object8(bundle.checkpoint) ? bundle.checkpoint : {};
8775
+ const checkpoint = await strictCheckpoint(stated, object8(bundle.completeness_certificate) ? bundle.completeness_certificate : {});
8442
8776
  const authenticated = checkpoint.signed !== void 0;
8443
8777
  let intervalCoverage = plain2.intervalCoverage, perRecordMembership = plain2.perRecordMembership;
8444
- if (object7(bundle.completeness) && bundle.completeness.selection === SELECTION_PRODUCER_SELECTED) {
8778
+ if (object8(bundle.completeness) && bundle.completeness.selection === SELECTION_PRODUCER_SELECTED) {
8445
8779
  intervalCoverage = {
8446
8780
  status: "withheld",
8447
8781
  findings: [SELECTION_NOT_CHECKABLE]
8448
8782
  };
8449
- perRecordMembership = await selectedMembership(bundle, checkpoint.signed);
8783
+ if (checkpoint.signed !== void 0)
8784
+ perRecordMembership = await selectedMembership(bundle, checkpoint.signed.root, checkpoint.signed.mmr_size, checkpoint.signed.log_id);
8785
+ else if (checkpoint.claim.status === "fail")
8786
+ perRecordMembership = object8(bundle.completeness_certificate) && "non_record_leaves" in bundle.completeness_certificate ? fail("completeness_certificate_invalid") : { status: "withheld", findings: ["checkpoint_unverified"] };
8450
8787
  }
8451
8788
  if (!authenticated) {
8452
8789
  intervalCoverage = unanchored(intervalCoverage);
@@ -8469,7 +8806,7 @@ ${body}
8469
8806
  }
8470
8807
  const witnesses = await verifyWitnessReceipts(stated.witnesses, checkpoint.signed, checkpoint.cose, options.witnessDirectory);
8471
8808
  const checkpointKey = checkpoint.signed?.key_id;
8472
- const failed2 = claims.some((claim) => claim.status === "fail") || witnesses.status === "fail";
8809
+ const failed2 = claims.some((claim) => claim.status === "fail") || witnesses.status === "fail" || categoryCoverageFails(plain2.categoryCoverage);
8473
8810
  return {
8474
8811
  ...plain2,
8475
8812
  intervalCoverage,
@@ -8561,31 +8898,29 @@ ${body}
8561
8898
  findings: [.../* @__PURE__ */ new Set([...claim.findings, "checkpoint_unverified"])]
8562
8899
  };
8563
8900
  }
8564
- async function selectedMembership(bundle, signed) {
8565
- if (signed === void 0)
8566
- return { status: "withheld", findings: ["checkpoint_unverified"] };
8901
+ async function selectedMembership(bundle, rootHex, size, logId) {
8567
8902
  const certificate = bundle.completeness_certificate;
8568
- const members = object7(certificate) ? certificate.memberships : void 0;
8569
- if (!object7(certificate) || !object7(members) || certificate.range_root !== signed.root)
8903
+ const members = object8(certificate) ? certificate.memberships : void 0;
8904
+ if (!object8(certificate) || !object8(members) || Object.hasOwn(certificate, "non_record_leaves") || certificate.range_root !== rootHex || certificate.log_id !== logId || typeof logId !== "string" || !isHex64(rootHex) || !integer(size))
8570
8905
  return fail("completeness_certificate_invalid");
8571
- const root = hex4(signed.root);
8572
- const ids = (Array.isArray(bundle.records) ? bundle.records : []).filter(object7).map(capsuleIdOf);
8906
+ const root = hex4(rootHex);
8907
+ const ids = (Array.isArray(bundle.records) ? bundle.records : []).filter(object8).map(capsuleIdOf);
8573
8908
  const findings = [], seen = /* @__PURE__ */ new Set();
8574
8909
  for (const id of ids) {
8575
8910
  const member = Object.hasOwn(members, id) ? members[id] : void 0;
8576
- const coordinates = object7(member) ? member.log_coordinates : void 0;
8577
- if (!object7(coordinates)) {
8911
+ const coordinates = object8(member) ? member.log_coordinates : void 0;
8912
+ if (!object8(coordinates)) {
8578
8913
  findings.push(`membership_record_unbound:${id}`);
8579
8914
  continue;
8580
8915
  }
8581
8916
  const seq = coordinates.seq, index = coordinates.leaf_index;
8582
- if (coordinates.log_id !== signed.log_id || !integer(seq) || !integer(index) || seq < 1 || index !== seq - 1 || seen.has(seq)) {
8917
+ if (coordinates.log_id !== logId || !integer(seq) || !integer(index) || seq < 1 || index !== seq - 1 || seen.has(seq)) {
8583
8918
  findings.push(`membership_coordinates_invalid:${id}`);
8584
8919
  continue;
8585
8920
  }
8586
8921
  seen.add(seq);
8587
- const proof = object7(member) ? parseProof(member.inclusion_proof) : void 0;
8588
- if (!proof || !isHex64(id) || proof.size !== signed.mmr_size || proof.leaf_index !== index || !await verifyProof(root, id, proof, index))
8922
+ const proof = object8(member) ? parseProof(member.inclusion_proof) : void 0;
8923
+ if (!proof || !isHex64(id) || proof.size !== size || proof.leaf_index !== index || !await verifyProof(root, id, proof, index))
8589
8924
  findings.push(`membership_proof_invalid:${id}`);
8590
8925
  }
8591
8926
  for (const id of Object.keys(members).sort(byCodePoint2))
@@ -8595,12 +8930,12 @@ ${body}
8595
8930
  }
8596
8931
  function membershipSeqs(bundle) {
8597
8932
  const certificate = bundle.completeness_certificate;
8598
- const members = object7(certificate) ? certificate.memberships : void 0;
8933
+ const members = object8(certificate) ? certificate.memberships : void 0;
8599
8934
  const out = /* @__PURE__ */ new Map();
8600
- if (object7(members))
8935
+ if (object8(members))
8601
8936
  for (const [id, member] of Object.entries(members)) {
8602
- const coordinates = object7(member) ? member.log_coordinates : void 0;
8603
- const seq = object7(coordinates) ? coordinates.seq : void 0;
8937
+ const coordinates = object8(member) ? member.log_coordinates : void 0;
8938
+ const seq = object8(coordinates) ? coordinates.seq : void 0;
8604
8939
  if (integer(seq))
8605
8940
  out.set(id, seq);
8606
8941
  }
@@ -8611,7 +8946,7 @@ ${body}
8611
8946
  if (!Array.isArray(raw))
8612
8947
  return { records, results, findings: ["records_malformed"] };
8613
8948
  for (const [index, record] of raw.entries()) {
8614
- if (!object7(record)) {
8949
+ if (!object8(record)) {
8615
8950
  findings.push(`record_malformed:${index}`);
8616
8951
  continue;
8617
8952
  }
@@ -8642,7 +8977,7 @@ ${body}
8642
8977
  if (!isHex64(root) || !records.has(root))
8643
8978
  return fail(...findings, "root_not_supplied_with_matching_identity");
8644
8979
  const complete = bundle.completeness;
8645
- if (!object7(complete))
8980
+ if (!object8(complete))
8646
8981
  return fail(...findings, "completeness_malformed");
8647
8982
  const depth = complete.closure_depth ?? 2;
8648
8983
  if (!integer(depth) || depth < 0)
@@ -8676,24 +9011,34 @@ ${body}
8676
9011
  }
8677
9012
  function citations(record) {
8678
9013
  const targets = [], chain = record.chain;
8679
- if (object7(chain) && typeof chain.parent_capsule_id === "string")
9014
+ if (object8(chain) && typeof chain.parent_capsule_id === "string")
8680
9015
  targets.push(chain.parent_capsule_id);
8681
9016
  if (Array.isArray(record.references)) {
8682
9017
  for (const reference of record.references)
8683
- if (object7(reference) && reference.type === "agent-action-capsule" && reference.digest_alg === "SHA-256" && typeof reference.digest === "string")
9018
+ if (object8(reference) && reference.type === "agent-action-capsule" && reference.digest_alg === "SHA-256" && typeof reference.digest === "string")
8684
9019
  targets.push(reference.digest);
8685
9020
  }
8686
9021
  return targets;
8687
9022
  }
8688
9023
  async function completeness(bundle, records) {
8689
- if (!object7(bundle.completeness_certificate) || !object7(bundle.checkpoint)) {
9024
+ if (!object8(bundle.completeness_certificate) || !object8(bundle.checkpoint)) {
8690
9025
  const absent = {
8691
9026
  status: "withheld",
8692
9027
  findings: ["completeness_evidence_absent"]
8693
9028
  };
8694
9029
  return [absent, absent];
8695
9030
  }
8696
- const certificate = bundle.completeness_certificate, parsed = parseCertificate(certificate, bundle.checkpoint);
9031
+ const certificate = bundle.completeness_certificate;
9032
+ if (object8(bundle.completeness) && Object.hasOwn(bundle.completeness, "selection")) {
9033
+ if (bundle.completeness.selection === SELECTION_PRODUCER_SELECTED)
9034
+ return plainSelected(bundle, bundle.checkpoint);
9035
+ const unsupported = {
9036
+ status: "withheld",
9037
+ findings: [CERTIFICATE_MODE_UNSUPPORTED]
9038
+ };
9039
+ return [unsupported, unsupported];
9040
+ }
9041
+ const parsed = parseCertificate(certificate, bundle.checkpoint);
8697
9042
  if (!parsed)
8698
9043
  return [
8699
9044
  fail("completeness_certificate_invalid"),
@@ -8707,9 +9052,33 @@ ${body}
8707
9052
  fail("checkpoint_authentication_invalid"),
8708
9053
  fail("checkpoint_authentication_invalid")
8709
9054
  ];
8710
- const findings = await memberships(parsed.root, parsed.logId, parsed.firstSeq, parsed.lastSeq, certificate.memberships, records, bundle.completeness, parsed.rangeProof.size);
8711
- const relative = () => checkpointStatus === "verified" ? pass() : { status: "pass", findings: ["checkpoint_unverified"] };
8712
- return [relative(), findings.length ? fail(...findings) : relative()];
9055
+ const { findings, failed: failed2 } = await memberships(parsed.root, parsed.logId, parsed.firstSeq, parsed.lastSeq, certificate, records, bundle.completeness, parsed.rangeProof.size);
9056
+ const qualifier = checkpointStatus === "verified" ? [] : ["checkpoint_unverified"];
9057
+ const interval = { status: "pass", findings: qualifier };
9058
+ if (failed2)
9059
+ return [interval, fail(...findings)];
9060
+ if (findings.length)
9061
+ return [
9062
+ interval,
9063
+ { status: "withheld", findings: [...findings, ...qualifier] }
9064
+ ];
9065
+ return [interval, { status: "pass", findings: [...qualifier] }];
9066
+ }
9067
+ async function plainSelected(bundle, checkpoint) {
9068
+ const interval = {
9069
+ status: "withheld",
9070
+ findings: ["selection_not_checkable"]
9071
+ };
9072
+ const membership = await selectedMembership(bundle, checkpoint.root, checkpoint.mmr_size, checkpoint.log_id);
9073
+ if (membership.status !== "pass")
9074
+ return [interval, membership];
9075
+ const status2 = await authenticateCheckpoint(checkpoint, checkpoint.log_id, hex4(checkpoint.root), checkpoint.mmr_size);
9076
+ if (status2 === "invalid")
9077
+ return [interval, fail("checkpoint_authentication_invalid")];
9078
+ return [
9079
+ interval,
9080
+ status2 === "verified" ? pass() : { status: "pass", findings: ["checkpoint_unverified"] }
9081
+ ];
8713
9082
  }
8714
9083
  async function loadCheckpointMetadata() {
8715
9084
  try {
@@ -8767,7 +9136,7 @@ ${body}
8767
9136
  };
8768
9137
  }
8769
9138
  function parseRangeProof(raw) {
8770
- const range = object7(raw) ? raw : void 0, fromSeq = range?.from_seq, toSeq = range?.to_seq, size = range?.size, fromIndex = range?.from_index, toIndex = range?.to_index, witness = range?.witness;
9139
+ const range = object8(raw) ? raw : void 0, fromSeq = range?.from_seq, toSeq = range?.to_seq, size = range?.size, fromIndex = range?.from_index, toIndex = range?.to_index, witness = range?.witness;
8771
9140
  if (!integer(fromSeq) || !integer(toSeq) || !integer(size) || !integer(fromIndex) || !integer(toIndex) || fromSeq < 1 || toSeq < fromSeq || size < 0 || fromIndex < 0 || toIndex < fromIndex || !Array.isArray(witness) || !witness.every(isHex64))
8772
9141
  return void 0;
8773
9142
  return { fromSeq, toSeq, size, fromIndex, toIndex, witness };
@@ -8779,16 +9148,17 @@ ${body}
8779
9148
  return false;
8780
9149
  return verifyRange2(root, BigInt(proof.size), BigInt(proof.fromIndex), BigInt(proof.toIndex), raw.map(hex4), proof.proof);
8781
9150
  }
8782
- async function memberships(root, logId, first, last, raw, records, completeness2, checkpointSize) {
8783
- if (!object7(raw))
8784
- return ["memberships_absent"];
9151
+ async function memberships(root, logId, first, last, certificate, records, completeness2, checkpointSize) {
9152
+ const raw = certificate.memberships;
9153
+ if (!object8(raw))
9154
+ return { findings: ["memberships_absent"], failed: true };
8785
9155
  const bySequence = /* @__PURE__ */ new Set(), boundRecords = /* @__PURE__ */ new Set(), findings = [];
8786
9156
  for (const [id, member] of Object.entries(raw)) {
8787
- if (!isHex64(id) || !records.has(id) || !object7(member)) {
9157
+ if (!isHex64(id) || !records.has(id) || !object8(member)) {
8788
9158
  findings.push(`membership_record_unknown:${id}`);
8789
9159
  continue;
8790
9160
  }
8791
- const coordinates = object7(member.log_coordinates) ? member.log_coordinates : void 0;
9161
+ const coordinates = object8(member.log_coordinates) ? member.log_coordinates : void 0;
8792
9162
  if (!coordinates) {
8793
9163
  findings.push(`membership_coordinates_missing:${id}`);
8794
9164
  continue;
@@ -8808,17 +9178,83 @@ ${body}
8808
9178
  if (!proof || proof.leaf_index !== leaf || proof.size !== checkpointSize || !await verifyProof(root, id, proof, leaf))
8809
9179
  findings.push(`membership_proof_invalid:${id}`);
8810
9180
  }
9181
+ let leafSeqs = /* @__PURE__ */ new Set(), unsupported = 0;
9182
+ if (Object.hasOwn(certificate, "non_record_leaves")) {
9183
+ const leaves = await nonRecordLeaves(certificate.non_record_leaves, first, last, certificate.body_digests, statedSeqs(raw));
9184
+ findings.push(...leaves.findings);
9185
+ leafSeqs = leaves.accounted;
9186
+ unsupported = leaves.findings.filter((f) => f.startsWith(UNSUPPORTED_LEAF)).length;
9187
+ }
8811
9188
  for (let seq = first; seq <= last; seq += 1)
8812
- if (!bySequence.has(seq))
9189
+ if (!bySequence.has(seq) && !leafSeqs.has(seq))
8813
9190
  findings.push(`membership_record_missing:${seq}`);
8814
- const declaredMissing = object7(completeness2) && Array.isArray(completeness2.missing) ? new Set(completeness2.missing.filter(isHex64)) : /* @__PURE__ */ new Set();
9191
+ const declaredMissing = object8(completeness2) && Array.isArray(completeness2.missing) ? new Set(completeness2.missing.filter(isHex64)) : /* @__PURE__ */ new Set();
8815
9192
  for (const id of records.keys())
8816
9193
  if (!boundRecords.has(id) && !declaredMissing.has(id))
8817
9194
  findings.push(`membership_record_unbound:${id}`);
8818
- return findings;
9195
+ return { findings, failed: findings.length > unsupported };
9196
+ }
9197
+ var UNSUPPORTED_LEAF = "non_record_leaf_type_unsupported:";
9198
+ var PADDING = "padding";
9199
+ var PADDING_MEMBERS = [
9200
+ "capsule_id",
9201
+ "epistemic_type",
9202
+ "record_type",
9203
+ "store_nonce"
9204
+ ];
9205
+ function statedSeqs(members) {
9206
+ const out = /* @__PURE__ */ new Set();
9207
+ for (const member of Object.values(members)) {
9208
+ const coordinates = object8(member) ? member.log_coordinates : void 0;
9209
+ const seq = object8(coordinates) ? coordinates.seq : void 0;
9210
+ if (integer(seq))
9211
+ out.add(seq);
9212
+ }
9213
+ return out;
9214
+ }
9215
+ async function nonRecordLeaves(raw, first, last, bodyDigests, recordSeqs) {
9216
+ const accounted = /* @__PURE__ */ new Set();
9217
+ if (!Array.isArray(raw))
9218
+ return { findings: ["non_record_leaves_malformed"], accounted };
9219
+ const digests = Array.isArray(bodyDigests) ? bodyDigests : [];
9220
+ const findings = [];
9221
+ for (const [index, element7] of raw.entries()) {
9222
+ if (!object8(element7)) {
9223
+ findings.push(`non_record_leaf_element_invalid:${index}`);
9224
+ continue;
9225
+ }
9226
+ const seq = element7.seq;
9227
+ if (!integer(seq) || seq < first || seq > last || recordSeqs.has(seq) || accounted.has(seq)) {
9228
+ findings.push(`non_record_leaf_seq_invalid:${index}`);
9229
+ continue;
9230
+ }
9231
+ accounted.add(seq);
9232
+ const content = element7.content;
9233
+ const recordType = object8(content) ? content.record_type : void 0;
9234
+ if (!object8(content) || typeof recordType !== "string") {
9235
+ findings.push(`non_record_leaf_malformed:${seq}`);
9236
+ continue;
9237
+ }
9238
+ if (recordType !== PADDING) {
9239
+ findings.push(`${UNSUPPORTED_LEAF}${seq}`);
9240
+ continue;
9241
+ }
9242
+ const names2 = Object.keys(content).sort();
9243
+ if (names2.length !== PADDING_MEMBERS.length || names2.some((name, i) => name !== PADDING_MEMBERS[i]) || content.epistemic_type !== "producer_claim" || !isHex64(content.store_nonce) || !isHex64(content.capsule_id)) {
9244
+ findings.push(`non_record_leaf_malformed:${seq}`);
9245
+ continue;
9246
+ }
9247
+ const leaf = await paddingLeaf(content);
9248
+ if (leaf !== content.capsule_id || leaf !== digests[seq - first])
9249
+ findings.push(`non_record_leaf_mismatch:${seq}`);
9250
+ }
9251
+ return { findings, accounted };
9252
+ }
9253
+ async function paddingLeaf(content) {
9254
+ return jsonDigest(Object.fromEntries(Object.entries(content).filter(([name]) => name !== "capsule_id")));
8819
9255
  }
8820
9256
  function parseProof(raw) {
8821
- if (!object7(raw) || raw.v !== 1 || raw.kind !== "inclusion" || !integer(raw.size) || !integer(raw.leaf_index) || raw.size < 0 || raw.leaf_index < 0)
9257
+ if (!object8(raw) || raw.v !== 1 || raw.kind !== "inclusion" || !integer(raw.size) || !integer(raw.leaf_index) || raw.size < 0 || raw.leaf_index < 0)
8822
9258
  return void 0;
8823
9259
  const hashes = (value) => Array.isArray(value) && value.every(isHex64) ? value : void 0;
8824
9260
  const witness = hashes(raw.witness), left = hashes(raw.peaks_left), right = hashes(raw.peaks_right);
@@ -8842,20 +9278,20 @@ ${body}
8842
9278
  async function disclosures(raw, records) {
8843
9279
  if (raw === void 0)
8844
9280
  raw = {};
8845
- if (!object7(raw))
9281
+ if (!object8(raw))
8846
9282
  return [{ capsuleId: "", member: "", status: DISCLOSURE_MISMATCH }];
8847
9283
  const findings = [];
8848
9284
  for (const [id, record] of [...records.entries()].sort(([a], [b]) => a.localeCompare(b))) {
8849
- if (Object.hasOwn(raw, id) && !object7(raw[id]))
9285
+ if (Object.hasOwn(raw, id) && !object8(raw[id]))
8850
9286
  continue;
8851
- const supplied = object7(raw[id]) ? raw[id] : {};
9287
+ const supplied = object8(raw[id]) ? raw[id] : {};
8852
9288
  for (const [member, path2] of Object.entries(disclosureEligibleFields))
8853
9289
  if (!Object.hasOwn(supplied, member) && typeof resolveDisclosurePath(record, path2) === "string")
8854
9290
  findings.push({ capsuleId: id, member, status: "withheld" });
8855
9291
  }
8856
9292
  for (const id of Object.keys(raw).sort()) {
8857
9293
  const members = raw[id], record = records.get(id);
8858
- if (!object7(members) || !record) {
9294
+ if (!object8(members) || !record) {
8859
9295
  findings.push({ capsuleId: id, member: "", status: DISCLOSURE_MISMATCH });
8860
9296
  continue;
8861
9297
  }
@@ -8891,7 +9327,7 @@ ${body}
8891
9327
  }
8892
9328
  async function extensions(bundle, covered) {
8893
9329
  const raw = bundle.extensions;
8894
- if (!object7(raw))
9330
+ if (!object8(raw))
8895
9331
  return [];
8896
9332
  const results = [];
8897
9333
  for (const kind of Object.keys(raw).sort()) {
@@ -9022,17 +9458,24 @@ ${body}
9022
9458
  return value;
9023
9459
  }
9024
9460
  function readSelection(plain2, strict2) {
9025
- return strict2 !== void 0 && strict2.strict.verdict !== "INVALID" && isProducerSelection(strict2) ? {
9461
+ if (strict2 !== void 0 && strict2.strict.verdict !== "INVALID" && isProducerSelection(strict2))
9462
+ return {
9463
+ ...plain2,
9464
+ intervalCoverage: strict2.intervalCoverage,
9465
+ perRecordMembership: strict2.perRecordMembership
9466
+ };
9467
+ return isProducerSelection(plain2) ? {
9026
9468
  ...plain2,
9027
- intervalCoverage: strict2.intervalCoverage,
9028
- perRecordMembership: strict2.perRecordMembership
9469
+ // No findings: the page's gate never reads this failure as records
9470
+ // the certificate left unbound (membershipProvenOrUnbound).
9471
+ perRecordMembership: { status: "fail", findings: [] }
9029
9472
  } : plain2;
9030
9473
  }
9031
9474
  function isProducerSelection(result) {
9032
9475
  return result.intervalCoverage.status === "withheld" && result.intervalCoverage.findings.includes(SELECTION_NOT_CHECKABLE);
9033
9476
  }
9034
9477
  function isVerifiedBundleContext(value) {
9035
- return object7(value) && contexts.has(value);
9478
+ return object8(value) && contexts.has(value);
9036
9479
  }
9037
9480
  var WITHHELD = Object.freeze({ state: "withheld" });
9038
9481
  var MISMATCHED = Object.freeze({
@@ -9060,20 +9503,20 @@ ${body}
9060
9503
  ({ records, recordIndex, resolvedDisclosures } = reuse);
9061
9504
  } else {
9062
9505
  const index = /* @__PURE__ */ new Map();
9063
- if (object7(bundle) && Array.isArray(bundle.records)) {
9506
+ if (object8(bundle) && Array.isArray(bundle.records)) {
9064
9507
  for (const record of bundle.records)
9065
- if (object7(record) && typeof record.capsule_id === "string" && !index.has(record.capsule_id) && verification.capsuleResults[record.capsule_id]?.ok === true && verification.capsuleResults[record.capsule_id]?.capsuleId === record.capsule_id)
9508
+ if (object8(record) && typeof record.capsule_id === "string" && !index.has(record.capsule_id) && verification.capsuleResults[record.capsule_id]?.ok === true && verification.capsuleResults[record.capsule_id]?.capsuleId === record.capsule_id)
9066
9509
  index.set(record.capsule_id, record);
9067
9510
  }
9068
9511
  records = Object.freeze([...index.values()]);
9069
9512
  recordIndex = new ReadonlyMapView(index);
9070
9513
  resolvedDisclosures = resolveFromVerification(bundle, verification.disclosures, index);
9071
9514
  }
9072
- const certificate = object7(bundle) ? bundle.completeness_certificate : void 0;
9515
+ const certificate = object8(bundle) ? bundle.completeness_certificate : void 0;
9073
9516
  deepFreeze(verification);
9074
9517
  const context = deepFreeze({
9075
9518
  bundle,
9076
- root: object7(bundle) && typeof bundle.root === "string" ? bundle.root : void 0,
9519
+ root: object8(bundle) && typeof bundle.root === "string" ? bundle.root : void 0,
9077
9520
  verification,
9078
9521
  strict: strict2,
9079
9522
  resolvedDisclosures,
@@ -9086,7 +9529,7 @@ ${body}
9086
9529
  graphClosure: verification.graphClosure,
9087
9530
  intervalCoverage: verification.intervalCoverage,
9088
9531
  perRecordMembership: verification.perRecordMembership,
9089
- memberships: object7(certificate) && object7(certificate.memberships) ? certificate.memberships : {}
9532
+ memberships: object8(certificate) && object8(certificate.memberships) ? certificate.memberships : {}
9090
9533
  }
9091
9534
  });
9092
9535
  contexts.add(context);
@@ -9096,13 +9539,13 @@ ${body}
9096
9539
  const status2 = /* @__PURE__ */ new Map();
9097
9540
  for (const result of results)
9098
9541
  status2.set(`${result.capsuleId}\0${result.member}`, result.status);
9099
- const overlay = object7(bundle) && object7(bundle.disclosures) ? bundle.disclosures : {};
9542
+ const overlay = object8(bundle) && object8(bundle.disclosures) ? bundle.disclosures : {};
9100
9543
  const resolved = /* @__PURE__ */ new Map();
9101
9544
  const one = (id, field) => {
9102
9545
  switch (status2.get(`${id}\0${field}`)) {
9103
9546
  case DISCLOSURE_MATCH: {
9104
9547
  const entry = overlay[id];
9105
- return object7(entry) && Object.hasOwn(entry, field) ? Object.freeze({ state: "disclosed", payload: entry[field] }) : MISMATCHED;
9548
+ return object8(entry) && Object.hasOwn(entry, field) ? Object.freeze({ state: "disclosed", payload: entry[field] }) : MISMATCHED;
9106
9549
  }
9107
9550
  case DISCLOSURE_MISMATCH:
9108
9551
  case DISCLOSURE_NO_COMMITTED_DIGEST:
@@ -9125,16 +9568,103 @@ ${body}
9125
9568
  return disclosureOf(context, capsuleId, field).payload;
9126
9569
  }
9127
9570
 
9571
+ // node_modules/@action-state-group/agent-action-capsule/dist/calibration-summary.js
9572
+ var isObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
9573
+ var asString = (value) => typeof value === "string" ? value : void 0;
9574
+ var CALIBRATION_SUMMARY_V1 = "calibration-summary/v1";
9575
+ var HUMAN_RATING_V1 = "human-rating/v1";
9576
+ var HEX_DIGEST = /^[0-9a-f]{64}$/u;
9577
+ var hasExactly = (value, members) => {
9578
+ const keys = Object.keys(value);
9579
+ return keys.length === members.length && members.every((member) => Object.hasOwn(value, member));
9580
+ };
9581
+ var nonEmpty = (value) => {
9582
+ const text2 = asString(value);
9583
+ return text2 === void 0 || text2.length === 0 ? void 0 : text2;
9584
+ };
9585
+ var isCount = (value) => Number.isSafeInteger(value) && value >= 0;
9586
+ var readKOfN = (value) => {
9587
+ if (!isObject(value) || !hasExactly(value, ["k", "n"]))
9588
+ return void 0;
9589
+ if (!isCount(value.k) || !isCount(value.n))
9590
+ return void 0;
9591
+ const k = value.k;
9592
+ const n = value.n;
9593
+ return k <= n ? { k, n } : void 0;
9594
+ };
9595
+ var readCitation = (value, purpose) => {
9596
+ if (!isObject(value) || !hasExactly(value, ["type", "digest_alg", "digest", "citation_purpose"]))
9597
+ return void 0;
9598
+ const type = nonEmpty(value.type);
9599
+ const digest = asString(value.digest);
9600
+ if (type === void 0 || value.digest_alg !== "SHA-256" || digest === void 0 || !HEX_DIGEST.test(digest) || value.citation_purpose !== purpose)
9601
+ return void 0;
9602
+ return { type, digest };
9603
+ };
9604
+ var readClause = (value) => {
9605
+ if (!isObject(value) || !hasExactly(value, ["clause_ref", "agreement", "drift"]))
9606
+ return void 0;
9607
+ const clauseRef = nonEmpty(value.clause_ref);
9608
+ const agreement = readKOfN(value.agreement);
9609
+ const drift = readKOfN(value.drift);
9610
+ if (clauseRef === void 0 || agreement === void 0 || drift === void 0)
9611
+ return void 0;
9612
+ return { clauseRef, agreement, drift };
9613
+ };
9614
+ function readCalibrationSummary(value) {
9615
+ if (!isObject(value) || !hasExactly(value, [
9616
+ "record_version",
9617
+ "record_id",
9618
+ "epistemic_type",
9619
+ "computed_at",
9620
+ "judge_pin",
9621
+ "clauses"
9622
+ ]) || value.record_version !== CALIBRATION_SUMMARY_V1 || value.epistemic_type !== "derived_metric")
9623
+ return void 0;
9624
+ const recordId = nonEmpty(value.record_id);
9625
+ const computedAt = asString(value.computed_at);
9626
+ const judgePin = readCitation(value.judge_pin, "calibrates");
9627
+ if (recordId === void 0 || computedAt === void 0 || judgePin === void 0 || !Array.isArray(value.clauses) || value.clauses.length === 0)
9628
+ return void 0;
9629
+ const clauses = [];
9630
+ for (const entry of value.clauses) {
9631
+ const clause = readClause(entry);
9632
+ if (clause === void 0)
9633
+ return void 0;
9634
+ clauses.push(clause);
9635
+ }
9636
+ return { recordId, computedAt, judgePin, clauses };
9637
+ }
9638
+ function readHumanRating(value) {
9639
+ if (!isObject(value) || !hasExactly(value, [
9640
+ "record_version",
9641
+ "record_id",
9642
+ "epistemic_type",
9643
+ "rated_at",
9644
+ "blind",
9645
+ "rater_ref",
9646
+ "case",
9647
+ "label"
9648
+ ]) || value.record_version !== HUMAN_RATING_V1 || value.epistemic_type !== "human_report" || value.blind !== true)
9649
+ return void 0;
9650
+ const recordId = nonEmpty(value.record_id);
9651
+ const ratedAt = asString(value.rated_at);
9652
+ const raterRef = nonEmpty(value.rater_ref);
9653
+ const ratedCase = readCitation(value.case, "rated_case");
9654
+ const label = nonEmpty(value.label);
9655
+ if (recordId === void 0 || ratedAt === void 0 || raterRef === void 0 || ratedCase === void 0 || label === void 0)
9656
+ return void 0;
9657
+ return { recordId, ratedAt, raterRef, ratedCase, label };
9658
+ }
9659
+
9128
9660
  // node_modules/@action-state-group/agent-action-capsule/dist/evidence-graph.js
9129
9661
  var zoneStatement = (value) => /^\d{4}-\d{2}-\d{2}$/u.test(value) ? "date-only" : /^\d{4}-\d{2}-\d{2}[Tt]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:[Zz]|[+-]\d{2}:\d{2})$/u.test(value) ? "stated" : "not-stated";
9130
- var isCount = (value) => isObject(value) && Number.isSafeInteger(value.k) && Number.isSafeInteger(value.n) && value.k >= 0 && value.n >= value.k;
9131
- var calibrationCount = (value) => value === void 0 ? void 0 : isCount(value) ? { k: value.k, n: value.n } : { rate: value };
9132
9662
  var EvidenceGraphError = class extends Error {
9133
9663
  };
9134
- var isObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
9135
- var asString = (value) => typeof value === "string" ? value : void 0;
9664
+ var isObject2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
9665
+ var asString2 = (value) => typeof value === "string" ? value : void 0;
9136
9666
  var asNumber = (value) => typeof value === "number" && Number.isFinite(value) ? value : void 0;
9137
- var objectOrEmpty = (value) => isObject(value) ? value : {};
9667
+ var objectOrEmpty = (value) => isObject2(value) ? value : {};
9138
9668
  var calendarDay = (date) => {
9139
9669
  const match = /^(\d{4})-(\d{2})-(\d{2})(?:[Tt](\d{2}):(\d{2})(?::(\d{2})(?:\.\d+)?)?([Zz]|[+-]\d{2}:\d{2})?)?$/u.exec(date);
9140
9670
  if (match === null)
@@ -9154,30 +9684,30 @@ ${body}
9154
9684
  return Math.floor(instant / 864e5);
9155
9685
  };
9156
9686
  var recordTimes = (record) => {
9157
- const sealTime = asString(record.timestamp);
9158
- const actionTime = asString(record.occurred_at);
9687
+ const sealTime = asString2(record.timestamp);
9688
+ const actionTime = asString2(record.occurred_at);
9159
9689
  const block = record.provenance_mode;
9160
- const provenanceMode = block !== null && typeof block === "object" && !Array.isArray(block) ? asString(block.mode) : void 0;
9690
+ const provenanceMode = block !== null && typeof block === "object" && !Array.isArray(block) ? asString2(block.mode) : void 0;
9161
9691
  return {
9162
9692
  ...sealTime === void 0 ? {} : { sealTime },
9163
9693
  ...actionTime === void 0 ? {} : { actionTime },
9164
9694
  ...provenanceMode === void 0 ? {} : { provenanceMode }
9165
9695
  };
9166
9696
  };
9167
- var committedDigest = (record, field) => asString(objectOrEmpty(objectOrEmpty(record.model_attestation).compute_attestation)[`${field}_digest`]);
9697
+ var committedDigest = (record, field) => asString2(objectOrEmpty(objectOrEmpty(record.model_attestation).compute_attestation)[`${field}_digest`]);
9168
9698
  var logCoordinates = (memberships2, capsuleId) => {
9169
9699
  const membership = memberships2[capsuleId];
9170
- if (!isObject(membership) || !isObject(membership.log_coordinates))
9700
+ if (!isObject2(membership) || !isObject2(membership.log_coordinates))
9171
9701
  return void 0;
9172
9702
  const coordinates = membership.log_coordinates;
9173
- const logId = asString(coordinates.log_id);
9703
+ const logId = asString2(coordinates.log_id);
9174
9704
  const seq = asNumber(coordinates.seq);
9175
9705
  const leafIndex = asNumber(coordinates.leaf_index);
9176
9706
  return logId === void 0 || seq === void 0 || leafIndex === void 0 ? void 0 : { logId, seq, leafIndex };
9177
9707
  };
9178
9708
  var status = (value) => value === "pass" || value === "fail" || value === "not_applicable" || value === "unjudgeable" ? value : void 0;
9179
9709
  var verdict = (value) => value === "pass" || value === "fail" || value === "unsure" ? value : void 0;
9180
- var actedOnReferences = (record) => Array.isArray(record.references) ? record.references.flatMap((reference) => isObject(reference) && reference.type === "agent-action-capsule" && reference.citation_purpose === "acted_on" ? asString(reference.digest) === void 0 ? [] : [asString(reference.digest)] : []) : [];
9710
+ var actedOnReferences = (record) => Array.isArray(record.references) ? record.references.flatMap((reference) => isObject2(reference) && reference.type === "agent-action-capsule" && reference.citation_purpose === "acted_on" ? asString2(reference.digest) === void 0 ? [] : [asString2(reference.digest)] : []) : [];
9181
9711
  var committedDigests = (record) => {
9182
9712
  const agentInputDigest = committedDigest(record, "agent_input");
9183
9713
  const agentOutputDigest = committedDigest(record, "agent_output");
@@ -9189,27 +9719,27 @@ ${body}
9189
9719
  async function buildEvidenceGraph(input) {
9190
9720
  const context = await verifiedBundleContext(input);
9191
9721
  const bundle = context.bundle;
9192
- if (!isObject(bundle) || !Array.isArray(bundle.records) || !isObject(bundle.disclosures)) {
9722
+ if (!isObject2(bundle) || !Array.isArray(bundle.records) || !isObject2(bundle.disclosures)) {
9193
9723
  throw new EvidenceGraphError("bundle must contain records and disclosures");
9194
9724
  }
9195
9725
  const records = context.records;
9196
9726
  const rootRecord2 = context.root === void 0 ? void 0 : context.recordIndex.get(context.root);
9197
9727
  if (rootRecord2 === void 0) {
9198
- throw new EvidenceGraphError(bundle.records.some((record) => isObject(record) && record.capsule_id === context.root) ? "root aggregate payload is not disclosed" : "root aggregate payload not disclosed");
9728
+ throw new EvidenceGraphError(bundle.records.some((record) => isObject2(record) && record.capsule_id === context.root) ? "root aggregate payload is not disclosed" : "root aggregate payload not disclosed");
9199
9729
  }
9200
9730
  const payloadOf = (record) => verifiedPayload(context, record.capsule_id, "agent_input");
9201
9731
  const rootPayload = payloadOf(rootRecord2);
9202
- if (!isObject(rootPayload) || rootPayload.spec_version !== "evaluation-summary/v1") {
9732
+ if (!isObject2(rootPayload) || rootPayload.spec_version !== "evaluation-summary/v1") {
9203
9733
  throw new EvidenceGraphError("root aggregate payload is not disclosed");
9204
9734
  }
9205
9735
  const memberships2 = context.completeness.memberships;
9206
9736
  const aggregate = {
9207
9737
  capsuleId: rootRecord2.capsule_id,
9208
- ...asString(rootPayload.cross_case_aggregation) === void 0 ? {} : {
9209
- crossCaseAggregation: asString(rootPayload.cross_case_aggregation)
9738
+ ...asString2(rootPayload.cross_case_aggregation) === void 0 ? {} : {
9739
+ crossCaseAggregation: asString2(rootPayload.cross_case_aggregation)
9210
9740
  },
9211
9741
  ...Object.hasOwn(rootPayload, "per_axis") ? { perAxis: rootPayload.per_axis } : {},
9212
- ...isObject(rootPayload.counts) && asNumber(rootPayload.counts.reports) !== void 0 && asNumber(rootPayload.counts.unique_cases) !== void 0 ? {
9742
+ ...isObject2(rootPayload.counts) && asNumber(rootPayload.counts.reports) !== void 0 && asNumber(rootPayload.counts.unique_cases) !== void 0 ? {
9213
9743
  counts: {
9214
9744
  reports: asNumber(rootPayload.counts.reports),
9215
9745
  uniqueCases: asNumber(rootPayload.counts.unique_cases)
@@ -9229,7 +9759,7 @@ ${body}
9229
9759
  if (referenced === void 0)
9230
9760
  continue;
9231
9761
  const payload = payloadOf(referenced);
9232
- if (!isObject(payload))
9762
+ if (!isObject2(payload))
9233
9763
  continue;
9234
9764
  if (payload.spec_version === "evaluation-report/v1")
9235
9765
  reportIds.add(id);
@@ -9242,9 +9772,9 @@ ${body}
9242
9772
  for (const reportId of reportIds) {
9243
9773
  const record = recordsById.get(reportId);
9244
9774
  const payload = payloadOf(record);
9245
- if (!isObject(payload) || payload.spec_version !== "evaluation-report/v1")
9775
+ if (!isObject2(payload) || payload.spec_version !== "evaluation-report/v1")
9246
9776
  continue;
9247
- const date = asString(payload.date);
9777
+ const date = asString2(payload.date);
9248
9778
  if (date === void 0)
9249
9779
  continue;
9250
9780
  const day = asNumber(payload.day);
@@ -9256,15 +9786,15 @@ ${body}
9256
9786
  continue;
9257
9787
  const input2 = disclosureOf(context, actRecord.capsule_id, "agent_input");
9258
9788
  const output = disclosureOf(context, actRecord.capsule_id, "agent_output");
9259
- const inputCase = isObject(input2.payload) && isObject(input2.payload.case) ? input2.payload.case : {};
9260
- const caseId = asString(inputCase.conversation_id);
9789
+ const inputCase = isObject2(input2.payload) && isObject2(input2.payload.case) ? input2.payload.case : {};
9790
+ const caseId = asString2(inputCase.conversation_id);
9261
9791
  const turnIdx = asNumber(inputCase.turn_idx);
9262
9792
  const actResolvedLogCoordinates = logCoordinates(memberships2, actRecord.capsule_id);
9263
9793
  acts.push({
9264
9794
  capsuleId: actRecord.capsule_id,
9265
9795
  caseId: caseId ?? actRecord.capsule_id,
9266
9796
  turnIdx: turnIdx ?? Number.MAX_SAFE_INTEGER,
9267
- ...isObject(input2.payload) ? { agentInput: input2.payload } : {},
9797
+ ...isObject2(input2.payload) ? { agentInput: input2.payload } : {},
9268
9798
  ...output.state === "disclosed" ? { agentOutput: output.payload } : {},
9269
9799
  agentInputDisclosure: input2.state,
9270
9800
  agentOutputDisclosure: output.state,
@@ -9276,21 +9806,21 @@ ${body}
9276
9806
  });
9277
9807
  }
9278
9808
  const cases = reportCases.flatMap((casePayload) => {
9279
- if (!isObject(casePayload))
9809
+ if (!isObject2(casePayload))
9280
9810
  return [];
9281
- const taskId = asString(casePayload.task_id);
9811
+ const taskId = asString2(casePayload.task_id);
9282
9812
  const trial = asNumber(casePayload.trial);
9283
9813
  if (taskId === void 0 || trial === void 0)
9284
9814
  return [];
9285
9815
  const matchingActs = acts.filter((act) => {
9286
- const actCase = isObject(act.agentInput) && isObject(act.agentInput.case) ? act.agentInput.case : {};
9816
+ const actCase = isObject2(act.agentInput) && isObject2(act.agentInput.case) ? act.agentInput.case : {};
9287
9817
  return actCase.task_id === taskId && actCase.trial === trial;
9288
9818
  });
9289
9819
  const caseId = matchingActs[0]?.caseId ?? `${taskId}:${trial}`;
9290
9820
  const judgments = (Array.isArray(casePayload.axis_judgments) ? casePayload.axis_judgments : []).flatMap((judgment) => {
9291
- if (!isObject(judgment))
9821
+ if (!isObject2(judgment))
9292
9822
  return [];
9293
- const axisId = asString(judgment.axis_id), outcomeId = asString(judgment.outcome_id), judgmentStatus = status(judgment.status), rationale = asString(judgment.rationale);
9823
+ const axisId = asString2(judgment.axis_id), outcomeId = asString2(judgment.outcome_id), judgmentStatus = status(judgment.status), rationale = asString2(judgment.rationale);
9294
9824
  return axisId === void 0 || outcomeId === void 0 || judgmentStatus === void 0 || rationale === void 0 ? [] : [
9295
9825
  {
9296
9826
  axisId,
@@ -9312,9 +9842,9 @@ ${body}
9312
9842
  }
9313
9843
  ];
9314
9844
  });
9315
- const outcomes = (Array.isArray(payload.outcomes) ? payload.outcomes : []).flatMap((outcome) => isObject(outcome) && asString(outcome.outcome_id) !== void 0 && (outcome.role === "required" || outcome.role === "optional") ? [
9845
+ const outcomes = (Array.isArray(payload.outcomes) ? payload.outcomes : []).flatMap((outcome) => isObject2(outcome) && asString2(outcome.outcome_id) !== void 0 && (outcome.role === "required" || outcome.role === "optional") ? [
9316
9846
  {
9317
- outcomeId: asString(outcome.outcome_id),
9847
+ outcomeId: asString2(outcome.outcome_id),
9318
9848
  role: outcome.role,
9319
9849
  aggregate: outcome.aggregate === "pass" || outcome.aggregate === "fail" ? outcome.aggregate : null
9320
9850
  }
@@ -9347,13 +9877,13 @@ ${body}
9347
9877
  report.day = position - origin + 1;
9348
9878
  }
9349
9879
  for (const record of records) {
9350
- if (!isObject(record.chain) || record.chain.relation !== "io.evaluation.human_rates")
9880
+ if (!isObject2(record.chain) || record.chain.relation !== "io.evaluation.human_rates")
9351
9881
  continue;
9352
- const reportId = asString(record.chain.parent_capsule_id);
9882
+ const reportId = asString2(record.chain.parent_capsule_id);
9353
9883
  if (reportId === void 0)
9354
9884
  continue;
9355
9885
  const payload = payloadOf(record);
9356
- const ratingVerdict = isObject(payload) ? verdict(payload.verdict) : void 0;
9886
+ const ratingVerdict = isObject2(payload) ? verdict(payload.verdict) : void 0;
9357
9887
  const report = reports.find((candidate) => candidate.capsuleId === reportId);
9358
9888
  if (report !== void 0 && ratingVerdict !== void 0)
9359
9889
  report.ratings.push({
@@ -9365,15 +9895,10 @@ ${body}
9365
9895
  let calibration;
9366
9896
  for (const record of records) {
9367
9897
  const payload = payloadOf(record);
9368
- if (!isObject(payload) || payload.spec_version !== "calibration-summary/v1")
9898
+ if (!isObject2(payload) || payload.record_version !== CALIBRATION_SUMMARY_V1)
9369
9899
  continue;
9370
- calibration = {
9371
- capsuleId: record.capsule_id,
9372
- ...Object.hasOwn(payload, "period_window") ? { periodWindow: payload.period_window } : {},
9373
- ...Object.hasOwn(payload, "confusion") ? { confusion: payload.confusion } : {},
9374
- ...Object.hasOwn(payload, "agreement") ? { agreement: calibrationCount(payload.agreement) } : {},
9375
- ...Object.hasOwn(payload, "corrected_rate") ? { correctedRate: calibrationCount(payload.corrected_rate) } : {}
9376
- };
9900
+ const summary = readCalibrationSummary(payload);
9901
+ calibration = summary === void 0 ? { capsuleId: record.capsule_id, matchesSchema: false } : { capsuleId: record.capsule_id, matchesSchema: true, summary };
9377
9902
  break;
9378
9903
  }
9379
9904
  return {
@@ -9484,8 +10009,8 @@ ${body}
9484
10009
  ]);
9485
10010
  var UNVERIFIED_KEY_LABEL = "stated key_id (not verified)";
9486
10011
  function statedTimes(capsule) {
9487
- const timestamp = asString(capsule.timestamp);
9488
- const provenanceMode = isObject(capsule.provenance_mode) ? capsule.provenance_mode : void 0;
10012
+ const timestamp = asString2(capsule.timestamp);
10013
+ const provenanceMode = isObject2(capsule.provenance_mode) ? capsule.provenance_mode : void 0;
9489
10014
  return {
9490
10015
  ...timestamp === void 0 ? {} : { timestamp },
9491
10016
  ...provenanceMode === void 0 ? {} : { provenanceMode }
@@ -9496,7 +10021,7 @@ ${body}
9496
10021
  var CONTRACT_REF = /^[^@\s]+@[^@\s]+$/u;
9497
10022
  var nonNegativeInteger = (value) => Number.isSafeInteger(value) && value >= 0;
9498
10023
  function digestRefFindings(path2, value) {
9499
- if (!isObject(value))
10024
+ if (!isObject2(value))
9500
10025
  return [`${path2}: not an object`];
9501
10026
  const findings = [];
9502
10027
  if (value.digest_alg !== "SHA-256")
@@ -9506,7 +10031,7 @@ ${body}
9506
10031
  return findings;
9507
10032
  }
9508
10033
  function presentationFindings(path2, value) {
9509
- if (!isObject(value))
10034
+ if (!isObject2(value))
9510
10035
  return [`${path2}: not an object`];
9511
10036
  const findings = [];
9512
10037
  switch (value.kind) {
@@ -9591,7 +10116,7 @@ ${body}
9591
10116
  return later;
9592
10117
  }
9593
10118
  function claimFindings(path2, value) {
9594
- if (!isObject(value))
10119
+ if (!isObject2(value))
9595
10120
  return [`${path2}: not an object`];
9596
10121
  const findings = [];
9597
10122
  for (const member of CLAIM_REQUIRED)
@@ -9626,7 +10151,7 @@ ${body}
9626
10151
  findings.push(`${path2}.verdict: out_of_scope where the requirement does not allow it`);
9627
10152
  if (Object.hasOwn(value, "type") && value.type !== REQUIREMENT_CLAIM)
9628
10153
  findings.push(`${path2}.verdict: out_of_scope on a ${String(value.type)} claim`);
9629
- if (isObject(value.presentation) && value.presentation.status === "NOT_APPLICABLE")
10154
+ if (isObject2(value.presentation) && value.presentation.status === "NOT_APPLICABLE")
9630
10155
  findings.push(`${path2}.presentation.status: NOT_APPLICABLE on an out_of_scope claim`);
9631
10156
  }
9632
10157
  if (!Array.isArray(value.evidence))
@@ -9639,14 +10164,14 @@ ${body}
9639
10164
  value.proofs.forEach((item, index) => {
9640
10165
  const itemPath = `${path2}.proofs[${index}]`;
9641
10166
  findings.push(...digestRefFindings(itemPath, item));
9642
- if (isObject(item) && !oneOf(PROOF_KINDS, item.kind))
10167
+ if (isObject2(item) && !oneOf(PROOF_KINDS, item.kind))
9643
10168
  findings.push(`${itemPath}.kind`);
9644
10169
  });
9645
10170
  findings.push(...presentationFindings(`${path2}.presentation`, value.presentation));
9646
10171
  return findings;
9647
10172
  }
9648
10173
  function validateEvidenceResult(value) {
9649
- if (!isObject(value))
10174
+ if (!isObject2(value))
9650
10175
  return ["result: not an object"];
9651
10176
  const findings = [];
9652
10177
  for (const key of Object.keys(value))
@@ -9660,10 +10185,10 @@ ${body}
9660
10185
  findings.push("claims: not a non-empty array");
9661
10186
  else
9662
10187
  value.claims.forEach((claim, index) => findings.push(...claimFindings(`claims[${index}]`, claim)));
9663
- const aggregate = isObject(value.aggregate) ? value.aggregate : void 0;
10188
+ const aggregate = isObject2(value.aggregate) ? value.aggregate : void 0;
9664
10189
  if (aggregate === void 0)
9665
10190
  findings.push("aggregate: not an object");
9666
- const coverage = isObject(aggregate?.coverage) ? aggregate.coverage : void 0;
10191
+ const coverage = isObject2(aggregate?.coverage) ? aggregate.coverage : void 0;
9667
10192
  if (coverage === void 0)
9668
10193
  findings.push("aggregate.coverage: not an object");
9669
10194
  else
@@ -9676,14 +10201,14 @@ ${body}
9676
10201
  findings.push(`aggregate.coverage.${member}: not a non-negative integer`);
9677
10202
  if (coverage !== void 0 && Object.hasOwn(coverage, "not_yet_in_force") && !nonNegativeInteger(coverage.not_yet_in_force))
9678
10203
  findings.push("aggregate.coverage.not_yet_in_force: not a non-negative integer");
9679
- if (coverage !== void 0 && Object.hasOwn(coverage, "requirements_covered") && (!Array.isArray(coverage.requirements_covered) || !coverage.requirements_covered.every((entry) => isObject(entry) && typeof entry.contract_ref === "string" && CONTRACT_REF.test(entry.contract_ref) && nonEmptyString3(entry.requirement_ref))))
10204
+ if (coverage !== void 0 && Object.hasOwn(coverage, "requirements_covered") && (!Array.isArray(coverage.requirements_covered) || !coverage.requirements_covered.every((entry) => isObject2(entry) && typeof entry.contract_ref === "string" && CONTRACT_REF.test(entry.contract_ref) && nonEmptyString3(entry.requirement_ref))))
9680
10205
  findings.push("aggregate.coverage.requirements_covered: not an array of (contract_ref, requirement_ref) pairs");
9681
10206
  for (const member of ["plan_ref", "dataset_ref"])
9682
10207
  if (Object.hasOwn(value, member))
9683
10208
  findings.push(...digestRefFindings(member, value[member]));
9684
10209
  if (Object.hasOwn(value, "plan_ref") !== Object.hasOwn(value, "dataset_ref"))
9685
10210
  findings.push("plan_ref, dataset_ref: one is present without the other");
9686
- const buckets = isObject(aggregate?.buckets) ? aggregate.buckets : void 0;
10211
+ const buckets = isObject2(aggregate?.buckets) ? aggregate.buckets : void 0;
9687
10212
  if (buckets === void 0)
9688
10213
  findings.push("aggregate.buckets: not an object");
9689
10214
  else {
@@ -9838,10 +10363,10 @@ ${body}
9838
10363
  }
9839
10364
  function reconcileBody(raw) {
9840
10365
  const body = raw.reconcile;
9841
- if (!isObject(body))
10366
+ if (!isObject2(body))
9842
10367
  return void 0;
9843
10368
  const { join_key, peer, period, tallies, state_of_record } = body;
9844
- if (!nonEmptyString3(join_key) || !nonEmptyString3(peer) || !isObject(period) || typeof period.start !== "string" || typeof period.end !== "string" || !isObject(tallies) || !RECONCILE_TALLY_KEYS.every((key) => nonNegativeInteger(tallies[key])) || !oneOf(STATES_OF_RECORD, state_of_record))
10369
+ if (!nonEmptyString3(join_key) || !nonEmptyString3(peer) || !isObject2(period) || typeof period.start !== "string" || typeof period.end !== "string" || !isObject2(tallies) || !RECONCILE_TALLY_KEYS.every((key) => nonNegativeInteger(tallies[key])) || !oneOf(STATES_OF_RECORD, state_of_record))
9845
10370
  return void 0;
9846
10371
  return {
9847
10372
  joinKey: join_key,
@@ -9853,7 +10378,7 @@ ${body}
9853
10378
  }
9854
10379
  function closeBody(raw) {
9855
10380
  const body = raw.close;
9856
- if (!isObject(body) || !oneOf(CLOSE_STATES, body.close_state) || !isObject(body.close_ref) || !isHex64(body.close_ref.digest))
10381
+ if (!isObject2(body) || !oneOf(CLOSE_STATES, body.close_state) || !isObject2(body.close_ref) || !isHex64(body.close_ref.digest))
9857
10382
  return void 0;
9858
10383
  return body;
9859
10384
  }
@@ -9861,14 +10386,14 @@ ${body}
9861
10386
  const inbound = /* @__PURE__ */ new Map();
9862
10387
  for (const record of context.records) {
9863
10388
  const header = verifiedPayload(context, record.capsule_id, "agent_input");
9864
- if (!isObject(header) || !Array.isArray(header.links))
10389
+ if (!isObject2(header) || !Array.isArray(header.links))
9865
10390
  continue;
9866
- const bookId = asString(header.book_id);
10391
+ const bookId = asString2(header.book_id);
9867
10392
  const signer = await signerOf(record);
9868
10393
  for (const link of header.links) {
9869
- if (!isObject(link) || !oneOf(CLOSE_LINK_TYPES, link.type))
10394
+ if (!isObject2(link) || !oneOf(CLOSE_LINK_TYPES, link.type))
9870
10395
  continue;
9871
- const target = asString(link.target);
10396
+ const target = asString2(link.target);
9872
10397
  if (target === void 0)
9873
10398
  continue;
9874
10399
  const list2 = inbound.get(target) ?? [];
@@ -9893,8 +10418,8 @@ ${body}
9893
10418
  }
9894
10419
  var lowerHex = /^(?:[0-9a-f]{2})+$/u;
9895
10420
  async function keyVerifies(record, keyId) {
9896
- const signature = record.signature;
9897
- if (typeof signature !== "string" || !lowerHex.test(signature))
10421
+ const signature2 = record.signature;
10422
+ if (typeof signature2 !== "string" || !lowerHex.test(signature2))
9898
10423
  return false;
9899
10424
  let recomputed;
9900
10425
  try {
@@ -9904,7 +10429,7 @@ ${body}
9904
10429
  }
9905
10430
  if (recomputed !== record.capsule_id)
9906
10431
  return false;
9907
- const envelope = await verifyProducerEnvelope(recomputed, hexToBytes(signature));
10432
+ const envelope = await verifyProducerEnvelope(recomputed, hexToBytes(signature2));
9908
10433
  if (!envelope.ok || envelope.publicKey === void 0)
9909
10434
  return false;
9910
10435
  const kid = Array.from(envelope.publicKey, (byte) => byte.toString(16).padStart(2, "0")).join("");
@@ -9922,7 +10447,7 @@ ${body}
9922
10447
  }
9923
10448
  return { links, ignored };
9924
10449
  }
9925
- var actedOnReferences2 = (record) => Array.isArray(record.references) ? record.references.flatMap((reference) => isObject(reference) && reference.type === "agent-action-capsule" && reference.citation_purpose === "acted_on" && typeof reference.digest === "string" ? [reference.digest] : []) : [];
10450
+ var actedOnReferences2 = (record) => Array.isArray(record.references) ? record.references.flatMap((reference) => isObject2(reference) && reference.type === "agent-action-capsule" && reference.citation_purpose === "acted_on" && typeof reference.digest === "string" ? [reference.digest] : []) : [];
9926
10451
  function resultDocument(context, root) {
9927
10452
  return resultCarriers(context, root)[0];
9928
10453
  }
@@ -9930,7 +10455,7 @@ ${body}
9930
10455
  const carriers = [];
9931
10456
  for (const member of ["agent_output", "agent_input"]) {
9932
10457
  const payload = verifiedPayload(context, record.capsule_id, member);
9933
- if (!isObject(payload))
10458
+ if (!isObject2(payload))
9934
10459
  continue;
9935
10460
  if (payload.result_version === RESULT_VERSION)
9936
10461
  carriers.push({ member, form: "payload", document: payload });
@@ -9941,13 +10466,13 @@ ${body}
9941
10466
  }
9942
10467
  function nonResultDescription(context, root) {
9943
10468
  const header = verifiedPayload(context, root.capsule_id, "agent_input");
9944
- const recordType = isObject(header) ? header.record_type : void 0;
10469
+ const recordType = isObject2(header) ? header.record_type : void 0;
9945
10470
  return typeof recordType === "string" ? `agent_input is a book record header of record_type ${JSON.stringify(recordType)}, not ${JSON.stringify(RESULT_RECORD_TYPE)}` : `no disclosed member carries an ${RESULT_VERSION} document or an ${RESULT_RECORD_TYPE} record header`;
9946
10471
  }
9947
10472
  async function isResultRoot(input) {
9948
10473
  const context = await verifiedBundleContext(input);
9949
10474
  const bundle = context.bundle;
9950
- if (!isObject(bundle) || !Array.isArray(bundle.records) || !isObject(bundle.disclosures))
10475
+ if (!isObject2(bundle) || !Array.isArray(bundle.records) || !isObject2(bundle.disclosures))
9951
10476
  return false;
9952
10477
  return carriesResultDocument(context);
9953
10478
  }
@@ -9971,7 +10496,7 @@ ${body}
9971
10496
  async function bookPayload(payloads, digest) {
9972
10497
  if (!Object.hasOwn(payloads, digest))
9973
10498
  return "absent";
9974
- const encoded = asString(payloads[digest]);
10499
+ const encoded = asString2(payloads[digest]);
9975
10500
  if (encoded === void 0)
9976
10501
  return "failed";
9977
10502
  const bytes = base64UrlBytes(encoded);
@@ -9984,7 +10509,7 @@ ${body}
9984
10509
  return typeof payload === "string" ? void 0 : payload;
9985
10510
  }
9986
10511
  async function carriedCapsuleId(header, payloads) {
9987
- if (!isObject(header) || header.record_type !== PUBLISHED_CAPSULE_RECORD_TYPE)
10512
+ if (!isObject2(header) || header.record_type !== PUBLISHED_CAPSULE_RECORD_TYPE)
9988
10513
  return void 0;
9989
10514
  const commitments = Array.isArray(header.payload_commitments) ? header.payload_commitments.filter(isHex64) : [];
9990
10515
  const capsuleDigest = commitments[0];
@@ -10009,7 +10534,7 @@ ${body}
10009
10534
  return void 0;
10010
10535
  const { capsule, id } = carried;
10011
10536
  const committed = committedDigest(capsule, "agent_input");
10012
- const actionId = asString(capsule.action_id);
10537
+ const actionId = asString2(capsule.action_id);
10013
10538
  return isHex64(committed) ? {
10014
10539
  capsuleId: id,
10015
10540
  inputDigest: committed,
@@ -10018,7 +10543,7 @@ ${body}
10018
10543
  } : void 0;
10019
10544
  }
10020
10545
  async function resolveCarriedInput(header, payloads, originals = {}) {
10021
- if (!isObject(header) || header.record_type !== PUBLISHED_CAPSULE_RECORD_TYPE)
10546
+ if (!isObject2(header) || header.record_type !== PUBLISHED_CAPSULE_RECORD_TYPE)
10022
10547
  return void 0;
10023
10548
  const commitments = Array.isArray(header.payload_commitments) ? header.payload_commitments.filter(isHex64) : [];
10024
10549
  const capsuleDigest = commitments[0];
@@ -10076,7 +10601,7 @@ ${body}
10076
10601
  return { state: "disclosure_mismatch" };
10077
10602
  if (found)
10078
10603
  return { state: "disclosed", payload: disclosed };
10079
- const attached = asString(originals[capsuleId]);
10604
+ const attached = asString2(originals[capsuleId]);
10080
10605
  if (attached !== void 0) {
10081
10606
  const bytes = base64UrlBytes(attached);
10082
10607
  if (bytes === void 0)
@@ -10094,12 +10619,12 @@ ${body}
10094
10619
  async function buildResultRoot(input) {
10095
10620
  const context = await verifiedBundleContext(input);
10096
10621
  const bundle = context.bundle;
10097
- if (!isObject(bundle) || !Array.isArray(bundle.records) || !isObject(bundle.disclosures))
10622
+ if (!isObject2(bundle) || !Array.isArray(bundle.records) || !isObject2(bundle.disclosures))
10098
10623
  throw new EvidenceGraphError("bundle must contain records and disclosures");
10099
10624
  const records = context.records;
10100
10625
  const rootRecord2 = context.root === void 0 ? void 0 : context.recordIndex.get(context.root);
10101
10626
  if (rootRecord2 === void 0)
10102
- throw new EvidenceGraphError(bundle.records.some((record) => isObject(record) && record.capsule_id === context.root) ? "root record failed verification" : "root record not supplied");
10627
+ throw new EvidenceGraphError(bundle.records.some((record) => isObject2(record) && record.capsule_id === context.root) ? "root record failed verification" : "root record not supplied");
10103
10628
  const rootCarriers = resultCarriers(context, rootRecord2);
10104
10629
  const carried = rootCarriers[0];
10105
10630
  if (carried === void 0)
@@ -10112,7 +10637,7 @@ ${body}
10112
10637
  otherCarriers.push(record.capsule_id);
10113
10638
  if (otherCarriers.length > 0)
10114
10639
  throw new EvidenceGraphError(`bundle carries ${otherCarriers.length + 1} Result v0 documents: root ${rootRecord2.capsule_id} and ${otherCarriers.join(", ")}; a bundle has exactly one headline document`);
10115
- const findings = carried.form === "book" ? isObject(carried.document) ? validateEvidenceResult(carried.document).map((finding) => `agent_input.statement.${finding}`) : [
10640
+ const findings = carried.form === "book" ? isObject2(carried.document) ? validateEvidenceResult(carried.document).map((finding) => `agent_input.statement.${finding}`) : [
10116
10641
  `agent_input.statement: ${carried.document === void 0 ? "absent" : "not an object"} on the ${RESULT_RECORD_TYPE} record header`
10117
10642
  ] : validateEvidenceResult(carried.document);
10118
10643
  if (findings.length > 0)
@@ -10120,15 +10645,15 @@ ${body}
10120
10645
  const document2 = carried.document;
10121
10646
  const memberships2 = context.completeness.memberships;
10122
10647
  const recordsById = context.recordIndex;
10123
- const bookPayloads = isObject(bundle.extensions) && isObject(bundle.extensions[BOOK_PAYLOADS_EXTENSION]) ? bundle.extensions[BOOK_PAYLOADS_EXTENSION] : {};
10124
- const inputOriginals = isObject(bundle.extensions) && isObject(bundle.extensions[AGENT_INPUT_ORIGINALS_EXTENSION]) ? bundle.extensions[AGENT_INPUT_ORIGINALS_EXTENSION] : {};
10648
+ const bookPayloads = isObject2(bundle.extensions) && isObject2(bundle.extensions[BOOK_PAYLOADS_EXTENSION]) ? bundle.extensions[BOOK_PAYLOADS_EXTENSION] : {};
10649
+ const inputOriginals = isObject2(bundle.extensions) && isObject2(bundle.extensions[AGENT_INPUT_ORIGINALS_EXTENSION]) ? bundle.extensions[AGENT_INPUT_ORIGINALS_EXTENSION] : {};
10125
10650
  let carriersById;
10126
10651
  const bookCarrier = async (id) => {
10127
10652
  if (carriersById === void 0) {
10128
10653
  carriersById = /* @__PURE__ */ new Map();
10129
10654
  for (const record of records) {
10130
10655
  const header = disclosureOf(context, record.capsule_id, "agent_input");
10131
- if (header.state !== "disclosed" || !isObject(header.payload) || header.payload.record_type !== PUBLISHED_CAPSULE_RECORD_TYPE)
10656
+ if (header.state !== "disclosed" || !isObject2(header.payload) || header.payload.record_type !== PUBLISHED_CAPSULE_RECORD_TYPE)
10132
10657
  continue;
10133
10658
  const carried2 = await carriedCapsuleId(header.payload, bookPayloads);
10134
10659
  if (carried2 !== void 0 && !recordsById.has(carried2.id))
@@ -10161,7 +10686,7 @@ ${body}
10161
10686
  carriedInputDigest: carriedCapsule.inputDigest,
10162
10687
  ...carriedCapsule.actionId === void 0 ? {} : { carriedActionId: carriedCapsule.actionId }
10163
10688
  },
10164
- ...carriedCapsule !== void 0 ? { stated: carriedCapsule.stated } : agentInput.state === "disclosed" && isObject(agentInput.payload) && agentInput.payload.record_type === PUBLISHED_CAPSULE_RECORD_TYPE ? {} : { stated: statedTimes(record) },
10689
+ ...carriedCapsule !== void 0 ? { stated: carriedCapsule.stated } : agentInput.state === "disclosed" && isObject2(agentInput.payload) && agentInput.payload.record_type === PUBLISHED_CAPSULE_RECORD_TYPE ? {} : { stated: statedTimes(record) },
10165
10690
  agentOutput: disclosureOf(context, record.capsule_id, "agent_output"),
10166
10691
  ...agentInputDigest === void 0 ? {} : { agentInputDigest },
10167
10692
  ...agentOutputDigest === void 0 ? {} : { agentOutputDigest },
@@ -10197,19 +10722,19 @@ ${body}
10197
10722
  const asserted = body.close_state;
10198
10723
  const closeRecord = recordsById.get(closeRef);
10199
10724
  const supplied = closeRecord !== void 0;
10200
- const peer = asString(body.peer);
10725
+ const peer = asString2(body.peer);
10201
10726
  const closeHeader = closeRecord === void 0 ? void 0 : verifiedPayload(context, closeRecord.capsule_id, "agent_input");
10202
- const closeBookId = isObject(closeHeader) ? asString(closeHeader.book_id) : void 0;
10727
+ const closeBookId = isObject2(closeHeader) ? asString2(closeHeader.book_id) : void 0;
10203
10728
  const closeSigner = closeRecord === void 0 ? {} : await signerOf(closeRecord);
10204
10729
  const { links, ignored } = counterpartyLinks({
10205
10730
  ...closeBookId === void 0 ? {} : { bookId: closeBookId },
10206
10731
  ...closeSigner
10207
10732
  }, peer, inbound.get(closeRef) ?? []);
10208
10733
  const derived = supplied && closeSigner.keyNotChecked !== true ? deriveCloseState(links) : void 0;
10209
- const peerCloseRef = isObject(body.peer_close_ref) ? asString(body.peer_close_ref.digest) : void 0;
10210
- const period = isObject(body.period) ? {
10211
- start: asString(body.period.start) ?? "",
10212
- end: asString(body.period.end) ?? ""
10734
+ const peerCloseRef = isObject2(body.peer_close_ref) ? asString2(body.peer_close_ref.digest) : void 0;
10735
+ const period = isObject2(body.period) ? {
10736
+ start: asString2(body.period.start) ?? "",
10737
+ end: asString2(body.period.end) ?? ""
10213
10738
  } : void 0;
10214
10739
  const wanted = derived === "AGREED" ? "acknowledges" : derived === "CONTESTED" ? "rebuts" : void 0;
10215
10740
  close = {
@@ -10397,18 +10922,19 @@ ${body}
10397
10922
  }
10398
10923
  function reportPayload(records, claim) {
10399
10924
  const digest = claim.evidence[0]?.digest;
10400
- if (digest === void 0)
10401
- return void 0;
10925
+ return digest === void 0 ? void 0 : citedPayload(records, digest);
10926
+ }
10927
+ function citedPayload(records, digest) {
10402
10928
  const record = records.get(digest);
10403
10929
  if (record === void 0)
10404
10930
  return void 0;
10405
10931
  const input = record.carriedInput ?? record.agentInput;
10406
10932
  if (input.state !== "disclosed")
10407
10933
  return void 0;
10408
- return isObject(input.payload) ? input.payload : void 0;
10934
+ return isObject2(input.payload) ? input.payload : void 0;
10409
10935
  }
10410
10936
  function dayOf(payload) {
10411
- const period = asString(payload?.period);
10937
+ const period = asString2(payload?.period);
10412
10938
  if (period === void 0)
10413
10939
  return "unknown";
10414
10940
  const colon = period.indexOf(":");
@@ -10416,7 +10942,7 @@ ${body}
10416
10942
  }
10417
10943
  var STATED_DAY = /^(\d{4}-\d{2}-\d{2})/u;
10418
10944
  function reportSealedDay(records, claim) {
10419
- const period = asString(reportPayload(records, claim)?.period);
10945
+ const period = asString2(reportPayload(records, claim)?.period);
10420
10946
  if (period !== void 0) {
10421
10947
  const colon = period.indexOf(":");
10422
10948
  return colon === -1 ? period : period.slice(colon + 1);
@@ -10435,7 +10961,7 @@ ${body}
10435
10961
  const input = record.carriedInput ?? record.agentInput;
10436
10962
  switch (input.state) {
10437
10963
  case "disclosed":
10438
- return isObject(input.payload) ? "disclosed" : "unreadable";
10964
+ return isObject2(input.payload) ? "disclosed" : "unreadable";
10439
10965
  case "withheld":
10440
10966
  return record.carriedInput !== void 0 && record.carriedCapsuleId === void 0 ? "invalid" : "withheld";
10441
10967
  case "disclosure_mismatch":
@@ -10525,12 +11051,12 @@ ${body}
10525
11051
  if (stated === void 0)
10526
11052
  return judged;
10527
11053
  const mode = stated.provenanceMode;
10528
- if (asString(mode?.mode) === "backfilled") {
10529
- const source = asString(mode?.source_asserted_at);
11054
+ if (asString2(mode?.mode) === "backfilled") {
11055
+ const source = asString2(mode?.source_asserted_at);
10530
11056
  const day2 = source === void 0 ? void 0 : STATED_DAY.exec(source)?.[1];
10531
11057
  if (source === void 0 || day2 === void 0)
10532
11058
  return judged;
10533
- const importedAt = asString(mode?.imported_at);
11059
+ const importedAt = asString2(mode?.imported_at);
10534
11060
  return {
10535
11061
  basis: "source",
10536
11062
  date: day2,
@@ -10565,35 +11091,35 @@ ${body}
10565
11091
  return "met";
10566
11092
  }
10567
11093
  function sealedCaseIds(payload) {
10568
- const c = isObject(payload.case) ? payload.case : void 0;
11094
+ const c = isObject2(payload.case) ? payload.case : void 0;
10569
11095
  if (c === void 0)
10570
11096
  return [];
10571
11097
  const parts = [c.benchmark, c.domain, c.task_id, c.trial].map((v) => typeof v === "string" || typeof v === "number" ? String(v) : void 0);
10572
11098
  if (parts.some((v) => v === void 0))
10573
11099
  return [];
10574
11100
  const ids = [`${parts[0]}:${parts[1]}:task-${parts[2]}:trial-${parts[3]}`];
10575
- const model = asString(c.agent_model);
11101
+ const model = asString2(c.agent_model);
10576
11102
  if (model !== void 0 && model.length > 0)
10577
11103
  ids.unshift(`${parts[0]}:${parts[1]}:${model}:task-${parts[2]}:trial-${parts[3]}`);
10578
11104
  return ids;
10579
11105
  }
10580
11106
  function transcriptTurns(payload) {
10581
- const interaction = isObject(payload.agent_interaction) ? payload.agent_interaction : void 0;
11107
+ const interaction = isObject2(payload.agent_interaction) ? payload.agent_interaction : void 0;
10582
11108
  if (interaction === void 0 || !Array.isArray(interaction.messages))
10583
11109
  return void 0;
10584
11110
  return interaction.messages.flatMap((m) => {
10585
- if (!isObject(m))
11111
+ if (!isObject2(m))
10586
11112
  return [];
10587
- const role = asString(m.role) ?? "unknown";
10588
- const content = asString(m.content);
11113
+ const role = asString2(m.role) ?? "unknown";
11114
+ const content = asString2(m.content);
10589
11115
  const calls = Array.isArray(m.tool_calls) ? m.tool_calls : [];
10590
11116
  return [
10591
11117
  {
10592
11118
  role,
10593
11119
  ...content === void 0 ? {} : { content },
10594
- toolCalls: calls.flatMap((call) => isObject(call) ? [
11120
+ toolCalls: calls.flatMap((call) => isObject2(call) ? [
10595
11121
  {
10596
- name: asString(call.name) ?? "unnamed",
11122
+ name: asString2(call.name) ?? "unnamed",
10597
11123
  arguments: JSON.stringify(call.arguments ?? null)
10598
11124
  }
10599
11125
  ] : [])
@@ -10613,7 +11139,7 @@ ${body}
10613
11139
  if (record !== void 0)
10614
11140
  records.push(record);
10615
11141
  }
10616
- const carriers = records.filter((r) => r.carriedInput?.state === "disclosed" && isObject(r.carriedInput.payload) && transcriptTurns(r.carriedInput.payload) !== void 0);
11142
+ const carriers = records.filter((r) => r.carriedInput?.state === "disclosed" && isObject2(r.carriedInput.payload) && transcriptTurns(r.carriedInput.payload) !== void 0);
10617
11143
  if (carriers.length === 0)
10618
11144
  return { state: "absent" };
10619
11145
  if (sourceCapsuleId === void 0)
@@ -10722,11 +11248,11 @@ ${body}
10722
11248
  }
10723
11249
  const target = claim.later && !claim.failed ? laterCriteria : criteria;
10724
11250
  const judgment = reportPayload(result.records, claim);
10725
- const rationale = judgment ? asString(judgment.rationale) : void 0;
10726
- const reasonCode = judgment ? asString(judgment.reason_code) : void 0;
10727
- const sourceCapsuleId = judgment ? asString(judgment.source_capsule_id) : void 0;
10728
- const judgePinDigest = judgment ? asString(judgment.judge_pin_digest) : void 0;
10729
- const clauseClaim = judgment !== void 0 && asString(judgment.clause_id) === `${check.id}.${criterion2.id}` ? asString(judgment.clause_claim) : void 0;
11251
+ const rationale = judgment ? asString2(judgment.rationale) : void 0;
11252
+ const reasonCode = judgment ? asString2(judgment.reason_code) : void 0;
11253
+ const sourceCapsuleId = judgment ? asString2(judgment.source_capsule_id) : void 0;
11254
+ const judgePinDigest = judgment ? asString2(judgment.judge_pin_digest) : void 0;
11255
+ const clauseClaim = judgment !== void 0 && asString2(judgment.clause_id) === `${check.id}.${criterion2.id}` ? asString2(judgment.clause_claim) : void 0;
10730
11256
  const { probabilities, confidence } = parseJudgeProbabilities(rationale);
10731
11257
  const cited2 = claim.evidence[0]?.digest;
10732
11258
  const record = cited2 === void 0 ? void 0 : result.records.get(cited2);
@@ -10808,20 +11334,20 @@ ${body}
10808
11334
  return tiers;
10809
11335
  }
10810
11336
  function pinComponents(value) {
10811
- if (!isObject(value))
11337
+ if (!isObject2(value))
10812
11338
  return void 0;
10813
- const modelId = asString(value.model_id);
10814
- const promptDigest = asString(value.prompt_digest);
10815
- const axesDigest = asString(value.axes_digest);
11339
+ const modelId = asString2(value.model_id);
11340
+ const promptDigest = asString2(value.prompt_digest);
11341
+ const axesDigest = asString2(value.axes_digest);
10816
11342
  if (modelId === void 0 || promptDigest === void 0 || axesDigest === void 0)
10817
11343
  return void 0;
10818
- const modelVersion = asString(value.model_version);
11344
+ const modelVersion = asString2(value.model_version);
10819
11345
  return {
10820
11346
  modelId,
10821
11347
  ...modelVersion === void 0 ? {} : { modelVersion },
10822
11348
  promptDigest,
10823
11349
  axesDigest,
10824
- ...isObject(value.sampling_params) ? { samplingParams: value.sampling_params } : {}
11350
+ ...isObject2(value.sampling_params) ? { samplingParams: value.sampling_params } : {}
10825
11351
  };
10826
11352
  }
10827
11353
  function pinPreimage(pin) {
@@ -10845,10 +11371,10 @@ ${body}
10845
11371
  continue;
10846
11372
  claimContracts.add(claim.contractRef);
10847
11373
  const payload = reportPayload(result.records, claim);
10848
- const contract = asString(payload?.contract_ref) ?? asString(payload?.contract);
11374
+ const contract = asString2(payload?.contract_ref) ?? asString2(payload?.contract);
10849
11375
  if (contract !== void 0)
10850
11376
  reportContracts.add(contract);
10851
- const pin = asString(payload?.judge_pin_digest);
11377
+ const pin = asString2(payload?.judge_pin_digest);
10852
11378
  if (pin !== void 0)
10853
11379
  pins.add(pin);
10854
11380
  const parts = pinComponents(payload?.judge_pin);
@@ -10882,63 +11408,116 @@ ${body}
10882
11408
  }
10883
11409
  return { ...runInfo, judgePinRecomputes: recomputes };
10884
11410
  }
11411
+ function judgedCase(result, caseDigest) {
11412
+ const citing = result.claims.filter((claim) => claim.type === REQUIREMENT_CLAIM && !claim.failed && claim.evidence.some((ref) => ref.digest === caseDigest));
11413
+ const first = citing[0];
11414
+ if (first === void 0)
11415
+ return void 0;
11416
+ const settled2 = citing.every((claim) => claim.requirementRef === first.requirementRef && claim.verdict === first.verdict);
11417
+ return settled2 ? {
11418
+ claimId: first.id,
11419
+ requirementRef: first.requirementRef,
11420
+ verdict: first.verdict
11421
+ } : void 0;
11422
+ }
11423
+ var COUNTED_LABELS = /* @__PURE__ */ new Set(["met", "not_met"]);
10885
11424
  function buildCalibration(result) {
10886
- const weeks = [];
11425
+ const readings2 = [];
10887
11426
  for (const claim of result.claims) {
10888
11427
  if (claim.type !== "calibration")
10889
11428
  continue;
10890
- const payload = reportPayload(result.records, claim);
10891
- if (payload === void 0)
11429
+ const summaries = [];
11430
+ const ratings = [];
11431
+ let ratingsNotMatching = 0;
11432
+ for (const digest of new Set(claim.evidence.map((ref) => ref.digest))) {
11433
+ const payload = citedPayload(result.records, digest);
11434
+ if (payload === void 0)
11435
+ continue;
11436
+ if (payload.record_version === CALIBRATION_SUMMARY_V1)
11437
+ summaries.push({ digest, payload });
11438
+ else if (payload.record_version === HUMAN_RATING_V1) {
11439
+ const rating = readHumanRating(payload);
11440
+ if (rating === void 0) {
11441
+ ratingsNotMatching += 1;
11442
+ continue;
11443
+ }
11444
+ const judged = judgedCase(result, rating.ratedCase.digest);
11445
+ ratings.push({
11446
+ digest,
11447
+ rating,
11448
+ ...judged === void 0 ? {} : {
11449
+ judged,
11450
+ ...COUNTED_LABELS.has(rating.label) && COUNTED_LABELS.has(judged.verdict) ? { agrees: rating.label === judged.verdict } : {}
11451
+ }
11452
+ });
11453
+ }
11454
+ }
11455
+ const first = summaries[0];
11456
+ if (first === void 0)
10892
11457
  continue;
10893
- const weekId = asString(payload.week);
10894
- if (weekId === void 0)
11458
+ const base = {
11459
+ claim,
11460
+ summaryDigest: first.digest,
11461
+ ratings,
11462
+ ratingsNotMatching,
11463
+ ratingsOutsideClauses: 0
11464
+ };
11465
+ if (summaries.length > 1) {
11466
+ readings2.push({ ...base, state: "ambiguous", clauses: [] });
10895
11467
  continue;
10896
- const sample = (Array.isArray(payload.sample) ? payload.sample : []).flatMap((entry) => {
10897
- if (!isObject(entry))
10898
- return [];
10899
- const conversationId = asString(entry.conversation_id);
10900
- const aiVerdict = asString(entry.ai_verdict);
10901
- const humanVerdict = asString(entry.human_verdict);
10902
- if (conversationId === void 0 || aiVerdict === void 0 || humanVerdict === void 0)
10903
- return [];
10904
- const note = asString(entry.note);
10905
- return [
10906
- {
10907
- conversationId,
10908
- aiVerdict,
10909
- humanVerdict,
10910
- ...note === void 0 ? {} : { note },
10911
- agrees: aiVerdict === humanVerdict
10912
- }
10913
- ];
11468
+ }
11469
+ const summary = readCalibrationSummary(first.payload);
11470
+ if (summary === void 0) {
11471
+ readings2.push({ ...base, state: "not_matching", clauses: [] });
11472
+ continue;
11473
+ }
11474
+ const recomputable = ratingsNotMatching === 0 && ratings.every((entry) => entry.judged !== void 0);
11475
+ const clauses = summary.clauses.map((tally) => {
11476
+ const bound = recomputable ? ratings.filter((entry) => entry.judged.requirementRef === tally.clauseRef && entry.agrees !== void 0) : [];
11477
+ if (bound.length === 0)
11478
+ return { ...tally, agreementCheck: "not_recomputable" };
11479
+ const recomputed = {
11480
+ k: bound.filter((entry) => entry.agrees === true).length,
11481
+ n: bound.length
11482
+ };
11483
+ const stated = tally.agreement;
11484
+ const agreementCheck = recomputed.k > stated.k || recomputed.n - recomputed.k > stated.n - stated.k ? "mismatch" : recomputed.k === stated.k && recomputed.n === stated.n ? "matches" : "not_recomputable";
11485
+ return { ...tally, recomputedAgreement: recomputed, agreementCheck };
10914
11486
  });
10915
- const k = sample.filter((entry) => entry.agrees).length;
10916
- const n = sample.length;
10917
- const from = asString(payload.from);
10918
- const to = asString(payload.to);
10919
- weeks.push({
10920
- weekId,
10921
- ...from === void 0 ? {} : { from },
10922
- ...to === void 0 ? {} : { to },
10923
- k,
10924
- n,
10925
- sample,
10926
- claim
11487
+ const clauseRefs = new Set(summary.clauses.map((c) => c.clauseRef));
11488
+ const ratingsOutsideClauses = ratings.filter((entry) => entry.judged !== void 0 && !clauseRefs.has(entry.judged.requirementRef)).length;
11489
+ readings2.push({
11490
+ ...base,
11491
+ ratingsOutsideClauses,
11492
+ state: "read",
11493
+ summary,
11494
+ clauses
10927
11495
  });
10928
11496
  }
10929
- weeks.sort((a, b) => a.weekId.localeCompare(b.weekId));
10930
- return weeks;
11497
+ readings2.sort((a, b) => {
11498
+ if (a.summary === void 0 || b.summary === void 0)
11499
+ return Number(a.summary === void 0) - Number(b.summary === void 0);
11500
+ return a.summary.computedAt.localeCompare(b.summary.computedAt) || a.summaryDigest.localeCompare(b.summaryDigest);
11501
+ });
11502
+ return readings2;
10931
11503
  }
10932
- function heldAndAdded(weeks) {
10933
- let held = 0, added = 0;
10934
- for (const week of weeks)
10935
- for (const sample of week.sample) {
10936
- if (sample.aiVerdict === "met" && sample.humanVerdict !== "met")
10937
- held += 1;
10938
- else if (sample.aiVerdict !== "met" && sample.humanVerdict === "met")
11504
+ function heldAndAdded(readings2) {
11505
+ let held2 = 0, added = 0;
11506
+ const seen = /* @__PURE__ */ new Set();
11507
+ for (const reading of readings2) {
11508
+ if (reading.state !== "read")
11509
+ continue;
11510
+ for (const { digest, rating, judged } of reading.ratings) {
11511
+ if (judged === void 0 || seen.has(digest))
11512
+ continue;
11513
+ seen.add(digest);
11514
+ if (judged.verdict === "met" && rating.label === "not_met")
11515
+ held2 += 1;
11516
+ else if (judged.verdict === "not_met" && rating.label === "met")
10939
11517
  added += 1;
10940
11518
  }
10941
- return { held, added };
11519
+ }
11520
+ return { held: held2, added };
10942
11521
  }
10943
11522
  function missedReasonGroups(terms, conversations) {
10944
11523
  const labelOf = (checkId, criterionId) => {
@@ -10997,11 +11576,11 @@ ${body}
10997
11576
  function citedContract(result, contractRef) {
10998
11577
  for (const record of result.records.values()) {
10999
11578
  const input = record.carriedInput ?? record.agentInput;
11000
- if (input.state !== "disclosed" || !isObject(input.payload))
11579
+ if (input.state !== "disclosed" || !isObject2(input.payload))
11001
11580
  continue;
11002
11581
  const doc = input.payload;
11003
- const id = asString(doc.id);
11004
- const version = asString(doc.version);
11582
+ const id = asString2(doc.id);
11583
+ const version = asString2(doc.version);
11005
11584
  if (id !== void 0 && version !== void 0 && Array.isArray(doc.requirements) && `${id}@${version}` === contractRef)
11006
11585
  return doc;
11007
11586
  }
@@ -11035,12 +11614,12 @@ ${body}
11035
11614
  checks.set(split2.checkId, criteria);
11036
11615
  }
11037
11616
  const at = contractRef?.lastIndexOf("@") ?? -1;
11038
- const outcome = Array.isArray(contract?.requirements) ? contract.requirements.find((r) => isObject(r) && r.profile === "outcome" && asString(r.statement) !== void 0) : void 0;
11617
+ const outcome = Array.isArray(contract?.requirements) ? contract.requirements.find((r) => isObject2(r) && r.profile === "outcome" && asString2(r.statement) !== void 0) : void 0;
11039
11618
  return {
11040
11619
  pack: {
11041
11620
  id: contractRef === void 0 || at <= 0 ? NOT_STATED : contractRef.slice(0, at),
11042
11621
  version: contractRef === void 0 || at <= 0 || at === contractRef.length - 1 ? NOT_STATED : contractRef.slice(at + 1),
11043
- outcomeStatement: asString(outcome?.statement) ?? NOT_STATED,
11622
+ outcomeStatement: asString2(outcome?.statement) ?? NOT_STATED,
11044
11623
  locked: NOT_STATED,
11045
11624
  agreement: NOT_STATED,
11046
11625
  resolutionRule: RESOLUTION_RULE
@@ -11070,7 +11649,7 @@ ${body}
11070
11649
  function contractCriteria(contract) {
11071
11650
  const ids = [];
11072
11651
  for (const requirement of contract?.requirements ?? []) {
11073
- const id = isObject(requirement) ? asString(requirement.id) : void 0;
11652
+ const id = isObject2(requirement) ? asString2(requirement.id) : void 0;
11074
11653
  if (id !== void 0 && criterionRef(id) !== void 0 && !ids.includes(id))
11075
11654
  ids.push(id);
11076
11655
  }
@@ -11106,7 +11685,7 @@ ${body}
11106
11685
  judgedDays: [...new Set(convos.map((c) => c.judgedDay))].sort()
11107
11686
  }));
11108
11687
  const calibration = buildCalibration(result);
11109
- const { held, added } = heldAndAdded(calibration);
11688
+ const { held: held2, added } = heldAndAdded(calibration);
11110
11689
  const checkPassCounts = /* @__PURE__ */ new Map();
11111
11690
  for (const check of terms.checks)
11112
11691
  checkPassCounts.set(check.id, conversations.filter((c) => c.checkVerdicts.get(check.id) === "met").length);
@@ -11131,7 +11710,7 @@ ${body}
11131
11710
  resolvedCount,
11132
11711
  missedCount: conversations.length - resolvedCount,
11133
11712
  totalCount: conversations.length,
11134
- heldCount: held,
11713
+ heldCount: held2,
11135
11714
  addedCount: added,
11136
11715
  notApplicableCount,
11137
11716
  outOfScopeCount,
@@ -11142,31 +11721,31 @@ ${body}
11142
11721
  }
11143
11722
 
11144
11723
  // node_modules/@action-state-group/agent-action-capsule/dist/report-rows.js
11145
- var rowCitationDigests = (row2) => Array.isArray(row2.references) ? row2.references.flatMap((reference) => isObject(reference) && reference.type === "agent-action-capsule" && reference.citation_purpose === "acted_on" ? asString(reference.digest) === void 0 ? [] : [asString(reference.digest)] : []) : [];
11724
+ var rowCitationDigests = (row2) => Array.isArray(row2.references) ? row2.references.flatMap((reference) => isObject2(reference) && reference.type === "agent-action-capsule" && reference.citation_purpose === "acted_on" ? asString2(reference.digest) === void 0 ? [] : [asString2(reference.digest)] : []) : [];
11146
11725
  async function buildReportRows(input) {
11147
11726
  const context = await verifiedBundleContext(input);
11148
11727
  const bundle = context.bundle;
11149
- if (!isObject(bundle) || !Array.isArray(bundle.records) || !isObject(bundle.disclosures)) {
11728
+ if (!isObject2(bundle) || !Array.isArray(bundle.records) || !isObject2(bundle.disclosures)) {
11150
11729
  return void 0;
11151
11730
  }
11152
11731
  const rootRecord2 = context.root === void 0 ? void 0 : context.recordIndex.get(context.root);
11153
11732
  if (rootRecord2 === void 0)
11154
11733
  return void 0;
11155
11734
  const rootPayload = verifiedPayload(context, rootRecord2.capsule_id, "agent_input");
11156
- if (!isObject(rootPayload) || rootPayload.spec_version !== "report/v1")
11735
+ if (!isObject2(rootPayload) || rootPayload.spec_version !== "report/v1")
11157
11736
  return void 0;
11158
11737
  const memberships2 = context.completeness.memberships;
11159
11738
  const recordsById = context.recordIndex;
11160
11739
  const rows = [];
11161
11740
  for (const raw of Array.isArray(rootPayload.rows) ? rootPayload.rows : []) {
11162
- if (!isObject(raw))
11741
+ if (!isObject2(raw))
11163
11742
  continue;
11164
- const rowId = asString(raw.row_id);
11165
- const label = asString(raw.label);
11166
- const rowStatus2 = asString(raw.status);
11743
+ const rowId = asString2(raw.row_id);
11744
+ const label = asString2(raw.label);
11745
+ const rowStatus2 = asString2(raw.status);
11167
11746
  if (rowId === void 0 || label === void 0 || rowStatus2 === void 0)
11168
11747
  continue;
11169
- const reason = asString(raw.reason);
11748
+ const reason = asString2(raw.reason);
11170
11749
  const citations2 = [];
11171
11750
  for (const digest of rowCitationDigests(raw)) {
11172
11751
  const record = recordsById.get(digest);
@@ -11190,7 +11769,7 @@ ${body}
11190
11769
  citations: citations2
11191
11770
  });
11192
11771
  }
11193
- const title = asString(rootPayload.title);
11772
+ const title = asString2(rootPayload.title);
11194
11773
  const rootResolvedLogCoordinates = logCoordinates(memberships2, rootRecord2.capsule_id);
11195
11774
  return {
11196
11775
  capsuleId: rootRecord2.capsule_id,
@@ -11285,7 +11864,7 @@ ${body}
11285
11864
  const unbound = new Set(unboundRecordIds(verified));
11286
11865
  const invalid2 = invalidRecordIds(verified);
11287
11866
  return (Array.isArray(bundle.records) ? bundle.records : []).flatMap((record) => {
11288
- const capsuleId = object8(record)?.capsule_id;
11867
+ const capsuleId = object9(record)?.capsule_id;
11289
11868
  if (typeof capsuleId !== "string")
11290
11869
  return [];
11291
11870
  return [
@@ -11329,7 +11908,7 @@ ${body}
11329
11908
  };
11330
11909
  var UNVERIFIED_BUNDLE_REFUSAL = "This bundle did not verify. Its records, rows and payloads are not shown; the verification page below lists which checks failed.";
11331
11910
  var recordsWord = (count2) => `${count2} ${count2 === 1 ? "record" : "records"}`;
11332
- var fields = (value) => object8(value) ?? {};
11911
+ var fields = (value) => object9(value) ?? {};
11333
11912
  var CLAIM_WORDS = {
11334
11913
  records: "each record's identity",
11335
11914
  signatures: "the records' producer signatures",
@@ -11520,7 +12099,7 @@ ${body}
11520
12099
  "range_proof_invalid"
11521
12100
  ]);
11522
12101
  function verificationCheckLists(bundle, verified, inputs = {}) {
11523
- const top = object8(bundle) ?? {};
12102
+ const top = object9(bundle) ?? {};
11524
12103
  const outcome = /* @__PURE__ */ new Map();
11525
12104
  const ran = (id, passed) => {
11526
12105
  outcome.set(id, passed ? "page" : "failed");
@@ -11531,7 +12110,7 @@ ${body}
11531
12110
  }
11532
12111
  ran("closure", verified.graphClosure.status !== "fail");
11533
12112
  const range = verified.intervalCoverage;
11534
- const signed = typeof object8(top.checkpoint)?.cose === "string" && object8(top.checkpoint).cose !== "";
12113
+ const signed = typeof object9(top.checkpoint)?.cose === "string" && object9(top.checkpoint).cose !== "";
11535
12114
  let passedWithoutCheckpoint = false;
11536
12115
  if (range.status !== "withheld") {
11537
12116
  const stopped = range.findings.some((f) => STOPPED_BEFORE_CHECKPOINT.has(f));
@@ -11578,7 +12157,7 @@ ${body}
11578
12157
  ran("composed", true);
11579
12158
  if (inputs.citedSigners === true)
11580
12159
  ran("cited-signers", true);
11581
- if (Array.isArray(top.records) && top.records.some((record) => typeof object8(record)?.signature === "string" && object8(record).signature !== ""))
12160
+ if (Array.isArray(top.records) && top.records.some((record) => typeof object9(record)?.signature === "string" && object9(record).signature !== ""))
11582
12161
  outcome.set("producer-signatures", "notChecked");
11583
12162
  if (Array.isArray(top.receipts) && top.receipts.length > 0)
11584
12163
  outcome.set("witness-receipts", "notChecked");
@@ -11631,7 +12210,7 @@ ${body}
11631
12210
  fail: "failed at least one check",
11632
12211
  not_checked: "not checked no evidence supplied"
11633
12212
  });
11634
- function object8(value) {
12213
+ function object9(value) {
11635
12214
  return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
11636
12215
  }
11637
12216
  function capsuleGroupStatus(capsuleResults, checks) {
@@ -11648,7 +12227,7 @@ ${body}
11648
12227
  if (!Array.isArray(raw))
11649
12228
  return [];
11650
12229
  return raw.flatMap((entry) => {
11651
- const record = object8(entry);
12230
+ const record = object9(entry);
11652
12231
  if (record === void 0)
11653
12232
  return [];
11654
12233
  const witness = record.witness, time = record.time, grade = receiptGradeWord(record.grade);
@@ -11656,7 +12235,7 @@ ${body}
11656
12235
  });
11657
12236
  }
11658
12237
  function completenessStatement(raw) {
11659
- const record = object8(raw);
12238
+ const record = object9(raw);
11660
12239
  if (record === void 0)
11661
12240
  return void 0;
11662
12241
  return {
@@ -11670,8 +12249,8 @@ ${body}
11670
12249
  return { name, status: status2, result: FIVE_WORD_RESULT[status2] };
11671
12250
  }
11672
12251
  function buildVerificationPageModel(bundle, verified, appliedInterpreters, checkInputs = {}) {
11673
- const top = object8(bundle) ?? {};
11674
- const checkpoint = object8(top.checkpoint);
12252
+ const top = object9(bundle) ?? {};
12253
+ const checkpoint = object9(top.checkpoint);
11675
12254
  const checks = [
11676
12255
  summarize("Required fields", capsuleGroupStatus(verified.capsuleResults, [1])),
11677
12256
  summarize("Capsule ID matches contents", capsuleGroupStatus(verified.capsuleResults, [2])),
@@ -13684,6 +14263,21 @@ ${s} [data-src="producer"]:not(.cv-src){font-style:italic}
13684
14263
  }
13685
14264
  ];
13686
14265
  }
14266
+ function withheldMark(claim, w) {
14267
+ if (claim.presentation.status !== "WITHHELD" || claim.failed)
14268
+ return void 0;
14269
+ const digests = claim.evidence.map((e) => e.digest);
14270
+ const mark = tagSource(
14271
+ el2(
14272
+ "span",
14273
+ "wh",
14274
+ digests.length === 0 ? w.t("card.mark.withheld") : w.t("card.mark.withheld.cited", { digests: digests.join(", ") })
14275
+ ),
14276
+ "core"
14277
+ );
14278
+ mark.dataset.mark = "withheld";
14279
+ return mark;
14280
+ }
13687
14281
  function refusedWordingNotice(w) {
13688
14282
  if (w.source.refused === void 0) return void 0;
13689
14283
  const p = tagSource(el2("p", "wref", w.t("card.wording.refused")), "core");
@@ -13711,6 +14305,8 @@ ${s} details.lv > summary .tg{display:inline-block;width:1em;margin-right:6px;co
13711
14305
  ${s} details.lv > summary .tg:before{content:"\\25B8"}
13712
14306
  ${s} details.lv[open] > summary .tg:before{content:"\\25BE"}
13713
14307
  ${s} details.lv[data-opened-by="view"] > summary .tg{color:var(--navy)}
14308
+ ${s} .wh{display:inline-block;color:var(--bad,#B3261E);font-weight:600;font-size:12.5px}
14309
+ ${s} .wh:before{content:"\\25B8";content:"\\25B8" / "";display:inline-block;width:1em;margin-right:6px;font-size:12px}
13714
14310
  ${s} .wref:before{content:"\\25A0";content:"\\25A0" / "";display:inline-block;width:1em;margin-right:6px;font-size:12px;color:#8A93A0}
13715
14311
  ${s} details.lv1.line{border:0;background:transparent;margin-top:4px}
13716
14312
  ${s} details.lv1.line > summary{padding:2px 0;font-size:13px}
@@ -14897,11 +15493,11 @@ path.cv-tl-good{fill:var(--person)}path.cv-tl-bad{fill:var(--bad)}path.cv-tl-ope
14897
15493
  const stated = record?.stated;
14898
15494
  if (stated === void 0) return judged;
14899
15495
  const mode = stated.provenanceMode;
14900
- if (asString(mode?.mode) === "backfilled") {
14901
- const source = asString(mode?.source_asserted_at);
15496
+ if (asString2(mode?.mode) === "backfilled") {
15497
+ const source = asString2(mode?.source_asserted_at);
14902
15498
  const day2 = source === void 0 ? void 0 : STATED_DAY2.exec(source)?.[1];
14903
15499
  if (source === void 0 || day2 === void 0) return judged;
14904
- const importedAt = asString(mode?.imported_at);
15500
+ const importedAt = asString2(mode?.imported_at);
14905
15501
  return {
14906
15502
  basis: "source",
14907
15503
  date: day2,
@@ -14948,16 +15544,16 @@ path.cv-tl-good{fill:var(--person)}path.cv-tl-bad{fill:var(--bad)}path.cv-tl-ope
14948
15544
  if (record === void 0) return void 0;
14949
15545
  const input = record.carriedInput ?? record.agentInput;
14950
15546
  if (input.state !== "disclosed") return void 0;
14951
- return isObject(input.payload) ? input.payload : void 0;
15547
+ return isObject2(input.payload) ? input.payload : void 0;
14952
15548
  }
14953
15549
  function dayOf2(payload) {
14954
- const period = asString(payload?.period);
15550
+ const period = asString2(payload?.period);
14955
15551
  if (period === void 0) return NOT_STATED;
14956
15552
  const colon = period.indexOf(":");
14957
15553
  return colon === -1 ? period : period.slice(colon + 1);
14958
15554
  }
14959
15555
  function sealedTier(payload) {
14960
- const type = asString(payload?.epistemic_type);
15556
+ const type = asString2(payload?.epistemic_type);
14961
15557
  if (type === "semantic_judgment") return "judged";
14962
15558
  if (type === "recomputed_determination") return "recomputed";
14963
15559
  return "not stated";
@@ -15039,10 +15635,10 @@ path.cv-tl-good{fill:var(--person)}path.cv-tl-bad{fill:var(--bad)}path.cv-tl-ope
15039
15635
  continue;
15040
15636
  }
15041
15637
  const payload = reportPayload2(result.records, claim);
15042
- const rationale = asString(payload?.rationale);
15043
- const contract = claim.contractRef || asString(payload?.contract_ref) || asString(payload?.contract);
15044
- const judgePinDigest = asString(payload?.judge_pin_digest);
15045
- const source = asString(payload?.source_capsule_id);
15638
+ const rationale = asString2(payload?.rationale);
15639
+ const contract = claim.contractRef || asString2(payload?.contract_ref) || asString2(payload?.contract);
15640
+ const judgePinDigest = asString2(payload?.judge_pin_digest);
15641
+ const source = asString2(payload?.source_capsule_id);
15046
15642
  if (source !== void 0) sources.add(source);
15047
15643
  if (judgedDay === NOT_STATED)
15048
15644
  judgedDay = reportSealedDay(result.records, claim) ?? dayOf2(payload);
@@ -15104,7 +15700,7 @@ path.cv-tl-good{fill:var(--person)}path.cv-tl-bad{fill:var(--bad)}path.cv-tl-ope
15104
15700
  const texts = /* @__PURE__ */ new Set();
15105
15701
  for (const p of claims) {
15106
15702
  if (p.claim.requirementRef !== criterionId) continue;
15107
- const text2 = asString(reportPayload2(result.records, p.claim)?.clause_claim);
15703
+ const text2 = asString2(reportPayload2(result.records, p.claim)?.clause_claim);
15108
15704
  if (text2 !== void 0) texts.add(text2);
15109
15705
  }
15110
15706
  if (texts.size === 1) return { text: [...texts][0], source: "sealed" };
@@ -16022,15 +16618,15 @@ ${s} .check .steps{margin:12px 0 0;padding-left:20px;font-size:14px;line-height:
16022
16618
  }
16023
16619
  function builtCommit() {
16024
16620
  if (false) return void 0;
16025
- return commitPrefix("7852ee1bf564b9eb2d32cfad8dcc1c7bcb315ae2");
16621
+ return commitPrefix("98259af6a7644e3e924da7cf170677598ca16670");
16026
16622
  }
16027
16623
  var commit = builtCommit();
16028
16624
  var unreleased = false;
16029
16625
  var VIEWER_BUILD = {
16030
16626
  viewer: "@action-state-group/capsule-viewer",
16031
- viewerVersion: "0.8.0",
16627
+ viewerVersion: "0.9.0",
16032
16628
  verifier: "@action-state-group/agent-action-capsule",
16033
- verifierVersion: "0.10.0",
16629
+ verifierVersion: "0.13.0",
16034
16630
  cllVersion: "0.3.0",
16035
16631
  ...commit === void 0 ? {} : { commit },
16036
16632
  ...unreleased ? { unreleased: true } : {}
@@ -16092,12 +16688,12 @@ ${s} .check .steps{margin:12px 0 0;padding-left:20px;font-size:14px;line-height:
16092
16688
  "module_sha256",
16093
16689
  "bundle"
16094
16690
  ]);
16095
- var isObject2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
16691
+ var isObject3 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
16096
16692
  function checkPresentationFragment(value) {
16097
16693
  const fail2 = (why) => {
16098
16694
  throw new FragmentDecodeError(`presentation fragment: ${why}`);
16099
16695
  };
16100
- if (!isObject2(value)) fail2("not a JSON object");
16696
+ if (!isObject3(value)) fail2("not a JSON object");
16101
16697
  const v = value;
16102
16698
  for (const key of Object.keys(v))
16103
16699
  if (!FRAGMENT_MEMBERS.has(key))
@@ -16116,12 +16712,12 @@ ${s} .check .steps{margin:12px 0 0;padding-left:20px;font-size:14px;line-height:
16116
16712
  fail2("theme_css is not a string");
16117
16713
  if (v.wording !== void 0) {
16118
16714
  const w = v.wording;
16119
- if (!isObject2(w) || Object.keys(w).some((k) => k !== "pack" && k !== "sha256") || typeof w.pack !== "string" || !isHex64(w.sha256))
16715
+ if (!isObject3(w) || Object.keys(w).some((k) => k !== "pack" && k !== "sha256") || typeof w.pack !== "string" || !isHex64(w.sha256))
16120
16716
  fail2("wording is not {pack, sha256}");
16121
16717
  }
16122
16718
  if (v.contract !== void 0) {
16123
16719
  const c = v.contract;
16124
- if (!isObject2(c) || Object.keys(c).some((k) => k !== "text" && k !== "sha256") || typeof c.text !== "string" || !isHex64(c.sha256))
16720
+ if (!isObject3(c) || Object.keys(c).some((k) => k !== "text" && k !== "sha256") || typeof c.text !== "string" || !isHex64(c.sha256))
16125
16721
  fail2("contract is not {text, sha256}");
16126
16722
  }
16127
16723
  if (!isHex64(v.core_runtime_sha256))
@@ -16301,13 +16897,19 @@ ${s} .check .steps{margin:12px 0 0;padding-left:20px;font-size:14px;line-height:
16301
16897
  "lines.cal.sealed": "sealed {span}",
16302
16898
  "lines.cal.policy-changed": "policy changed",
16303
16899
  "lines.hc.h": "Human spot checks",
16304
- "lines.hc.lede": "Re-grades by a person, as this bundle's re-grade records state them.",
16900
+ "lines.hc.lede": "Re-grades by a person, as this bundle's calibration summary states them, clause by clause.",
16305
16901
  "lines.hc.none": "No human re-grade records in this bundle.",
16306
- "lines.hc.col.week": "Week",
16902
+ "lines.hc.not-matching": "A calibration summary is cited but does not match its schema (for example, a count larger than its total), so none of it is read.",
16903
+ "lines.hc.ambiguous": "A calibration claim cites more than one summary, so none of them is read.",
16904
+ "lines.hc.col.clause": "Clause",
16307
16905
  "lines.hc.col.agreed": "Agreed",
16308
- "lines.hc.col.held": "Held",
16309
- "lines.hc.col.added": "Added",
16906
+ "lines.hc.col.drift": "Drift",
16907
+ "lines.hc.col.recount": "Recount from the ratings",
16310
16908
  "lines.hc.agreed": "{k} of {n}",
16909
+ "lines.hc.drift": "{k} of {n}",
16910
+ "lines.hc.recount.matches": "matches the stated count",
16911
+ "lines.hc.recount.mismatch": "does not match the stated count",
16912
+ "lines.hc.recount.not_recomputable": "not recounted here: the ratings are missing, or not tied to a judged term",
16311
16913
  "lines.terms.h": "The terms: what counts as resolved",
16312
16914
  "lines.terms.lede": 'Every term below is read from the sealed claims and reports in this bundle, or marked "not stated".',
16313
16915
  "lines.terms.lede.agreed": 'Every term below is read from the sealed claims and reports in this bundle, or marked "not stated". Agreed with the counterparty: {agreement}.',
@@ -16522,6 +17124,8 @@ ${s} .check .steps{margin:12px 0 0;padding-left:20px;font-size:14px;line-height:
16522
17124
  "requirement_tier.unstated": "Tier not stated",
16523
17125
  "card.pf.assurance": "Assurance (as sealed on the claim)",
16524
17126
  "card.pf.assurance.line": "tier {tier} \xB7 grade {grade} \xB7 sufficiency {sufficiency} \xB7 carrier status {status}",
17127
+ "card.mark.withheld": "Withheld by the holder",
17128
+ "card.mark.withheld.cited": "Withheld by the holder \xB7 cites {digests}",
16525
17129
  "card.wording.refused": "The wording pack supplied with this page was refused, so this card is drawn with the viewer's built-in words only.",
16526
17130
  "card.pf.wording.refused": "a wording pack supplied with the page (wording_sha256 {sha256}) was refused: {reason}. Only the built-in {baseId} (wording_sha256 {baseSha256}) was applied.",
16527
17131
  "card.wording.refused.digest": "its bytes do not hash to its wording_sha256",
@@ -17109,6 +17713,8 @@ ${s} .check .steps{margin:12px 0 0;padding-left:20px;font-size:14px;line-height:
17109
17713
  "requirement_tier.unstated": "Tier not stated",
17110
17714
  "card.pf.assurance": "Assurance (as sealed on the claim)",
17111
17715
  "card.pf.assurance.line": "tier {tier} \xB7 grade {grade} \xB7 sufficiency {sufficiency} \xB7 carrier status {status}",
17716
+ "card.mark.withheld": "Withheld by the holder",
17717
+ "card.mark.withheld.cited": "Withheld by the holder \xB7 cites {digests}",
17112
17718
  "card.wording.refused": "The wording pack supplied with this page was refused, so this card is drawn with the viewer's built-in words only.",
17113
17719
  "card.pf.wording.refused": "a wording pack supplied with the page (wording_sha256 {sha256}) was refused: {reason}. Only the built-in {baseId} (wording_sha256 {baseSha256}) was applied.",
17114
17720
  "card.wording.refused.digest": "its bytes do not hash to its wording_sha256",
@@ -17746,6 +18352,10 @@ ${s} .check .steps{margin:12px 0 0;padding-left:20px;font-size:14px;line-height:
17746
18352
  // aggregate counts informational rows the derived lines leave out: a
17747
18353
  // pack cannot make an informational row read as must-have.
17748
18354
  ...SECTION3_ENUMS.requirement_tier.map((v) => `requirement_tier.${v}`),
18355
+ // The red mark on a WITHHELD claim says the holder withheld it and nothing
18356
+ // more: a pack cannot hint at what is behind it.
18357
+ "card.mark.withheld",
18358
+ "card.mark.withheld.cited",
17749
18359
  "lines.rtier.unstated.note",
17750
18360
  "groups.rtier.unstated.note",
17751
18361
  "lines.rtier.sealed-note",
@@ -18034,6 +18644,11 @@ ${s} .check .steps{margin:12px 0 0;padding-left:20px;font-size:14px;line-height:
18034
18644
  "prov.brief.verifier.stated",
18035
18645
  "prov.brief.verifier.not-stated",
18036
18646
  "lines.hc.none",
18647
+ "lines.hc.not-matching",
18648
+ "lines.hc.ambiguous",
18649
+ "lines.hc.recount.matches",
18650
+ "lines.hc.recount.mismatch",
18651
+ "lines.hc.recount.not_recomputable",
18037
18652
  "lines.terms.lede",
18038
18653
  "lines.terms.lede.agreed",
18039
18654
  "lines.terms.version.value",
@@ -18326,8 +18941,8 @@ ${key}`);
18326
18941
  return problems.map((p) => `${pack.id}: ${p}`);
18327
18942
  }
18328
18943
  var DEFAULT_PACK_SHA256 = Object.freeze({
18329
- lines: "047b4938c07e05a7d122246e0e80a11b9db2fc65edf02286e8f49f4bc618ac6c",
18330
- groups: "3d269d31a57915293bb7f81cefb93b450e845aa07be26bd9a7e203defd560784"
18944
+ lines: "b6a94ccd2fb2b1ee6675a031e9ef55ca7143a61ed1f5c5518d3c5a28ab3ed849",
18945
+ groups: "90ded4f81aed5f5335cd85d71a930f6af31571d19eeb07e50f710d415420a768"
18331
18946
  });
18332
18947
  function fill(key, text2, vars) {
18333
18948
  return text2.replace(PLACEHOLDER, (whole, name) => {
@@ -18415,22 +19030,22 @@ ${key}`);
18415
19030
  if (record === void 0) return void 0;
18416
19031
  const input = record.carriedInput ?? record.agentInput;
18417
19032
  if (input.state !== "disclosed") return void 0;
18418
- return isObject(input.payload) ? input.payload : void 0;
19033
+ return isObject2(input.payload) ? input.payload : void 0;
18419
19034
  }
18420
19035
  function pinComponents2(value) {
18421
- if (!isObject(value)) return void 0;
18422
- const modelId = asString(value.model_id);
18423
- const promptDigest = asString(value.prompt_digest);
18424
- const axesDigest = asString(value.axes_digest);
19036
+ if (!isObject2(value)) return void 0;
19037
+ const modelId = asString2(value.model_id);
19038
+ const promptDigest = asString2(value.prompt_digest);
19039
+ const axesDigest = asString2(value.axes_digest);
18425
19040
  if (modelId === void 0 || promptDigest === void 0 || axesDigest === void 0)
18426
19041
  return void 0;
18427
- const modelVersion = asString(value.model_version);
19042
+ const modelVersion = asString2(value.model_version);
18428
19043
  return {
18429
19044
  modelId,
18430
19045
  ...modelVersion === void 0 ? {} : { modelVersion },
18431
19046
  promptDigest,
18432
19047
  axesDigest,
18433
- ...isObject(value.sampling_params) ? { samplingParams: value.sampling_params } : {}
19048
+ ...isObject2(value.sampling_params) ? { samplingParams: value.sampling_params } : {}
18434
19049
  };
18435
19050
  }
18436
19051
  async function tallyJudges(records, claims) {
@@ -18459,14 +19074,14 @@ ${key}`);
18459
19074
  continue;
18460
19075
  }
18461
19076
  const payload = reportPayload3(records, claim);
18462
- if (asString(payload?.epistemic_type) === "recomputed_determination") {
18463
- const checker = asString(payload?.checker_ref);
19077
+ if (asString2(payload?.epistemic_type) === "recomputed_determination") {
19078
+ const checker = asString2(payload?.checker_ref);
18464
19079
  if (checker !== void 0)
18465
19080
  checkers.set(checker, (checkers.get(checker) ?? 0) + 1);
18466
19081
  else recomputedUnnamed += 1;
18467
19082
  continue;
18468
19083
  }
18469
- const digest = asString(payload?.judge_pin_digest);
19084
+ const digest = asString2(payload?.judge_pin_digest);
18470
19085
  if (digest !== void 0) {
18471
19086
  const entry = pins.get(digest) ?? {
18472
19087
  count: 0,
@@ -18523,8 +19138,8 @@ ${key}`);
18523
19138
  }
18524
19139
  var fmt2 = (n) => n.toLocaleString();
18525
19140
  var quoted = (value) => JSON.stringify(value.length > 120 ? `${value.slice(0, 120)}\u2026` : value);
18526
- var HEX_DIGEST = /^[0-9a-f]+$/iu;
18527
- var short = (digest) => HEX_DIGEST.test(digest) ? digest.length > 12 ? `${digest.slice(0, 12)}\u2026` : digest : quoted(digest);
19141
+ var HEX_DIGEST2 = /^[0-9a-f]+$/iu;
19142
+ var short = (digest) => HEX_DIGEST2.test(digest) ? digest.length > 12 ? `${digest.slice(0, 12)}\u2026` : digest : quoted(digest);
18528
19143
  function judgedByMock(tally) {
18529
19144
  return tally.pins.some(
18530
19145
  (pin) => pin.model !== void 0 && /\bmock\b/i.test(pin.model)
@@ -18611,10 +19226,10 @@ ${key}`);
18611
19226
  "tree_size"
18612
19227
  ];
18613
19228
  function isReceipt(value) {
18614
- return isObject(value) && typeof value.ts_url === "string" && RECEIPT_FIELDS.every((name) => Object.hasOwn(value, name));
19229
+ return isObject2(value) && typeof value.ts_url === "string" && RECEIPT_FIELDS.every((name) => Object.hasOwn(value, name));
18615
19230
  }
18616
19231
  function witnessEntries(checkpoint) {
18617
- if (!isObject(checkpoint) || !Array.isArray(checkpoint.witnesses)) return [];
19232
+ if (!isObject2(checkpoint) || !Array.isArray(checkpoint.witnesses)) return [];
18618
19233
  return checkpoint.witnesses.map((w) => {
18619
19234
  if (!isReceipt(w)) return { stub: false, malformed: true };
18620
19235
  if (w.is_stub === true) return { stub: true, malformed: false };
@@ -18636,7 +19251,7 @@ ${key}`);
18636
19251
  function witnessStatus(bundle, verified) {
18637
19252
  const aac = verified.strict?.witnesses ?? void 0;
18638
19253
  if (aac?.status === "fail") return "invalid";
18639
- const checkpoint = isObject(bundle) ? bundle.checkpoint : void 0;
19254
+ const checkpoint = isObject2(bundle) ? bundle.checkpoint : void 0;
18640
19255
  const entries = checkedWitnessEntries(witnessEntries(checkpoint), aac);
18641
19256
  if (entries.length === 0) return "absent";
18642
19257
  return entries.some((e) => e.passed) ? "verified" : "not-checked";
@@ -18651,9 +19266,9 @@ ${key}`);
18651
19266
  return verified.strict === void 0 ? "witness-unreported" : "not-witnessed";
18652
19267
  }
18653
19268
  function witnessLine(bundle, verified, w = DEFAULT_WORDS.lines) {
18654
- const checkpoint = isObject(bundle) ? bundle.checkpoint : void 0;
19269
+ const checkpoint = isObject2(bundle) ? bundle.checkpoint : void 0;
18655
19270
  const page = buildVerificationPageModel(bundle, verified);
18656
- const logId = isObject(checkpoint) ? asString(checkpoint.log_id) : void 0;
19271
+ const logId = isObject2(checkpoint) ? asString2(checkpoint.log_id) : void 0;
18657
19272
  const facts = [];
18658
19273
  if (logId !== void 0)
18659
19274
  facts.push(w.t("prov.witness.log", { log: quoted(logId) }));
@@ -18667,7 +19282,7 @@ ${key}`);
18667
19282
  ].some((claim) => claim.findings.includes("checkpoint_unverified"));
18668
19283
  const about = facts.length === 0 ? [] : [
18669
19284
  w.t(
18670
- isObject(checkpoint) && typeof checkpoint.cose === "string" ? unchecked ? "prov.witness.about.unchecked" : "prov.witness.about" : "prov.witness.about.unsigned",
19285
+ isObject2(checkpoint) && typeof checkpoint.cose === "string" ? unchecked ? "prov.witness.about.unchecked" : "prov.witness.about" : "prov.witness.about.unsigned",
18671
19286
  { facts: facts.join(", ") }
18672
19287
  )
18673
19288
  ];
@@ -18767,9 +19382,9 @@ ${key}`);
18767
19382
  ...build.cllVersion === void 0 ? {} : { cll: build.cllVersion }
18768
19383
  }
18769
19384
  );
18770
- const report = isObject(bundle) && isObject(bundle.verification) ? bundle.verification : void 0;
18771
- const producer = asString(report?.producer);
18772
- const version = asString(report?.version) ?? asString(report?.producer_version);
19385
+ const report = isObject2(bundle) && isObject2(bundle.verification) ? bundle.verification : void 0;
19386
+ const producer = asString2(report?.producer);
19387
+ const version = asString2(report?.version) ?? asString2(report?.producer_version);
18773
19388
  const built = producer === void 0 ? w.t("prov.verifier.built.not-stated") : w.t("prov.verifier.built", {
18774
19389
  producer: quoted(producer),
18775
19390
  version: version === void 0 ? w.t("prov.verifier.version.not-stated") : w.t("prov.verifier.version", { version: quoted(version) })
@@ -19069,7 +19684,7 @@ ${key}`);
19069
19684
  this.name = "ContractError";
19070
19685
  }
19071
19686
  };
19072
- var isObject3 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
19687
+ var isObject4 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
19073
19688
  async function checkContractInput(contract) {
19074
19689
  if (!/^[0-9a-f]{64}$/u.test(contract.sha256))
19075
19690
  throw new ContractError("contract sha256 is not a lowercase hex SHA-256");
@@ -19089,7 +19704,7 @@ ${key}`);
19089
19704
  `contract is not a compiled Evidence Contract: ${why}`
19090
19705
  );
19091
19706
  };
19092
- if (!isObject3(parsed)) return bad2("not a JSON object");
19707
+ if (!isObject4(parsed)) return bad2("not a JSON object");
19093
19708
  const { id, version, requirements } = parsed;
19094
19709
  if (typeof id !== "string" || id === "")
19095
19710
  return bad2("id is not a non-empty string");
@@ -19098,7 +19713,7 @@ ${key}`);
19098
19713
  if (!Array.isArray(requirements)) return bad2("requirements is not a list");
19099
19714
  const tiers = /* @__PURE__ */ new Map();
19100
19715
  requirements.forEach((requirement, i) => {
19101
- if (!isObject3(requirement))
19716
+ if (!isObject4(requirement))
19102
19717
  return bad2(`requirement ${i + 1} is not an object`);
19103
19718
  const rid = requirement.id;
19104
19719
  if (typeof rid !== "string" || rid === "")
@@ -19720,6 +20335,8 @@ ${key}`);
19720
20335
  const cell2 = element3("td", text2);
19721
20336
  for (const [key, value] of Object.entries(data))
19722
20337
  cell2.dataset[key] = value;
20338
+ const mark = withheldMark(criterion2.claim, w);
20339
+ if (mark !== void 0) cell2.append(el8("br", ""), mark);
19723
20340
  tr.append(cell2);
19724
20341
  }
19725
20342
  tbody.append(tr);
@@ -20426,48 +21043,65 @@ ${key}`);
20426
21043
  host.append(section);
20427
21044
  return;
20428
21045
  }
20429
- const table3 = document.createElement("table");
20430
- table3.className = "hct";
20431
- table3.dataset.weeks = String(calibration.length);
20432
- const thead = document.createElement("thead");
20433
- const headRow = document.createElement("tr");
20434
- headRow.append(
20435
- element3("th", w.t("lines.hc.col.week")),
20436
- el8("th", "n", w.t("lines.hc.col.agreed")),
20437
- el8("th", "n", w.t("lines.hc.col.held")),
20438
- el8("th", "n", w.t("lines.hc.col.added"))
20439
- );
20440
- thead.append(headRow);
20441
- table3.append(thead);
20442
- const tbody = document.createElement("tbody");
20443
- for (const week of calibration) {
20444
- const tr = document.createElement("tr");
20445
- tr.dataset.week = week.weekId;
20446
- tr.dataset.k = String(week.k);
20447
- tr.dataset.n = String(week.n);
20448
- tr.append(el8("td", "", week.weekId));
20449
- tr.append(
20450
- el8(
20451
- "td",
20452
- "n",
20453
- w.t("lines.hc.agreed", { k: String(week.k), n: String(week.n) })
20454
- )
21046
+ for (const reading of calibration) {
21047
+ if (reading.state !== "read") {
21048
+ const note = el8(
21049
+ "p",
21050
+ "",
21051
+ w.t(
21052
+ reading.state === "ambiguous" ? "lines.hc.ambiguous" : "lines.hc.not-matching"
21053
+ )
21054
+ );
21055
+ note.dataset.calibration = reading.state;
21056
+ section.append(note);
21057
+ continue;
21058
+ }
21059
+ const table3 = document.createElement("table");
21060
+ table3.className = "hct";
21061
+ table3.dataset.calibration = "read";
21062
+ table3.dataset.clauses = String(reading.clauses.length);
21063
+ const thead = document.createElement("thead");
21064
+ const headRow = document.createElement("tr");
21065
+ headRow.append(
21066
+ element3("th", w.t("lines.hc.col.clause")),
21067
+ el8("th", "n", w.t("lines.hc.col.agreed")),
21068
+ el8("th", "n", w.t("lines.hc.col.drift")),
21069
+ element3("th", w.t("lines.hc.col.recount"))
20455
21070
  );
20456
- const held = week.sample.filter(
20457
- (s) => s.aiVerdict === "met" && s.humanVerdict !== "met"
20458
- ).length;
20459
- const added = week.sample.filter(
20460
- (s) => s.aiVerdict !== "met" && s.humanVerdict === "met"
20461
- ).length;
20462
- const heldCell = el8("td", "n", String(held));
20463
- heldCell.dataset.held = String(held);
20464
- const addedCell = el8("td", "n", String(added));
20465
- addedCell.dataset.added = String(added);
20466
- tr.append(heldCell, addedCell);
20467
- tbody.append(tr);
21071
+ thead.append(headRow);
21072
+ table3.append(thead);
21073
+ const tbody = document.createElement("tbody");
21074
+ for (const clause of reading.clauses) {
21075
+ const tr = document.createElement("tr");
21076
+ tr.dataset.clause = clause.clauseRef;
21077
+ tr.dataset.k = String(clause.agreement.k);
21078
+ tr.dataset.n = String(clause.agreement.n);
21079
+ tr.dataset.agreementCheck = clause.agreementCheck;
21080
+ tr.append(
21081
+ el8("td", "", clause.clauseRef),
21082
+ el8(
21083
+ "td",
21084
+ "n",
21085
+ w.t("lines.hc.agreed", {
21086
+ k: String(clause.agreement.k),
21087
+ n: String(clause.agreement.n)
21088
+ })
21089
+ ),
21090
+ el8(
21091
+ "td",
21092
+ "n",
21093
+ w.t("lines.hc.drift", {
21094
+ k: String(clause.drift.k),
21095
+ n: String(clause.drift.n)
21096
+ })
21097
+ ),
21098
+ el8("td", "", w.t(`lines.hc.recount.${clause.agreementCheck}`))
21099
+ );
21100
+ tbody.append(tr);
21101
+ }
21102
+ table3.append(tbody);
21103
+ section.append(table3);
20468
21104
  }
20469
- table3.append(tbody);
20470
- section.append(table3);
20471
21105
  host.append(section);
20472
21106
  }
20473
21107
  function renderTerms(host, model, w) {
@@ -21558,8 +22192,11 @@ ${key}`);
21558
22192
  if (test.reportDigest === void 0)
21559
22193
  ev.append(element4("span", w.t("groups.pf.absent")));
21560
22194
  }
21561
- if (test.claim !== void 0)
22195
+ if (test.claim !== void 0) {
21562
22196
  ev.append(proofList([assuranceRow(test.claim, w)]));
22197
+ const mark = withheldMark(test.claim, w);
22198
+ if (mark !== void 0) ev.append(mark);
22199
+ }
21563
22200
  box.append(ev);
21564
22201
  }
21565
22202
  return box;
@@ -21824,7 +22461,7 @@ ${key}`);
21824
22461
  }
21825
22462
 
21826
22463
  // src/outcome-report-presentation.ts
21827
- function object9(value) {
22464
+ function object10(value) {
21828
22465
  return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
21829
22466
  }
21830
22467
  var CRITERION_REF = /^[a-z0-9_]+\.[a-z0-9_]+$/u;
@@ -21836,7 +22473,7 @@ ${key}`);
21836
22473
  return typeof value === "string" && value.trim().length > 0 && value.length <= max ? value : void 0;
21837
22474
  }
21838
22475
  function readProducerNote(value) {
21839
- const note = object9(value);
22476
+ const note = object10(value);
21840
22477
  if (note === void 0 || !Array.isArray(note.lines)) return void 0;
21841
22478
  const raw = note.lines;
21842
22479
  if (raw.length === 0 || raw.length > MAX_NOTE_LINES) return void 0;
@@ -21851,7 +22488,7 @@ ${key}`);
21851
22488
  if (!Array.isArray(value)) return void 0;
21852
22489
  const entries = value;
21853
22490
  const edited = entries.flatMap((entry) => {
21854
- const item = object9(entry);
22491
+ const item = object10(entry);
21855
22492
  const criterion2 = typeof item?.criterion === "string" && CRITERION_REF.test(item.criterion) ? item.criterion : void 0;
21856
22493
  const badge = text(item?.badge, MAX_BADGE);
21857
22494
  return criterion2 === void 0 || badge === void 0 ? [] : [{ criterion: criterion2, badge }];
@@ -21859,9 +22496,9 @@ ${key}`);
21859
22496
  return edited.length === 0 ? void 0 : edited;
21860
22497
  }
21861
22498
  function readOutcomeReportPresentation(bundle) {
21862
- const top = object9(bundle);
21863
- const extensions2 = object9(top?.extensions);
21864
- const block = object9(extensions2?.["outcome-report/v1"]);
22499
+ const top = object10(bundle);
22500
+ const extensions2 = object10(top?.extensions);
22501
+ const block = object10(extensions2?.["outcome-report/v1"]);
21865
22502
  if (block === void 0 || block.enabled !== true) return void 0;
21866
22503
  const percentages = block.percentages === true;
21867
22504
  const producerNote = readProducerNote(block.producer_note);
@@ -22101,7 +22738,7 @@ ${key}`);
22101
22738
  };
22102
22739
 
22103
22740
  // src/record-page.ts
22104
- var object10 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
22741
+ var object11 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
22105
22742
  var HEX = /^[0-9a-f]+$/u;
22106
22743
  var ANY_HEX = /^[0-9a-fA-F]+$/u;
22107
22744
  function shortHex(value) {
@@ -22170,8 +22807,8 @@ ${key}`);
22170
22807
  const outer = readCbor(bytes, at);
22171
22808
  if (at.i !== bytes.length) return void 0;
22172
22809
  if (!Array.isArray(outer) || outer.length !== 4) return void 0;
22173
- const [protectedBytes, unprotected, payload, signature] = outer;
22174
- if (!(protectedBytes instanceof Uint8Array) || !(unprotected instanceof Map) || !(signature instanceof Uint8Array))
22810
+ const [protectedBytes, unprotected, payload, signature2] = outer;
22811
+ if (!(protectedBytes instanceof Uint8Array) || !(unprotected instanceof Map) || !(signature2 instanceof Uint8Array))
22175
22812
  return void 0;
22176
22813
  const headers = readCbor(protectedBytes, { i: 0 });
22177
22814
  if (!(headers instanceof Map)) return void 0;
@@ -22188,7 +22825,7 @@ ${key}`);
22188
22825
  ...kid instanceof Uint8Array ? { kid: toHex3(kid) } : {},
22189
22826
  unprotectedEntries: unprotected.size,
22190
22827
  ...payload instanceof Uint8Array ? { payloadHex: toHex3(payload) } : {},
22191
- signatureBytes: signature.length,
22828
+ signatureBytes: signature2.length,
22192
22829
  tagged
22193
22830
  };
22194
22831
  }
@@ -22219,13 +22856,13 @@ ${key}`);
22219
22856
  const items = value.map((v) => show(v, depth + 1));
22220
22857
  return depth > 0 ? `[${items.join(", ")}]` : items.join(" \xB7 ");
22221
22858
  }
22222
- const entries = Object.entries(object10(value)).sort(
22859
+ const entries = Object.entries(object11(value)).sort(
22223
22860
  ([a], [b]) => a < b ? -1 : a > b ? 1 : 0
22224
22861
  );
22225
22862
  if (depth > 1) return `{${entries.length} members}`;
22226
22863
  return entries.map(([k, v]) => `${k} ${show(v, depth + 1)}`).join(" \xB7 ");
22227
22864
  }
22228
- var hasDigest = (value) => Object.entries(object10(value)).some(
22865
+ var hasDigest = (value) => Object.entries(object11(value)).some(
22229
22866
  ([k, v]) => k.endsWith("_digest") || hasDigest(v)
22230
22867
  );
22231
22868
  function tagsOf(members, record) {
@@ -22264,7 +22901,7 @@ ${key}`);
22264
22901
  var REF_TYPE = "agent-action-capsule";
22265
22902
  function ladder(input, w) {
22266
22903
  const { context, capsuleId } = input;
22267
- const raw = object10(context.recordIndex.get(capsuleId));
22904
+ const raw = object11(context.recordIndex.get(capsuleId));
22268
22905
  const strict2 = context.strict?.records.find((r) => r.capsuleId === capsuleId);
22269
22906
  const t = (key, vars) => w.t(key, vars);
22270
22907
  const rungs = [];
@@ -22308,7 +22945,7 @@ ${key}`);
22308
22945
  strict2 === void 0 && envelope ? t("record.rung.3.unchecked") : void 0,
22309
22946
  t("record.rung.3.sub")
22310
22947
  );
22311
- const chain = object10(raw.chain);
22948
+ const chain = object11(raw.chain);
22312
22949
  const parent2 = typeof chain.parent_capsule_id === "string" ? chain.parent_capsule_id : void 0;
22313
22950
  add2(
22314
22951
  4,
@@ -22365,10 +23002,10 @@ ${key}`);
22365
23002
  t("record.rung.8.sub")
22366
23003
  );
22367
23004
  const refs = (Array.isArray(raw.references) ? raw.references : []).filter(
22368
- (r) => object10(r).type === REF_TYPE && typeof object10(r).digest === "string"
23005
+ (r) => object11(r).type === REF_TYPE && typeof object11(r).digest === "string"
22369
23006
  );
22370
23007
  const here = refs.filter(
22371
- (r) => context.recordIndex.has(object10(r).digest)
23008
+ (r) => context.recordIndex.has(object11(r).digest)
22372
23009
  ).length;
22373
23010
  add2(
22374
23011
  9,
@@ -22414,7 +23051,7 @@ ${key}`);
22414
23051
  function envelopeCard(input, w) {
22415
23052
  const { context, capsuleId } = input;
22416
23053
  const voice = input.voice;
22417
- const raw = object10(context.recordIndex.get(capsuleId));
23054
+ const raw = object11(context.recordIndex.get(capsuleId));
22418
23055
  const card2 = el10("section", "l3-card");
22419
23056
  card2.dataset.l3 = "envelope";
22420
23057
  card2.append(el10("h4", "l3-k", w.t("record.envelope.title")));
@@ -22512,7 +23149,7 @@ ${key}`);
22512
23149
  return w.t(`record.tag.${tag}`);
22513
23150
  }
22514
23151
  function capsuleCard(input, w) {
22515
- const raw = object10(input.context.recordIndex.get(input.capsuleId));
23152
+ const raw = object11(input.context.recordIndex.get(input.capsuleId));
22516
23153
  const card2 = el10("section", "l3-card");
22517
23154
  card2.dataset.l3 = "capsule";
22518
23155
  card2.append(el10("h4", "l3-k", w.t("record.capsule.title")));
@@ -22589,7 +23226,7 @@ ${key}`);
22589
23226
  return foot;
22590
23227
  }
22591
23228
  function renderRecordPage(input, w) {
22592
- const raw = object10(input.context.recordIndex.get(input.capsuleId));
23229
+ const raw = object11(input.context.recordIndex.get(input.capsuleId));
22593
23230
  const page = el10("div", "cv-l3");
22594
23231
  page.dataset.level = "3";
22595
23232
  page.dataset.recordPage = input.capsuleId;
@@ -22849,7 +23486,7 @@ ${key}`);
22849
23486
  }
22850
23487
 
22851
23488
  // src/record-content.ts
22852
- var isObject4 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
23489
+ var isObject5 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
22853
23490
  function canonicalJson(value, indent) {
22854
23491
  const pad = indent === void 0 ? "" : " ".repeat(indent);
22855
23492
  const write = (v, depth) => {
@@ -22860,7 +23497,7 @@ ${pad.repeat(depth)}`;
22860
23497
  const colon = pad === "" ? ":" : ": ";
22861
23498
  if (Array.isArray(v))
22862
23499
  return v.length === 0 ? "[]" : `[${v.map((item) => open + write(item, depth + 1)).join(",")}${close}]`;
22863
- if (isObject4(v)) {
23500
+ if (isObject5(v)) {
22864
23501
  const keys = Object.keys(v).sort(byCodeUnits);
22865
23502
  return keys.length === 0 ? "{}" : `{${keys.map(
22866
23503
  (key) => `${open}${JSON.stringify(key)}${colon}${write(v[key], depth + 1)}`
@@ -22874,12 +23511,12 @@ ${pad.repeat(depth)}`;
22874
23511
  return a < b ? -1 : a > b ? 1 : 0;
22875
23512
  }
22876
23513
  function conversationTurns(content) {
22877
- if (!isObject4(content)) return void 0;
22878
- const interaction = isObject4(content.agent_interaction) ? content.agent_interaction : void 0;
23514
+ if (!isObject5(content)) return void 0;
23515
+ const interaction = isObject5(content.agent_interaction) ? content.agent_interaction : void 0;
22879
23516
  if (interaction === void 0 || !Array.isArray(interaction.messages))
22880
23517
  return void 0;
22881
23518
  return interaction.messages.flatMap((m) => {
22882
- if (!isObject4(m)) return [];
23519
+ if (!isObject5(m)) return [];
22883
23520
  const role = typeof m.role === "string" ? m.role : "unknown";
22884
23521
  const text2 = typeof m.content === "string" ? m.content : void 0;
22885
23522
  const calls = Array.isArray(m.tool_calls) ? m.tool_calls : [];
@@ -22888,7 +23525,7 @@ ${pad.repeat(depth)}`;
22888
23525
  role,
22889
23526
  ...text2 === void 0 ? {} : { content: text2 },
22890
23527
  toolCalls: calls.flatMap(
22891
- (call) => isObject4(call) ? [
23528
+ (call) => isObject5(call) ? [
22892
23529
  {
22893
23530
  name: typeof call.name === "string" ? call.name : "unnamed",
22894
23531
  // Re-serialised as there, but in canonical member order,
@@ -22954,7 +23591,7 @@ ${pad.repeat(depth)}`;
22954
23591
  `;
22955
23592
 
22956
23593
  // src/compliance-presentation.ts
22957
- function object11(value) {
23594
+ function object12(value) {
22958
23595
  return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
22959
23596
  }
22960
23597
  function str2(value) {
@@ -22964,7 +23601,7 @@ ${pad.repeat(depth)}`;
22964
23601
  return Array.isArray(value) ? value.filter((v) => typeof v === "string") : [];
22965
23602
  }
22966
23603
  function readFinding(value) {
22967
- const obj = object11(value);
23604
+ const obj = object12(value);
22968
23605
  const id = str2(obj?.id);
22969
23606
  const severity = str2(obj?.severity);
22970
23607
  const recommendation = str2(obj?.recommendation);
@@ -22974,7 +23611,7 @@ ${pad.repeat(depth)}`;
22974
23611
  return { id, severity, recommendation, ownerDue };
22975
23612
  }
22976
23613
  function readRow(value) {
22977
- const obj = object11(value);
23614
+ const obj = object12(value);
22978
23615
  const criterionId = str2(obj?.criterion_id);
22979
23616
  const name = str2(obj?.name);
22980
23617
  if (criterionId === void 0 || name === void 0) return void 0;
@@ -22988,14 +23625,14 @@ ${pad.repeat(depth)}`;
22988
23625
  };
22989
23626
  }
22990
23627
  function readApplicability(value) {
22991
- const obj = object11(value);
23628
+ const obj = object12(value);
22992
23629
  const status2 = obj?.status === "in_force" || obj?.status === "future" ? obj.status : void 0;
22993
23630
  const note = str2(obj?.note);
22994
23631
  if (status2 === void 0 || note === void 0) return void 0;
22995
23632
  return { status: status2, note };
22996
23633
  }
22997
23634
  function readObligation(value) {
22998
- const obj = object11(value);
23635
+ const obj = object12(value);
22999
23636
  const key = str2(obj?.key);
23000
23637
  const article = str2(obj?.article);
23001
23638
  const title = str2(obj?.title);
@@ -23020,7 +23657,7 @@ ${pad.repeat(depth)}`;
23020
23657
  };
23021
23658
  }
23022
23659
  function readQualityProtocol(value) {
23023
- const obj = object11(value);
23660
+ const obj = object12(value);
23024
23661
  if (obj === void 0) return void 0;
23025
23662
  const protocol = str2(obj.protocol);
23026
23663
  const cadence = str2(obj.cadence);
@@ -23034,9 +23671,9 @@ ${pad.repeat(depth)}`;
23034
23671
  };
23035
23672
  }
23036
23673
  function readCompliancePresentation(bundle) {
23037
- const top = object11(bundle);
23038
- const extensions2 = object11(top?.extensions);
23039
- const block = object11(extensions2?.["eu-ai-act-compliance/v1"]);
23674
+ const top = object12(bundle);
23675
+ const extensions2 = object12(top?.extensions);
23676
+ const block = object12(extensions2?.["eu-ai-act-compliance/v1"]);
23040
23677
  if (block === void 0 || block.enabled !== true) return void 0;
23041
23678
  const regulation = str2(block.regulation) ?? "Regulation (EU) 2024/1689";
23042
23679
  const obligations = Array.isArray(block.obligations) ? block.obligations.flatMap((o) => {
@@ -23800,16 +24437,16 @@ ${pad.repeat(depth)}`;
23800
24437
  const id = record.bookRecordId ?? record.capsuleId;
23801
24438
  if (!read.has(id)) read.set(id, record);
23802
24439
  }
23803
- const bundle = object12(context.bundle);
24440
+ const bundle = object13(context.bundle);
23804
24441
  const memberships2 = context.completeness.memberships;
23805
- const extensions2 = object12(bundle.extensions);
23806
- const payloads = object12(extensions2[BOOK_PAYLOADS_EXTENSION]);
23807
- const originals = object12(extensions2[AGENT_INPUT_ORIGINALS_EXTENSION]);
24442
+ const extensions2 = object13(bundle.extensions);
24443
+ const payloads = object13(extensions2[BOOK_PAYLOADS_EXTENSION]);
24444
+ const originals = object13(extensions2[AGENT_INPUT_ORIGINALS_EXTENSION]);
23808
24445
  for (const raw of context.records) {
23809
24446
  const id = raw.capsule_id;
23810
24447
  if (read.has(id)) continue;
23811
24448
  const agentInput = disclosureOf(context, id, "agent_input");
23812
- const header = agentInput.state === "disclosed" && object12(agentInput.payload).record_type === PUBLISHED_CAPSULE_RECORD_TYPE ? agentInput.payload : void 0;
24449
+ const header = agentInput.state === "disclosed" && object13(agentInput.payload).record_type === PUBLISHED_CAPSULE_RECORD_TYPE ? agentInput.payload : void 0;
23813
24450
  const carried = header === void 0 ? void 0 : await carriedCapsuleCommitment(header, payloads);
23814
24451
  const carriedInput = header === void 0 ? void 0 : await resolveCarriedInput(header, payloads, originals);
23815
24452
  const references = Array.isArray(raw.references) ? raw.references : [];
@@ -23830,7 +24467,7 @@ ${pad.repeat(depth)}`;
23830
24467
  carriedInputDigest: carried.inputDigest
23831
24468
  },
23832
24469
  cites: references.flatMap((ref) => {
23833
- const r = object12(ref);
24470
+ const r = object13(ref);
23834
24471
  return r.citation_purpose === "acted_on" && typeof r.digest === "string" ? [r.digest] : [];
23835
24472
  })
23836
24473
  });
@@ -23838,9 +24475,9 @@ ${pad.repeat(depth)}`;
23838
24475
  return read;
23839
24476
  }
23840
24477
  function recordKind(raw, read) {
23841
- const header = read?.agentInput.state === "disclosed" ? object12(read.agentInput.payload).record_type : void 0;
24478
+ const header = read?.agentInput.state === "disclosed" ? object13(read.agentInput.payload).record_type : void 0;
23842
24479
  if (typeof header === "string") return header;
23843
- const own = object12(raw).action_type;
24480
+ const own = object13(raw).action_type;
23844
24481
  return typeof own === "string" ? own : void 0;
23845
24482
  }
23846
24483
  function renderCoverageStatusCounts(records) {
@@ -24049,9 +24686,9 @@ ${pad.repeat(depth)}`;
24049
24686
  }
24050
24687
  const read = bundleVerified(verified) ? await recordEntries(context, result) : /* @__PURE__ */ new Map();
24051
24688
  const rawRecords = /* @__PURE__ */ new Map();
24052
- for (const raw of Array.isArray(object12(bundle).records) ? object12(bundle).records : [])
24053
- if (typeof object12(raw).capsule_id === "string")
24054
- rawRecords.set(object12(raw).capsule_id, raw);
24689
+ for (const raw of Array.isArray(object13(bundle).records) ? object13(bundle).records : [])
24690
+ if (typeof object13(raw).capsule_id === "string")
24691
+ rawRecords.set(object13(raw).capsule_id, raw);
24055
24692
  renderCheckpointCoverage(
24056
24693
  page,
24057
24694
  model.records,
@@ -24113,28 +24750,23 @@ ${pad.repeat(depth)}`;
24113
24750
  section.append(element6("p", "no human-check data"));
24114
24751
  return section;
24115
24752
  }
24753
+ if (!calibration.matchesSchema) {
24754
+ section.append(element6("p", "does not match calibration-summary/v1"));
24755
+ return section;
24756
+ }
24116
24757
  const details = element6("dl");
24117
- appendValue(details, "confusion matrix", calibration.confusion);
24118
- appendCount(details, "agreement", calibration.agreement);
24119
- appendCount(details, "corrected rate", calibration.correctedRate);
24120
- appendValue(details, "period window", calibration.periodWindow);
24758
+ for (const clause of calibration.summary.clauses) {
24759
+ appendCount(details, `${clause.clauseRef} agreement`, clause.agreement);
24760
+ appendCount(details, `${clause.clauseRef} drift`, clause.drift);
24761
+ }
24121
24762
  section.append(details);
24122
24763
  return section;
24123
24764
  }
24124
24765
  function appendCount(parent2, label, count2) {
24125
24766
  parent2.append(element6("dt", label));
24126
- const cell2 = element6("dd");
24127
- if (count2 === void 0) {
24128
- cell2.textContent = "not stated";
24129
- cell2.dataset.count = "not-stated";
24130
- } else if ("rate" in count2) {
24131
- cell2.textContent = "rate given, k and n not stated";
24132
- cell2.dataset.count = "not-stated";
24133
- } else {
24134
- cell2.textContent = `${count2.k} of ${count2.n}`;
24135
- cell2.dataset.k = String(count2.k);
24136
- cell2.dataset.n = String(count2.n);
24137
- }
24767
+ const cell2 = element6("dd", `${count2.k} of ${count2.n}`);
24768
+ cell2.dataset.k = String(count2.k);
24769
+ cell2.dataset.n = String(count2.n);
24138
24770
  parent2.append(cell2);
24139
24771
  }
24140
24772
  function renderProvenance2(capsuleId, coordinates, times) {
@@ -24184,13 +24816,13 @@ ${pad.repeat(depth)}`;
24184
24816
  section.append(renderProvenance2(act.capsuleId, act.logCoordinates, act));
24185
24817
  return section;
24186
24818
  }
24187
- function object12(value) {
24819
+ function object13(value) {
24188
24820
  return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
24189
24821
  }
24190
24822
  function renderWithheldActs(acts, host) {
24191
24823
  for (const act of acts) {
24192
24824
  if (act.agentInput !== void 0 && act.agentOutput !== void 0) continue;
24193
- const committed = object12({
24825
+ const committed = object13({
24194
24826
  agent_input_digest: act.agentInputDigest,
24195
24827
  agent_output_digest: act.agentOutputDigest
24196
24828
  });
@@ -24987,7 +25619,7 @@ ${pad.repeat(depth)}`;
24987
25619
  manifest: BUILTIN_MANIFEST_EVALUATION_SUMMARY_GRAPH,
24988
25620
  canRender: async (context) => await evidenceGraphOf(context) !== void 0,
24989
25621
  buildModel: async (context) => {
24990
- const records = object12(context.bundle).records;
25622
+ const records = object13(context.bundle).records;
24991
25623
  return {
24992
25624
  graph: defined(
24993
25625
  await evidenceGraphOf(context),
@@ -25439,7 +26071,7 @@ ${pad.repeat(depth)}`;
25439
26071
  context.countersigners
25440
26072
  );
25441
26073
  const bannerModel = verificationBanner(context, stamps);
25442
- const records = object12(bundle).records;
26074
+ const records = object13(bundle).records;
25443
26075
  const coverage = {
25444
26076
  uncheckpointed: bannerModel.uncheckpointed,
25445
26077
  total: Array.isArray(records) ? records.length : 0
@@ -25615,15 +26247,15 @@ ${pad.repeat(depth)}`;
25615
26247
  const next = parts[parts.length - 1].nextElementSibling;
25616
26248
  if (next?.hasAttribute(mark)) parts.push(next);
25617
26249
  }
25618
- const held = [...parts, ...stripNode === void 0 ? [] : [stripNode]];
26250
+ const held2 = [...parts, ...stripNode === void 0 ? [] : [stripNode]];
25619
26251
  return {
25620
26252
  parts,
25621
- held,
26253
+ held: held2,
25622
26254
  header: bar.previousElementSibling,
25623
- words: snapshot(held),
26255
+ words: snapshot(held2),
25624
26256
  looks: {
25625
- plain: looks(held, false),
25626
- chrome: looks(held, true)
26257
+ plain: looks(held2, false),
26258
+ chrome: looks(held2, true)
25627
26259
  }
25628
26260
  };
25629
26261
  };
@@ -25830,6 +26462,86 @@ ${pad.repeat(depth)}`;
25830
26462
  ...payload.contract === void 0 ? {} : { contract: payload.contract }
25831
26463
  });
25832
26464
  }
26465
+
26466
+ // src/reader-witnesses.ts
26467
+ var DEFAULT_READER_WITNESSES = Object.freeze({
26468
+ witnesses: Object.freeze([])
26469
+ });
26470
+ var HEX_DER = /^(?:[0-9a-f]{2})+$/u;
26471
+ function parseReaderWitnesses(value) {
26472
+ if (typeof value !== "object" || value === null || Array.isArray(value))
26473
+ return void 0;
26474
+ const list2 = value.witnesses;
26475
+ if (Object.keys(value).length !== 1 || !Array.isArray(list2)) return void 0;
26476
+ const witnesses = [];
26477
+ for (const row2 of list2) {
26478
+ if (typeof row2 !== "object" || row2 === null || Array.isArray(row2))
26479
+ return void 0;
26480
+ const { name, keys, ...rest } = row2;
26481
+ if (Object.keys(rest).length > 0) return void 0;
26482
+ if (typeof name !== "string" || name.trim() === "") return void 0;
26483
+ if (!Array.isArray(keys) || keys.length === 0 || !keys.every((k) => typeof k === "string" && HEX_DER.test(k)))
26484
+ return void 0;
26485
+ witnesses.push({ name, keys: [...keys] });
26486
+ }
26487
+ return { witnesses };
26488
+ }
26489
+ var held;
26490
+ function readerWitnessPolicy() {
26491
+ return held ?? DEFAULT_READER_WITNESSES;
26492
+ }
26493
+ function setReaderWitnessPolicy(value) {
26494
+ if (value === null) {
26495
+ held = void 0;
26496
+ return true;
26497
+ }
26498
+ const parsed = parseReaderWitnesses(value);
26499
+ if (parsed === void 0) return false;
26500
+ held = parsed;
26501
+ return true;
26502
+ }
26503
+ var fromHex2 = (hex5) => {
26504
+ const out = new Uint8Array(new ArrayBuffer(hex5.length / 2));
26505
+ for (let i = 0; i < out.length; i += 1)
26506
+ out[i] = Number.parseInt(hex5.slice(2 * i, 2 * i + 2), 16);
26507
+ return out;
26508
+ };
26509
+ async function readerAnchorWitness(anchor, checkpoint, receipts2) {
26510
+ let same3 = "not_carried";
26511
+ if (checkpoint !== null) {
26512
+ try {
26513
+ const digest = await globalThis.crypto.subtle.digest(
26514
+ "SHA-256",
26515
+ fromHex2(checkpoint)
26516
+ );
26517
+ same3 = Array.from(
26518
+ new Uint8Array(digest),
26519
+ (b) => b.toString(16).padStart(2, "0")
26520
+ ).join("") === anchor ? "match" : "mismatch";
26521
+ } catch {
26522
+ same3 = "unchecked";
26523
+ }
26524
+ }
26525
+ if (receipts2 === null || receipts2.length === 0 || same3 === "mismatch") {
26526
+ return {
26527
+ checkpoint: same3,
26528
+ status: receipts2 === null ? "NOT_PRESENT" : "NOT_CHECKED",
26529
+ witness: null,
26530
+ witnessed_time: null
26531
+ };
26532
+ }
26533
+ const report = await checkAnchorWitnessed(
26534
+ anchor,
26535
+ receipts2.map(fromHex2),
26536
+ readerWitnessPolicy()
26537
+ );
26538
+ return {
26539
+ checkpoint: same3,
26540
+ status: report.status,
26541
+ witness: report.witness,
26542
+ witnessed_time: report.witnessed_time
26543
+ };
26544
+ }
25833
26545
  return __toCommonJS(browser_exports2);
25834
26546
  })();
25835
26547
  /*! Bundled license information: