@action-state-group/capsule-viewer 0.19.2 → 0.21.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.
Files changed (38) hide show
  1. package/README.md +6 -0
  2. package/dist/alias-interpreters.js +11 -3
  3. package/dist/alias-interpreters.js.map +1 -1
  4. package/dist/browser.d.ts +1 -0
  5. package/dist/browser.js +4 -0
  6. package/dist/browser.js.map +1 -1
  7. package/dist/card-registered.d.ts +46 -0
  8. package/dist/card-registered.js +104 -0
  9. package/dist/card-registered.js.map +1 -0
  10. package/dist/claim-reasons.d.ts +25 -0
  11. package/dist/claim-reasons.js +42 -0
  12. package/dist/claim-reasons.js.map +1 -0
  13. package/dist/compliance-presentation.d.ts +31 -3
  14. package/dist/compliance-presentation.js +39 -11
  15. package/dist/compliance-presentation.js.map +1 -1
  16. package/dist/compliance-view.js +13 -7
  17. package/dist/compliance-view.js.map +1 -1
  18. package/dist/compliance.d.ts +5 -2
  19. package/dist/compliance.js +10 -4
  20. package/dist/compliance.js.map +1 -1
  21. package/dist/contract-report-wording.d.ts +2 -0
  22. package/dist/contract-report-wording.js +14 -2
  23. package/dist/contract-report-wording.js.map +1 -1
  24. package/dist/contract-report.d.ts +5 -1
  25. package/dist/contract-report.js +4 -1
  26. package/dist/contract-report.js.map +1 -1
  27. package/dist/evidence-graph-view.js +5 -1
  28. package/dist/evidence-graph-view.js.map +1 -1
  29. package/dist/evidence-graph.iife.js +410 -118
  30. package/dist/generic-report-view.d.ts +5 -1
  31. package/dist/generic-report-view.js +57 -13
  32. package/dist/generic-report-view.js.map +1 -1
  33. package/dist/presentation-registry.js +2 -2
  34. package/dist/presentation-registry.js.map +1 -1
  35. package/dist/viewer-build.js +2 -2
  36. package/dist/wording/contract-report-eu-ai-act.en.json +2 -0
  37. package/dist/wording/contract-report-generic.en.json +9 -0
  38. package/package.json +2 -2
