@action-state-group/capsule-viewer 0.19.2 → 0.20.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.
@@ -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) {
@@ -17736,15 +17863,15 @@ ${s} .check .steps{margin:12px 0 0;padding-left:20px;font-size:14px;line-height:
17736
17863
  }
17737
17864
  function builtCommit() {
17738
17865
  if (false) return void 0;
17739
- return commitPrefix("613a8a95144e5851bbb61df72df8cc76b7500381");
17866
+ return commitPrefix("9a4fae0d6bdb7dbd15a71262283d9234470d76e0");
17740
17867
  }
17741
17868
  var commit = builtCommit();
17742
17869
  var unreleased = false;
17743
17870
  var VIEWER_BUILD = {
17744
17871
  viewer: "@action-state-group/capsule-viewer",
17745
- viewerVersion: "0.19.2",
17872
+ viewerVersion: "0.20.0",
17746
17873
  verifier: "@action-state-group/agent-action-capsule",
17747
- verifierVersion: "0.14.0",
17874
+ verifierVersion: "0.16.0",
17748
17875
  cllVersion: "0.4.0",
17749
17876
  ...commit === void 0 ? {} : { commit },
17750
17877
  ...unreleased ? { unreleased: true } : {}
@@ -19585,6 +19712,15 @@ ${s} .check .steps{margin:12px 0 0;padding-left:20px;font-size:14px;line-height:
19585
19712
  "generic.later.title": "Not yet in force \xB7 {n}",
19586
19713
  "generic.later.readiness": "readiness",
19587
19714
  "generic.later.note": "Applies from {date}, as the producer copied it from the contract, not re-checked here: readiness only, not counted.",
19715
+ "generic.reason.says": "The report's producer gives this reason: {text}",
19716
+ "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.",
19717
+ "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.",
19718
+ "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.",
19719
+ "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.",
19720
+ "generic.reason.unworded": "The report's producer gives a reason this page has no words for: {code}",
19721
+ "generic.reason.grade": "Grade: {grade}.",
19722
+ "generic.reason.flag.one": "{n} claim with a reason from the producer",
19723
+ "generic.reason.flag.other": "{n} claims with a reason from the producer",
19588
19724
  "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
19725
  "generic.claim.type": "Claim type",
19590
19726
  "generic.claim.unrecognized": "unrecognized claim type {type}",
@@ -20043,6 +20179,13 @@ ${s} .check .steps{margin:12px 0 0;padding-left:20px;font-size:14px;line-height:
20043
20179
  "groups.rtier.totals.out-of-scope",
20044
20180
  "groups.rtier.totals.unstated",
20045
20181
  "groups.rtier.totals.failed",
20182
+ "generic.reason.says",
20183
+ "generic.reason.token.capsule_signature_did_not_verify",
20184
+ "generic.reason.token.capsule_signer_not_trusted",
20185
+ "generic.reason.token.counterparty_leg_signature_did_not_verify",
20186
+ "generic.reason.token.counterparty_leg_signer_not_trusted",
20187
+ "generic.reason.unworded",
20188
+ "generic.reason.grade",
20046
20189
  "generic.rtier.totals",
20047
20190
  "generic.rtier.totals.out-of-scope",
20048
20191
  "generic.rtier.totals.unstated",
@@ -20649,7 +20792,7 @@ ${key}`);
20649
20792
  var DEFAULT_PACK_SHA256 = Object.freeze({
20650
20793
  lines: "4a03428e884337321754bd6657df0ebb6d5441821378a3b1ff17f2a625021cc5",
20651
20794
  groups: "76acc9598202663738d7d2903ca1a042d9b7ca21799297946e4da39ea77d5250",
20652
- generic: "6c7570711462e9a9af94faac45f56414fd97a1681608be03299f6fa756eaa41c"
20795
+ generic: "9987467e7d99ff4680fa6d7e2d2d634455f729958bfbd53ebac86c14508b031d"
20653
20796
  });
20654
20797
  function fill(key, text2, vars) {
20655
20798
  return text2.replace(PLACEHOLDER, (whole, name) => {
@@ -20693,6 +20836,7 @@ ${key}`);
20693
20836
  return target !== void 0 ? t(target) : section3(key) ?? value;
20694
20837
  },
20695
20838
  row: (requirementRef, part) => context.singleContract ? section3(`row.${requirementRef}.${part}`) : void 0,
20839
+ reason: (requirementRef, code2) => context.singleContract ? section3(`row.${requirementRef}.reason.${code2}`) : void 0,
20696
20840
  group: (segment) => context.singleContract ? section3(`group.${segment}.title`) : void 0,
20697
20841
  grouping,
20698
20842
  source: supplied === void 0 ? {
@@ -24353,6 +24497,9 @@ ${key}`);
24353
24497
  .gr .rname{font-weight:600;color:var(--navy)}
24354
24498
  .gr .rname code,.gr .cid{font-family:ui-monospace,Menlo,monospace;font-size:12.5px;word-break:break-all}
24355
24499
  .gr ul.claims{list-style:none;margin:6px 0 0;padding:0}
24500
+ .gr .rreason,.gr .rflag{font-size:12.5px;border-radius:6px;padding:2px 8px;background:#EEF0F3;color:var(--slate)}
24501
+ .gr .rreason{margin:4px 0 6px 22px}
24502
+ .gr .rreason[data-tone="warn"],.gr .rflag[data-tone="warn"]{background:var(--bad-l);color:var(--bad);font-weight:700}
24356
24503
  .gr .tier-note{font-size:12.5px;color:var(--slate)}
24357
24504
  ` + levelCss("gr") + frontCss(".gr")
24358
24505
  };
@@ -24444,18 +24591,48 @@ ${key}`);
24444
24591
  if (mark !== void 0) body.append(mark);
24445
24592
  return body;
24446
24593
  }
24447
- function claimItem(claim, w) {
24594
+ function reasonLines(claim, w, reasons) {
24595
+ const found = reasons?.get(claim.id);
24596
+ if (found === void 0) return [];
24597
+ const { code: code2 } = found;
24598
+ const packText = found.keyable ? w.reason(claim.requirementRef, code2) : void 0;
24599
+ const coreText = packText === void 0 && found.core ? w.t(`generic.reason.token.${code2}`) : void 0;
24600
+ const text2 = packText ?? coreText;
24601
+ const line = el10("p", "rreason");
24602
+ line.dataset.reasonCode = code2;
24603
+ line.dataset.reasonKind = found.kind;
24604
+ line.dataset.tone = found.kind === "finding" ? "warn" : "note";
24605
+ if (claim.later) line.append(w.t("generic.later.readiness"), " ");
24606
+ if (claim.verdict !== "not_evaluable")
24607
+ line.append(
24608
+ w.t("generic.reason.grade", { grade: w.enumWord("grade", claim.grade) }),
24609
+ " "
24610
+ );
24611
+ line.append(
24612
+ tagSource(
24613
+ el10(
24614
+ "span",
24615
+ "",
24616
+ text2 !== void 0 ? w.t("generic.reason.says", { text: text2 }) : w.t("generic.reason.unworded", { code: code2 })
24617
+ ),
24618
+ packText !== void 0 ? "pack" : "core"
24619
+ )
24620
+ );
24621
+ return [line];
24622
+ }
24623
+ function claimItem(claim, w, reasons) {
24448
24624
  const item = el10("li", "");
24449
24625
  item.dataset.claimRef = claim.id;
24450
24626
  const head2 = el10("span", "");
24451
24627
  const id = tagSource(el10("code", "cid", claim.id), "producer");
24452
24628
  head2.append(id, " ", verdictPill(shownVerdict(claim), w));
24453
24629
  item.append(
24454
- levelToggle(2, head2, () => claimProofs(claim, w), { className: "claim" })
24630
+ levelToggle(2, head2, () => claimProofs(claim, w), { className: "claim" }),
24631
+ ...reasonLines(claim, w, reasons)
24455
24632
  );
24456
24633
  return item;
24457
24634
  }
24458
- function rowItem(row2, w, later, tierOf) {
24635
+ function rowItem(row2, w, later, tierOf, reasons) {
24459
24636
  const label = w.row(row2.requirementRef, "label");
24460
24637
  const name = el10("span", "rname");
24461
24638
  if (label !== void 0)
@@ -24470,6 +24647,14 @@ ${key}`);
24470
24647
  summary.append(" ", chip);
24471
24648
  }
