@coreguard/agent-commerce 0.3.0 → 0.4.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.
package/README.md CHANGED
@@ -12,7 +12,7 @@ bytes approved, and for verifying any executed trace against that receipt.
12
12
  - **Fail-closed execution verification** — a consent plus an executed trace
13
13
  yields a verdict with named drift classes (AGR/1 taxonomy); incomplete or
14
14
  ambiguous evidence is never treated as a pass.
15
- - **stdio MCP server** (JSON-RPC 2.0, protocol `2025-06-18`) exposing forty-six tools,
15
+ - **stdio MCP server** (JSON-RPC 2.0, protocol `2025-06-18`) exposing 94 tools,
16
16
  all offline, all deterministic, zero keys.
17
17
 
18
18
  MIT. Node ≥ 18. No network calls, no stored credentials, no wall clock.
@@ -349,7 +349,7 @@ License: MIT.
349
349
 
350
350
  ## Release readiness / MCPRush evidence
351
351
 
352
- - **Release notes:** `docs/releases/0.2.1.md` (latest) · `docs/releases/0.2.0.md`
352
+ - **Release notes:** `docs/releases/0.3.0.md` (latest) · `docs/releases/0.2.1.md`
353
353
  - **Publish readiness checklist:** `docs/releases/0.1.3-publish-readiness.md`
354
354
  - **Security & threat model:** `docs/agent-commerce-mcp-security.md`
355
355
  - **Client compatibility matrix + run log:** `docs/agent-commerce-mcp-compatibility.md`
package/mcp.mjs CHANGED
@@ -7,7 +7,7 @@
7
7
  * (one JSON object per line, both directions) — the same shape MCP clients
8
8
  * speak for stdio servers.
9
9
  *
10
- * Tools (all offline/self-hosted, deterministic, zero network keys): 10 core consent/verification tools + 10 Wave 1 Machine Economy tools + 6 Wave 2 CGCP/1 mapping tools (intent/receipt/limits/revoke/audit) + 20 Wave 3 tools (policy reasoning, MCP supply-chain audit, evidence, operations, interop) = 46 total. Optional trust roots enable Ed25519 signature verification for telemetry/delegation; no custody, no broadcast, no network calls; external settlement/physical truth/device identity beyond supplied key material NOT proven.
10
+ * Tools (all offline/self-hosted, deterministic, zero network keys): 10 core consent/verification tools + 10 Wave 1 Machine Economy tools + 6 Wave 2 CGCP/1 mapping tools (intent/receipt/limits/revoke/audit) + 20 Wave 3 tools (policy reasoning, MCP supply-chain audit, evidence, operations, interop) + 24 Wave 4 tools (cross-border/bank/chain/machine/loan evidence) + 24 Wave 5 tools (authority, KYC/AML, reconciliation, chain evidence, machine economy, evidence packs) = 94 total. Optional trust roots enable Ed25519 signature verification for telemetry/delegation; no custody, no broadcast, no network calls; external settlement/physical truth/device identity beyond supplied key material NOT proven.
11
11
  *
12
12
  * BOUNDARIES (standing): synthetic demo data is the caller's; nothing here
