@agent-custody/receipts 0.12.0 → 0.14.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/dist/log.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // Append-only Merkle log with RFC 6962 / RFC 9162 hashing and inclusion proofs.
2
2
  // Leaves are stored as JSONL so anyone holding the file can recompute the root.
3
3
  import { createHash } from "node:crypto";
4
- import { appendFileSync, existsSync, mkdirSync, readFileSync } from "node:fs";
4
+ import { appendFileSync, closeSync, mkdirSync, openSync, readSync, statSync, unlinkSync } from "node:fs";
5
5
  import { dirname } from "node:path";
6
6
  const h = (...parts) => {
7
7
  const c = createHash("sha256");
@@ -153,26 +153,108 @@ export function verifyInclusion(leaf, proof, rootHex) {
153
153
  }
154
154
  return sn === 0 && r.toString("hex") === rootHex;
155
155
  }
156
+ const LOCK_STALE_MS = 10_000;
157
+ const LOCK_WAIT_MS = 20_000;
158
+ const pause = (ms) => Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
156
159
  export class MerkleLog {
157
160
  hashes = [];
158
- tree;
161
+ tree = new SubtreeCache(this.hashes);
159
162
  file;
163
+ bytes = 0;
164
+ inode = -1;
160
165
  constructor(file) {
161
166
  this.file = file;
162
- this.tree = new SubtreeCache(this.hashes);
163
- if (existsSync(file)) {
164
- for (const line of readFileSync(file, "utf8").split("\n")) {
165
- if (!line.trim())
166
- continue;
167
- const parsed = JSON.parse(line);
168
- // A pruned leaf keeps only its hash, and a leaf appended by hash never had content here: the tree, its
169
- // roots, and every proof are the same either way.
170
- this.hashes.push(typeof parsed === "string" ? leafHash(parsed) : Buffer.from((parsed.pruned ?? parsed.hash), "hex"));
167
+ mkdirSync(dirname(file), { recursive: true });
168
+ this.catchUp();
169
+ }
170
+ /** Reads the leaves that another handle or process appended since the last read. A file that was replaced or cut short is read again from the start. */
171
+ catchUp() {
172
+ let st;
173
+ try {
174
+ st = statSync(this.file);
175
+ }
176
+ catch {
177
+ st = null;
178
+ }
179
+ if (!st || st.ino !== this.inode || st.size < this.bytes) {
180
+ this.hashes.length = 0;
181
+ this.tree = new SubtreeCache(this.hashes);
182
+ this.bytes = 0;
183
+ }
184
+ if (!st)
185
+ return;
186
+ this.inode = st.ino;
187
+ if (st.size === this.bytes)
188
+ return;
189
+ const buf = Buffer.alloc(st.size - this.bytes);
190
+ const fd = openSync(this.file, "r");
191
+ let got = 0;
192
+ try {
193
+ while (got < buf.length) {
194
+ const n = readSync(fd, buf, got, buf.length - got, this.bytes + got);
195
+ if (n === 0)
196
+ break;
197
+ got += n;
171
198
  }
172
199
  }
173
- else {
174
- mkdirSync(dirname(file), { recursive: true });
200
+ finally {
201
+ closeSync(fd);
202
+ }
203
+ this.bytes += got;
204
+ for (const line of buf.subarray(0, got).toString("utf8").split("\n")) {
205
+ if (!line.trim())
206
+ continue;
207
+ const parsed = JSON.parse(line);
208
+ // A pruned leaf keeps only its hash, and a leaf appended by hash never had content here: the tree, its
209
+ // roots, and every proof are the same either way.
210
+ this.hashes.push(typeof parsed === "string" ? leafHash(parsed) : Buffer.from((parsed.pruned ?? parsed.hash), "hex"));
211
+ }
212
+ }
213
+ /**
214
+ * Runs `fn` while this process holds `<file>.lock`, made with O_EXCL. Each hook of a coding agent is its own
215
+ * process, so appends overlap. A lock older than ten seconds belongs to a process that died: the next writer removes it.
216
+ */
217
+ locked(fn) {
218
+ const lock = `${this.file}.lock`;
219
+ const deadline = Date.now() + LOCK_WAIT_MS;
220
+ for (;;) {
221
+ try {
222
+ closeSync(openSync(lock, "wx"));
223
+ break;
224
+ }
225
+ catch (e) {
226
+ if (e.code !== "EEXIST")
227
+ throw e;
228
+ }
229
+ try {
230
+ if (Date.now() - statSync(lock).mtimeMs > LOCK_STALE_MS)
231
+ unlinkSync(lock);
232
+ }
233
+ catch {
234
+ // The holder released the lock between the two calls. Try again.
235
+ }
236
+ if (Date.now() > deadline)
237
+ throw new Error(`${lock} is held by another process, so the log is not appended. Remove the file if no agent-custody process runs.`);
238
+ pause(2 + Math.random() * 8);
175
239
  }
240
+ try {
241
+ return fn();
242
+ }
243
+ finally {
244
+ try {
245
+ unlinkSync(lock);
246
+ }
247
+ catch { /* a writer removed it as stale */ }
248
+ }
249
+ }
250
+ /** Under the lock: reads what other writers appended, then writes this line, so each leaf gets the next index. */
251
+ appendLine(line, hash) {
252
+ return this.locked(() => {
253
+ this.catchUp();
254
+ appendFileSync(this.file, line);
255
+ this.bytes += Buffer.byteLength(line);
256
+ return this.pushHash(hash());
257
+ });
176
258
  }
177
259
  get size() {
178
260
  return this.hashes.length;
@@ -183,8 +265,7 @@ export class MerkleLog {
183
265
  }
184
266
  /** Appends a leaf (an opaque string, typically a canonical JSON envelope). Returns its proof against the new root. */
185
267
  append(leaf) {
186
- appendFileSync(this.file, JSON.stringify(leaf) + "\n");
187
- return this.pushHash(leafHash(leaf));
268
+ return this.appendLine(JSON.stringify(leaf) + "\n", () => leafHash(leaf));
188
269
  }
189
270
  /**
190
271
  * Appends a leaf by its RFC 6962 leaf hash, sha256(0x00 || leaf), as hex. The log commits to the leaf without ever
@@ -193,8 +274,7 @@ export class MerkleLog {
193
274
  appendHash(leafHashHex) {
194
275
  if (!/^[0-9a-f]{64}$/.test(leafHashHex))
195
276
  throw new Error("leafHash must be 64 lowercase hex characters");
196
- appendFileSync(this.file, JSON.stringify({ hash: leafHashHex }) + "\n");
197
- return this.pushHash(Buffer.from(leafHashHex, "hex"));
277
+ return this.appendLine(JSON.stringify({ hash: leafHashHex }) + "\n", () => Buffer.from(leafHashHex, "hex"));
198
278
  }
199
279
  pushHash(hash) {
200
280
  this.hashes.push(hash);
package/dist/policy.d.ts CHANGED
@@ -18,6 +18,12 @@ export interface PolicyRequest {
18
18
  export declare function hasPermitRule(policyText: string): boolean;
19
19
  /** Why Cedar cannot parse the policy set, or an empty list when it can. */
20
20
  export declare function policyParseErrors(policyText: string): string[];
21
+ /** The text of each static policy, in file order. Cedar names them `policy0`, `policy1`, and so on in this order. */
22
+ export declare function policyRules(policyText: string): string[];
23
+ /** The `@reason("...")` annotation of each static policy, in file order, or null for a policy without one. */
24
+ export declare function policyReasons(policyText: string): (string | null)[];
25
+ /** The reason of the policy that a Cedar id such as `policy3` names: its `@reason` text, or the id when it has none. */
26
+ export declare function reasonOfRule(id: string, reasons: readonly (string | null)[]): string;
21
27
  export declare function policyDigest(policyText: string): string;
22
28
  /**
23
29
  * Cedar's JSON context reads `{ "__entity": … }` and `{ "__extn": … }` as typed values. Arguments come from the agent,
package/dist/policy.js CHANGED
@@ -16,6 +16,23 @@ export function policyParseErrors(policyText) {
16
16
  const parsed = cedar.checkParsePolicySet({ staticPolicies: policyText });
17
17
  return parsed.type === "success" ? [] : parsed.errors.map((e) => e.message);
18
18
  }
19
+ /** The text of each static policy, in file order. Cedar names them `policy0`, `policy1`, and so on in this order. */
20
+ export function policyRules(policyText) {
21
+ const parts = cedar.policySetTextToParts(policyText);
22
+ return parts.type === "success" ? parts.policies : [];
23
+ }
24
+ /** The `@reason("...")` annotation of each static policy, in file order, or null for a policy without one. */
25
+ export function policyReasons(policyText) {
26
+ return policyRules(policyText).map((rule) => {
27
+ const j = cedar.policyToJson(rule);
28
+ const reason = j.type === "success" ? j.json.annotations?.reason : undefined;
29
+ return typeof reason === "string" && reason.trim() ? reason.trim() : null;
30
+ });
31
+ }
32
+ /** The reason of the policy that a Cedar id such as `policy3` names: its `@reason` text, or the id when it has none. */
33
+ export function reasonOfRule(id, reasons) {
34
+ return reasons[Number(id.replace(/^policy/, ""))] ?? id;
35
+ }
19
36
  export function policyDigest(policyText) {
20
37
  return sha256Hex(policyText);
21
38
  }
@@ -1,6 +1,15 @@
1
1
  // Adapter for Claude Code hooks (command hooks over stdin/stdout) and the Claude Agent SDK (in-process hooks).
2
2
  // Both use the same input and output JSON, so one handler serves both.
3
+ import { reasonOfRule } from "../policy.js";
3
4
  import { createSdkIssuer, receiptIdOf, denies } from "./index.js";
5
+ /** What Claude Code and the person see. A rule with a `@reason` gives its text; any other rule gives its id. The rules are in file order. A deny with no rule keeps the plain text. */
6
+ function denialText(issuer, policy, reason, evidence) {
7
+ if (policy.reasons.length === 0)
8
+ return `agent-custody: ${reason} (${evidence})`;
9
+ const ids = [...policy.reasons].sort((a, b) => Number(a.replace(/^policy/, "")) - Number(b.replace(/^policy/, "")));
10
+ const said = [...ids.map((id) => reasonOfRule(id, issuer.ruleReasons)), ...policy.errors].join("; ");
11
+ return `agent-custody denied this call: ${said} (${ids.length === 1 ? "rule" : "rules"} ${ids.join(", ")}, ${evidence})`;
12
+ }
4
13
  function toEvent(input) {
5
14
  const raw = input.tool_input;
6
15
  const args = raw && typeof raw === "object" && !Array.isArray(raw) ? raw : { input: raw ?? null };
@@ -18,13 +27,20 @@ export async function handleHookEvent(issuer, input) {
18
27
  const policy = issuer.decide(ev);
19
28
  if (denies(policy)) {
20
29
  const reason = [...policy.reasons, ...policy.errors].join("; ") || "no permit policy matched";
21
- const bundle = await issuer.record(ev, { status: "denied", reason }, policy);
30
+ // A hook that throws does not block the call, so a log outage must not cost the denial.
31
+ let evidence;
32
+ try {
33
+ evidence = `receipt ${receiptIdOf(await issuer.record(ev, { status: "denied", reason }, policy))}`;
34
+ }
35
+ catch (e) {
36
+ evidence = `no receipt: ${e instanceof Error ? e.message : String(e)}`;
37
+ }
22
38
  return {
23
39
  continue: true,
24
40
  hookSpecificOutput: {
25
41
  hookEventName: "PreToolUse",
26
42
  permissionDecision: "deny",
27
- permissionDecisionReason: `agent-custody: ${reason} (receipt ${receiptIdOf(bundle)})`,
43
+ permissionDecisionReason: denialText(issuer, policy, reason, evidence),
28
44
  },
29
45
  };
30
46
  }
@@ -27,6 +27,8 @@ export interface SdkIssuer {
27
27
  keyid: string;
28
28
  /** where the leaves go: the local file or the remote log */
29
29
  log: LogSink;
30
+ /** The `@reason` text of each policy in the policy file, in file order, or null for a policy without one. Parsed once at load. */
31
+ ruleReasons: readonly (string | null)[];
30
32
  /** Evaluates the configured policy for a call. Returns null when no policy is configured. */
31
33
  decide(ev: ToolEvent): PolicyDecision | null;
32
34
  /** Issues one receipt for a completed, failed, denied, or errored call. Rejects if the log refuses it. */
package/dist/sdk/index.js CHANGED
@@ -7,7 +7,7 @@ import { digestOf, loadPrivateKey } from "../crypto.js";
7
7
  import { createIssuer } from "../issue.js";
8
8
  import { openExporter } from "../otel.js";
9
9
  import { openLog } from "../log-sink.js";
10
- import { evaluate } from "../policy.js";
10
+ import { evaluate, policyReasons } from "../policy.js";
11
11
  export const SDK_VERSION = "0.1.0";
12
12
  /** True when a decision is a deny that must be enforced: a deny made in observe mode (`enforced: false`) is recorded, not acted on. */
13
13
  export function denies(policy) {
@@ -36,6 +36,7 @@ export function createSdkIssuer(cfg) {
36
36
  // the capture rules are applied by the issuer to every statement it signs, so every adapter's receipt gets them
37
37
  const issuer = createIssuer(key, cfg.receiptsDir, openLog(cfg, key), { exporter: openExporter(cfg), capture: { rules: cfg.capture, key: captureKey } });
38
38
  const policyText = cfg.policyFile ? readFileSync(cfg.policyFile, "utf8") : null;
39
+ const ruleReasons = policyText === null ? [] : policyReasons(policyText);
39
40
  const decide = (ev) => {
40
41
  if (policyText === null)
41
42
  return null;
@@ -68,6 +69,7 @@ export function createSdkIssuer(cfg) {
68
69
  agentId: cfg.agentId,
69
70
  keyid: issuer.keyid,
70
71
  log: issuer.log,
72
+ ruleReasons,
71
73
  decide,
72
74
  record,
73
75
  wrap(tool, fn, meta = {}) {
package/dist/witness.js CHANGED
@@ -41,7 +41,7 @@ export class Witness {
41
41
  }
42
42
  }
43
43
  async logKeys() {
44
- const res = await this.f(new URL("/.well-known/agent-custody-log.json", this.o.logUrl));
44
+ const res = await this.f(new URL("/.well-known/agent-custody-log.json", this.o.logUrl), { signal: AbortSignal.timeout(10_000) });
45
45
  if (!res.ok)
46
46
  throw new Error(`log key document: ${res.status}`);
47
47
  const doc = (await res.json());
@@ -49,7 +49,7 @@ export class Witness {
49
49
  }
50
50
  async latest(tenant) {
51
51
  const base = this.o.checkpointsUrl.endsWith("/") ? this.o.checkpointsUrl : `${this.o.checkpointsUrl}/`;
52
- const res = await this.f(new URL(`${safe(tenant)}/latest.json`, base));
52
+ const res = await this.f(new URL(`${safe(tenant)}/latest.json`, base), { signal: AbortSignal.timeout(10_000) });
53
53
  if (res.status === 404)
54
54
  return null;
55
55
  if (!res.ok)
@@ -59,7 +59,7 @@ export class Witness {
59
59
  async proof(tenant, oldSize, newSize) {
60
60
  const base = this.o.logUrl.endsWith("/") ? this.o.logUrl : `${this.o.logUrl}/`;
61
61
  const path = tenant === "default" ? `consistency?old=${oldSize}&new=${newSize}` : `t/${tenant}/consistency?old=${oldSize}&new=${newSize}`;
62
- const res = await this.f(new URL(path, base));
62
+ const res = await this.f(new URL(path, base), { signal: AbortSignal.timeout(10_000) });
63
63
  if (!res.ok)
64
64
  throw new Error(`consistency proof for ${tenant}: ${res.status}`);
65
65
  return (await res.json()).hashes;
@@ -0,0 +1,59 @@
1
+ # Completeness: matching the provider's records against the receipts
2
+
3
+ A verified receipt proves what went through the gateway. Nothing on the gateway's side can see an action that never went through it: whoever holds the Stripe key can issue a refund straight through Stripe's API. The provider's own record is the only place that action shows. `agent-custody completeness` lets an auditor check it, with a read-only key of their own.
4
+
5
+ ## What it reports
6
+
7
+ For a window and a set of tools, it lists the provider's objects and matches each to a verified receipt by the provider's object id, which the receipt's result carries.
8
+
9
+ | section | meaning | what to do |
10
+ | --- | --- | --- |
11
+ | provider actions with no receipt | an object the provider created in the window that no verified receipt names | the finding this command exists for: an action taken outside the gateway, or by a gateway whose receipts you were not given |
12
+ | receipts the provider does not have | an executed receipt in the window whose object the provider has no record of | a receipt for something that did not happen at the provider, or an object in another account or mode |
13
+ | mismatches | a matched pair whose amount, currency (ignoring case), or a beneficiary field differs | the receipt and the provider disagree about what happened |
14
+ | one provider object, several receipts | more than one verified receipt names the same provider object; each is still compared with it | one action recorded twice, or receipts that contradict each other |
15
+ | forwarded without an outcome receipt | a call committed to the log before it was forwarded (`precommit`) whose outcome receipt is missing | the gateway stopped after forwarding; this explains a provider object that has no receipt, without guessing which one |
16
+ | unmatchable | a verified, executed receipt whose provider id cannot be read, or whose amount, currency, or beneficiary argument cannot be compared, because a capture rule withholds it | match it by hand against the values disclosed with `agent-custody reveal` |
17
+ | not verified | a receipt file that failed verification, or a valid receipt or authorization stored under a name that is not its signed receipt id | it is not matched, so its provider object shows as having no receipt |
18
+
19
+ The result is `COMPLETE` only when every section but the matches is empty, and the command exits 1 otherwise.
20
+
21
+ Only receipts that verify against the keys you give are matched. A forged or edited receipt file cannot cover for a provider action, because it fails verification and its object then appears as having no receipt. Denied, withheld, and failed calls are not expected to have a provider object, and reconciliation receipts are skipped, because the original receipt is the one that names the object.
22
+
23
+ The provider is listed fifteen minutes either side of the window (`marginMs` in code), so a receipt signed just inside the window still finds an object created just outside it. The margin does not widen the period reported on: a pair is reported only when its receipt or its object falls inside the window, and a call forwarded without an outcome only when its authorization was signed inside it.
24
+
25
+ An authorization is tied to its outcome by the receipt id both of them sign, never by the file name. A valid receipt copied under the name of a missing outcome therefore hides nothing: it is reported as not verified, and the call is still listed as forwarded without an outcome.
26
+
27
+ ## Running it
28
+
29
+ ```bash
30
+ export STRIPE_AUDIT_KEY=rk_live_... # a restricted key with read access to refunds, held by the auditor
31
+ agent-custody completeness --receipts ./receipts --issuer-key gateway.pub --principal-key principal.pub \
32
+ --log log.jsonl --provider stripe --object refunds --key-env STRIPE_AUDIT_KEY \
33
+ --tool stripe.refund --since 2026-10-01T00:00:00Z --until 2026-11-01T00:00:00Z
34
+ ```
35
+
36
+ | flag | default | meaning |
37
+ | --- | --- | --- |
38
+ | `--receipts <dir>` | | the auditor's copy of the receipts directory, authorization files included |
39
+ | `--issuer-key`, `--principal-key`, `--approval-key`, `--log-key`, `--log`, `--log-id` | | how each receipt is verified, as for `verify` |
40
+ | `--provider stripe` | | the provider; Stripe is the only one so far |
41
+ | `--object` | `refunds` | `refunds`, `payouts`, or `transfers` |
42
+ | `--key-env NAME` | | the environment variable holding the read-only key; never a flag value |
43
+ | `--tool <name>` | | each tool whose executed calls create provider objects; repeatable |
44
+ | `--since`, `--until` | | the window, ISO times; `--until` is exclusive |
45
+ | `--id-path` | `id` | where the provider's object id sits in the JSON of the result's first text item; Stripe's own response uses `id` |
46
+ | `--amount-field`, `--currency-field` | `amount`, `currency` | the call arguments compared with the provider's amount and currency |
47
+ | `--beneficiary <arg>=<field>` | | a call argument that must equal a provider field, such as `charge=charge` or `customer_id=metadata.customer_id`; repeatable |
48
+ | `--json` | | the full report as JSON |
49
+
50
+ Use a restricted Stripe key with read-only access to the objects you check. The command only lists objects: it never creates, retries, or reconciles anything. The operator's `reconcile` command is a different thing: it settles one financial operation through the gateway and writes a receipt.
51
+
52
+ ## Limits
53
+
54
+ - **The receipts you were given.** The check proves completeness against those receipts. A second gateway, or a second receipts directory, that issued receipts you were not handed shows up as provider actions with no receipt, which is the correct finding.
55
+ - **One provider account and mode per run.** Test-mode and live-mode objects are separate lists.
56
+ - **The id must be readable.** A capture rule that withholds the result content also withholds the object id inside it, and such receipts are reported as unmatchable, never as matched or missing. A rule that keeps `content` in clear (`result: { mode: "digest", clear: ["content"] }`) leaves the id readable. Likewise, keep the amount, currency, and beneficiary arguments in clear, or those comparisons are reported as unmatchable. Reading values from disclosures is still to come.
57
+ - **Stripe first.** Other providers, and on-chain transfers from an agent's wallet, are `ProviderSource` implementations still to come.
58
+
59
+ In code, `checkCompleteness({ receiptsDir, verify, source, tools, sinceMs, untilMs })` returns the report, `stripeSource({ secretKey, object })` lists Stripe objects, and `formatCompleteness(report)` prints it. Example 35 runs the whole check against a stand-in for Stripe's list API.
@@ -2,6 +2,8 @@
2
2
 
3
3
  Auditors ask for controls by their names. This page maps the requirements they cite most to the artefacts agent-custody produces, so a security questionnaire can be answered with a file rather than a paragraph. It is a map, not a certificate: the artefacts are evidence that a control operated, and the control itself, the policy, the grant, the retention window, the person who reviews an alarm, is yours.
4
4
 
5
+ This page is dated. The SOC 2, ISO/IEC 27001, and UK GDPR sections below are not re-checked against primary text since they were first written. The section "Regulations and frameworks for AI agents" carries a primary source and an "as of" date for each framework. No part of this page says that the product makes you compliant.
6
+
5
7
  Two rules keep the answers honest. First, say which producer made the receipt: a gateway receipt was enforced outside the agent's process, an SDK receipt is the agent's own report, and the receipt's `issuer.kind` says which. Second, say where the log runs: with the default local log the operator can rewrite history, with a log run by someone else they cannot, and with a witness neither operator can. The [proof table](../README.md#what-a-receipt-proves-and-what-it-does-not) has the full list of claims and against whom each holds.
6
8
 
7
9
  ## The artefacts
@@ -41,14 +43,122 @@ Two rules keep the answers honest. First, say which producer made the receipt: a
41
43
  | A.8.16, monitoring activities | networks, systems, and applications are monitored | `log-check` from a machine that is not the log's, and the per-receipt spans in the SIEM |
42
44
  | A.8.32, change management | changes are subject to change management | the policy digest, the grant's window, and the receipts either side of a change; for agent-made changes, the merge gate below |
43
45
 
44
- ## EU AI Act, obligations on high-risk systems and their deployers
46
+ ## Regulations and frameworks for AI agents
45
47
 
46
- | article | what it asks | what answers it |
47
- | --- | --- | --- |
48
- | Article 12, record-keeping | automatic recording of events over the system's lifetime, enabling traceability | one receipt per tool call, in a tamper-evident log, with the facts the agent was shown and the beliefs it wrote; `explain` traces any action to its causes and consequences |
49
- | Article 14, human oversight | humans can understand, oversee, and intervene | the grant is a human's signature over what the agent may do; the policy decides on facts the agent did not supply; retract and forget are the intervention, receipted |
50
- | Article 19, retention of logs | logs are kept for a period appropriate to the purpose | retention windows per space in the memory server; `prune` on the receipt log keeps every proof valid while the content is gone; a legal hold overrides both |
51
- | Article 26, deployer obligations | deployers keep logs and monitor operation | the same receipts and the same monitor; a tenant on the hosted log has its own log id and checkpoints an auditor can fetch |
48
+ This section was checked against primary sources on 2026-11-02. Each row links to the primary text. Each framework has its own "as of" date. A rule can change after that date. Open the link before you rely on a date or a quotation.
49
+
50
+ Read the last column of each table first. It states what a receipt does not supply. No row says that a receipt makes you compliant. Compliance depends on facts that no receipt records, and on how a regulator or an auditor reads the rule. This page is not legal advice.
51
+
52
+ | framework | kind | status on 2026-11-02 | applies from | as of |
53
+ | --- | --- | --- | --- | --- |
54
+ | [EU AI Act](#eu-ai-act), Regulation (EU) 2024/1689 | regulation | in force. The Digital Omnibus on AI, Regulation (EU) 2026/1744, is adopted law, not a proposal | high-risk duties in Chapter III, Sections 1 to 3: 2 December 2027 for Annex III systems, 2 August 2028 for Annex I systems | 2026-11-02 |
55
+ | [FINRA](#finra) | existing rules and a guidance report | no new rule for agents. The 2026 report is guidance | not applicable | 2026-11-02 |
56
+ | [MAS](#mas-singapore), Guidelines on Artificial Intelligence Risk Management | supervisory expectations | issued 7 October 2026 | 7 October 2027. Sections 5 and 6 may be met by 7 October 2028 | 2026-11-02 |
57
+ | [Colorado](#colorado), SB26-189 | state statute | signed into law | 1 January 2027, for consequential decisions made on or after that date | 2026-11-02 |
58
+ | [DORA](#dora), Regulation (EU) 2022/2554 | regulation | applies | 17 January 2025 | 2026-11-02 |
59
+ | [CSA AICM](#csa-ai-controls-matrix) | voluntary control framework | version 1.1 is published | not applicable | 2026-11-02 |
60
+ | [OWASP agentic guidance](#owasp-top-10-for-agentic-applications) | voluntary risk list | 2026 edition, December 2025 | not applicable | 2026-11-02 |
61
+ | [ISO/IEC 42001](#iso-iec-42001) | voluntary management system standard | edition 1, 2023 | not applicable | 2026-11-02 |
62
+
63
+ ### EU AI Act
64
+
65
+ **Dates.** The regulation as first published sets the general date of application at 2 August 2026 ([Article 113](https://eur-lex.europa.eu/eli/reg/2024/1689/oj)). Regulation [(EU) 2026/1744](https://eur-lex.europa.eu/eli/reg/2026/1744/oj), the Digital Omnibus on AI, replaces point (c) of the third paragraph of Article 113. It is dated 8 July 2026. It appeared in the Official Journal on 24 July 2026. It enters into force on the third day after publication, which is 27 July 2026. It is adopted law. Chapter III, Sections 1, 2, and 3, now apply from:
66
+
67
+ - 2 December 2027, for AI systems classified as high-risk under Article 6(2) and Annex III;
68
+ - 2 August 2028, for AI systems classified as high-risk under Article 6(1) and Annex I.
69
+
70
+ Articles 12 and 14 are in Section 2. Articles 19 and 26 are in Section 3. So none of them applies to a high-risk system on 2026-11-02. The Omnibus does not amend Article 12, 14, 19, or 26, and it does not amend the list in Annex III. The Omnibus changes other dates too, for example for Article 50(2) and for new Article 5 prohibitions. This page covers the logging duties only. This page lists no later amending act. Check the Official Journal before you rely on a date.
71
+
72
+ **Scope.** Articles 12, 19, and 26(6) bind high-risk AI systems. Annex III lists eight areas: biometrics; critical infrastructure; education and vocational training; employment and workers' management; access to essential private and public services and benefits (including credit scoring and life and health insurance pricing); law enforcement; migration, asylum, and border control; and the administration of justice and democratic processes. A general agent that calls tools is not high-risk by that fact. It is in scope when its intended use sits in one of these areas, or when Article 6(1) and Annex I make it high-risk. Article 6(3) lets a provider show that an Annex III system is not high-risk. It never excludes a system that profiles natural persons.
73
+
74
+ | provision | what it asks | what a receipt supplies | what a receipt does not supply |
75
+ | --- | --- | --- | --- |
76
+ | [Article 12](https://eur-lex.europa.eu/eli/reg/2024/1689/oj), record-keeping | High-risk systems "technically allow for the automatic recording of events (logs) over the lifetime of the system". The logs help to identify risk situations, to support post-market monitoring, and to monitor operation under Article 26(5). Systems in Annex III point 1(a) have more minimum items in Article 12(3). | One signed receipt for each tool call that goes through the gateway: the grant, the policy decision and its digest, digests of the arguments and the result, and the position in the log. `explain` traces an action to its causes and consequences. | Events that are not tool calls, for example what the model did inside one step. The items in Article 12(3), for example the reference database and the input data that matched. A decision on whether your system is high-risk. An SDK receipt is the agent's own report, so it is weaker evidence than a gateway receipt. |
77
+ | [Article 19](https://eur-lex.europa.eu/eli/reg/2024/1689/oj), logs kept by providers | Providers keep the Article 12(1) logs "to the extent such logs are under their control". The period suits the intended purpose and is "at least six months", unless other Union or national law says otherwise, in particular data protection law. Providers that are financial institutions keep the logs with the documentation that financial services law requires. | Receipts and the log stay with the party that runs the gateway. The hosted log holds hashes only, so the receipts stay with you. `prune` keeps every proof valid after the content goes. In the memory server, retention windows apply by space and a legal hold overrides them. | The six-month minimum. `prune` takes any cutoff that you give it and has no minimum. You set the period, and you check it against data protection law. The hosted log is not a copy of the receipts. Logs outside the gateway. |
78
+ | [Article 26(6)](https://eur-lex.europa.eu/eli/reg/2024/1689/oj), logs kept by deployers | Deployers keep the logs that the high-risk system generates, "to the extent such logs are under their control", for at least six months, unless other law says otherwise. Deployers that are financial institutions keep them with their financial services documentation. | The same receipts and the same log. A tenant on the hosted log has its own log identifier and checkpoints, and an export that works with no server. | The same limits as Article 19. A receipt is a record of a tool call through the gateway. It may not be all the logs that the system generates. |
79
+ | [Article 26(5)](https://eur-lex.europa.eu/eli/reg/2024/1689/oj), monitoring by deployers | Deployers monitor the operation of the system on the basis of the instructions for use. They inform the provider, and in some cases the market surveillance authority. They suspend use when there is a risk. | The monitor, `log-check`, the OpenTelemetry and Splunk exports, and `agent-custody revoke`, which makes every session under a grant refuse its next call. | The decision that a risk exists. The duty to inform the provider or an authority. The instructions for use. |
80
+ | [Article 14](https://eur-lex.europa.eu/eli/reg/2024/1689/oj), human oversight | Systems are designed so that natural persons can oversee them, understand their output, and stop them. | The grant is a human's signature over what the agent may do. A payload-bound approval records the human who approved one action. Retract and forget are receipted calls. | The human-machine interface. The training of the overseer. Evidence that the overseer understood the output. |
81
+
82
+ Source for this section: Regulation (EU) 2024/1689 and Regulation (EU) 2026/1744 in the Official Journal. As of 2026-11-02.
83
+
84
+ ### FINRA
85
+
86
+ FINRA has no rule written for AI agents. Its rules are technology-neutral. Regulatory Notice 24-09 (27 June 2024) says that FINRA rules apply to the use of generative AI "just as they apply when member firms use any other technology or tool", and that it "does not create new legal or regulatory requirements". The 2026 Annual Regulatory Oversight Report (9 December 2025) adds a section on AI agents. It is guidance, not a rule.
87
+
88
+ | provision | what it asks | what a receipt supplies | what a receipt does not supply |
89
+ | --- | --- | --- | --- |
90
+ | Rule 3110, supervision, as the [2026 report](https://www.finra.org/rules-guidance/guidance/reports/2026-finra-annual-regulatory-oversight-report/gen-ai) cites it | A member firm has "a reasonably designed supervisory system tailored to its business". | Per-call evidence that a supervisor can sample: who authorized the call, the policy decision, and the result. | The supervisory system itself: the procedures, the reviews, and the person who reads the records. |
91
+ | [2026 report, AI agents](https://www.finra.org/rules-guidance/guidance/reports/2026-finra-annual-regulatory-oversight-report/gen-ai) | Lists the risks of autonomy without human validation, of action beyond the intended scope and authority, and of outcomes that are "difficult to trace or explain". Says that firms may consider "how to track agent actions and decisions" and how to set guardrails. | A receipt for each call, allowed or denied. The grant states the scope, and the policy enforces it outside the agent's process. `explain` traces one action. | A record of the agent's reasoning. A guarantee that every action went through the gateway. A human check, unless you use approvals. |
92
+ | [2026 report, generative AI](https://www.finra.org/rules-guidance/guidance/reports/2026-finra-annual-regulatory-oversight-report/gen-ai) | Says that generative AI "can implicate rules regarding supervision, communications, recordkeeping and fair dealing". Says that a firm may consider "storing prompt and output logs". The section names no recordkeeping rule. | Tool-call records in a signed, tamper-evident log. | Prompts and model outputs: a receipt has no prompt text. Customer communications. A finding that a record meets a books-and-records storage rule. This page did not check such a rule. |
93
+
94
+ Sources: the 2026 report, in the links above; [Regulatory Notice 24-09](https://www.finra.org/rules-guidance/notices/24-09). As of 2026-11-02.
95
+
96
+ ### MAS, Singapore
97
+
98
+ The Monetary Authority of Singapore issued its Guidelines on Artificial Intelligence Risk Management on 7 October 2026. They set supervisory expectations. They apply to all financial institutions and all forms of AI, and paragraph 1.5 names AI agents. The guidelines take effect on 7 October 2027. Paragraph 1.8 says that firms may meet the expectations in Sections 3 and 4 from that date, and those in Sections 5 and 6 by 7 October 2028. The two paragraphs below are in Section 5.
99
+
100
+ | provision | what it asks | what a receipt supplies | what a receipt does not supply |
101
+ | --- | --- | --- | --- |
102
+ | [Paragraph 5.9(d)](https://www.mas.gov.sg/-/media/mas-media-library/regulation/guidelines/bd/guidelines-on-artificial-intelligence-risk-management-for-financial-institutions/guidelines-on-artificial-intelligence-risk-management.pdf), human oversight: documentation and review | Processes "to document logs and other records generated through development, deployment, operation, monitoring and incident management", and a regular review of human oversight decisions and interventions. | Operation records: each call with its decision. The grant, approval, retract, and forget calls are receipts too, so they show when a human intervened. | Logs of development. The review process and its findings. |
103
+ | [Paragraph 5.23(d)](https://www.mas.gov.sg/-/media/mas-media-library/regulation/guidelines/bd/guidelines-on-artificial-intelligence-risk-management-for-financial-institutions/guidelines-on-artificial-intelligence-risk-management.pdf), post-deployment monitoring: documentation | Records of monitoring, results, incidents, and remediation. Access to AI systems "should be strictly controlled and logged". For generative AI or AI agents, "enhanced documentation" such as "logging prompts and model responses, together with applicable model versions and reasoning processes" may be considered. | A tamper-evident record of tool calls and of the policy that decided each one. The receipt names the model, in a field marked `claimed`. | Prompts, model responses, and reasoning. A verified model version: no hosted provider signs the model identity. Records of the monitoring that people did. |
104
+
105
+ Source: the [MAS guidelines](https://www.mas.gov.sg/regulation/guidelines/guidelines-on-artificial-intelligence-risk-management-for-financial-institutions), dated 7 October 2026. As of 2026-11-02.
106
+
107
+ ### Colorado
108
+
109
+ Colorado Senate Bill 26-189 repeals and re-enacts part 17 of article 1 of title 6 of the Colorado Revised Statutes, which was the 2024 Colorado AI Act. It regulates "automated decision-making technology" (ADMT) that is used to materially influence a "consequential decision". The bill page shows that the Governor signed it on 14 May 2026. Section 5 of the act says that the act takes effect on 1 January 2027, except a few provisions that took effect on passage. It also says that the act applies to consequential decisions made on or after 1 January 2027. A consequential decision is one about a covered domain: education, employment, residential real estate, a financial or lending service, insurance, health-care services, or essential government services and public benefits. The Attorney General enforces the act. The act creates no new private right of action. The act tells the Attorney General to adopt rules on post-adverse-outcome disclosure on or before 1 January 2027. Read those rules, and check for any court order, before you rely on the date.
110
+
111
+ | provision | what it asks | what a receipt supplies | what a receipt does not supply |
112
+ | --- | --- | --- | --- |
113
+ | [Section 6-1-1703](https://leg.colorado.gov/bill_files/116489/download), deployer record keeping | A deployer retains, for not less than three years after the date of a consequential decision, "records reasonably necessary to demonstrate compliance" with part 17. The records may include ADMT version identifiers, changelogs, and documentation of material mitigation changes. | A signed record of each tool call. The policy digest identifies the exact policy that decided the call, so a change to the policy is visible. `prune` and the retention windows let you keep a record for the period that you choose. | The notices, the post-adverse-outcome disclosures, and the consumer rights that part 17 creates. A test of whether a decision is consequential. An ADMT version identifier: the model identity is `claimed`. A three-year minimum: `prune` has no minimum. The arguments of a call can hold personal data, so privacy law can ask you to delete what this law asks you to keep. |
114
+ | [Section 6-1-1702](https://leg.colorado.gov/bill_files/116489/download), developer documentation | From 1 January 2027, a developer of a covered ADMT makes documentation available to each deployer. A developer retains records for not less than three years after their creation. | Nothing here. A receipt records a call, not the documentation of a developer. | The developer documentation. |
115
+
116
+ Sources: the [bill page](https://leg.colorado.gov/bills/sb26-189) and the [enrolled act](https://leg.colorado.gov/bill_files/116489/download) of Senate Bill 26-189. As of 2026-11-02.
117
+
118
+ ### DORA
119
+
120
+ Regulation (EU) 2022/2554 applies from 17 January 2025 (Article 64). It covers the financial entities listed in Article 2, for example credit institutions, payment institutions, investment firms, and insurance undertakings. It also covers ICT third-party service providers. The text of DORA and the text of the logging standard below do not use the term "artificial intelligence". Each firm decides whether it treats the tool calls of an agent as ICT operations.
121
+
122
+ | provision | what it asks | what a receipt supplies | what a receipt does not supply |
123
+ | --- | --- | --- | --- |
124
+ | [Article 17](https://eur-lex.europa.eu/eli/reg/2022/2554/oj), ICT-related incident management | Financial entities "record all ICT-related incidents and significant cyber threats". The process identifies, tracks, logs, categorises, and classifies incidents. | Evidence about what an agent did around an incident: the action pack, the blast radius of a wrong fact, and the receipts of denied calls. | The incident register. The classification under Article 18. The report to the authority. The root cause analysis. |
125
+ | [Delegated Regulation (EU) 2024/1774, Article 12](https://eur-lex.europa.eu/eli/reg_del/2024/1774/oj), logging | Logging procedures, protocols, and tools. They log events about access control and identity management, change management, and ICT operations. They protect log systems "against tampering, deletion, and unauthorised access", and they synchronise clocks. The entity sets the retention period. | A signed, hashed, append-only log. The audit proves that nobody rewrote the log between two points. The grant records who may act. The policy digest records a change to the policy. | Logs of capacity management and network traffic. The retention period: you set it. Synchronised clocks: the timestamp in a receipt is the producer's own. |
126
+
127
+ Sources: Regulation (EU) 2022/2554 and Delegated Regulation (EU) 2024/1774 in the Official Journal. As of 2026-11-02.
128
+
129
+ ### CSA AI Controls Matrix
130
+
131
+ The AI Controls Matrix (AICM) of the Cloud Security Alliance is a voluntary framework. Version 1.1 has 247 control objectives in 18 domains. It maps to ISO/IEC 42001, ISO/IEC 27001, the EU AI Act, NIST AI RMF and AI 600-1, BSI AIC4, and AIUC-1. Its questionnaire, the AI-CAIQ, has 320 questions. The CSA artifact page gives 22 June 2026 as the release date. The CSA announcement is dated 14 July 2026.
132
+
133
+ | provision | what it asks | what a receipt supplies | what a receipt does not supply |
134
+ | --- | --- | --- | --- |
135
+ | [AICM v1.1](https://cloudsecurityalliance.org/artifacts/ai-controls-matrix-v1-1) as a whole | Control objectives that an organization assesses itself against, or that a third party assesses, through the AI-CAIQ. | Evidence for any control objective that asks for a record of what an AI system did: the artefacts in the table under "The artefacts". | A mapping to control identifiers. The control spreadsheet is a download that this update did not read, so this page names no AICM control. A receipt is evidence for a control. It is not the control. |
136
+
137
+ Sources: the [CSA artifact page](https://cloudsecurityalliance.org/artifacts/ai-controls-matrix-v1-1) and the [CSA announcement](https://cloudsecurityalliance.org/blog/2026/07/14/ai-controls-matrix-v1-1-strengthening-the-foundation-for-trustworthy-ai). As of 2026-11-02.
138
+
139
+ ### OWASP Top 10 for Agentic Applications
140
+
141
+ The OWASP Gen AI Security Project published the Top 10 for Agentic Applications for 2026 on 9 December 2025. It is a list of risks and mitigations. It is guidance, not law. Its mitigation lists ask for logs in several places. The rows below name five of them.
142
+
143
+ | item | what it asks | what a receipt supplies | what a receipt does not supply |
144
+ | --- | --- | --- | --- |
145
+ | ASI01, Agent Goal Hijack | "Comprehensive logging and continuous monitoring of agent activity", with a baseline of tool-use patterns. | A record of each tool call, the monitor, and the SIEM exports. | The baseline and the alerts. You build them. |
146
+ | ASI02, Tool Misuse and Exploitation | "Immutable logs of all tool invocations and parameter changes", and monitoring for anomalous tool chains. | A signed receipt in a Merkle log for each call through the gateway, with the digest of the arguments. | Calls that do not go through the gateway. Detection of an anomalous chain. |
147
+ | ASI08, Cascading Failures | Tamper-evident, time-stamped logs of inter-agent messages, policy decisions, and execution outcomes, with lineage for every propagated action. | Policy decisions and execution outcomes. `explain` and the blast radius give lineage. | Inter-agent messages that are not tool calls. |
148
+ | ASI09, Human-Agent Trust Exploitation | "Immutable logs" of user queries and agent actions. | The actions of the agent. | User queries. |
149
+ | ASI10, Rogue Agents | "Immutable and signed audit logs of all agent actions, tool calls, and inter-agent communication". | Signed receipts of tool calls. | Inter-agent communication. A kill switch: the document lists one as a separate mitigation. |
150
+
151
+ Source: the [OWASP document](https://genai.owasp.org/resource/owasp-top-10-for-agentic-applications-for-2026/), version 2026, December 2025. As of 2026-11-02.
152
+
153
+ ### ISO/IEC 42001
154
+
155
+ ISO/IEC 42001:2023 is the standard for an artificial intelligence management system. Edition 1 was published on 2023-12-18. It specifies requirements for establishing, implementing, and maintaining a management system in an organization that offers or uses AI-enabled products or services.
156
+
157
+ | provision | what it asks | what a receipt supplies | what a receipt does not supply |
158
+ | --- | --- | --- | --- |
159
+ | [ISO/IEC 42001:2023](https://webstore.iec.ch/publication/90574) as a whole | A management system for an organization: its policies, roles, risk processes, and controls. | Operating evidence that a control ran, in a form that an auditor verifies with public keys. | The management system. A certificate: an audit of the organization produces that. A mapping to clauses or Annex A controls. The standard is sold, and this update did not read the text, so this page names no clause. |
160
+
161
+ Source: the [IEC publication page](https://webstore.iec.ch/publication/90574). As of 2026-11-02.
52
162
 
53
163
  ## UK GDPR
54
164
 
package/docs/policies.md CHANGED
@@ -168,6 +168,18 @@ permit(principal, action == Action::"memory.retract", resource)
168
168
  when { context.facts has target && context.facts.target.provenance == "claimed" };
169
169
  ```
170
170
 
171
+ ## Saying why a rule denies
172
+
173
+ Put a `@reason("...")` annotation before a `forbid` rule. The Claude Code hook shows the text to the agent and to the person who reads the session, and `agent-custody report` prints it before the rule.
174
+
175
+ ```cedar
176
+ @reason("force push rewrites shared history")
177
+ forbid(principal, action == Action::"Bash", resource)
178
+ when { context.args has command && context.args.command like "*git push*--force*" };
179
+ ```
180
+
181
+ The hook text is `agent-custody denied this call: force push rewrites shared history (rule policy1, receipt <id>)`. A rule with no annotation shows its id. The annotation is part of the policy file, so it changes the policy digest, but it never changes the decision or the receipt format. Keep the reason short and say what the rule forbids, not what the agent did. Only the Claude Code hook and the report read it today.
182
+
171
183
  ## Gotchas
172
184
 
173
185
  - **Integers only.** `12.50` is not a Cedar value. Send `1250`.