24472
24649
  summary.append(tally(row2, w, later));
24650
+ const given = row2.claims.filter((claim) => reasons?.has(claim.id));
24651
+ if (given.length > 0) {
24652
+ const flag = el10("span", "rflag", w.p("generic.reason.flag", given.length));
24653
+ flag.dataset.tone = given.some(
24654
+ (claim) => reasons.get(claim.id).kind === "finding"
24655
+ ) ? "warn" : "note";
24656
+ summary.append(" ", flag);
24657
+ }
24473
24658
  const toggle = levelToggle(
24474
24659
  1,
24475
24660
  summary,
@@ -24490,7 +24675,7 @@ ${key}`);
24490
24675
  ))
24491
24676
  body.append(el10("p", "rnote", w.t("generic.later.note", { date })));
24492
24677
  const list2 = el10("ul", "claims");
24493
- for (const claim of row2.claims) list2.append(claimItem(claim, w));
24678
+ for (const claim of row2.claims) list2.append(claimItem(claim, w, reasons));
24494
24679
  body.append(el10("h3", "", w.t("generic.claims.h")), list2);
24495
24680
  return body;
24496
24681
  },
@@ -24500,7 +24685,7 @@ ${key}`);
24500
24685
  toggle.dataset.contract = row2.contractRef;