13
13
  * contacts any platform or payment network (no contact/integration/endorsement
@@ -59,6 +59,7 @@ import {
59
59
  import { createIntent, issueReceipt, verifyReceipt as verifyCgcpReceipt, checkLimits, revokeConsent, auditTransaction, CGCP_MCP_BOUNDARY } from "./cgcp-mcp-tools.mjs";
60
60
  import { WAVE3_TOOLS, WAVE3_HANDLERS, WAVE3_VALIDATORS, WAVE3_BOUNDARY } from "./wave3.mjs";
61
61
  import { WAVE4_TOOLS, WAVE4_HANDLERS, WAVE4_VALIDATORS, WAVE4_BOUNDARY } from "./wave4.mjs";
62
+ import { WAVE5_TOOLS, WAVE5_HANDLERS, WAVE5_VALIDATORS, WAVE5_BOUNDARY } from "./wave5.mjs";
62
63
 
63
64
  const PROTOCOL_VERSION = "2025-06-18";
64
65
 
@@ -153,6 +154,31 @@ const TOOL_NAMES = Object.freeze([
153
154
  "coreguard_assess_credit_line_utilization",
154
155
  "coreguard_verify_escrow_milestone",
155
156
  "coreguard_create_incident_war_room",
157
+ // Wave 5 (CG-W5/1) — authority, KYC/AML, reconciliation, chain evidence and machine economy. Offline, caller-supplied evidence only.
158
+ "coreguard_canonicalize_payment_instruction",
159
+ "coreguard_verify_payment_authorization_chain",
160
+ "coreguard_verify_kyc_evidence",
161
+ "coreguard_verify_ubo_evidence",
162
+ "coreguard_verify_travel_rule_packet",
163
+ "coreguard_verify_aml_alert_disposition",
164
+ "coreguard_verify_sanctions_list_version",
165
+ "coreguard_verify_fx_rate_lock",
166
+ "coreguard_reconcile_multi_ledger",
167
+ "coreguard_verify_camt054_notification",
168
+ "coreguard_verify_mt103_fields",
169
+ "coreguard_verify_beneficiary_change",
170
+ "coreguard_verify_stellar_path_payment",
171
+ "coreguard_verify_evm_permit_evidence",
172
+ "coreguard_verify_coredao_delegation_evidence",
173
+ "coreguard_verify_pi_attestation_chain",
174
+ "coreguard_verify_erc4337_userop_evidence",
175
+ "coreguard_verify_token_approval_revocation",
176
+ "coreguard_create_machine_budget_lease",
177
+ "coreguard_verify_machine_budget_consumption",
178
+ "coreguard_verify_robot_handoff_chain",
179
+ "coreguard_verify_agent_authority_intersection",
180
+ "coreguard_create_inference_receipt",
181
+ "coreguard_export_evidence_pack",
156
182
  ]);
157
183
 
158
184
  /**
@@ -208,6 +234,7 @@ function requireString(args, key) {
208
234
  const VALIDATORS = Object.freeze({
209
235
  ...WAVE3_VALIDATORS,
210
236
  ...WAVE4_VALIDATORS,
237
+ ...WAVE5_VALIDATORS,
211
238
  coreguard_authorize(args) {
212
239
  const missing = requireObjects(args, ["intent", "policy", "declaredTrace"]);
213
240
  if (missing) return missing;
@@ -713,6 +740,7 @@ const TOOLS = Object.freeze([
713
740
  },
714
741
  ...WAVE3_TOOLS,
715
742
  ...WAVE4_TOOLS,
743
+ ...WAVE5_TOOLS,
716
744
  ]);
717
745
 
718
746
  function withCallerContext(value, args) {
@@ -808,6 +836,10 @@ async function callTool(name, args, { consumedSet } = {}) {
808
836
  const ctx = { toolNames: TOOL_NAMES, version: PACKAGE.version, serverName: SERVER_INFO.name, protocolVersion: PROTOCOL_VERSION };
809
837
  return success(withCallerContext(WAVE4_HANDLERS[name](a, ctx), a));
810
838
  }
839
+ if (WAVE5_HANDLERS[name]) {
840
+ const ctx = { toolNames: TOOL_NAMES, version: PACKAGE.version, serverName: SERVER_INFO.name, protocolVersion: PROTOCOL_VERSION };
841
+ return success(withCallerContext(WAVE5_HANDLERS[name](a, ctx), a));
842
+ }
811
843
  return failure(ERROR_CODES.UNKNOWN_TOOL, `unknown tool: ${String(name)}`);
812
844
  } catch (err) {
813
845
  return failure(ERROR_CODES.TOOL_ERROR, err?.message ?? String(err));
@@ -872,10 +904,12 @@ export function createMcpHandler({ write } = {}) {
872
904
 
873
905
  export function selfCheck() {
874
906
  return [
875
- ["tools exposed", TOOL_NAMES.length === 70 && TOOL_NAMES[0] === "coreguard_authorize" && TOOL_NAMES[9] === "coreguard_consumption_status" && TOOL_NAMES[19] === "coreguard_verify_delegation_chain" && TOOL_NAMES[25] === "coreguard_audit_transaction" && TOOL_NAMES[45] === "coreguard_describe_surface" && TOOL_NAMES[69] === "coreguard_create_incident_war_room"],
907
+ ["tools exposed", TOOL_NAMES.length === 94 && TOOL_NAMES[0] === "coreguard_authorize" && TOOL_NAMES[9] === "coreguard_consumption_status" && TOOL_NAMES[19] === "coreguard_verify_delegation_chain" && TOOL_NAMES[25] === "coreguard_audit_transaction" && TOOL_NAMES[45] === "coreguard_describe_surface" && TOOL_NAMES[69] === "coreguard_create_incident_war_room" && TOOL_NAMES[93] === "coreguard_export_evidence_pack"],
876
908
  ["wave 3 declares schemas for every tool", WAVE3_TOOLS.length === 20 && WAVE3_TOOLS.every((t) => t.name.startsWith("coreguard_") && t.inputSchema?.required?.length > 0 && t.outputSchema?.type === "object" && WAVE3_HANDLERS[t.name])],
877
909
  ["wave 4 declares schemas for every tool", WAVE4_TOOLS.length === 24 && WAVE4_TOOLS.every((t) => t.name.startsWith("coreguard_") && t.inputSchema && t.outputSchema?.type === "object" && WAVE4_HANDLERS[t.name])],
878
910
  ["wave 4 boundary travels", WAVE4_BOUNDARY.includes("VERIFIED ≠ SAFE")],
911
+ ["wave 5 declares schemas for every tool", WAVE5_TOOLS.length === 24 && WAVE5_TOOLS.every((t) => t.name.startsWith("coreguard_") && t.inputSchema?.required?.length > 0 && t.outputSchema?.type === "object" && WAVE5_HANDLERS[t.name])],
912
+ ["wave 5 boundary travels", WAVE5_BOUNDARY.includes("VERIFIED ≠ SAFE") && WAVE5_BOUNDARY.includes("no settlement finality")],
879
913
  ["wave 3 boundary travels", WAVE3_BOUNDARY.includes("VERIFIED ≠ SAFE")],
880
914
  ["protocol version pinned", PROTOCOL_VERSION === "2025-06-18"],
881
915
  ["spec surfaced", CONSENT_SPEC === "CGCR/1" && AGENT_COMMERCE_VERSION === "AC-SDK/1"],
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@coreguard/agent-commerce",
3
- "version": "0.3.0",
4
- "description": "CoreGuard Agent Commerce: consent receipts (CGCR/1) and fail-closed execution verification (AGR/1) for agentic purchases — SDK, REST surface, and a stdio MCP server (70 tools, JSON-RPC 2.0, offline, zero keys)",
3
+ "version": "0.4.0",
4
+ "description": "CoreGuard Agent Commerce: consent receipts (CGCR/1) and fail-closed execution verification (AGR/1) for agentic purchases — SDK, REST surface, and a stdio MCP server (94 tools, JSON-RPC 2.0, offline, zero keys)",
5
5
  "type": "module",
6
6
  "main": "./index.mjs",
7
7
  "exports": {
@@ -37,7 +37,8 @@
37
37
  "./prod/kms-anchor.mjs": "./prod/kms-anchor.mjs",
38
38
  "./machine-economy.mjs": "./machine-economy.mjs",
39
39
  "./cgcp-mcp-tools.mjs": "./cgcp-mcp-tools.mjs",
40
- "./wave4.mjs": "./wave4.mjs"
40
+ "./wave4.mjs": "./wave4.mjs",
41
+ "./wave5.mjs": "./wave5.mjs"
41
42
  },
42
43
  "bin": {
43
44
  "coreguard-agent-commerce-mcp": "./bin/mcp.mjs",
@@ -85,7 +86,8 @@
85
86
  "trust-card.mjs",
86
87
  "trust.mjs",
87
88
  "wave3.mjs",
88
- "wave4.mjs"
89
+ "wave4.mjs",
90
+ "wave5.mjs"
89
91
  ],
90
92
  "engines": {
91
93
  "node": ">=18"
package/server.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
3
  "name": "io.github.EslaM-X/coreguard-agent-commerce",
4
- "description": "Fail-closed consent receipts and execution verification for agentic purchases. 70 MCP tools.",
4
+ "description": "Fail-closed consent receipts and execution verification for agentic purchases. 94 MCP tools.",
5
5
  "repository": {
6
6
  "url": "https://github.com/coreguard-global/CoreGuard",
7
7
  "source": "github"
8
8
  },
9
- "version": "0.3.0",
9
+ "version": "0.4.0",
10
10
  "packages": [
11
11
  {
12
12
  "registryType": "npm",
13
13
  "identifier": "@coreguard/agent-commerce",
14
- "version": "0.3.0",
14
+ "version": "0.4.0",
15
15
  "transport": {
16
16
  "type": "stdio"
17
17
  }
package/wave5.mjs ADDED
@@ -0,0 +1,698 @@
1
+ /**
2
+ * CoreGuard Agent Commerce — Wave 5 (CG-W5/1)
3
+ *
4
+ * "Financial Operations & Machine-Economy Authority" — deterministic, offline
5
+ * evidence tools for payment authorization, KYC/AML/travel-rule packets,
6
+ * multi-ledger reconciliation, chain-specific settlement evidence, agent
7
+ * authority, robot handoffs, inference receipts, and evidence-pack export.
8
+ *
9
+ * Every input is caller-supplied. No live bank, SWIFT, card, PI, Stellar,
10
+ * Ethereum, Core DAO, DeFi, credit-bureau or regulator call is performed.
11
+ * VERIFIED ≠ SAFE: a verdict describes the supplied evidence only. It is not
12
+ * settlement finality, sanctions clearance, KYC/AML approval, model correctness
13
+ * or a compliance certification.
14
+ */
15
+
16
+ import { createHash } from "node:crypto";
17
+
18
+ export const WAVE5_VERSION = "CG-W5/1";
19
+ export const WAVE5_BOUNDARY =
20
+ "Wave 5 is deterministic, offline verification over caller-supplied evidence. " +
21
+ "It does not contact SWIFT, banks, card networks, PI Network, Stellar Horizon, Ethereum RPC, Core DAO, DeFi protocols, credit bureaus, regulators, KYC providers or sanctions lists. " +
22
+ "Outputs are evidence/risk signals only; VERIFIED ≠ SAFE; no settlement finality, sanctions clearance, KYC/AML approval, model correctness or compliance certification is claimed.";
23
+
24
+ const isObj = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
25
+ const arr = (v) => Array.isArray(v) ? v : [];
26
+ const str = (v) => typeof v === "string" ? v : "";
27
+ const num = (v) => typeof v === "number" && Number.isFinite(v) ? v : null;
28
+ const dec = (v) => { if (typeof v === "string" && /^-?[0-9]+(\.[0-9]+)?$/.test(v)) return v; if (Number.isInteger(v)) return String(v); return null; };
29
+ const decInt = (v) => { if (typeof v === "string" && /^[0-9]+$/.test(v)) return BigInt(v); if (Number.isInteger(v) && v >= 0) return BigInt(v); return null; };
30
+ const lower = (v) => str(v).toLowerCase();
31
+ const upper = (v) => str(v).toUpperCase();
32
+
33
+ const SHA256 = /^sha256:[0-9a-f]{64}$/;
34
+
35
+ /**
36
+ * Deterministic JSON projection for digest input. JSON-RPC cannot carry
37
+ * BigInt/circular values, but the exported SDK can; a digest must never throw
38
+ * and must never silently drop a value. Unsupported leaves are tagged inline.
39
+ */
40
+ export function canonicalJson(value, seen = new WeakSet()) {
41
+ if (typeof value === "bigint") return JSON.stringify(`bigint:${value.toString()}`);
42
+ if (value === null || value === undefined) return "null";
43
+ if (typeof value !== "object") {
44
+ if (typeof value === "number" && !Number.isFinite(value)) return "null";
45
+ if (["string", "boolean", "number"].includes(typeof value)) return JSON.stringify(value);
46
+ return JSON.stringify(`unsupported:${typeof value}`);
47
+ }
48
+ if (seen.has(value)) return JSON.stringify("[CIRCULAR]");
49
+ seen.add(value);
50
+ try {
51
+ if (Array.isArray(value)) return "[" + value.map((v) => canonicalJson(v, seen)).join(",") + "]";
52
+ return "{" + Object.keys(value).sort().map((k) => JSON.stringify(k) + ":" + canonicalJson(value[k], seen)).join(",") + "}";
53
+ } finally {
54
+ seen.delete(value);
55
+ }
56
+ }
57
+ export function digestOf(value) { return "sha256:" + createHash("sha256").update(canonicalJson(value)).digest("hex"); }
58
+
59
+ /** Deep redaction for exported evidence packs: nested named keys are removed too. */
60
+ function deepRedact(value, fields, seen = new WeakSet()) {
61
+ if (value === null || typeof value !== "object") return value;
62
+ if (seen.has(value)) return "[CIRCULAR]";
63
+ seen.add(value);
64
+ try {
65
+ if (Array.isArray(value)) return value.map((v) => deepRedact(v, fields, seen));
66
+ const redacted = {};
67
+ for (const [k, v] of Object.entries(value)) redacted[k] = fields.includes(k) ? "[REDACTED]" : deepRedact(v, fields, seen);
68
+ return redacted;
69
+ } finally {
70
+ seen.delete(value);
71
+ }
72
+ }
73
+
74
+ function ok(type, fields) { return { type, spec: WAVE5_VERSION, status: "OK", ...fields, boundary: WAVE5_BOUNDARY }; }
75
+ function refusal(type, code, detail, fields = {}) { return { type, spec: WAVE5_VERSION, status: "REFUSED", refusal: { code, detail }, ...fields, boundary: WAVE5_BOUNDARY }; }
76
+ function check(id, okv, severity, detail, evidence = {}) { return { id, ok: !!okv, severity, detail, evidence }; }
77
+ function summarizeChecks(checks) {
78
+ const failed = checks.filter((c) => !c.ok);
79
+ const critical = failed.filter((c) => c.severity === "CRITICAL");
80
+ const high = failed.filter((c) => c.severity === "HIGH");
81
+ return { verdict: critical.length ? "FAIL" : high.length ? "WARN" : failed.length ? "WARN" : "PASS", checks, failed: failed.map((c) => c.id), critical: critical.map((c) => c.id) };
82
+ }
83
+ function requireObj(args, key, type) {
84
+ if (!isObj(args) || !isObj(args[key])) return refusal(type, "INVALID_ARGUMENT", `${key} must be an object`, { field: key });
85
+ return null;
86
+ }
87
+ function requireArr(args, key, type) {
88
+ if (!isObj(args) || !Array.isArray(args[key])) return refusal(type, "INVALID_ARGUMENT", `${key} must be an array`, { field: key });
89
+ return null;
90
+ }
91
+ const allPresent = (values) => values.every((v) => str(v).length > 0);
92
+ const sorted = (values) => [...new Set(arr(values).map(str).filter(Boolean))].sort();
93
+
94
+ // 1 — canonicalize a payment instruction into an approval-ready object.
95
+ export function canonicalizePaymentInstruction(args = {}) {
96
+ const bad = requireObj(args, "instruction", "canonicalize_payment_instruction"); if (bad) return bad;
97
+ const i = args.instruction;
98
+ const canonical = {
99
+ instructionId: str(i.instructionId || i.id),
100
+ payerId: str(i.payerId || i.debtorId),
101
+ payeeId: str(i.payeeId || i.creditorId),
102
+ amountMinor: decInt(i.amountMinor)?.toString() ?? null,
103
+ currency: upper(str(i.currency)),
104
+ purpose: str(i.purpose || i.purposeCode),
105
+ corridor: `${upper(str(i.sourceCountry))}->${upper(str(i.destinationCountry))}`,
106
+ };
107
+ const checks = [
108
+ check("INSTRUCTION_ID", !!canonical.instructionId, "HIGH", "instructionId present"),
109
+ check("PAYER", !!canonical.payerId, "HIGH", "payerId present"),
110
+ check("PAYEE", !!canonical.payeeId, "CRITICAL", "payeeId present"),
111
+ check("AMOUNT", canonical.amountMinor !== null, "CRITICAL", "amountMinor is a digit string"),
112
+ check("CURRENCY", !!canonical.currency, "CRITICAL", "currency present"),
113
+ ];
114
+ return ok("canonicalize_payment_instruction", { canonical, digest: digestOf(canonical), ...summarizeChecks(checks) });
115
+ }
116
+
117
+ // 2 — verify a delegation/authorization chain with scope inheritance.
118
+ export function verifyPaymentAuthorizationChain(args = {}) {
119
+ const bad = requireArr(args, "chain", "verify_payment_authorization_chain"); if (bad) return bad;
120
+ const chain = args.chain.filter(isObj);
121
+ const now = decInt(args.nowSeconds);
122
+ const edges = chain.map((link) => ({
123
+ delegator: str(link.delegator), delegate: str(link.delegate),
124
+ scope: sorted(link.scope), expiresAtSeconds: decInt(link.expiresAtSeconds)?.toString() ?? null,
125
+ signature: !!str(link.signature),
126
+ }));
127
+ const continuous = edges.length > 1 && edges.slice(1).every((e, idx) => e.delegator === edges[idx].delegate);
128
+ const expired = edges.filter((e) => e.expiresAtSeconds !== null && now !== null && BigInt(e.expiresAtSeconds) < now);
129
+ const scopeIntersection = edges.length ? edges.reduce((acc, e) => acc.filter((s) => e.scope.includes(s)), [...edges[0].scope]) : [];
130
+ const checks = [
131
+ check("LINKS", edges.length > 0, "CRITICAL", `${edges.length} authorization links`),
132
+ check("CONTINUOUS", continuous, "CRITICAL", "each delegate is the next delegator"),
133
+ check("SCOPE_PRESENT", edges.every((e) => e.scope.length > 0), "CRITICAL", "every link carries at least one scope"),
134
+ check("NOT_EXPIRED", now !== null ? expired.length === 0 : true, "HIGH", `expired links: ${expired.length}`),
135
+ check("SIGNATURES", edges.every((e) => e.signature), "HIGH", "every link carries a caller-supplied signature marker"),
136
+ ];
137
+ return ok("verify_payment_authorization_chain", {
138
+ root: edges[0]?.delegator ?? null, terminal: edges.at(-1)?.delegate ?? null,
139
+ scopeIntersection, expiredLinks: expired.map((e) => e.delegate), chainDigest: digestOf(edges), ...summarizeChecks(checks),
140
+ });
141
+ }
142
+
143
+ // 3 — KYC evidence freshness/completeness gate (no live KYC provider).
144
+ export function verifyKycEvidence(args = {}) {
145
+ const badE = requireObj(args, "evidence", "verify_kyc_evidence"); if (badE) return badE;
146
+ const badP = requireObj(args, "policy", "verify_kyc_evidence"); if (badP) return badP;
147
+ const e = args.evidence, p = args.policy;
148
+ const now = decInt(args.nowSeconds), at = decInt(e.checkedAtSeconds), maxAge = decInt(p.maxAgeSeconds);
149
+ const fresh = now !== null && at !== null && maxAge !== null ? (now >= at && now - at <= maxAge) : false;
150
+ const requiredDocuments = sorted(p.requiredDocuments);
151
+ const held = sorted(e.documentDigests);
152
+ const missing = requiredDocuments.filter((d) => !held.includes(d));
153
+ const providers = sorted(p.allowedProviders);
154
+ const checks = [
155
+ check("SUBJECT", !!str(e.subjectId), "CRITICAL", "subjectId present"),
156
+ check("RESULT", ["CLEAR", "VERIFIED", "PASS"].includes(upper(str(e.result))), "CRITICAL", `result=${str(e.result)}`),
157
+ check("FRESH", fresh, "HIGH", "KYC evidence is fresh at pinned nowSeconds"),
158
+ check("DOCUMENTS", missing.length === 0, "HIGH", `missing document digests: ${missing.join(", ") || "none"}`),
159
+ check("PROVIDER", !providers.length || providers.includes(str(e.providerId)), "MEDIUM", "provider allowed when an allowlist is supplied"),
160
+ ];
161
+ const out = ok("verify_kyc_evidence", { subjectId: str(e.subjectId), fresh, missingDocuments: missing, ...summarizeChecks(checks) });
162
+ out.boundary = WAVE5_BOUNDARY + " KYC evidence is caller-supplied; no identity provider, document registry or regulator decision is contacted.";
163
+ return out;
164
+ }
165
+
166
+ // 4 — beneficial-ownership packet consistency.
167
+ export function verifyUboEvidence(args = {}) {
168
+ const badE = requireObj(args, "entity", "verify_ubo_evidence"); if (badE) return badE;
169
+ const e = args.entity, p = isObj(args.policy) ? args.policy : {};
170
+ const owners = arr(e.owners).filter(isObj).map((o) => ({ ownerId: str(o.ownerId), pct: num(o.pct) ?? num(o.percent) }));
171
+ const sum = owners.reduce((a, o) => a + (o.pct ?? 0), 0);
172
+ const threshold = num(p.minDisclosurePct) ?? 25;
173
+ const disclosed = owners.filter((o) => (o.pct ?? 0) >= threshold);
174
+ const checks = [
175
+ check("ENTITY_ID", !!str(e.entityId), "CRITICAL", "entityId present"),
176
+ check("OWNERS", owners.length > 0, "CRITICAL", "at least one owner is disclosed"),
177
+ check("OWNER_IDS", owners.every((o) => !!o.ownerId), "HIGH", "every owner has an ownerId"),
178
+ check("PCT_SUM", Math.abs(sum - 100) <= 0.01, "HIGH", `ownership percentages sum to ${sum}`),
179
+ check("DISCLOSURE", disclosed.length > 0, "HIGH", `at least one owner at or above ${threshold}%`),
180
+ ];
181
+ const out = ok("verify_ubo_evidence", { entityId: str(e.entityId), ownershipSumPct: sum, disclosedOwners: disclosed.map((o) => o.ownerId), digest: digestOf(e), ...summarizeChecks(checks) });
182
+ out.boundary = WAVE5_BOUNDARY + " Ownership is a caller-supplied packet; no company registry or beneficial-ownership database is queried.";
183
+ return out;
184
+ }
185
+
186
+ // 5 — travel-rule packet completeness (no live VASP network).
187
+ export function verifyTravelRulePacket(args = {}) {
188
+ const bad = requireObj(args, "packet", "verify_travel_rule_packet"); if (bad) return bad;
189
+ const p = args.packet, policy = isObj(args.policy) ? args.policy : {};
190
+ const fields = ["originatorName", "originatorAccount", "beneficiaryName", "beneficiaryAccount", "originatorVasp", "beneficiaryVasp"];
191
+ const missing = fields.filter((f) => !str(p[f]));
192
+ const allowed = sorted(policy.allowedVasps);
193
+ const checks = [
194
+ check("FIELDS", missing.length === 0, "CRITICAL", `missing fields: ${missing.join(", ") || "none"}`),
195
+ check("AMOUNT", dec(p.amountMinor) !== null, "CRITICAL", "amountMinor parseable"),
196
+ check("CURRENCY", !!str(p.currency), "HIGH", "currency present"),
197
+ check("VASPS", !allowed.length || (allowed.includes(str(p.originatorVasp)) && allowed.includes(str(p.beneficiaryVasp))), "HIGH", "VASPs allowed when an allowlist is supplied"),
198
+ ];
199
+ const out = ok("verify_travel_rule_packet", { packetId: str(p.packetId || p.transferId), missingFields: missing, digest: digestOf(p), ...summarizeChecks(checks) });
200
+ out.boundary = WAVE5_BOUNDARY + " This is packet completeness evidence only; no travel-rule message is sent and no VASP is contacted.";
201
+ return out;
202
+ }
203
+
204
+ // 6 — AML alert disposition evidence (no live monitoring system).
205
+ export function verifyAmlAlertDisposition(args = {}) {
206
+ const bad = requireObj(args, "alert", "verify_aml_alert_disposition"); if (bad) return bad;
207
+ const a = args.alert;
208
+ const detected = decInt(a.detectedAtSeconds), reviewed = decInt(a.reviewedAtSeconds);
209
+ const rationale = str(a.rationale);
210
+ const checks = [
211
+ check("ALERT_ID", !!str(a.alertId), "CRITICAL", "alertId present"),
212
+ check("DISPOSITION", ["CLEARED", "ESCALATED", "FILED_SAR", "CLOSED"].includes(upper(str(a.disposition))), "CRITICAL", `disposition=${str(a.disposition)}`),
213
+ check("REVIEWER", !!str(a.reviewer), "HIGH", "reviewer present"),
214
+ check("RATIONALE", rationale.length >= 10, "HIGH", `rationale length ${rationale.length}`),
215
+ check("SEQUENCE", detected !== null && reviewed !== null ? reviewed >= detected : false, "CRITICAL", "review is not before detection"),
216
+ check("CASE_ID", !!str(a.caseId), "MEDIUM", "caseId present"),
217
+ ];
218
+ const out = ok("verify_aml_alert_disposition", { alertId: str(a.alertId), disposition: upper(str(a.disposition)), ...summarizeChecks(checks) });
219
+ out.boundary = WAVE5_BOUNDARY + " Disposition is caller-supplied evidence; no alert is generated, closed or reported to any authority.";
220
+ return out;
221
+ }
222
+
223
+ // 7 — sanctions list version alignment (no list download).
224
+ export function verifySanctionsListVersion(args = {}) {
225
+ const badE = requireObj(args, "evidence", "verify_sanctions_list_version"); if (badE) return badE;
226
+ const badP = requireObj(args, "policy", "verify_sanctions_list_version"); if (badP) return badP;
227
+ const e = args.evidence, p = args.policy;
228
+ const now = decInt(args.nowSeconds), published = decInt(e.publishedAtSeconds), maxAge = decInt(p.maxAgeSeconds);
229
+ const ver = decInt(e.listVersion), min = decInt(p.minVersion);
230
+ const fresh = now !== null && published !== null && maxAge !== null ? (now >= published && now - published <= maxAge) : false;
231
+ const checks = [
232
+ check("LIST_NAME", !str(p.requiredListName) || str(e.listName) === str(p.requiredListName), "HIGH", "list name matches policy"),
233
+ check("VERSION", ver !== null && min !== null ? ver >= min : false, "CRITICAL", `listVersion ${e.listVersion} >= ${p.minVersion}`),
234
+ check("FRESH", fresh, "HIGH", "list snapshot is fresh at pinned nowSeconds"),
235
+ check("DIGEST", /^sha256:[0-9a-f]{64}$/.test(str(e.digest)), "HIGH", "list digest is a sha256 digest string"),
236
+ ];
237
+ const out = ok("verify_sanctions_list_version", { listName: str(e.listName), listVersion: str(e.listVersion), fresh, ...summarizeChecks(checks) });
238
+ out.boundary = WAVE5_BOUNDARY + " No sanctions list is downloaded or screened; this checks a caller-supplied version stamp only.";
239
+ return out;
240
+ }
241
+
242
+ // 8 — FX rate lock evidence bound to an intent amount and expiry.
243
+ export function verifyFxRateLock(args = {}) {
244
+ const bad = requireObj(args, "lock", "verify_fx_rate_lock"); if (bad) return bad;
245
+ const l = args.lock, x = isObj(args.expected) ? args.expected : {};
246
+ const now = decInt(args.nowSeconds), expires = decInt(l.expiresAtSeconds);
247
+ const rate = dec(l.rate), amount = decInt(l.amountMinor), quote = decInt(l.quoteMinor);
248
+ const checks = [
249
+ check("LOCK_ID", !!str(l.lockId), "HIGH", "lockId present"),
250
+ check("PAIR", !!str(l.baseCurrency) && !!str(l.quoteCurrency), "HIGH", "currency pair present"),
251
+ check("RATE", rate !== null && Number(rate) > 0, "CRITICAL", `rate=${l.rate}`),
252
+ check("AMOUNT", !dec(x.amountMinor) || dec(l.amountMinor) === dec(x.amountMinor), "CRITICAL", "locked amount matches expected amount"),
253
+ check("QUOTE", quote !== null && (!dec(x.quoteMinor) || quote.toString() === dec(x.quoteMinor)), "CRITICAL", "locked quote matches expected quote"),
254
+ check("NOT_EXPIRED", now !== null && expires !== null ? expires >= now : false, "CRITICAL", "rate lock not expired at pinned nowSeconds"),
255
+ ];
256
+ return ok("verify_fx_rate_lock", { lockId: str(l.lockId), expired: now !== null && expires !== null ? expires < now : null, digest: digestOf(l), ...summarizeChecks(checks) });
257
+ }
258
+
259
+ // 9 — multi-ledger reconciliation with explicit breaks.
260
+ export function reconcileMultiLedger(args = {}) {
261
+ const bad = requireArr(args, "sources", "reconcile_multi_ledger"); if (bad) return bad;
262
+ const sources = args.sources.filter(isObj);
263
+ const x = isObj(args.expected) ? args.expected : {};
264
+ const expectedAmount = dec(x.amountMinor), expectedCurrency = upper(str(x.currency));
265
+ const breaks = [];
266
+ for (const s of sources) {
267
+ const reasons = [];
268
+ if (expectedAmount !== null && dec(s.amountMinor) !== expectedAmount) reasons.push("AMOUNT");
269
+ if (expectedCurrency && upper(str(s.currency)) !== expectedCurrency) reasons.push("CURRENCY");
270
+ if (!str(s.reference)) reasons.push("REFERENCE");
271
+ if (!/^sha256:[0-9a-f]{64}$/.test(str(s.digest))) reasons.push("DIGEST");
272
+ if (reasons.length) breaks.push({ sourceId: str(s.sourceId || s.id || `source-${sources.indexOf(s)}`), reasons });
273
+ }
274
+ const checks = [
275
+ check("SOURCES", sources.length > 0, "CRITICAL", `${sources.length} sources supplied`),
276
+ check("BREAKS", breaks.length === 0, "CRITICAL", `${breaks.length} ledger break(s)`),
277
+ ];
278
+ return ok("reconcile_multi_ledger", { sourceCount: sources.length, breaks, digest: digestOf(sources), ...summarizeChecks(checks) });
279
+ }
280
+
281
+ // 10 — caller-supplied camt.054-like credit notification.
282
+ export function verifyCamt054Notification(args = {}) {
283
+ const bad = requireObj(args, "notification", "verify_camt054_notification"); if (bad) return bad;
284
+ const n = args.notification, x = isObj(args.expected) ? args.expected : {};
285
+ const entries = arr(n.entries).filter(isObj);
286
+ const entryChecks = entries.flatMap((e, idx) => [
287
+ check(`ENTRY_${idx}_AMOUNT`, dec(e.amountMinor) !== null, "CRITICAL", `entry ${idx} amount parseable`),
288
+ check(`ENTRY_${idx}_CURRENCY`, !!str(e.currency), "HIGH", `entry ${idx} currency present`),
289
+ check(`ENTRY_${idx}_REFERENCE`, !!str(e.reference), "MEDIUM", `entry ${idx} reference present`),
290
+ ]);
291
+ const checks = [
292
+ check("MESSAGE_ID", !!str(n.messageId), "HIGH", "messageId present"),
293
+ check("ACCOUNT", !!str(n.accountId), "HIGH", "accountId present"),
294
+ check("ENTRIES", entries.length > 0, "CRITICAL", "at least one notification entry"),
295
+ ...entryChecks,
296
+ check("BALANCE", dec(n.balanceMinor) !== null, "HIGH", "balanceMinor parseable"),
297
+ check("EXPECTED_AMOUNT", !dec(x.amountMinor) || entries.some((e) => dec(e.amountMinor) === dec(x.amountMinor)), "CRITICAL", "an entry matches the expected amount"),
298
+ ];
299
+ return ok("verify_camt054_notification", { messageId: str(n.messageId), entryCount: entries.length, digest: digestOf(n), ...summarizeChecks(checks) });
300
+ }
301
+
302
+ // 11 — MT103-like field map validation.
303
+ export function verifyMt103Fields(args = {}) {
304
+ const bad = requireObj(args, "fields", "verify_mt103_fields"); if (bad) return bad;
305
+ const f = args.fields;
306
+ const requiredTags = [":20:", ":23B:", ":32A:", ":50K:", ":59:", ":70:"];
307
+ const present = requiredTags.filter((tag) => isObj(f) ? !!str(f[tag]) : false);
308
+ const missing = requiredTags.filter((tag) => !present.includes(tag));
309
+ const dateAmount = str(isObj(f) ? f[":32A:"] : "");
310
+ const format = /^(\d{6})([A-Z]{3})([0-9.,]+)$/.exec(dateAmount);
311
+ const checks = [
312
+ check("MANDATORY_FIELDS", missing.length === 0, "CRITICAL", `missing tags: ${missing.join(" ") || "none"}`),
313
+ check("32A_FORMAT", !!format, "HIGH", "field 32A is YYMMDDCCCamount"),
314
+ check("UETR", !!str(f.uetr), "MEDIUM", "uetr present when supplied"),
315
+ ];
316
+ return ok("verify_mt103_fields", { present, missing, parsed32A: format ? { date: format[1], currency: format[2], amount: format[3] } : null, digest: digestOf(f), ...summarizeChecks(checks) });
317
+ }
318
+
319
+ // 12 — last-moment beneficiary/account change defense.
320
+ export function verifyBeneficiaryChange(args = {}) {
321
+ const badA = requireObj(args, "approved", "verify_beneficiary_change"); if (badA) return badA;
322
+ const badE = requireObj(args, "executed", "verify_beneficiary_change"); if (badE) return badE;
323
+ const a = args.approved, e = args.executed, p = isObj(args.policy) ? args.policy : {};
324
+ const fields = ["beneficiaryId", "account", "bank"];
325
+ const changed = fields.filter((f) => str(a[f]) !== str(e[f]));
326
+ const reapprovalWaived = p.requireReapproval === false;
327
+ const checks = [
328
+ check("BENEFICIARY_ID", str(a.beneficiaryId) === str(e.beneficiaryId), "CRITICAL", `approved=${str(a.beneficiaryId)} executed=${str(e.beneficiaryId)}`),
329
+ check("ACCOUNT", str(a.account) === str(e.account), "CRITICAL", `approved=${str(a.account)} executed=${str(e.account)}`),
330
+ check("BANK", str(a.bank) === str(e.bank), "HIGH", "bank matches approved instruction"),
331
+ // A caller-supplied policy flag cannot waiver executed-vs-approved drift:
332
+ // the drift checks above stay CRITICAL. It only records the gate request.
333
+ check("REAPPROVAL", !reapprovalWaived, "HIGH", reapprovalWaived ? "caller requested no re-approval gate; drift checks still apply" : "re-approval gate active"),
334
+ ];
335
+ return ok("verify_beneficiary_change", {
336
+ changedFields: changed, reapprovalRequired: changed.length > 0,
337
+ reapprovalGateRequested: !reapprovalWaived,
338
+ digest: digestOf({ approved: a, executed: e }), ...summarizeChecks(checks),
339
+ });
340
+ }
341
+
342
+ // 13 — Stellar path payment evidence (no Horizon call).
343
+ export function verifyStellarPathPayment(args = {}) {
344
+ const bad = requireObj(args, "evidence", "verify_stellar_path_payment"); if (bad) return bad;
345
+ const e = args.evidence, x = isObj(args.expected) ? args.expected : {};
346
+ const checks = [
347
+ check("TX_HASH", !!str(e.txHash), "CRITICAL", "txHash present"),
348
+ check("STATUS", ["SUCCESS", "CONFIRMED"].includes(upper(str(e.status))), "CRITICAL", `status=${str(e.status)}`),
349
+ check("SOURCE_ASSET", !str(x.sourceAsset) || str(e.sourceAsset) === str(x.sourceAsset), "HIGH", "source asset matches"),
350
+ check("DEST_ASSET", !str(x.destAsset) || str(e.destAsset) === str(x.destAsset), "HIGH", "destination asset matches"),
351
+ check("AMOUNTS", dec(e.sendAmount) !== null && dec(e.destAmount) !== null, "CRITICAL", "send and destination amounts parseable"),
352
+ check("DESTINATION", !str(x.destination) || str(e.destination) === str(x.destination), "HIGH", "destination account matches"),
353
+ check("PATH_DIGEST", !!str(e.pathDigest) || arr(e.path).length > 0, "MEDIUM", "path digest or path assets present"),
354
+ ];
355
+ const out = ok("verify_stellar_path_payment", { txHash: str(e.txHash), pathLength: arr(e.path).length, ...summarizeChecks(checks) });
356
+ out.boundary = WAVE5_BOUNDARY + " No Stellar Horizon or network call is made; the path is a caller-supplied packet.";
357
+ return out;
358
+ }
359
+
360
+ // 14 — EVM permit/allowance evidence (no RPC, no signature recovery).
361
+ export function verifyEvmPermitEvidence(args = {}) {
362
+ const bad = requireObj(args, "evidence", "verify_evm_permit_evidence"); if (bad) return bad;
363
+ const e = args.evidence, p = isObj(args.policy) ? args.policy : {};
364
+ const now = decInt(args.nowSeconds), deadline = decInt(e.deadline), value = decInt(e.value), max = decInt(p.maxValue);
365
+ const spenders = sorted(p.allowedSpenders).map(lower);
366
+ const checks = [
367
+ check("TOKEN", /^0x[0-9a-fA-F]{40}$/.test(str(e.token)), "HIGH", "token address format"),
368
+ check("OWNER", !!str(e.owner), "HIGH", "owner present"),
369
+ check("SPENDER", !spenders.length || spenders.includes(lower(str(e.spender))), "CRITICAL", "spender allowed when an allowlist is supplied"),
370
+ check("VALUE", value !== null && (max === null || value <= max), "CRITICAL", "permit value within policy"),
371
+ check("DEADLINE", now !== null && deadline !== null ? deadline >= now : false, "CRITICAL", "permit not expired at pinned nowSeconds"),
372
+ check("SIGNATURE", !!str(e.signature), "CRITICAL", "caller-supplied signature marker present"),
373
+ check("NONCE", decInt(e.nonce) !== null, "MEDIUM", "nonce parseable"),
374
+ ];
375
+ const out = ok("verify_evm_permit_evidence", { token: str(e.token), spender: str(e.spender), digest: digestOf(e), ...summarizeChecks(checks) });
376
+ out.boundary = WAVE5_BOUNDARY + " Signature validity and on-chain allowance are not verified; the caller supplies all fields.";
377
+ return out;
378
+ }
379
+
380
+ // 15 — Core DAO delegation/staking evidence (no RPC).
381
+ export function verifyCoreDaoDelegationEvidence(args = {}) {
382
+ const bad = requireObj(args, "evidence", "verify_coredao_delegation_evidence"); if (bad) return bad;
383
+ const e = args.evidence, p = isObj(args.policy) ? args.policy : {};
384
+ const validators = sorted(p.allowedValidators);
385
+ const amount = decInt(e.amount), min = decInt(p.minAmount);
386
+ const checks = [
387
+ check("CHAIN_ID", decInt(e.chainId) === 1116n, "CRITICAL", "caller-supplied chainId is explicitly 1116"),
388
+ check("DELEGATOR", !!str(e.delegator), "HIGH", "delegator present"),
389
+ check("VALIDATOR", !validators.length || validators.includes(str(e.validator)), "CRITICAL", "validator allowed when an allowlist is supplied"),
390
+ check("AMOUNT", amount !== null && (min === null || amount >= min), "CRITICAL", "delegated amount meets policy minimum"),
391
+ check("STATUS", ["ACTIVE", "BONDED", "DELEGATED"].includes(upper(str(e.status))), "HIGH", `status=${str(e.status)}`),
392
+ check("UNBONDING", decInt(p.maxUnbondingSeconds) === null || decInt(e.unbondingSeconds) === null || decInt(e.unbondingSeconds) <= decInt(p.maxUnbondingSeconds), "HIGH", "unbonding period within policy"),
393
+ ];
394
+ const out = ok("verify_coredao_delegation_evidence", { validator: str(e.validator), amount: amount?.toString() ?? null, ...summarizeChecks(checks) });
395
+ out.boundary = WAVE5_BOUNDARY + " No Core DAO RPC or staking contract call is made; evidence is caller-supplied.";
396
+ return out;
397
+ }
398
+
399
+ // 16 — Pi payment attestation chain integrity.
400
+ export function verifyPiAttestationChain(args = {}) {
401
+ const bad = requireArr(args, "chain", "verify_pi_attestation_chain"); if (bad) return bad;
402
+ const chain = args.chain.filter(isObj);
403
+ const expected = isObj(args.expected) ? args.expected : {};
404
+ const digestsValid = chain.length > 0 && chain.every((l) => SHA256.test(str(l.digest)));
405
+ const linked = digestsValid && chain.length > 1 && chain.slice(1).every((link, idx) => SHA256.test(str(link.previousDigest)) && str(link.previousDigest) === str(chain[idx].digest));
406
+ const root = chain.at(-1)?.digest ?? null;
407
+ const checks = [
408
+ check("LINKS", chain.length > 0, "CRITICAL", `${chain.length} attestation links`),
409
+ check("DIGESTS", digestsValid, "CRITICAL", "every link carries a sha256 digest"),
410
+ check("LINKED", linked, "CRITICAL", "each link cites a valid previous sha256 digest"),
411
+ check("ROOT", !str(expected.rootDigest) || root === str(expected.rootDigest), "HIGH", "attestation root matches expected root"),
412
+ check("PAYMENT_ID", chain.length > 0 && (!str(expected.paymentId) || str(chain[0]?.paymentId) === str(expected.paymentId)), "CRITICAL", "paymentId matches expected"),
413
+ check("ATTESTORS", chain.length > 0 && chain.every((l) => !!str(l.attestor)), "HIGH", "every link names an attestor"),
414
+ ];
415
+ const out = ok("verify_pi_attestation_chain", { rootDigest: root, paymentId: str(chain[0]?.paymentId), ...summarizeChecks(checks) });
416
+ out.boundary = WAVE5_BOUNDARY + " Pi attestation evidence is caller-supplied; no Pi Network API or mainnet settlement check is performed.";
417
+ return out;
418
+ }
419
+
420
+ // 17 — ERC-4337 UserOperation evidence packet.
421
+ export function verifyErc4337UserOpEvidence(args = {}) {
422
+ const bad = requireObj(args, "userOp", "verify_erc4337_userop_evidence"); if (bad) return bad;
423
+ const u = args.userOp, p = isObj(args.policy) ? args.policy : {};
424
+ const senders = sorted(p.allowedSenders).map(lower), paymasters = sorted(p.allowedPaymasters).map(lower);
425
+ const gas = decInt(u.gasLimit), maxGas = decInt(p.maxGasLimit);
426
+ const checks = [
427
+ check("SENDER", !senders.length || senders.includes(lower(str(u.sender))), "CRITICAL", "sender allowed when an allowlist is supplied"),
428
+ check("NONCE", decInt(u.nonce) !== null, "CRITICAL", "nonce parseable"),
429
+ check("CALLDATA_DIGEST", /^sha256:[0-9a-f]{64}$/.test(str(u.callDataDigest)), "HIGH", "callDataDigest format"),
430
+ check("SIGNATURE", !!str(u.signature), "CRITICAL", "caller-supplied signature marker present"),
431
+ check("GAS_LIMIT", gas !== null && (maxGas === null || gas <= maxGas), "HIGH", "gas limit within policy"),
432
+ check("PAYMASTER", !paymasters.length || !str(u.paymaster) || paymasters.includes(lower(str(u.paymaster))), "HIGH", "paymaster allowed when supplied"),
433
+ ];
434
+ const out = ok("verify_erc4337_userop_evidence", { sender: str(u.sender), digest: digestOf(u), ...summarizeChecks(checks) });
435
+ out.boundary = WAVE5_BOUNDARY + " No bundler, paymaster or chain call is made; signature validity is not recovered.";
436
+ return out;
437
+ }
438
+
439
+ // 18 — token approval revocation evidence.
440
+ export function verifyTokenApprovalRevocation(args = {}) {
441
+ const bad = requireObj(args, "evidence", "verify_token_approval_revocation"); if (bad) return bad;
442
+ const e = args.evidence;
443
+ const before = decInt(e.allowanceBefore), after = decInt(e.allowanceAfter);
444
+ const checks = [
445
+ check("TOKEN", /^0x[0-9a-fA-F]{40}$/.test(str(e.token)), "HIGH", "token address format"),
446
+ check("OWNER", !!str(e.owner), "HIGH", "owner present"),
447
+ check("SPENDER", !!str(e.spender), "HIGH", "spender present"),
448
+ check("BEFORE", before !== null && before > 0n, "CRITICAL", "there was an allowance to revoke"),
449
+ check("AFTER_ZERO", after === 0n, "CRITICAL", `allowanceAfter=${e.allowanceAfter}`),
450
+ check("TX_HASH", /^0x[0-9a-fA-F]{64}$/.test(str(e.txHash)), "HIGH", "txHash format"),
451
+ ];
452
+ const out = ok("verify_token_approval_revocation", { token: str(e.token), spender: str(e.spender), digest: digestOf(e), ...summarizeChecks(checks) });
453
+ out.boundary = WAVE5_BOUNDARY + " No transaction is broadcast and no chain state is read; this checks a caller-supplied receipt.";
454
+ return out;
455
+ }
456
+
457
+ // 19 — deterministic budget lease for a machine or robot.
458
+ export function createMachineBudgetLease(args = {}) {
459
+ const badL = requireObj(args, "lease", "create_machine_budget_lease"); if (badL) return badL;
460
+ const l = args.lease, p = isObj(args.policy) ? args.policy : {};
461
+ const amount = decInt(l.amountMinor), max = decInt(p.maxAmountMinor);
462
+ const start = decInt(l.startAtSeconds), end = decInt(l.endAtSeconds);
463
+ const allowedScopes = sorted(p.allowedScopes), scopes = sorted(l.scope);
464
+ const checks = [
465
+ check("LEASE_ID", !!str(l.leaseId), "CRITICAL", "leaseId present"),
466
+ check("MACHINE", !!str(l.machineId), "CRITICAL", "machineId present"),
467
+ check("WINDOW", start !== null && end !== null && end >= start, "CRITICAL", "valid time window"),
468
+ check("AMOUNT", amount !== null && (max === null || amount <= max), "CRITICAL", "lease amount within policy"),
469
+ check("SCOPES", scopes.length > 0 && (!allowedScopes.length || scopes.every((s) => allowedScopes.includes(s))), "HIGH", "scopes are non-empty and allowed"),
470
+ ];
471
+ const lease = { spec: WAVE5_VERSION, type: "machine_budget_lease", ...l, policyDigest: digestOf(p), createdAtSeconds: decInt(args.nowSeconds)?.toString() ?? null };
472
+ return ok("create_machine_budget_lease", { lease, leaseDigest: digestOf(lease), ...summarizeChecks(checks) });
473
+ }
474
+
475
+ // 20 — verify spend events against a lease.
476
+ export function verifyMachineBudgetConsumption(args = {}) {
477
+ const badL = requireObj(args, "lease", "verify_machine_budget_consumption"); if (badL) return badL;
478
+ const badE = requireArr(args, "events", "verify_machine_budget_consumption"); if (badE) return badE;
479
+ const l = args.lease, events = args.events.filter(isObj);
480
+ const limit = decInt(l.amountMinor);
481
+ const start = decInt(l.startAtSeconds), end = decInt(l.endAtSeconds);
482
+ const scopes = sorted(l.scope);
483
+ let spent = 0n;
484
+ const breaks = [];
485
+ const seenReferences = new Set();
486
+ for (const e of events) {
487
+ const reasons = [];
488
+ const at = decInt(e.atSeconds), amount = decInt(e.amountMinor);
489
+ const reference = str(e.reference);
490
+ if (!reference) reasons.push("REFERENCE");
491
+ const duplicate = !!reference && seenReferences.has(reference);
492
+ if (reference) seenReferences.add(reference);
493
+ if (duplicate) reasons.push("DUPLICATE_REFERENCE");
494
+ // A replayed reference is a break and must not consume budget twice.
495
+ if (amount !== null && !duplicate) spent += amount; else if (amount === null) reasons.push("AMOUNT");
496
+ if (start !== null && at !== null && (at < start || at > end)) reasons.push("WINDOW");
497
+ if (scopes.length && !scopes.includes(str(e.scope))) reasons.push("SCOPE");
498
+ if (reasons.length) breaks.push({ reference: reference || "unreferenced", reasons });
499
+ }
500
+ const checks = [
501
+ check("EVENTS", events.length > 0, "MEDIUM", `${events.length} consumption events`),
502
+ check("BREAKS", breaks.length === 0, "CRITICAL", `${breaks.length} policy break(s)`),
503
+ check("BUDGET", limit !== null ? spent <= limit : false, "CRITICAL", `spent ${spent} <= lease ${limit}`),
504
+ ];
505
+ return ok("verify_machine_budget_consumption", { leaseId: str(l.leaseId), spentMinor: spent.toString(), remainingMinor: limit !== null ? (limit - spent).toString() : null, breaks, ...summarizeChecks(checks) });
506
+ }
507
+
508
+ // 21 — robot task handoff chain integrity.
509
+ export function verifyRobotHandoffChain(args = {}) {
510
+ const bad = requireArr(args, "chain", "verify_robot_handoff_chain"); if (bad) return bad;
511
+ const chain = args.chain.filter(isObj);
512
+ const expected = isObj(args.expected) ? args.expected : {};
513
+ const taskIds = [...new Set(chain.map((l) => str(l.taskId)))];
514
+ const digestsValid = chain.length > 0 && chain.every((l) => SHA256.test(str(l.digest)));
515
+ const continuous = chain.length > 1 && chain.slice(1).every((l, idx) => !!str(l.fromRobot) && str(l.fromRobot) === str(chain[idx].toRobot));
516
+ const ordered = chain.length > 0 && chain.every((l, idx) => decInt(l.atSeconds) !== null && (idx === 0 || decInt(l.atSeconds) >= decInt(chain[idx - 1].atSeconds)));
517
+ const linked = digestsValid && chain.length > 1 && chain.slice(1).every((l, idx) => SHA256.test(str(l.previousDigest)) && str(l.previousDigest) === str(chain[idx].digest));
518
+ const checks = [
519
+ check("LINKS", chain.length > 0, "CRITICAL", `${chain.length} handoff links`),
520
+ check("TASK_ID", taskIds.length === 1 && !!taskIds[0] && (!str(expected.taskId) || taskIds[0] === str(expected.taskId)), "CRITICAL", `task ids: ${taskIds.join(", ") || "none"}`),
521
+ check("CONTINUOUS", continuous, "CRITICAL", "each toRobot becomes the next fromRobot"),
522
+ check("TIME_ORDER", ordered, "HIGH", "handoffs are time-ordered with parseable atSeconds"),
523
+ check("DIGESTS", digestsValid, "CRITICAL", "every link carries a sha256 digest"),
524
+ check("DIGEST_CHAIN", linked, "HIGH", "each link cites a valid previous sha256 digest"),
525
+ ];
526
+ return ok("verify_robot_handoff_chain", { taskId: taskIds[0] ?? null, handoffs: chain.length, digest: digestOf(chain), ...summarizeChecks(checks) });
527
+ }
528
+
529
+ // 22 — authority scope intersection and overreach detection.
530
+ export function verifyAgentAuthorityIntersection(args = {}) {
531
+ const badP = requireArr(args, "principalScope", "verify_agent_authority_intersection"); if (badP) return badP;
532
+ const badA = requireArr(args, "agentScope", "verify_agent_authority_intersection"); if (badA) return badA;
533
+ const principal = sorted(args.principalScope), agent = sorted(args.agentScope), requested = sorted(args.requested ?? []);
534
+ const agentOverreach = agent.filter((s) => !principal.includes(s));
535
+ const requestOverreach = requested.filter((s) => !agent.includes(s));
536
+ const intersection = principal.filter((s) => agent.includes(s));
537
+ const checks = [
538
+ check("PRINCIPAL_SCOPE", principal.length > 0, "CRITICAL", "principal scope is non-empty"),
539
+ check("AGENT_SCOPE", agent.length > 0, "CRITICAL", "agent scope is non-empty"),
540
+ check("AGENT_WITHIN_PRINCIPAL", agentOverreach.length === 0, "CRITICAL", `agent-only scopes: ${agentOverreach.join(", ") || "none"}`),
541
+ check("REQUEST_WITHIN_AGENT", requestOverreach.length === 0, "CRITICAL", `requested scopes outside agent authority: ${requestOverreach.join(", ") || "none"}`),
542
+ ];
543
+ return ok("verify_agent_authority_intersection", { intersection, agentOverreach, requestOverreach, digest: digestOf({ principal, agent, requested }), ...summarizeChecks(checks) });
544
+ }
545
+
546
+ // 23 — deterministic inference receipt (binds digests, not truth).
547
+ export function createInferenceReceipt(args = {}) {
548
+ const bad = requireObj(args, "evidence", "create_inference_receipt"); if (bad) return bad;
549
+ const e = args.evidence;
550
+ const checks = [
551
+ check("MODEL", !!str(e.modelId), "HIGH", "modelId present"),
552
+ check("PROMPT_DIGEST", /^sha256:[0-9a-f]{64}$/.test(str(e.promptDigest)), "CRITICAL", "promptDigest format"),
553
+ check("OUTPUT_DIGEST", /^sha256:[0-9a-f]{64}$/.test(str(e.outputDigest)), "CRITICAL", "outputDigest format"),
554
+ check("POLICY_DIGEST", !!str(e.policyDigest), "HIGH", "policyDigest present"),
555
+ check("COST", dec(e.costMinor) !== null, "HIGH", "costMinor parseable"),
556
+ check("LATENCY", num(e.latencyMs) !== null && num(e.latencyMs) >= 0, "MEDIUM", "latencyMs non-negative"),
557
+ ];
558
+ const receipt = { spec: WAVE5_VERSION, type: "inference_receipt", ...e, createdAtSeconds: decInt(args.nowSeconds)?.toString() ?? null };
559
+ const out = ok("create_inference_receipt", { receipt, receiptDigest: digestOf(receipt), ...summarizeChecks(checks) });
560
+ out.boundary = WAVE5_BOUNDARY + " It does not attest correctness, safety or permission; a receipt binds supplied digests only.";
561
+ return out;
562
+ }
563
+
564
+ // 24 — export a redacted, merkle-rooted evidence pack for human review.
565
+ export function exportEvidencePack(args = {}) {
566
+ const bad = requireArr(args, "items", "export_evidence_pack"); if (bad) return bad;
567
+ const items = args.items.filter(isObj);
568
+ const p = isObj(args.policy) ? args.policy : {};
569
+ const maxItems = decInt(p.maxItems);
570
+ const redactFields = sorted(p.redactFields);
571
+ const entries = items.map((item) => {
572
+ const source = item.body ?? item;
573
+ const body = redactFields.length ? deepRedact(source, redactFields) : source;
574
+ const computed = digestOf(source);
575
+ return { id: str(item.id), body, providedDigest: str(item.digest || ""), computedDigest: computed, intact: !str(item.digest) || str(item.digest) === computed };
576
+ });
577
+ const root = digestOf(entries.map((e) => e.computedDigest).sort());
578
+ const checks = [
579
+ check("ITEMS", items.length > 0, "CRITICAL", `${items.length} evidence items`),
580
+ check("MAX_ITEMS", maxItems === null || BigInt(items.length) <= maxItems, "HIGH", "item count within policy"),
581
+ check("INTEGRITY", entries.every((e) => e.intact), "CRITICAL", "every provided digest matches its body"),
582
+ check("IDS", entries.every((e) => !!e.id), "HIGH", "every item has an id"),
583
+ ];
584
+ const pack = { spec: WAVE5_VERSION, type: "evidence_pack", root, redactedFields: redactFields, items: entries, createdAtSeconds: decInt(args.nowSeconds)?.toString() ?? null };
585
+ const out = ok("export_evidence_pack", { pack, packDigest: digestOf(pack), root, ...summarizeChecks(checks) });
586
+ out.boundary = WAVE5_BOUNDARY + " The pack is for export/review only; nothing is submitted to a regulator, court or counterparty by this tool.";
587
+ return out;
588
+ }
589
+
590
+ // ---------------------------------------------------------------------------
591
+ // MCP tool definitions / handlers / validators
592
+ // ---------------------------------------------------------------------------
593
+
594
+ const CALLER_CONTEXT = { type: "object", description: "Optional caller context echoed back in response (never a cryptographic input).", additionalProperties: true };
595
+ const schema = (properties, required, description) => ({
596
+ type: "object", description, additionalProperties: true,
597
+ properties: { ...properties, callerContext: CALLER_CONTEXT },
598
+ ...(required ? { required } : {}),
599
+ });
600
+ // Every Wave 5 result shares an envelope. Declaring it makes the outputSchema
601
+ // testable instead of merely asserting `type: object` with open properties.
602
+ const out = (description) => ({
603
+ type: "object",
604
+ description: description.length > 40 ? description : description + " (deterministic, caller-supplied evidence).",
605
+ additionalProperties: true,
606
+ properties: {
607
+ type: { type: "string" },
608
+ spec: { type: "string" },
609
+ status: { type: "string", enum: ["OK", "REFUSED"] },
610
+ refusal: { type: "object", description: "Present only when status is REFUSED." },
611
+ verdict: { type: "string", enum: ["PASS", "WARN", "FAIL"] },
612
+ checks: { type: "array", items: { type: "object" } },
613
+ failed: { type: "array", items: { type: "string" } },
614
+ critical: { type: "array", items: { type: "string" } },
615
+ boundary: { type: "string" },
616
+ },
617
+ });
618
+
619
+ export const WAVE5_TOOLS = Object.freeze([
620
+ { name: "coreguard_canonicalize_payment_instruction", description: "Normalize a caller-supplied payment instruction into a canonical, digest-bound object ready for approval. Offline; no bank or rail contact.", inputSchema: schema({ instruction: { type: "object" } }, ["instruction"], "Payment instruction to canonicalize."), outputSchema: out("Canonical instruction, digest and checks.") },
621
+ { name: "coreguard_verify_payment_authorization_chain", description: "Verify a caller-supplied delegation chain for continuity, scoped authority, expiry and signature markers at a pinned time. No IdP call.", inputSchema: schema({ chain: { type: "array", items: { type: "object" } }, nowSeconds: { type: "string", pattern: "^[0-9]+$" } }, ["chain"], "Delegation links and pinned time."), outputSchema: out("Authorization chain verdict with scope intersection.") },
622
+ { name: "coreguard_verify_kyc_evidence", description: "Check a caller-supplied KYC evidence packet for freshness, required documents and provider allowlist. No live KYC or identity-provider call.", inputSchema: schema({ evidence: { type: "object" }, policy: { type: "object" }, nowSeconds: { type: "string", pattern: "^[0-9]+$" } }, ["evidence", "policy", "nowSeconds"], "KYC evidence, policy, pinned time."), outputSchema: out("KYC evidence verdict with explicit boundary.") },
623
+ { name: "coreguard_verify_ubo_evidence", description: "Verify a caller-supplied beneficial-ownership packet for owner identifiers, percentage sum and disclosure threshold. No registry call.", inputSchema: schema({ entity: { type: "object" }, policy: { type: "object" } }, ["entity"], "Entity ownership packet and optional policy."), outputSchema: out("Ownership packet verdict and digest.") },
624
+ { name: "coreguard_verify_travel_rule_packet", description: "Check a caller-supplied travel-rule packet for required originator, beneficiary, VASP and amount fields. No VASP network is contacted.", inputSchema: schema({ packet: { type: "object" }, policy: { type: "object" } }, ["packet"], "Travel-rule packet and optional policy."), outputSchema: out("Travel-rule packet completeness verdict.") },
625
+ { name: "coreguard_verify_aml_alert_disposition", description: "Verify a caller-supplied AML alert disposition for reviewer, rationale, sequence and case id. No alert is generated or reported.", inputSchema: schema({ alert: { type: "object" } }, ["alert"], "AML alert disposition packet."), outputSchema: out("AML disposition verdict with explicit boundary.") },
626
+ { name: "coreguard_verify_sanctions_list_version", description: "Check a caller-supplied sanctions-list version stamp against a pinned policy minimum and freshness window. No list is downloaded.", inputSchema: schema({ evidence: { type: "object" }, policy: { type: "object" }, nowSeconds: { type: "string", pattern: "^[0-9]+$" } }, ["evidence", "policy", "nowSeconds"], "List stamp, policy, pinned time."), outputSchema: out("List-version assessment and checks.") },
627
+ { name: "coreguard_verify_fx_rate_lock", description: "Verify a caller-supplied FX rate lock against an expected intent amount and a pinned expiry. No market-data feed is used.", inputSchema: schema({ lock: { type: "object" }, expected: { type: "object" }, nowSeconds: { type: "string", pattern: "^[0-9]+$" } }, ["lock", "nowSeconds"], "Rate lock, optional expected values, pinned time."), outputSchema: out("Rate-lock verdict with expiry state.") },
628
+ { name: "coreguard_reconcile_multi_ledger", description: "Reconcile caller-supplied ledger sources against an expected amount/currency and emit named breaks. No ledger API is contacted.", inputSchema: schema({ sources: { type: "array", items: { type: "object" } }, expected: { type: "object" } }, ["sources"], "Ledger sources and expected values."), outputSchema: out("Reconciliation verdict with explicit breaks.") },
629
+ { name: "coreguard_verify_camt054_notification", description: "Parse and validate a caller-supplied camt.054-like credit notification with entries and balance. No bank statement API is contacted.", inputSchema: schema({ notification: { type: "object" }, expected: { type: "object" } }, ["notification"], "Camt.054-like notification and optional expectations."), outputSchema: out("Notification verdict, entry count and digest.") },
630
+ { name: "coreguard_verify_mt103_fields", description: "Validate mandatory fields and the 32A date/currency/amount shape in a caller-supplied MT103-like field map. No SWIFT access.", inputSchema: schema({ fields: { type: "object" } }, ["fields"], "MT103-like field map."), outputSchema: out("Present/missing tags and parsed 32A field.") },
631
+ { name: "coreguard_verify_beneficiary_change", description: "Detect beneficiary, account or bank drift between an approved instruction and an executed packet, with an explicit re-approval gate. Offline.", inputSchema: schema({ approved: { type: "object" }, executed: { type: "object" }, policy: { type: "object" } }, ["approved", "executed"], "Approved and executed beneficiary packets."), outputSchema: out("Change verdict with re-approval requirement.") },
632
+ { name: "coreguard_verify_stellar_path_payment", description: "Verify caller-supplied Stellar path-payment evidence for status, assets, amounts, destination and path digest. No Horizon call.", inputSchema: schema({ evidence: { type: "object" }, expected: { type: "object" } }, ["evidence"], "Path-payment evidence and optional expectations."), outputSchema: out("Path-payment evidence verdict.") },
633
+ { name: "coreguard_verify_evm_permit_evidence", description: "Verify caller-supplied EVM permit evidence for token, spender, value, deadline, nonce and signature marker. No RPC or signature recovery.", inputSchema: schema({ evidence: { type: "object" }, policy: { type: "object" }, nowSeconds: { type: "string", pattern: "^[0-9]+$" } }, ["evidence", "nowSeconds"], "Permit evidence, policy, pinned time."), outputSchema: out("Permit evidence verdict and digest.") },
634
+ { name: "coreguard_verify_coredao_delegation_evidence", description: "Verify caller-supplied Core DAO delegation evidence for chain 1116, validator allowlist, amount and unbonding policy. No RPC call.", inputSchema: schema({ evidence: { type: "object" }, policy: { type: "object" } }, ["evidence"], "Delegation evidence and optional policy."), outputSchema: out("Delegation evidence verdict.") },
635
+ { name: "coreguard_verify_pi_attestation_chain", description: "Verify the digest linkage and root of a caller-supplied Pi payment attestation chain. No Pi API or mainnet settlement check.", inputSchema: schema({ chain: { type: "array", items: { type: "object" } }, expected: { type: "object" } }, ["chain"], "Attestation links and optional expectations."), outputSchema: out("Attestation chain verdict and root digest.") },
636
+ { name: "coreguard_verify_erc4337_userop_evidence", description: "Verify a caller-supplied ERC-4337 UserOperation packet for sender, nonce, calldata digest, signature marker and gas policy. No bundler call.", inputSchema: schema({ userOp: { type: "object" }, policy: { type: "object" } }, ["userOp"], "UserOperation packet and optional policy."), outputSchema: out("UserOperation evidence verdict and digest.") },
637
+ { name: "coreguard_verify_token_approval_revocation", description: "Verify caller-supplied token approval revocation evidence shows a positive previous allowance and a zero current allowance. No broadcast.", inputSchema: schema({ evidence: { type: "object" } }, ["evidence"], "Allowance revocation evidence packet."), outputSchema: out("Revocation verdict with digest.") },
638
+ { name: "coreguard_create_machine_budget_lease", description: "Create a deterministic, digest-bound budget lease for a machine or robot with scope, time window and amount ceiling. No control of any device.", inputSchema: schema({ lease: { type: "object" }, policy: { type: "object" }, nowSeconds: { type: "string", pattern: "^[0-9]+$" } }, ["lease"], "Lease terms and optional policy."), outputSchema: out("Lease record, digest and checks.") },
639
+ { name: "coreguard_verify_machine_budget_consumption", description: "Verify machine spend events against a budget lease for amount, window, scope and reference, with named breaks. Offline arithmetic only.", inputSchema: schema({ lease: { type: "object" }, events: { type: "array", items: { type: "object" } } }, ["lease", "events"], "Lease and consumption events."), outputSchema: out("Spend total, remaining budget and breaks.") },
640
+ { name: "coreguard_verify_robot_handoff_chain", description: "Verify a robot task handoff chain for a single task id, continuity, time order and digest linkage. No robot telemetry source is contacted.", inputSchema: schema({ chain: { type: "array", items: { type: "object" } }, expected: { type: "object" } }, ["chain"], "Handoff links and optional expectations."), outputSchema: out("Handoff chain verdict and digest.") },
641
+ { name: "coreguard_verify_agent_authority_intersection", description: "Intersect principal, agent and requested authority scopes and name any overreach. Deterministic set arithmetic; no policy service call.", inputSchema: schema({ principalScope: { type: "array", items: { type: "string" } }, agentScope: { type: "array", items: { type: "string" } }, requested: { type: "array", items: { type: "string" } } }, ["principalScope", "agentScope"], "Principal, agent and requested scopes."), outputSchema: out("Authority intersection and overreach lists.") },
642
+ { name: "coreguard_create_inference_receipt", description: "Create a deterministic receipt binding caller-supplied model, prompt, output and policy digests with cost and latency. It does not attest correctness.", inputSchema: schema({ evidence: { type: "object" }, nowSeconds: { type: "string", pattern: "^[0-9]+$" } }, ["evidence"], "Inference evidence to bind."), outputSchema: out("Inference receipt and digest with boundary.") },
643
+ { name: "coreguard_export_evidence_pack", description: "Export a redacted, digest-rooted evidence pack from caller-supplied items for human review. Nothing is submitted to any external party.", inputSchema: schema({ items: { type: "array", items: { type: "object" } }, policy: { type: "object" }, nowSeconds: { type: "string", pattern: "^[0-9]+$" } }, ["items"], "Evidence items and optional export policy."), outputSchema: out("Evidence pack, merkle-style root and digest.") },
644
+ ]);
645
+
646
+ export const WAVE5_HANDLERS = Object.freeze({
647
+ coreguard_canonicalize_payment_instruction: (a) => canonicalizePaymentInstruction(a),
648
+ coreguard_verify_payment_authorization_chain: (a) => verifyPaymentAuthorizationChain(a),
649
+ coreguard_verify_kyc_evidence: (a) => verifyKycEvidence(a),
650
+ coreguard_verify_ubo_evidence: (a) => verifyUboEvidence(a),
651
+ coreguard_verify_travel_rule_packet: (a) => verifyTravelRulePacket(a),
652
+ coreguard_verify_aml_alert_disposition: (a) => verifyAmlAlertDisposition(a),
653
+ coreguard_verify_sanctions_list_version: (a) => verifySanctionsListVersion(a),
654
+ coreguard_verify_fx_rate_lock: (a) => verifyFxRateLock(a),
655
+ coreguard_reconcile_multi_ledger: (a) => reconcileMultiLedger(a),
656
+ coreguard_verify_camt054_notification: (a) => verifyCamt054Notification(a),
657
+ coreguard_verify_mt103_fields: (a) => verifyMt103Fields(a),
658
+ coreguard_verify_beneficiary_change: (a) => verifyBeneficiaryChange(a),
659
+ coreguard_verify_stellar_path_payment: (a) => verifyStellarPathPayment(a),
660
+ coreguard_verify_evm_permit_evidence: (a) => verifyEvmPermitEvidence(a),
661
+ coreguard_verify_coredao_delegation_evidence: (a) => verifyCoreDaoDelegationEvidence(a),
662
+ coreguard_verify_pi_attestation_chain: (a) => verifyPiAttestationChain(a),
663
+ coreguard_verify_erc4337_userop_evidence: (a) => verifyErc4337UserOpEvidence(a),
664
+ coreguard_verify_token_approval_revocation: (a) => verifyTokenApprovalRevocation(a),
665
+ coreguard_create_machine_budget_lease: (a) => createMachineBudgetLease(a),
666
+ coreguard_verify_machine_budget_consumption: (a) => verifyMachineBudgetConsumption(a),
667
+ coreguard_verify_robot_handoff_chain: (a) => verifyRobotHandoffChain(a),
668
+ coreguard_verify_agent_authority_intersection: (a) => verifyAgentAuthorityIntersection(a),
669
+ coreguard_create_inference_receipt: (a) => createInferenceReceipt(a),
670
+ coreguard_export_evidence_pack: (a) => exportEvidencePack(a),
671
+ });
672
+
673
+ export const WAVE5_VALIDATORS = Object.freeze({
674
+ coreguard_canonicalize_payment_instruction: (a) => (isObj(a?.instruction) ? null : { code: "MISSING_ARGUMENT", detail: "instruction is required and must be an object" }),
675
+ coreguard_verify_payment_authorization_chain: (a) => (Array.isArray(a?.chain) ? null : { code: "MISSING_ARGUMENT", detail: "chain is required and must be an array" }),
676
+ coreguard_verify_kyc_evidence: (a) => (isObj(a?.evidence) && isObj(a?.policy) && typeof a?.nowSeconds === "string" ? null : { code: "MISSING_ARGUMENT", detail: "evidence, policy, nowSeconds required" }),
677
+ coreguard_verify_ubo_evidence: (a) => (isObj(a?.entity) ? null : { code: "MISSING_ARGUMENT", detail: "entity is required and must be an object" }),
678
+ coreguard_verify_travel_rule_packet: (a) => (isObj(a?.packet) ? null : { code: "MISSING_ARGUMENT", detail: "packet is required and must be an object" }),
679
+ coreguard_verify_aml_alert_disposition: (a) => (isObj(a?.alert) ? null : { code: "MISSING_ARGUMENT", detail: "alert is required and must be an object" }),
680
+ coreguard_verify_sanctions_list_version: (a) => (isObj(a?.evidence) && isObj(a?.policy) && typeof a?.nowSeconds === "string" ? null : { code: "MISSING_ARGUMENT", detail: "evidence, policy, nowSeconds required" }),
681
+ coreguard_verify_fx_rate_lock: (a) => (isObj(a?.lock) && typeof a?.nowSeconds === "string" ? null : { code: "MISSING_ARGUMENT", detail: "lock and nowSeconds required" }),
682
+ coreguard_reconcile_multi_ledger: (a) => (Array.isArray(a?.sources) ? null : { code: "MISSING_ARGUMENT", detail: "sources is required and must be an array" }),
683
+ coreguard_verify_camt054_notification: (a) => (isObj(a?.notification) ? null : { code: "MISSING_ARGUMENT", detail: "notification is required and must be an object" }),
684
+ coreguard_verify_mt103_fields: (a) => (isObj(a?.fields) ? null : { code: "MISSING_ARGUMENT", detail: "fields is required and must be an object" }),
685
+ coreguard_verify_beneficiary_change: (a) => (isObj(a?.approved) && isObj(a?.executed) ? null : { code: "MISSING_ARGUMENT", detail: "approved and executed are required objects" }),
686
+ coreguard_verify_stellar_path_payment: (a) => (isObj(a?.evidence) ? null : { code: "MISSING_ARGUMENT", detail: "evidence is required and must be an object" }),
687
+ coreguard_verify_evm_permit_evidence: (a) => (isObj(a?.evidence) && typeof a?.nowSeconds === "string" ? null : { code: "MISSING_ARGUMENT", detail: "evidence and nowSeconds required" }),
688
+ coreguard_verify_coredao_delegation_evidence: (a) => (isObj(a?.evidence) ? null : { code: "MISSING_ARGUMENT", detail: "evidence is required and must be an object" }),
689
+ coreguard_verify_pi_attestation_chain: (a) => (Array.isArray(a?.chain) ? null : { code: "MISSING_ARGUMENT", detail: "chain is required and must be an array" }),
690
+ coreguard_verify_erc4337_userop_evidence: (a) => (isObj(a?.userOp) ? null : { code: "MISSING_ARGUMENT", detail: "userOp is required and must be an object" }),
691
+ coreguard_verify_token_approval_revocation: (a) => (isObj(a?.evidence) ? null : { code: "MISSING_ARGUMENT", detail: "evidence is required and must be an object" }),
692
+ coreguard_create_machine_budget_lease: (a) => (isObj(a?.lease) ? null : { code: "MISSING_ARGUMENT", detail: "lease is required and must be an object" }),
693
+ coreguard_verify_machine_budget_consumption: (a) => (isObj(a?.lease) && Array.isArray(a?.events) ? null : { code: "MISSING_ARGUMENT", detail: "lease and events required" }),
694
+ coreguard_verify_robot_handoff_chain: (a) => (Array.isArray(a?.chain) ? null : { code: "MISSING_ARGUMENT", detail: "chain is required and must be an array" }),
695
+ coreguard_verify_agent_authority_intersection: (a) => (Array.isArray(a?.principalScope) && Array.isArray(a?.agentScope) ? null : { code: "MISSING_ARGUMENT", detail: "principalScope and agentScope required" }),
696
+ coreguard_create_inference_receipt: (a) => (isObj(a?.evidence) ? null : { code: "MISSING_ARGUMENT", detail: "evidence is required and must be an object" }),
697
+ coreguard_export_evidence_pack: (a) => (Array.isArray(a?.items) ? null : { code: "MISSING_ARGUMENT", detail: "items is required and must be an array" }),
698
+ });