@@ -5144,6 +5144,7 @@ var EvidenceGraph = (() => {
5144
5144
  readWordingPack: () => readWordingPack,
5145
5145
  readerAnchorWitness: () => readerAnchorWitness,
5146
5146
  readerCadenceWitness: () => readerCadenceWitness,
5147
+ readerCardRegistered: () => readerCardRegistered,
5147
5148
  readerCardSignature: () => readerCardSignature,
5148
5149
  readerWitnessPolicy: () => readerWitnessPolicy,
5149
5150
  registerPresentation: () => registerPresentation,
@@ -5194,6 +5195,8 @@ var EvidenceGraph = (() => {
5194
5195
  return Uint8Array.of(major << 5 | 24, length);
5195
5196
  if (length < 65536)
5196
5197
  return Uint8Array.of(major << 5 | 25, length >>> 8, length & 255);
5198
+ if (length <= 4294967295)
5199
+ return Uint8Array.of(major << 5 | 26, length >>> 24, length >>> 16 & 255, length >>> 8 & 255, length & 255);
5197
5200
  throw new RangeError("CBOR value too large");
5198
5201
  }
5199
5202
  function bstr(value) {
@@ -6009,7 +6012,7 @@ var EvidenceGraph = (() => {
6009
6012
  schema_version: "1",
6010
6013
  _vendored_from: "action-state-group/scitt-payload-binding",
6011
6014
  _vendored_source: "spec/cpb-provisional-registry.md",
6012
- _vendored_commit: "e0ad1c7e0b0248b9aed25c747f174548cb8e141d",
6015
+ _vendored_commit: "b4af5817f7677f5a21bfd238c86ec95f30780352",
6013
6016
  _vendored_note: "Machine-readable resolver projection of the CPB *provisional* (Rung 3) Artifact Type entries. Lossy by design: name -> status + governed closed-set values. The markdown is normative; do not hand-edit -- re-run scripts/vendor_cpb_registry.py.",
6014
6017
  provisional_artifact_types: {
6015
6018
  "verifiable-agent-conversation": {
@@ -6019,12 +6022,12 @@ var EvidenceGraph = (() => {
6019
6022
  },
6020
6023
  "trace-trust-record": {
6021
6024
  status: "provisional",
6022
- reference: "`agentrust-io/trace-spec` @ `e0afe8eba628244afd591433014b182530a0c11c`",
6025
+ reference: "`agentrust-io/trace-spec` @ `e0afe8eba628244afd591433014b182530a0c11c` \u2014 `spec/trace-v0.2.md` \xA73.2.2 (row 1), `spec/registry-anchor-v1.md` \xA71 and \xA72 (row 2), `schema/trace-claim.json` (the closed field set both rows range over).",
6023
6026
  governed_values: {}
6024
6027
  },
6025
6028
  "mesh-inference-exchange": {
6026
6029
  status: "provisional",
6027
- reference: "`action-state-group/capsule-emit-mesh` @ `0304296` (`mesh_record_emitter.py`, `mesh_record_verifier.py`)",
6030
+ reference: "`action-state-group/capsule-emit-mesh` @ `9be03df`",
6028
6031
  governed_values: {
6029
6032
  terminal_state: [
6030
6033
  "completed",
@@ -6042,13 +6045,7 @@ var EvidenceGraph = (() => {
6042
6045
  "backend_dispatch",
6043
6046
  "client_egress"
6044
6047
  ]
6045
- },
6046
- capsule_field_values: {
6047
- "effect.type": ["inference_completion"],
6048
- effect_attestation: ["host_served_observed"],
6049
- "chain.relation": ["follows"]
6050
- },
6051
- capsule_field_values_source: "action-state-group/capsule-emit-mesh plugins/admission-policy/src/capsule_emit.rs (effect_type, effect_attestation, chain.relation) and capsule_sidecar.py"
6048
+ }
6052
6049
  },
6053
6050
  "mmr-checkpoint": {
6054
6051
  status: "provisional",
@@ -6056,7 +6053,7 @@ var EvidenceGraph = (() => {
6056
6053
  governed_values: {}
6057
6054
  }
6058
6055
  },
6059
- snapshot_sha256: "c401fceb810116b64e3ea2f824d03bd016a63c7e47daf7a74ab239adf35e7cbc"
6056
+ snapshot_sha256: "7d76464ad5be64eaf526938863bf6ed88a920297edae646e3ed26474267abf3b"
6060
6057
  };
6061
6058
 
6062
6059
  // node_modules/@action-state-group/agent-action-capsule/dist/provisional.js
@@ -6576,6 +6573,19 @@ var EvidenceGraph = (() => {
6576
6573
  flattened.push(...proof.peaks_left.map(hex2).toReversed());
6577
6574
  return verifyHexInclusion2(root, BigInt(proof.size), BigInt(leafIndex), identity2, flattened);
6578
6575
  }
6576
+ var uint = (value) => integer(value) && value >= 0;
6577
+ var hexList = (value) => Array.isArray(value) && value.every(isHex64);
6578
+ function consistencyProof2(raw) {
6579
+ if (!object3(raw) || raw.kind !== "consistency" || raw.v !== 1 || !uint(raw.old_size) || !uint(raw.new_size) || !hexList(raw.old_peaks) || !hexList(raw.new_peaks) || !Array.isArray(raw.witness) || !raw.witness.every(hexList))
6580
+ return void 0;
6581
+ return {
6582
+ oldSize: BigInt(raw.old_size),
6583
+ newSize: BigInt(raw.new_size),
6584
+ oldPeaks: raw.old_peaks.map(hex2),
6585
+ witness: raw.witness.map((path2) => path2.map(hex2)),
6586
+ newPeaks: raw.new_peaks.map(hex2)
6587
+ };
6588
+ }
6579
6589
 
6580
6590
  // node_modules/@action-state-group/agent-action-capsule/dist/bip340.js
6581
6591
  var P = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn;
@@ -8155,40 +8165,19 @@ var EvidenceGraph = (() => {
8155
8165
  }
8156
8166
  }
8157
8167
  var plainObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value) && !(value instanceof JsonNumber);
8158
- function normalized(value) {
8159
- if (Array.isArray(value))
8160
- return value.map(normalized);
8161
- if (!plainObject(value))
8162
- return value;
8163
- const out = {};
8164
- for (const [key, member] of Object.entries(value)) {
8165
- const next = normalized(member);
8166
- if (next === null || Array.isArray(next) && next.length === 0 || plainObject(next) && Object.keys(next).length === 0)
8167
- continue;
8168
- Object.defineProperty(out, key, {
8169
- value: next,
8170
- enumerable: true,
8171
- writable: true,
8172
- configurable: true
8173
- });
8174
- }
8175
- return out;
8176
- }
8177
8168
  async function recordCapsuleId(record) {
8178
- const algorithm = record.canonicalization_id ?? "jcs-n";
8179
- if (algorithm !== "jcs-n" && algorithm !== "jcs")
8169
+ if (record.canonicalization_id !== "jcs")
8180
8170
  throw new TypeError("cannot recompute this canonicalization_id");
8181
- const vintage = algorithm === "jcs-n";
8182
8171
  const canonical = {};
8183
8172
  for (const [key, member] of Object.entries(record))
8184
- if (key !== "capsule_id" && key !== "signature" && key !== "key_id" && !(vintage && key === "chain"))
8173
+ if (key !== "capsule_id" && key !== "signature" && key !== "key_id")
8185
8174
  Object.defineProperty(canonical, key, {
8186
8175
  value: member,
8187
8176
  enumerable: true,
8188
8177
  writable: true,
8189
8178
  configurable: true
8190
8179
  });
8191
- return sha256Hex(jcs(vintage ? normalized(canonical) : canonical));
8180
+ return sha256Hex(jcs(canonical));
8192
8181
  }
8193
8182
  function digitPairs(value, member) {
8194
8183
  if (typeof value !== "string" || !/^(?:[0-9A-Fa-f]{2})+$/u.test(value))
@@ -8451,8 +8440,8 @@ var EvidenceGraph = (() => {
8451
8440
  }
8452
8441
  };
8453
8442
  var utf84 = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
8454
- function decodeReceiptItem(data, topTag) {
8455
- const value = decodeCbor(data);
8443
+ function decodeReceiptItem(data, topTag, shortest = true) {
8444
+ const value = decodeCbor(data, shortest);
8456
8445
  const walk2 = (item, depth) => {
8457
8446
  if (typeof item === "bigint" && item < -(1n << 63n))
8458
8447
  throw new SyntaxError("an integer below -2^63");
@@ -8476,7 +8465,7 @@ var EvidenceGraph = (() => {
8476
8465
  walk2(value, 0);
8477
8466
  return value;
8478
8467
  }
8479
- function decodeCbor(data) {
8468
+ function decodeCbor(data, shortest = true) {
8480
8469
  let offset = 0;
8481
8470
  const byte = () => {
8482
8471
  const value2 = data[offset++];
@@ -8500,7 +8489,7 @@ var EvidenceGraph = (() => {
8500
8489
  let value2 = 0n;
8501
8490
  for (let i = 0; i < width; i += 1)
8502
8491
  value2 = value2 << 8n | BigInt(byte());
8503
- if (value2 < [24n, 1n << 8n, 1n << 16n, 1n << 32n][add3 - 24])
8492
+ if (shortest && value2 < [24n, 1n << 8n, 1n << 16n, 1n << 32n][add3 - 24])
8504
8493
  throw new SyntaxError("CBOR argument is not in its shortest form");
8505
8494
  return value2;
8506
8495
  };
@@ -8985,20 +8974,20 @@ var EvidenceGraph = (() => {
8985
8974
  return typeof label === "string" ? GRADES.get(label) ?? null : null;
8986
8975
  }
8987
8976
  function registrationTimeOf(headers) {
8988
- const none = (reason) => ({
8977
+ const none2 = (reason) => ({
8989
8978
  registrationTime: null,
8990
8979
  registrationTimeReason: reason
8991
8980
  });
8992
8981
  if (!headers.has(HDR_CWT_CLAIMS))
8993
- return none("iat_absent");
8982
+ return none2("iat_absent");
8994
8983
  const claims = headers.get(HDR_CWT_CLAIMS);
8995
8984
  if (!(claims instanceof CborMap))
8996
- return none("iat_invalid");
8985
+ return none2("iat_invalid");
8997
8986
  if (!claims.has(CWT_IAT))
8998
- return none("iat_absent");
8987
+ return none2("iat_absent");
8999
8988
  const iat = claims.get(CWT_IAT);
9000
8989
  if (typeof iat !== "bigint" || iat < 0n || iat > MAX_IAT)
9001
- return none("iat_invalid");
8990
+ return none2("iat_invalid");
9002
8991
  return { registrationTime: Number(iat), registrationTimeReason: null };
9003
8992
  }
9004
8993
  async function verifyCll(signed, record, key) {
@@ -9395,7 +9384,17 @@ ${body}
9395
9384
  witness,
9396
9385
  registration_time: time
9397
9386
  });
9398
- if (!ANCHOR_DIGEST.test(anchorDigest) || !(receipt instanceof Uint8Array))
9387
+ if (!ANCHOR_DIGEST.test(anchorDigest))
9388
+ return report("FAIL");
9389
+ return await receiptOverEntry(hexToBytes(anchorDigest), receipt, policy);
9390
+ }
9391
+ async function receiptOverEntry(entry, receipt, policy) {
9392
+ const report = (status2, witness = null, time = null) => ({
9393
+ status: status2,
9394
+ witness,
9395
+ registration_time: time
9396
+ });
9397
+ if (!(receipt instanceof Uint8Array))
9399
9398
  return report("FAIL");
9400
9399
  const parsed = parseAnchorReceipt(receipt);
9401
9400
  if (parsed === null)
@@ -9403,10 +9402,9 @@ ${body}
9403
9402
  const keys = anchorPolicyKeys(policy).filter(({ type }) => type === parsed.alg);
9404
9403
  if (keys.length === 0)
9405
9404
  return report("NOT_CHECKED");
9406
- const leaf = hexToBytes(anchorDigest);
9407
9405
  let unavailable = false;
9408
9406
  for (const { name, spki } of keys) {
9409
- const result3 = await verifyCoseReceipt(receipt, leaf, spki);
9407
+ const result3 = await verifyCoseReceipt(receipt, entry, spki);
9410
9408
  if (result3.ok)
9411
9409
  return report("PASS", name, parsed.time);
9412
9410
  if (result3.unavailable)
@@ -9414,19 +9412,21 @@ ${body}
9414
9412
  }
9415
9413
  return report(unavailable ? "NOT_CHECKED" : "FAIL");
9416
9414
  }
9415
+ function earliest(passed) {
9416
+ let chosen;
9417
+ for (const r of passed) {
9418
+ if (chosen === void 0 || r.registration_time !== null && (chosen.registration_time === null || r.registration_time < chosen.registration_time))
9419
+ chosen = r;
9420
+ }
9421
+ return chosen;
9422
+ }
9417
9423
  async function checkAnchorWitnessed(anchorDigest, receipts3, policy) {
9418
9424
  const reports = [];
9419
9425
  for (const receipt of receipts3)
9420
9426
  reports.push(await checkAnchorReceipt(anchorDigest, receipt, policy));
9421
9427
  const statuses = new Set(reports.map((r) => r.status));
9422
9428
  const status2 = reports.length === 0 ? "NOT_PRESENT" : statuses.has("PASS") ? "PASS" : statuses.has("FAIL") ? "FAIL" : "NOT_CHECKED";
9423
- let chosen;
9424
- for (const r of reports) {
9425
- if (r.status !== "PASS")
9426
- continue;
9427
- if (chosen === void 0 || r.registration_time !== null && (chosen.registration_time === null || r.registration_time < chosen.registration_time))
9428
- chosen = r;
9429
- }
9429
+ const chosen = earliest(reports.filter((r) => r.status === "PASS"));
9430
9430
  return {
9431
9431
  status: status2,
9432
9432
  receipts: reports,
@@ -9434,6 +9434,105 @@ ${body}
9434
9434
  witnessed_time: chosen?.registration_time ?? null
9435
9435
  };
9436
9436
  }
9437
+ var CARD_METHOD = "SCITT Transparent Statement over the card digest, RFC 9942 Receipts (standard-history-v0 \xA713)";
9438
+ var RECEIPTS_LABEL = 394n;
9439
+ function parseCardStatement(octets) {
9440
+ try {
9441
+ if (!(octets instanceof Uint8Array) || octets.length === 0 || octets.length > MAX_ANCHOR_RECEIPT_OCTETS)
9442
+ return null;
9443
+ const outer = decodeReceiptItem(octets, true);
9444
+ if (!(outer instanceof CborTag) || outer.tag !== 18n || !Array.isArray(outer.value) || outer.value.length !== 4)
9445
+ return null;
9446
+ const [protectedBytes, unprotected, payload, signature2] = outer.value;
9447
+ if (!(protectedBytes instanceof Uint8Array) || protectedBytes.length === 0 || !(payload instanceof Uint8Array) || payload.length !== 32 || !(signature2 instanceof Uint8Array) || signature2.length !== 64)
9448
+ return null;
9449
+ const headers = decodeReceiptItem(protectedBytes, false);
9450
+ if (!(headers instanceof CborMap))
9451
+ return null;
9452
+ for (const [label, value] of headers.entries) {
9453
+ if (label === 1n) {
9454
+ if (value !== -8n)
9455
+ return null;
9456
+ } else if (label === HDR_CWT_CLAIMS) {
9457
+ if (!(value instanceof CborMap) || typeof value.get(1n) !== "string" || typeof value.get(2n) !== "string")
9458
+ return null;
9459
+ } else if (label === 4n) {
9460
+ if (!(value instanceof Uint8Array))
9461
+ return null;
9462
+ } else if (label === 3n) {
9463
+ if (typeof value !== "string")
9464
+ return null;
9465
+ } else if (!(typeof label === "bigint" && label < PRIVATE_LABEL))
9466
+ return null;
9467
+ }
9468
+ const claims = headers.get(HDR_CWT_CLAIMS);
9469
+ if (!headers.has(1n) || !(claims instanceof CborMap))
9470
+ return null;
9471
+ if (!(unprotected instanceof CborMap) || unprotected.entries.length !== 1 || unprotected.entries[0][0] !== RECEIPTS_LABEL)
9472
+ return null;
9473
+ const receipts3 = unprotected.entries[0][1];
9474
+ if (!Array.isArray(receipts3) || receipts3.length === 0 || receipts3.length > MAX_ANCHOR_PROOFS || !receipts3.every((r) => r instanceof Uint8Array))
9475
+ return null;
9476
+ return {
9477
+ protectedBytes,
9478
+ iss: claims.get(1n),
9479
+ sub: claims.get(2n),
9480
+ payload,
9481
+ signature: signature2,
9482
+ receipts: receipts3
9483
+ };
9484
+ } catch {
9485
+ return null;
9486
+ }
9487
+ }
9488
+ var bytesEqual2 = (a, b) => a.length === b.length && a.every((byte, i) => byte === b[i]);
9489
+ async function checkCardStatement(card2, holder, anchor, octets, policy) {
9490
+ const report = (status2, service = null, time = null) => ({ status: status2, service, registration_time: time });
9491
+ const statement = parseCardStatement(octets);
9492
+ if (statement === null)
9493
+ return report("FAIL");
9494
+ if (!(card2 instanceof Uint8Array) || !bytesEqual2(statement.payload, sha256(card2)))
9495
+ return report("FAIL");
9496
+ if (statement.iss !== holder || statement.sub !== anchor)
9497
+ return report("FAIL");
9498
+ if (typeof holder !== "string" || !ANCHOR_DIGEST.test(holder))
9499
+ return report("FAIL");
9500
+ const message = producerEnvelopeSigningBytes(statement.protectedBytes, statement.payload);
9501
+ const key = hexToBytes(holder);
9502
+ if (!strictEd25519(key, statement.signature))
9503
+ return report("FAIL");
9504
+ let verified;
9505
+ try {
9506
+ verified = await verifyEd25519Strict(key, statement.signature, message);
9507
+ } catch {
9508
+ return report("NOT_CHECKED");
9509
+ }
9510
+ if (!verified)
9511
+ return report("FAIL");
9512
+ const entry = sha256(message);
9513
+ const reports = [];
9514
+ for (const receipt of statement.receipts)
9515
+ reports.push(await receiptOverEntry(entry, receipt, policy));
9516
+ const chosen = earliest(reports.filter((r) => r.status === "PASS"));
9517
+ if (chosen !== void 0)
9518
+ return report("PASS", chosen.witness, chosen.registration_time);
9519
+ return report(reports.some((r) => r.status === "FAIL") ? "FAIL" : "NOT_CHECKED");
9520
+ }
9521
+ async function checkCardRegistered(card2, holder, anchor, statements, policy) {
9522
+ const reports = [];
9523
+ for (const octets of statements ?? [])
9524
+ reports.push(await checkCardStatement(card2, holder, anchor, octets, policy));
9525
+ const statuses = new Set(reports.map((r) => r.status));
9526
+ const status2 = reports.length === 0 ? "NOT_PRESENT" : statuses.has("PASS") ? "PASS" : statuses.has("FAIL") ? "FAIL" : "NOT_CHECKED";
9527
+ const chosen = earliest(reports.filter((r) => r.status === "PASS"));
9528
+ return {
9529
+ status: status2,
9530
+ method: CARD_METHOD,
9531
+ statements: reports,
9532
+ service: chosen?.service ?? null,
9533
+ registration_time: chosen?.registration_time ?? null
9534
+ };
9535
+ }
9437
9536
 
9438
9537
  // node_modules/@action-state-group/agent-action-capsule/dist/parent-witness.js
9439
9538
  var PARENT_LOG_WITNESS_KIND = "parent-log-witness/v1";
@@ -9444,8 +9543,6 @@ ${body}
9444
9543
  extent: null,
9445
9544
  receipts: []
9446
9545
  });
9447
- var uint = (value) => integer(value) && value >= 0;
9448
- var hexList = (value) => Array.isArray(value) && value.every(isHex64);
9449
9546
  async function digest(...parts) {
9450
9547
  const joined = new Uint8Array(parts.reduce((n, p) => n + p.length, 0));
9451
9548
  let offset = 0;
@@ -9477,17 +9574,6 @@ ${body}
9477
9574
  const signed = await signedCheckpointFields(cose);
9478
9575
  return signed === void 0 ? "invalid" : { signed, cose };
9479
9576
  }
9480
- function consistencyProof2(raw) {
9481
- if (!object3(raw) || raw.kind !== "consistency" || raw.v !== 1 || !uint(raw.old_size) || !uint(raw.new_size) || !hexList(raw.old_peaks) || !hexList(raw.new_peaks) || !Array.isArray(raw.witness) || !raw.witness.every(hexList))
9482
- return void 0;
9483
- return {
9484
- oldSize: BigInt(raw.old_size),
9485
- newSize: BigInt(raw.new_size),
9486
- oldPeaks: raw.old_peaks.map(hex2),
9487
- witness: raw.witness.map((path2) => path2.map(hex2)),
9488
- newPeaks: raw.new_peaks.map(hex2)
9489
- };
9490
- }
9491
9577
  async function verifyParentLogWitness(block, signed, cose, directory) {
9492
9578
  if (signed === void 0 || cose === void 0)
9493
9579
  return {
@@ -10985,6 +11071,12 @@ ${body}
10985
11071
  "rebuts"
10986
11072
  ]);
10987
11073
  var UNVERIFIED_KEY_LABEL = "stated key_id (not verified)";
11074
+ var REASON_KINDS = Object.freeze({
11075
+ capsule_signature_did_not_verify: "finding",
11076
+ capsule_signer_not_trusted: "setting",
11077
+ counterparty_leg_signature_did_not_verify: "finding",
11078
+ counterparty_leg_signer_not_trusted: "setting"
11079
+ });
10988
11080
  function statedTimes(capsule) {
10989
11081
  const timestamp = asString2(capsule.timestamp);
10990
11082
  const provenanceMode = isObject3(capsule.provenance_mode) ? capsule.provenance_mode : void 0;
@@ -11766,6 +11858,10 @@ ${body}
11766
11858
  outOfScopeAllowed: raw.out_of_scope_allowed === true,
11767
11859
  ...typeof raw.applies_from === "string" ? { appliesFrom: raw.applies_from } : {},
11768
11860
  later: later.has(raw.id),
11861
+ ...typeof raw.reason === "string" ? {
11862
+ reason: raw.reason,
11863
+ reasonKind: Object.hasOwn(REASON_KINDS, raw.reason) ? REASON_KINDS[raw.reason] : "unregistered"
11864
+ } : {},
11769
11865
  support: evidence.length > 0 && missing.length === 0 ? "supported" : "unsupported",
11770
11866
  evidence,
11771
11867
  missing,
@@ -11947,15 +12043,16 @@ ${body}
11947
12043
  return "unreadable";
11948
12044
  }
11949
12045
  }
11950
- function caseActionIds(conversationId) {
11951
- const ids = [`urn:${conversationId}`];
11952
- const named = /^([^:]+):([^:]+):.+:(task-[^:]+:trial-[^:]+)$/u.exec(conversationId);
11953
- if (named !== null)
11954
- ids.push(`urn:${named[1]}:${named[2]}:${named[3]}`);
11955
- return ids;
11956
- }
11957
12046
  function isCaseRecordFor(record, conversationId) {
11958
- return record?.carriedCapsuleId !== void 0 && record.carriedActionId !== void 0 && caseActionIds(conversationId).includes(record.carriedActionId);
12047
+ if (record?.carriedCapsuleId === void 0 || record.carriedActionId === void 0)
12048
+ return false;
12049
+ if (record.carriedActionId === `urn:${conversationId}`)
12050
+ return true;
12051
+ const input = record.carriedInput;
12052
+ if (input === void 0 || input.state !== "disclosed" || !isObject3(input.payload))
12053
+ return false;
12054
+ const ids = sealedCaseIds(input.payload);
12055
+ return ids.includes(conversationId) && ids.some((id) => record.carriedActionId === `urn:${id}`);
11959
12056
  }
11960
12057
  function claimsCitedCase(records, conversationId, claims, allClaims = claims) {
11961
12058
  if (claims.length === 0 || !claims.every((claim) => reportState(records, claim) === "withheld"))
@@ -12697,6 +12794,9 @@ ${body}
12697
12794
  };
12698
12795
  }
12699
12796
 
12797
+ // node_modules/@action-state-group/agent-action-capsule/dist/retained-head.js
12798
+ init_browser();
12799
+
12700
12800
  // node_modules/@action-state-group/agent-action-capsule/dist/report-rows.js
12701
12801
  var rowCitationDigests = (row2) => Array.isArray(row2.references) ? row2.references.flatMap((reference) => isObject3(reference) && reference.type === "agent-action-capsule" && reference.citation_purpose === "acted_on" ? asString2(reference.digest) === void 0 ? [] : [asString2(reference.digest)] : []) : [];
12702
12802
  async function buildReportRows(input) {
@@ -14751,6 +14851,33 @@ ${body}
14751
14851
  return { plan, rows };
14752
14852
  }
14753
14853
 
14854
+ // src/claim-reasons.ts
14855
+ var RESERVED = /* @__PURE__ */ new Set([
14856
+ "label",
14857
+ "detail",
14858
+ "not_evaluable"
14859
+ ]);
14860
+ var CORE_REASON_CODES = /* @__PURE__ */ new Set([
14861
+ "capsule_signature_did_not_verify",
14862
+ "capsule_signer_not_trusted",
14863
+ "counterparty_leg_signature_did_not_verify",
14864
+ "counterparty_leg_signer_not_trusted"
14865
+ ]);
14866
+ function claimReasons(claims) {
14867
+ const out = /* @__PURE__ */ new Map();
14868
+ for (const claim of claims) {
14869
+ if (claim.failed || claim.reason === void 0) continue;
14870
+ const kind = claim.reasonKind ?? "unregistered";
14871
+ out.set(claim.id, {
14872
+ code: claim.reason,
14873
+ kind,
14874
+ keyable: kind !== "unregistered" && !RESERVED.has(claim.reason),
14875
+ core: CORE_REASON_CODES.has(claim.reason)
14876
+ });
14877
+ }
14878
+ return out;
14879
+ }
14880
+
14754
14881
  // src/frame-tokens.generated.ts
14755
14882
  var COMPLIANCE_FRAME_VARS = "--navy:#232F42;--gold-l:#FBEFD9;--cream:#F6F2EA;--line:#E3DED3;--slate:#6B7482;--ink:#1F2733;--ok:#2E7D5B;--ok-l:#E3F1EA;--bad:#B5462F;--bad-l:#F8E6E1;--person:#5B4BA0;--person-l:#ECE8F7;--r:14px;";
14756
14883
  var OUTCOME_FRAME_VARS = "--navy:#232F42;--gold:#E8A33D;--gold-l:#FBEFD9;--cream:#F6F2EA;--line:#E3DED3;--slate:#6B7482;--ink:#1F2733;--ok:#2E7D5B;--ok-l:#E3F1EA;--bad:#B5462F;--bad-l:#F8E6E1;--person:#5B4BA0;--person-l:#ECE8F7;--r:14px;";
@@ -16635,9 +16762,9 @@ path.cv-tl-good{fill:var(--person)}path.cv-tl-bad{fill:var(--bad)}path.cv-tl-ope
16635
16762
  if (type === "recomputed_determination") return "recomputed";
16636
16763
  return "not stated";
16637
16764
  }
16638
- function agree(values, none, mixed) {
16639
- const distinct = new Set(values.filter((v) => v !== none));
16640
- if (distinct.size === 0) return none;
16765
+ function agree(values, none2, mixed) {
16766
+ const distinct = new Set(values.filter((v) => v !== none2));
16767
+ if (distinct.size === 0) return none2;
16641
16768
  return distinct.size === 1 ? [...distinct][0] : mixed;
16642
16769
  }
16643
16770
  function parseClaim(claim) {
@@ -16887,8 +17014,10 @@ path.cv-tl-good{fill:var(--person)}path.cv-tl-bad{fill:var(--bad)}path.cv-tl-ope
16887
17014
  obligationKey: obligation.key,
16888
17015
  article: obligation.article,
16889
17016
  testName: row2.name,
16890
- severity: row2.finding.severity,
16891
- recommendation: row2.finding.recommendation,
17017
+ ..."observed" in row2.finding ? { observed: row2.finding.observed } : {
17018
+ severity: row2.finding.severity,
17019
+ recommendation: row2.finding.recommendation
17020
+ },
16892
17021
  ownerDue: row2.finding.ownerDue,
16893
17022
  sessionIds: row2.sessionsByVerdict.get("not_met") ?? []
16894
17023
  });
@@ -17736,15 +17865,15 @@ ${s} .check .steps{margin:12px 0 0;padding-left:20px;font-size:14px;line-height:
17736
17865
  }
17737
17866
  function builtCommit() {
17738
17867
  if (false) return void 0;
17739
- return commitPrefix("613a8a95144e5851bbb61df72df8cc76b7500381");
17868
+ return commitPrefix("003fc8941d80de5d1753181aba7b524bd86a85a9");
17740
17869
  }
17741
17870
  var commit = builtCommit();
17742
17871
  var unreleased = false;
17743
17872
  var VIEWER_BUILD = {
17744
17873
  viewer: "@action-state-group/capsule-viewer",
17745
- viewerVersion: "0.19.2",
17874
+ viewerVersion: "0.21.0",
17746
17875
  verifier: "@action-state-group/agent-action-capsule",
17747
- verifierVersion: "0.14.0",
17876
+ verifierVersion: "0.16.0",
17748
17877
  cllVersion: "0.4.0",
17749
17878
  ...commit === void 0 ? {} : { commit },
17750
17879
  ...unreleased ? { unreleased: true } : {}
@@ -18636,7 +18765,9 @@ ${s} .check .steps{margin:12px 0 0;padding-left:20px;font-size:14px;line-height:
18636
18765
  "groups.summary.h": "What was checked and what we found",
18637
18766
  "groups.summary.lede": "Each session (one conversation with the agent) was checked against {tests} under {obligations}. Results are counts of sessions: there is no overall score. Open a requirement to read the sessions behind its exceptions.",
18638
18767
  "groups.summary.basis": `Every count and result is read from the sealed claims and reports in this bundle, or marked "not stated". The regulation named above, obligation titles, requirement names, the article, the plain-language summary, applicability, method, finding ids, severities, recommendations and the notes on undecided requirements and quality checks are the producer's mapping, set in italics: carried beside the signed records, not in them.`,
18768
+ "groups.summary.basis.v2": `Every count and result is read from the sealed claims and reports in this bundle, or marked "not stated". The regulation named above, obligation titles, requirement names, the article, the plain-language summary, applicability, method, finding ids, what each finding observed, its owner and due date, and the notes on undecided requirements and quality checks are the producer's mapping, set in italics: carried beside the signed records, not in them.`,
18639
18769
  "groups.summary.basis.pack-titles": `Every count and result is read from the sealed claims and reports in this bundle, or marked "not stated". The regulation named above, requirement names, the article, the plain-language summary, applicability, method, finding ids, severities, recommendations and the notes on undecided requirements and quality checks are the producer's mapping, set in italics: carried beside the signed records, not in them. Obligation titles are the Act's article headings, from this page's wording pack.`,
18770
+ "groups.summary.basis.pack-titles.v2": `Every count and result is read from the sealed claims and reports in this bundle, or marked "not stated". The regulation named above, requirement names, the article, the plain-language summary, applicability, method, finding ids, what each finding observed, its owner and due date, and the notes on undecided requirements and quality checks are the producer's mapping, set in italics: carried beside the signed records, not in them. Obligation titles are the Act's article headings, from this page's wording pack.`,
18640
18771
  "groups.fn.records.one": "\xB9 Records are the {records} sealed items in this bundle. A session is one conversation with the agent, made of one or more records; this bundle has {n} session.",
18641
18772
  "groups.fn.records.other": "\xB9 Records are the {records} sealed items in this bundle. A session is one conversation with the agent, made of one or more records; this bundle has {n} sessions.",
18642
18773
  "groups.fn.resolved.tiered": "\xB2 A session is met when every requirement that applied to it was satisfied and at least one applied. A requirement the contract marks informational never changes the answer.",
@@ -19585,6 +19716,15 @@ ${s} .check .steps{margin:12px 0 0;padding-left:20px;font-size:14px;line-height:
19585
19716
  "generic.later.title": "Not yet in force \xB7 {n}",
19586
19717
  "generic.later.readiness": "readiness",
19587
19718
  "generic.later.note": "Applies from {date}, as the producer copied it from the contract, not re-checked here: readiness only, not counted.",
19719
+ "generic.reason.says": "The report's producer gives this reason: {text}",
19720
+ "generic.reason.token.capsule_signature_did_not_verify": "A record this claim needed has a signature that did not verify, so the record was not used.",
19721
+ "generic.reason.token.capsule_signer_not_trusted": "A record this claim needed is signed by a key outside the keys the report's producer trusted, so the record was not used. This alone is not a sign of tampering.",
19722
+ "generic.reason.token.counterparty_leg_signature_did_not_verify": "The other side's signed leg was found and its signature did not verify, so it does not raise the grade.",
19723
+ "generic.reason.token.counterparty_leg_signer_not_trusted": "The other side's signed leg was found, signed by a key outside the keys the report's producer trusted, so it does not raise the grade. This alone is not a sign of tampering.",
19724
+ "generic.reason.unworded": "The report's producer gives a reason this page has no words for: {code}",
19725
+ "generic.reason.grade": "Grade: {grade}.",
19726
+ "generic.reason.flag.one": "{n} claim with a reason from the producer",
19727
+ "generic.reason.flag.other": "{n} claims with a reason from the producer",
19588
19728
  "generic.producer.note": "Requirement names, groups and claim ids are the producer's identifiers, shown as written unless a wording pack names them; they are not sealed evidence.",
19589
19729
  "generic.claim.type": "Claim type",
19590
19730
  "generic.claim.unrecognized": "unrecognized claim type {type}",
@@ -20043,6 +20183,13 @@ ${s} .check .steps{margin:12px 0 0;padding-left:20px;font-size:14px;line-height:
20043
20183
  "groups.rtier.totals.out-of-scope",
20044
20184
  "groups.rtier.totals.unstated",
20045
20185
  "groups.rtier.totals.failed",
20186
+ "generic.reason.says",
20187
+ "generic.reason.token.capsule_signature_did_not_verify",
20188
+ "generic.reason.token.capsule_signer_not_trusted",
20189
+ "generic.reason.token.counterparty_leg_signature_did_not_verify",
20190
+ "generic.reason.token.counterparty_leg_signer_not_trusted",
20191
+ "generic.reason.unworded",
20192
+ "generic.reason.grade",
20046
20193
  "generic.rtier.totals",
20047
20194
  "generic.rtier.totals.out-of-scope",
20048
20195
  "generic.rtier.totals.unstated",
@@ -20413,6 +20560,8 @@ ${s} .check .steps{margin:12px 0 0;padding-left:20px;font-size:14px;line-height:
20413
20560
  "groups.ob.ok.unverified",
20414
20561
  "groups.summary.basis",
20415
20562
  "groups.summary.basis.pack-titles",
20563
+ "groups.summary.basis.v2",
20564
+ "groups.summary.basis.pack-titles.v2",
20416
20565
  "groups.summary.lede",
20417
20566
  "groups.pf.case-record.from-claims",
20418
20567
  "groups.pf.no-claim",
@@ -20648,8 +20797,8 @@ ${key}`);
20648
20797
  }
20649
20798
  var DEFAULT_PACK_SHA256 = Object.freeze({
20650
20799
  lines: "4a03428e884337321754bd6657df0ebb6d5441821378a3b1ff17f2a625021cc5",
20651
- groups: "76acc9598202663738d7d2903ca1a042d9b7ca21799297946e4da39ea77d5250",
20652
- generic: "6c7570711462e9a9af94faac45f56414fd97a1681608be03299f6fa756eaa41c"
20800
+ groups: "81aeee3abd2d336824d81e24c7f5fad87227ffb4ff8f247cad96c4c855912b9f",
20801
+ generic: "9987467e7d99ff4680fa6d7e2d2d634455f729958bfbd53ebac86c14508b031d"
20653
20802
  });
20654
20803
  function fill(key, text2, vars) {
20655
20804
  return text2.replace(PLACEHOLDER, (whole, name) => {
@@ -20693,6 +20842,7 @@ ${key}`);
20693
20842
  return target !== void 0 ? t(target) : section3(key) ?? value;
20694
20843
  },
20695
20844
  row: (requirementRef, part) => context.singleContract ? section3(`row.${requirementRef}.${part}`) : void 0,
20845
+ reason: (requirementRef, code2) => context.singleContract ? section3(`row.${requirementRef}.reason.${code2}`) : void 0,
20696
20846
  group: (segment) => context.singleContract ? section3(`group.${segment}.title`) : void 0,
20697
20847
  grouping,
20698
20848
  source: supplied === void 0 ? {
@@ -23849,7 +23999,7 @@ ${key}`);
23849
23999
  "p",
23850
24000
  "",
23851
24001
  w.t(
23852
- packTitlesOnPage(model, w) ? "groups.summary.basis.pack-titles" : "groups.summary.basis"
24002
+ (packTitlesOnPage(model, w) ? "groups.summary.basis.pack-titles" : "groups.summary.basis") + (presentation.version === 2 ? ".v2" : "")
23853
24003
  )
23854
24004
  );
23855
24005
  basis.dataset.basis = "terms";
@@ -23899,11 +24049,13 @@ ${key}`);
23899
24049
  const fh = el9("div", "fh");
23900
24050
  fh.append(
23901
24051
  maybeProducer(w, "b", "", w.t("groups.finding", { id: finding.id }), true),
23902
- severityPill(finding.severity, w),
24052
+ ...finding.severity === void 0 ? [] : [severityPill(finding.severity, w)],
23903
24053
  element4("span", count(w, "session", finding.sessionIds.length))
23904
24054
  );
23905
24055
  box.append(fh);
23906
- box.append(maybeProducer(w, "div", "rec", finding.recommendation, true));
24056
+ const statement = finding.observed ?? finding.recommendation;
24057
+ if (statement !== void 0)
24058
+ box.append(maybeProducer(w, "div", "rec", statement, true));
23907
24059
  const own = el9("div", "own", w.t("groups.finding.owner"));
23908
24060
  own.append(producerText(w, finding.ownerDue));
23909
24061
  box.append(own);
@@ -24353,6 +24505,9 @@ ${key}`);
24353
24505
  .gr .rname{font-weight:600;color:var(--navy)}
24354
24506
  .gr .rname code,.gr .cid{font-family:ui-monospace,Menlo,monospace;font-size:12.5px;word-break:break-all}
24355
24507
  .gr ul.claims{list-style:none;margin:6px 0 0;padding:0}
24508
+ .gr .rreason,.gr .rflag{font-size:12.5px;border-radius:6px;padding:2px 8px;background:#EEF0F3;color:var(--slate)}
24509
+ .gr .rreason{margin:4px 0 6px 22px}
24510
+ .gr .rreason[data-tone="warn"],.gr .rflag[data-tone="warn"]{background:var(--bad-l);color:var(--bad);font-weight:700}
24356
24511
  .gr .tier-note{font-size:12.5px;color:var(--slate)}
24357
24512
  ` + levelCss("gr") + frontCss(".gr")
24358
24513
  };
@@ -24444,18 +24599,48 @@ ${key}`);
24444
24599
  if (mark !== void 0) body.append(mark);
24445
24600
  return body;
24446
24601
  }
24447
- function claimItem(claim, w) {
24602
+ function reasonLines(claim, w, reasons) {
24603
+ const found = reasons?.get(claim.id);
24604
+ if (found === void 0) return [];
24605
+ const { code: code2 } = found;
24606
+ const packText = found.keyable ? w.reason(claim.requirementRef, code2) : void 0;
24607
+ const coreText = packText === void 0 && found.core ? w.t(`generic.reason.token.${code2}`) : void 0;
24608
+ const text2 = packText ?? coreText;
24609
+ const line = el10("p", "rreason");
24610
+ line.dataset.reasonCode = code2;
24611
+ line.dataset.reasonKind = found.kind;
24612
+ line.dataset.tone = found.kind === "finding" ? "warn" : "note";
24613
+ if (claim.later) line.append(w.t("generic.later.readiness"), " ");
24614
+ if (claim.verdict !== "not_evaluable")
24615
+ line.append(
24616
+ w.t("generic.reason.grade", { grade: w.enumWord("grade", claim.grade) }),
24617
+ " "
24618
+ );
24619
+ line.append(
24620
+ tagSource(
24621
+ el10(
24622
+ "span",
24623
+ "",
24624
+ text2 !== void 0 ? w.t("generic.reason.says", { text: text2 }) : w.t("generic.reason.unworded", { code: code2 })
24625
+ ),
24626
+ packText !== void 0 ? "pack" : "core"
24627
+ )
24628
+ );
24629
+ return [line];
24630
+ }
24631
+ function claimItem(claim, w, reasons) {
24448
24632
  const item = el10("li", "");
24449
24633
  item.dataset.claimRef = claim.id;
24450
24634
  const head2 = el10("span", "");
24451
24635
  const id = tagSource(el10("code", "cid", claim.id), "producer");
24452
24636
  head2.append(id, " ", verdictPill(shownVerdict(claim), w));
24453
24637
  item.append(
24454
- levelToggle(2, head2, () => claimProofs(claim, w), { className: "claim" })
24638
+ levelToggle(2, head2, () => claimProofs(claim, w), { className: "claim" }),
24639
+ ...reasonLines(claim, w, reasons)
24455
24640
  );
24456
24641
  return item;
24457
24642
  }
24458
- function rowItem(row2, w, later, tierOf) {
24643
+ function rowItem(row2, w, later, tierOf, reasons) {
24459
24644
  const label = w.row(row2.requirementRef, "label");
24460
24645
  const name = el10("span", "rname");
24461
24646
  if (label !== void 0)
@@ -24470,6 +24655,14 @@ ${key}`);
24470
24655
  summary.append(" ", chip);
24471
24656
  }
24472
24657
  summary.append(tally(row2, w, later));
24658
+ const given = row2.claims.filter((claim) => reasons?.has(claim.id));
24659
+ if (given.length > 0) {
24660
+ const flag = el10("span", "rflag", w.p("generic.reason.flag", given.length));
24661
+ flag.dataset.tone = given.some(
24662
+ (claim) => reasons.get(claim.id).kind === "finding"
24663
+ ) ? "warn" : "note";
24664
+ summary.append(" ", flag);
24665
+ }
24473
24666
  const toggle = levelToggle(
24474
24667
  1,
24475
24668
  summary,
@@ -24490,7 +24683,7 @@ ${key}`);
24490
24683
  ))
24491
24684
  body.append(el10("p", "rnote", w.t("generic.later.note", { date })));
24492
24685
  const list2 = el10("ul", "claims");
24493
- for (const claim of row2.claims) list2.append(claimItem(claim, w));
24686
+ for (const claim of row2.claims) list2.append(claimItem(claim, w, reasons));
24494
24687
  body.append(el10("h3", "", w.t("generic.claims.h")), list2);
24495
24688
  return body;
24496
24689
  },
@@ -24500,7 +24693,7 @@ ${key}`);
24500
24693
  toggle.dataset.contract = row2.contractRef;
24501
24694
  return toggle;
24502
24695
  }
24503
- function groupedRows(rows, w, later, tierOf) {
24696
+ function groupedRows(rows, w, later, tierOf, reasons) {
24504
24697
  const box = el10("div", "groups");
24505
24698
  const order = [];
24506
24699
  const byGroup = /* @__PURE__ */ new Map();
@@ -24525,7 +24718,7 @@ ${key}`);
24525
24718
  part.append(heading);
24526
24719
  }
24527
24720
  for (const row2 of byGroup.get(group))
24528
- part.append(rowItem(row2, w, later, tierOf));
24721
+ part.append(rowItem(row2, w, later, tierOf, reasons));
24529
24722
  box.append(part);
24530
24723
  }
24531
24724
  return box;
@@ -24535,9 +24728,10 @@ ${key}`);
24535
24728
  heading.append(" ", tagSource(el10("code", "", contract), "producer"));
24536
24729
  return heading;
24537
24730
  }
24538
- function byContract(rows, w, later, tierOf) {
24731
+ function byContract(rows, w, later, tierOf, reasons) {
24539
24732
  const contracts = [...new Set(rows.map((row2) => row2.contractRef))];
24540
- if (contracts.length <= 1) return groupedRows(rows, w, later, tierOf);
24733
+ if (contracts.length <= 1)
24734
+ return groupedRows(rows, w, later, tierOf, reasons);
24541
24735
  const box = el10("div", "contracts");
24542
24736
  for (const contract of contracts) {
24543
24737
  const part = el10("div", "contract");
@@ -24548,14 +24742,15 @@ ${key}`);
24548
24742
  rows.filter((row2) => row2.contractRef === contract),
24549
24743
  w,
24550
24744
  later,
24551
- tierOf
24745
+ tierOf,
24746
+ reasons
24552
24747
  )
24553
24748
  );
24554
24749
  box.append(part);
24555
24750
  }
24556
24751
  return box;
24557
24752
  }
24558
- async function drawGeneric(levels, result3, bundle, verified, w, tierOf) {
24753
+ async function drawGeneric(levels, result3, bundle, verified, w, tierOf, reasons) {
24559
24754
  const tierFor = (claim) => tierOf === void 0 ? "unstated" : tierOf(claim.contractRef, claim.requirementRef);
24560
24755
  const inForce = result3.claims.filter((claim) => !claim.later);
24561
24756
  const later = result3.claims.filter((claim) => claim.later);
@@ -24580,7 +24775,8 @@ ${key}`);
24580
24775
  const section = el10("section", "front-card");
24581
24776
  section.dataset.section = "rows";
24582
24777
  const rows = rowsOf(inForce);
24583
- if (tierOf === void 0) section.append(byContract(rows, w, false));
24778
+ if (tierOf === void 0)
24779
+ section.append(byContract(rows, w, false, void 0, reasons));
24584
24780
  else
24585
24781
  for (const tier of ROW_TIERS) {
24586
24782
  const inTier = rows.filter(
@@ -24598,7 +24794,7 @@ ${key}`);
24598
24794
  })
24599
24795
  ),
24600
24796
  el10("p", "rnote", w.t(`generic.rtier.${tier}.note`)),
24601
- byContract(inTier, w, false, tierOf)
24797
+ byContract(inTier, w, false, tierOf, reasons)
24602
24798
  );
24603
24799
  section.append(part);
24604
24800
  }
@@ -24612,7 +24808,7 @@ ${key}`);
24612
24808
  "",
24613
24809
  w.t("generic.later.title", { n: later.length.toLocaleString() })
24614
24810
  ),
24615
- byContract(laterRows, w, true, tierOf)
24811
+ byContract(laterRows, w, true, tierOf, reasons)
24616
24812
  );
24617
24813
  section.append(part);
24618
24814
  }
@@ -24745,7 +24941,18 @@ ${key}`);
24745
24941
  w,
24746
24942
  tierOf
24747
24943
  );
24748
- else await drawGeneric(levels, result3, bundle, verified, w, tierOf);
24944
+ else
24945
+ await drawGeneric(
24946
+ levels,
24947
+ result3,
24948
+ bundle,
24949
+ verified,
24950
+ w,
24951
+ tierOf,
24952
+ // The pack's `row.<ref>.reason.<code>` words apply only to a Result
24953
+ // citing one contract (the Words gate); the reason itself shows always.
24954
+ input.reasons
24955
+ );
24749
24956
  regions.L0.append(levels.L0);
24750
24957
  regions.L1.append(levels.L1);
24751
24958
  regions.L2.append(levels.L2);
@@ -25368,9 +25575,9 @@ ${key}`);
25368
25575
  const hex6 = typeof raw.signature === "string" ? raw.signature : void 0;
25369
25576
  const view = hex6 === void 0 ? void 0 : readEnvelope(hex6);
25370
25577
  if (hex6 === void 0) {
25371
- const none = el11("p", "l3-note", w.t("record.envelope.none"));
25372
- none.dataset.l3 = "no-envelope";
25373
- card2.append(none);
25578
+ const none2 = el11("p", "l3-note", w.t("record.envelope.none"));
25579
+ none2.dataset.l3 = "no-envelope";
25580
+ card2.append(none2);
25374
25581
  } else if (view === void 0) {
25375
25582
  const bad2 = el11("p", "l3-note", w.t("record.envelope.unreadable"));
25376
25583
  bad2.dataset.l3 = "unreadable-envelope";
@@ -25998,23 +26205,31 @@ ${pad.repeat(depth)}`;
25998
26205
  function strArray(value) {
25999
26206
  return Array.isArray(value) ? value.filter((v) => typeof v === "string") : [];
26000
26207
  }
26001
- function readFinding(value) {
26208
+ var COMPLIANCE_KEY_V1 = "eu-ai-act-compliance/v1";
26209
+ var COMPLIANCE_KEY_V2 = "eu-ai-act-obligations-report/v2";
26210
+ function readFinding(value, key) {
26002
26211
  const obj = object12(value);
26003
26212
  const id = str2(obj?.id);
26213
+ const ownerDue = str2(obj?.owner_due);
26214
+ if (key === COMPLIANCE_KEY_V2) {
26215
+ const observed = str2(obj?.observed);
26216
+ if (id === void 0 || observed === void 0 || ownerDue === void 0)
26217
+ return void 0;
26218
+ return { id, observed, ownerDue };
26219
+ }
26004
26220
  const severity = str2(obj?.severity);
26005
26221
  const recommendation = str2(obj?.recommendation);
26006
- const ownerDue = str2(obj?.owner_due);
26007
26222
  if (id === void 0 || severity === void 0 || recommendation === void 0 || ownerDue === void 0)
26008
26223
  return void 0;
26009
26224
  return { id, severity, recommendation, ownerDue };
26010
26225
  }
26011
- function readRow(value) {
26226
+ function readRow(value, key) {
26012
26227
  const obj = object12(value);
26013
26228
  const criterionId = str2(obj?.criterion_id);
26014
26229
  const name = str2(obj?.name);
26015
26230
  if (criterionId === void 0 || name === void 0) return void 0;
26016
26231
  const notEvaluableNote = str2(obj?.not_evaluable_note);
26017
- const finding = obj?.finding === void 0 ? void 0 : readFinding(obj.finding);
26232
+ const finding = obj?.finding === void 0 ? void 0 : readFinding(obj.finding, key);
26018
26233
  return {
26019
26234
  criterionId,
26020
26235
  name,
@@ -26029,7 +26244,7 @@ ${pad.repeat(depth)}`;
26029
26244
  if (status2 === void 0 || note === void 0) return void 0;
26030
26245
  return { status: status2, note };
26031
26246
  }
26032
- function readObligation(value) {
26247
+ function readObligation(value, extension) {
26033
26248
  const obj = object12(value);
26034
26249
  const key = str2(obj?.key);
26035
26250
  const article = str2(obj?.article);
@@ -26040,7 +26255,7 @@ ${pad.repeat(depth)}`;
26040
26255
  if (key === void 0 || article === void 0 || title === void 0 || plain2 === void 0 || method === void 0 || applicability === void 0)
26041
26256
  return void 0;
26042
26257
  const rows = Array.isArray(obj?.rows) ? obj.rows.flatMap((r) => {
26043
- const row2 = readRow(r);
26258
+ const row2 = readRow(r, extension);
26044
26259
  return row2 === void 0 ? [] : [row2];
26045
26260
  }) : [];
26046
26261
  return {
@@ -26068,25 +26283,29 @@ ${pad.repeat(depth)}`;
26068
26283
  ...note === void 0 ? {} : { note }
26069
26284
  };
26070
26285
  }
26071
- function readCompliancePresentation(bundle) {
26286
+ function readComplianceBlock(bundle, key) {
26072
26287
  const top = object12(bundle);
26073
26288
  const extensions2 = object12(top?.extensions);
26074
- const block = object12(extensions2?.["eu-ai-act-compliance/v1"]);
26289
+ const block = object12(extensions2?.[key]);
26075
26290
  if (block === void 0 || block.enabled !== true) return void 0;
26076
26291
  const regulation = str2(block.regulation) ?? "Regulation (EU) 2024/1689";
26077
26292
  const obligations = Array.isArray(block.obligations) ? block.obligations.flatMap((o) => {
26078
- const obligation = readObligation(o);
26293
+ const obligation = readObligation(o, key);
26079
26294
  return obligation === void 0 ? [] : [obligation];
26080
26295
  }) : [];
26081
26296
  if (obligations.length === 0) return void 0;
26082
26297
  const qualityProtocol = readQualityProtocol(block.quality_protocol);
26083
26298
  return {
26084
26299
  enabled: true,
26300
+ version: key === COMPLIANCE_KEY_V2 ? 2 : 1,
26085
26301
  regulation,
26086
26302
  obligations,
26087
26303
  ...qualityProtocol === void 0 ? {} : { qualityProtocol }
26088
26304
  };
26089
26305
  }
26306
+ function readCompliancePresentation(bundle) {
26307
+ return readComplianceBlock(bundle, COMPLIANCE_KEY_V2) ?? readComplianceBlock(bundle, COMPLIANCE_KEY_V1);
26308
+ }
26090
26309
 
26091
26310
  // src/presentation-registry.ts
26092
26311
  var PRESENTATION_MANIFEST_VERSION = "aac.presentation-manifest/v0";
@@ -26178,7 +26397,7 @@ ${pad.repeat(depth)}`;
26178
26397
  var EXTENSION_READERS = {
26179
26398
  [CONTRACT_REPORT_KIND]: readContractReport,
26180
26399
  "outcome-report/v1": (bundle) => readOutcomeReportPresentation(bundle) !== void 0,
26181
- "eu-ai-act-compliance/v1": (bundle) => readCompliancePresentation(bundle) !== void 0
26400
+ [COMPLIANCE_KEY_V1]: (bundle) => readComplianceBlock(bundle, COMPLIANCE_KEY_V1) !== void 0
26182
26401
  };
26183
26402
  function describeContext(context) {
26184
26403
  const bundle = isPlainObject(context.bundle) ? context.bundle : {};
@@ -26409,9 +26628,16 @@ ${pad.repeat(depth)}`;
26409
26628
  id: "outcome-report-card",
26410
26629
  accepts: (bundle) => readOutcomeReportPresentation(bundle) !== void 0
26411
26630
  },
26412
- "eu-ai-act-compliance/v1": {
26631
+ [COMPLIANCE_KEY_V1]: {
26632
+ id: "compliance-card",
26633
+ // The card draws the v2 block when it accepts one, so the v1 block is
26634
+ // read only when no v2 block is accepted.
26635
+ accepts: (bundle) => readComplianceBlock(bundle, COMPLIANCE_KEY_V1) !== void 0 && readComplianceBlock(bundle, COMPLIANCE_KEY_V2) === void 0
26636
+ },
26637
+ // The v2 name of the same card (findings state what was observed).
26638
+ [COMPLIANCE_KEY_V2]: {
26413
26639
  id: "compliance-card",
26414
- accepts: (bundle) => readCompliancePresentation(bundle) !== void 0
26640
+ accepts: (bundle) => readComplianceBlock(bundle, COMPLIANCE_KEY_V2) !== void 0
26415
26641
  }
26416
26642
  });
26417
26643
  function aliasExtensionRows(bundle, rows, applied) {
@@ -28007,7 +28233,10 @@ ${pad.repeat(depth)}`;
28007
28233
  CONTRACT_REPORT_MANIFEST.id
28008
28234
  );
28009
28235
  const supported = contractReportInput(context.bundle);
28010
- const input = supported === void 0 ? { grouping: "generic" } : claimsFitCard(result3, supported.grouping) ? supported : void 0;
28236
+ const input = supported === void 0 ? {
28237
+ grouping: "generic",
28238
+ reasons: claimReasons(result3.claims)
28239
+ } : claimsFitCard(result3, supported.grouping) ? supported : void 0;
28011
28240
  if (typeof context.bundle === "object" && context.bundle !== null)
28012
28241
  contractReportDrawn.set(
28013
28242
  context.bundle,
@@ -29275,6 +29504,69 @@ ${pad.repeat(depth)}`;
29275
29504
  return result2("NOT_CHECKED");
29276
29505
  }
29277
29506
 
29507
+ // src/card-registered.ts
29508
+ var MAX_CARD_STATEMENTS = 64;
29509
+ var MAX_STATEMENT_HEX = 2 * 10485760;
29510
+ var HEX2 = /^(?:[0-9a-f]{2})+$/u;
29511
+ var ANCHOR = /^[0-9a-f]{64}$/u;
29512
+ var none = (status2, statements = [], keyId = null) => ({
29513
+ status: status2,
29514
+ service: null,
29515
+ registration_time: null,
29516
+ statements,
29517
+ key_id: keyId
29518
+ });
29519
+ var fromHex4 = (hex6) => {
29520
+ const out = new Uint8Array(new ArrayBuffer(hex6.length / 2));
29521
+ for (let i = 0; i < out.length; i += 1)
29522
+ out[i] = Number.parseInt(hex6.slice(2 * i, 2 * i + 2), 16);
29523
+ return out;
29524
+ };
29525
+ async function cardRegisteredUnder(card2, key, anchor, statements, policy) {
29526
+ const report = await checkCardRegistered(
29527
+ card2,
29528
+ key,
29529
+ anchor,
29530
+ statements.map(
29531
+ (s) => HEX2.test(s) && s.length <= MAX_STATEMENT_HEX ? fromHex4(s) : new Uint8Array(0)
29532
+ ),
29533
+ policy
29534
+ );
29535
+ return {
29536
+ status: report.status,
29537
+ service: report.service,
29538
+ registration_time: report.registration_time,
29539
+ statements: report.statements,
29540
+ key_id: key
29541
+ };
29542
+ }
29543
+ async function readerCardRegistered(context, statements) {
29544
+ if (statements === null || statements.length === 0)
29545
+ return none("NOT_PRESENT");
29546
+ try {
29547
+ if (statements.length > MAX_CARD_STATEMENTS || statements.some((s) => typeof s !== "string"))
29548
+ return none("NOT_CHECKED");
29549
+ if (!isVerifiedBundleContext(context)) return none("NOT_CHECKED");
29550
+ const signature2 = await readerCardSignature(context);
29551
+ const disclosed = context.root ? context.resolvedDisclosures.get(context.root)?.agent_input : void 0;
29552
+ if (signature2.status !== "PASS" || signature2.key_id === null || disclosed === void 0 || disclosed.state !== "disclosed")
29553
+ return none("NOT_CHECKED");
29554
+ const card2 = disclosed.payload;
29555
+ const anchor = card2 !== null && typeof card2 === "object" ? card2.anchor : void 0;
29556
+ if (typeof anchor !== "string" || !ANCHOR.test(anchor))
29557
+ return none("NOT_CHECKED");
29558
+ return await cardRegisteredUnder(
29559
+ jcs(card2),
29560
+ signature2.key_id,
29561
+ anchor,
29562
+ statements,
29563
+ readerWitnessPolicy()
29564
+ );
29565
+ } catch {
29566
+ return none("NOT_CHECKED");
29567
+ }
29568
+ }
29569
+
29278
29570
  // src/wording/history-view.en.json
29279
29571
  var history_view_en_default = {
29280
29572
  wording_pack_version: "0",