24501
24686
  return toggle;
24502
24687
  }
24503
- function groupedRows(rows, w, later, tierOf) {
24688
+ function groupedRows(rows, w, later, tierOf, reasons) {
24504
24689
  const box = el10("div", "groups");
24505
24690
  const order = [];
24506
24691
  const byGroup = /* @__PURE__ */ new Map();
@@ -24525,7 +24710,7 @@ ${key}`);
24525
24710
  part.append(heading);
24526
24711
  }
24527
24712
  for (const row2 of byGroup.get(group))
24528
- part.append(rowItem(row2, w, later, tierOf));
24713
+ part.append(rowItem(row2, w, later, tierOf, reasons));
24529
24714
  box.append(part);
24530
24715
  }
24531
24716
  return box;
@@ -24535,9 +24720,10 @@ ${key}`);
24535
24720
  heading.append(" ", tagSource(el10("code", "", contract), "producer"));
24536
24721
  return heading;
24537
24722
  }
24538
- function byContract(rows, w, later, tierOf) {
24723
+ function byContract(rows, w, later, tierOf, reasons) {
24539
24724
  const contracts = [...new Set(rows.map((row2) => row2.contractRef))];
24540
- if (contracts.length <= 1) return groupedRows(rows, w, later, tierOf);
24725
+ if (contracts.length <= 1)
24726
+ return groupedRows(rows, w, later, tierOf, reasons);
24541
24727
  const box = el10("div", "contracts");
24542
24728
  for (const contract of contracts) {
24543
24729
  const part = el10("div", "contract");
@@ -24548,14 +24734,15 @@ ${key}`);
24548
24734
  rows.filter((row2) => row2.contractRef === contract),
24549
24735
  w,
24550
24736
  later,
24551
- tierOf
24737
+ tierOf,
24738
+ reasons
24552
24739
  )
24553
24740
  );
24554
24741
  box.append(part);
24555
24742
  }
24556
24743
  return box;
24557
24744
  }
24558
- async function drawGeneric(levels, result3, bundle, verified, w, tierOf) {
24745
+ async function drawGeneric(levels, result3, bundle, verified, w, tierOf, reasons) {
24559
24746
  const tierFor = (claim) => tierOf === void 0 ? "unstated" : tierOf(claim.contractRef, claim.requirementRef);
24560
24747
  const inForce = result3.claims.filter((claim) => !claim.later);
24561
24748
  const later = result3.claims.filter((claim) => claim.later);
@@ -24580,7 +24767,8 @@ ${key}`);
24580
24767
  const section = el10("section", "front-card");
24581
24768
  section.dataset.section = "rows";
24582
24769
  const rows = rowsOf(inForce);
24583
- if (tierOf === void 0) section.append(byContract(rows, w, false));
24770
+ if (tierOf === void 0)
24771
+ section.append(byContract(rows, w, false, void 0, reasons));
24584
24772
  else
24585
24773
  for (const tier of ROW_TIERS) {
24586
24774
  const inTier = rows.filter(
@@ -24598,7 +24786,7 @@ ${key}`);
24598
24786
  })
24599
24787
  ),
24600
24788
  el10("p", "rnote", w.t(`generic.rtier.${tier}.note`)),
24601
- byContract(inTier, w, false, tierOf)
24789
+ byContract(inTier, w, false, tierOf, reasons)
24602
24790
  );
24603
24791
  section.append(part);
24604
24792
  }
@@ -24612,7 +24800,7 @@ ${key}`);
24612
24800
  "",
24613
24801
  w.t("generic.later.title", { n: later.length.toLocaleString() })
24614
24802
  ),
24615
- byContract(laterRows, w, true, tierOf)
24803
+ byContract(laterRows, w, true, tierOf, reasons)
24616
24804
  );
24617
24805
  section.append(part);
24618
24806
  }
@@ -24745,7 +24933,18 @@ ${key}`);
24745
24933
  w,
24746
24934
  tierOf
24747
24935
  );
24748
- else await drawGeneric(levels, result3, bundle, verified, w, tierOf);
24936
+ else
24937
+ await drawGeneric(
24938
+ levels,
24939
+ result3,
24940
+ bundle,
24941
+ verified,
24942
+ w,
24943
+ tierOf,
24944
+ // The pack's `row.<ref>.reason.<code>` words apply only to a Result
24945
+ // citing one contract (the Words gate); the reason itself shows always.
24946
+ input.reasons
24947
+ );
24749
24948
  regions.L0.append(levels.L0);
24750
24949
  regions.L1.append(levels.L1);
24751
24950
  regions.L2.append(levels.L2);
@@ -25368,9 +25567,9 @@ ${key}`);
25368
25567
  const hex6 = typeof raw.signature === "string" ? raw.signature : void 0;
25369
25568
  const view = hex6 === void 0 ? void 0 : readEnvelope(hex6);
25370
25569
  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);
25570
+ const none2 = el11("p", "l3-note", w.t("record.envelope.none"));
25571
+ none2.dataset.l3 = "no-envelope";
25572
+ card2.append(none2);
25374
25573
  } else if (view === void 0) {
25375
25574
  const bad2 = el11("p", "l3-note", w.t("record.envelope.unreadable"));
25376
25575
  bad2.dataset.l3 = "unreadable-envelope";
@@ -28007,7 +28206,10 @@ ${pad.repeat(depth)}`;
28007
28206
  CONTRACT_REPORT_MANIFEST.id
28008
28207
  );
28009
28208
  const supported = contractReportInput(context.bundle);
28010
- const input = supported === void 0 ? { grouping: "generic" } : claimsFitCard(result3, supported.grouping) ? supported : void 0;
28209
+ const input = supported === void 0 ? {
28210
+ grouping: "generic",
28211
+ reasons: claimReasons(result3.claims)
28212
+ } : claimsFitCard(result3, supported.grouping) ? supported : void 0;
28011
28213
  if (typeof context.bundle === "object" && context.bundle !== null)
28012
28214
  contractReportDrawn.set(
28013
28215
  context.bundle,
@@ -29275,6 +29477,69 @@ ${pad.repeat(depth)}`;
29275
29477
  return result2("NOT_CHECKED");
29276
29478
  }
29277
29479
 
29480
+ // src/card-registered.ts
29481
+ var MAX_CARD_STATEMENTS = 64;
29482
+ var MAX_STATEMENT_HEX = 2 * 10485760;
29483
+ var HEX2 = /^(?:[0-9a-f]{2})+$/u;
29484
+ var ANCHOR = /^[0-9a-f]{64}$/u;
29485
+ var none = (status2, statements = [], keyId = null) => ({
29486
+ status: status2,
29487
+ service: null,
29488
+ registration_time: null,
29489
+ statements,
29490
+ key_id: keyId
29491
+ });
29492
+ var fromHex4 = (hex6) => {
29493
+ const out = new Uint8Array(new ArrayBuffer(hex6.length / 2));
29494
+ for (let i = 0; i < out.length; i += 1)
29495
+ out[i] = Number.parseInt(hex6.slice(2 * i, 2 * i + 2), 16);
29496
+ return out;
29497
+ };
29498
+ async function cardRegisteredUnder(card2, key, anchor, statements, policy) {
29499
+ const report = await checkCardRegistered(
29500
+ card2,
29501
+ key,
29502
+ anchor,
29503
+ statements.map(
29504
+ (s) => HEX2.test(s) && s.length <= MAX_STATEMENT_HEX ? fromHex4(s) : new Uint8Array(0)
29505
+ ),
29506
+ policy
29507
+ );
29508
+ return {
29509
+ status: report.status,
29510
+ service: report.service,
29511
+ registration_time: report.registration_time,
29512
+ statements: report.statements,
29513
+ key_id: key
29514
+ };
29515
+ }
29516
+ async function readerCardRegistered(context, statements) {
29517
+ if (statements === null || statements.length === 0)
29518
+ return none("NOT_PRESENT");
29519
+ try {
29520
+ if (statements.length > MAX_CARD_STATEMENTS || statements.some((s) => typeof s !== "string"))
29521
+ return none("NOT_CHECKED");
29522
+ if (!isVerifiedBundleContext(context)) return none("NOT_CHECKED");
29523
+ const signature2 = await readerCardSignature(context);
29524
+ const disclosed = context.root ? context.resolvedDisclosures.get(context.root)?.agent_input : void 0;
29525
+ if (signature2.status !== "PASS" || signature2.key_id === null || disclosed === void 0 || disclosed.state !== "disclosed")
29526
+ return none("NOT_CHECKED");
29527
+ const card2 = disclosed.payload;
29528
+ const anchor = card2 !== null && typeof card2 === "object" ? card2.anchor : void 0;
29529
+ if (typeof anchor !== "string" || !ANCHOR.test(anchor))
29530
+ return none("NOT_CHECKED");
29531
+ return await cardRegisteredUnder(
29532
+ jcs(card2),
29533
+ signature2.key_id,
29534
+ anchor,
29535
+ statements,
29536
+ readerWitnessPolicy()
29537
+ );
29538
+ } catch {
29539
+ return none("NOT_CHECKED");
29540
+ }
29541
+ }
29542
+
29278
29543
  // src/wording/history-view.en.json
29279
29544
  var history_view_en_default = {
29280
29545
  wording_pack_version: "0",