@agent-custody/receipts 0.13.0 → 0.15.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 +46 -28
- package/dist/check.d.ts +10 -0
- package/dist/check.js +179 -3
- package/dist/claude-init.d.ts +46 -0
- package/dist/claude-init.js +208 -0
- package/dist/cli.js +126 -11
- package/dist/config.d.ts +128 -1
- package/dist/config.js +92 -3
- package/dist/console.js +16 -7
- package/dist/deny-report.d.ts +30 -0
- package/dist/deny-report.js +106 -0
- package/dist/door.d.ts +203 -0
- package/dist/door.js +712 -0
- package/dist/export.d.ts +39 -0
- package/dist/export.js +95 -0
- package/dist/gateway.js +53 -21
- package/dist/index.d.ts +8 -0
- package/dist/index.js +7 -0
- package/dist/issue.js +5 -65
- package/dist/lock.d.ts +12 -0
- package/dist/lock.js +124 -0
- package/dist/log-admin.js +3 -3
- package/dist/log.d.ts +20 -3
- package/dist/log.js +117 -24
- package/dist/opa-server.d.ts +34 -0
- package/dist/opa-server.js +93 -0
- package/dist/policy-rego.d.ts +30 -0
- package/dist/policy-rego.js +114 -0
- package/dist/policy.d.ts +6 -0
- package/dist/policy.js +17 -0
- package/dist/pr-summary.d.ts +25 -0
- package/dist/pr-summary.js +87 -0
- package/dist/receipt.d.ts +3 -1
- package/dist/retention.d.ts +1 -1
- package/dist/retention.js +14 -4
- package/dist/sdk/claude.js +18 -2
- package/dist/sdk/index.d.ts +2 -0
- package/dist/sdk/index.js +11 -2
- package/dist/simulate.d.ts +3 -1
- package/dist/simulate.js +15 -7
- package/dist/verify.js +6 -3
- package/dist/witness.js +3 -3
- package/docs/compliance.md +117 -7
- package/docs/configuration.md +3 -3
- package/docs/door-signals.md +66 -0
- package/docs/door.md +168 -0
- package/docs/github-action.md +164 -0
- package/docs/policies.md +124 -1
- package/docs/sdk.md +99 -1
- package/docs/tutorials.md +5 -0
- package/docs/usage.md +3 -3
- package/docs/verification.md +9 -2
- package/package.json +16 -14
- package/templates/claude-code.cedar +373 -0
- package/vectors/audit.json +27 -27
- package/vectors/canonical.json +5 -5
- package/vectors/merkle.json +123 -0
- package/vectors/receipts.json +1258 -1005
package/dist/retention.d.ts
CHANGED
|
@@ -16,6 +16,6 @@ export interface PruneResult {
|
|
|
16
16
|
/**
|
|
17
17
|
* Prunes every leaf whose receipt timestamp is before the cutoff. Leaves already pruned, and leaves that are not
|
|
18
18
|
* receipts, are left as they are. Rewrites the log file in place and deletes the pruned receipts' bundle files, and
|
|
19
|
-
* the salts the issuer kept for them.
|
|
19
|
+
* the salts the issuer kept for them. It holds the log lock, so a receipt that a hook appends during the prune is not lost.
|
|
20
20
|
*/
|
|
21
21
|
export declare function pruneLog(logFile: string, before: string, receiptsDir?: string): PruneResult;
|
package/dist/retention.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
// the Merkle tree, every root, and every inclusion and consistency proof for the remaining leaves are unchanged, while
|
|
4
4
|
// the pruned receipt's content is gone from the log and its bundle file is removed. A verifier holding a pruned
|
|
5
5
|
// receipt's bundle can still prove inclusion; nobody holding only the log can recover what the receipt said.
|
|
6
|
-
import { existsSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
|
|
6
|
+
import { appendFileSync, existsSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
|
|
7
7
|
import { join } from "node:path";
|
|
8
|
-
import { leafHash } from "./log.js";
|
|
8
|
+
import { leafHash, logLocked } from "./log.js";
|
|
9
9
|
/** where the issuer keeps the salts behind a receipt's commitments, under the receipts directory; private, pruned with the receipt */
|
|
10
10
|
export const SALTS_DIR = "salts";
|
|
11
11
|
/** a receipt id as the issuer mints it; anything else never becomes part of a path */
|
|
@@ -29,10 +29,20 @@ function receiptOf(leaf) {
|
|
|
29
29
|
/**
|
|
30
30
|
* Prunes every leaf whose receipt timestamp is before the cutoff. Leaves already pruned, and leaves that are not
|
|
31
31
|
* receipts, are left as they are. Rewrites the log file in place and deletes the pruned receipts' bundle files, and
|
|
32
|
-
* the salts the issuer kept for them.
|
|
32
|
+
* the salts the issuer kept for them. It holds the log lock, so a receipt that a hook appends during the prune is not lost.
|
|
33
33
|
*/
|
|
34
34
|
export function pruneLog(logFile, before, receiptsDir) {
|
|
35
|
-
|
|
35
|
+
return logLocked(logFile, () => pruneLocked(logFile, before, receiptsDir));
|
|
36
|
+
}
|
|
37
|
+
function pruneLocked(logFile, before, receiptsDir) {
|
|
38
|
+
let text = readFileSync(logFile, "utf8");
|
|
39
|
+
const whole = text.lastIndexOf("\n") + 1;
|
|
40
|
+
if (whole < text.length) {
|
|
41
|
+
// the remains of a writer that died in its write: kept apart, as an append keeps them
|
|
42
|
+
appendFileSync(`${logFile}.torn`, text.slice(whole), { mode: 0o600 });
|
|
43
|
+
text = text.slice(0, whole);
|
|
44
|
+
}
|
|
45
|
+
const lines = text.split("\n").filter((l) => l.trim());
|
|
36
46
|
const out = [];
|
|
37
47
|
const result = { pruned: [], kept: 0, bundlesRemoved: 0 };
|
|
38
48
|
lines.forEach((line, i) => {
|
package/dist/sdk/claude.js
CHANGED
|
@@ -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
|
-
|
|
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:
|
|
43
|
+
permissionDecisionReason: denialText(issuer, policy, reason, evidence),
|
|
28
44
|
},
|
|
29
45
|
};
|
|
30
46
|
}
|
package/dist/sdk/index.d.ts
CHANGED
|
@@ -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,8 @@ 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, policyDigest, policyReasons } from "../policy.js";
|
|
11
|
+
import { compileRego, evaluateRego, isRegoFile } from "../policy-rego.js";
|
|
11
12
|
export const SDK_VERSION = "0.1.0";
|
|
12
13
|
/** 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
14
|
export function denies(policy) {
|
|
@@ -36,10 +37,17 @@ export function createSdkIssuer(cfg) {
|
|
|
36
37
|
// the capture rules are applied by the issuer to every statement it signs, so every adapter's receipt gets them
|
|
37
38
|
const issuer = createIssuer(key, cfg.receiptsDir, openLog(cfg, key), { exporter: openExporter(cfg), capture: { rules: cfg.capture, key: captureKey } });
|
|
38
39
|
const policyText = cfg.policyFile ? readFileSync(cfg.policyFile, "utf8") : null;
|
|
40
|
+
// a Rego file is compiled once, here: one that does not compile stops the issuer from being created
|
|
41
|
+
const rego = policyText !== null && isRegoFile(cfg.policyFile) ? compileRego(policyText) : undefined;
|
|
42
|
+
if (rego && !rego.policy)
|
|
43
|
+
throw new Error(`${cfg.policyFile} does not compile: ${rego.errors.join("; ")}`);
|
|
44
|
+
const regoDigest = rego ? policyDigest(policyText) : "";
|
|
45
|
+
const ruleReasons = policyText === null || rego ? [] : policyReasons(policyText);
|
|
39
46
|
const decide = (ev) => {
|
|
40
47
|
if (policyText === null)
|
|
41
48
|
return null;
|
|
42
|
-
const
|
|
49
|
+
const request = { agentId: cfg.agentId, tool: ev.tool, context: { args: ev.args, facts: {} } };
|
|
50
|
+
const d = rego?.policy ? evaluateRego(rego.policy, regoDigest, request) : evaluate(policyText, request);
|
|
43
51
|
return cfg.mode === "observe" ? { ...d, enforced: false } : d;
|
|
44
52
|
};
|
|
45
53
|
function record(ev, outcome, policy = null) {
|
|
@@ -68,6 +76,7 @@ export function createSdkIssuer(cfg) {
|
|
|
68
76
|
agentId: cfg.agentId,
|
|
69
77
|
keyid: issuer.keyid,
|
|
70
78
|
log: issuer.log,
|
|
79
|
+
ruleReasons,
|
|
71
80
|
decide,
|
|
72
81
|
record,
|
|
73
82
|
wrap(tool, fn, meta = {}) {
|
package/dist/simulate.d.ts
CHANGED
|
@@ -42,6 +42,8 @@ export interface SimulationOptions {
|
|
|
42
42
|
disclosures?: ReadonlyMap<string, unknown>;
|
|
43
43
|
/** Calls that have no receipt to replay. Each counts in `total` and is reported as skipped. */
|
|
44
44
|
unreplayable?: SimulationSkip[];
|
|
45
|
+
/** The proposed policy's language. Rego is compiled once with the opa binary on PATH. Default cedar. */
|
|
46
|
+
language?: "cedar" | "rego";
|
|
45
47
|
}
|
|
46
48
|
/**
|
|
47
49
|
* Check an authorization bundle that has no receipt, as the verifier does for an embedded one: the issuer signed it, it
|
|
@@ -50,7 +52,7 @@ export interface SimulationOptions {
|
|
|
50
52
|
*/
|
|
51
53
|
export declare function verifyOrphanAuthorization(bundle: AuthorizationBundle, issuerKeys: PublicKeyRef[], logKeys: PublicKeyRef[]): AuthorizationStatement["predicate"];
|
|
52
54
|
/**
|
|
53
|
-
* Compare a proposed Cedar policy with recorded policy decisions, using each receipt's original arguments, fact
|
|
55
|
+
* Compare a proposed Cedar or Rego policy with recorded policy decisions, using each receipt's original arguments, fact
|
|
54
56
|
* values, agent, and (for gateways) grant context. Observe-mode decisions are the baseline even when the call ran.
|
|
55
57
|
* Receipts are not signature-verified here; verify their bundles separately when their authenticity matters. A
|
|
56
58
|
* reconciliation receipt is trusted as a provider read only after `verifyBundle` accepts it: the library checks no more
|
package/dist/simulate.js
CHANGED
|
@@ -6,6 +6,7 @@ import { canonicalize, dsseVerify } from "./crypto.js";
|
|
|
6
6
|
import { decodeDelegation, DELEGATION_TYPE, delegationValidAt } from "./delegation.js";
|
|
7
7
|
import { leafHash, verifyInclusion } from "./log.js";
|
|
8
8
|
import { evaluate, policyDigest } from "./policy.js";
|
|
9
|
+
import { compileRego, evaluateRego } from "./policy-rego.js";
|
|
9
10
|
import { AUTHORIZATION_PREDICATE_TYPE, RECEIPT_TYPE, TREEHEAD_TYPE } from "./receipt.js";
|
|
10
11
|
import { structuralProblem } from "./verify.js";
|
|
11
12
|
const strings = (v) => Array.isArray(v) && v.every((x) => typeof x === "string");
|
|
@@ -55,7 +56,7 @@ export function verifyOrphanAuthorization(bundle, issuerKeys, logKeys) {
|
|
|
55
56
|
return statement.predicate;
|
|
56
57
|
}
|
|
57
58
|
/**
|
|
58
|
-
* Compare a proposed Cedar policy with recorded policy decisions, using each receipt's original arguments, fact
|
|
59
|
+
* Compare a proposed Cedar or Rego policy with recorded policy decisions, using each receipt's original arguments, fact
|
|
59
60
|
* values, agent, and (for gateways) grant context. Observe-mode decisions are the baseline even when the call ran.
|
|
60
61
|
* Receipts are not signature-verified here; verify their bundles separately when their authenticity matters. A
|
|
61
62
|
* reconciliation receipt is trusted as a provider read only after `verifyBundle` accepts it: the library checks no more
|
|
@@ -66,9 +67,14 @@ export function verifyOrphanAuthorization(bundle, issuerKeys, logKeys) {
|
|
|
66
67
|
* The receipts are read once, one at a time, so a caller can verify and parse a large history lazily.
|
|
67
68
|
*/
|
|
68
69
|
export function simulatePolicy(policyText, receipts, options = {}) {
|
|
69
|
-
const
|
|
70
|
-
if (
|
|
71
|
-
throw new Error(`invalid
|
|
70
|
+
const rego = options.language === "rego" ? compileRego(policyText) : undefined;
|
|
71
|
+
if (rego && !rego.policy)
|
|
72
|
+
throw new Error(`invalid Rego policy: ${rego.errors.join("; ")}`);
|
|
73
|
+
if (!rego) {
|
|
74
|
+
const parsed = cedar.checkParsePolicySet({ staticPolicies: policyText });
|
|
75
|
+
if (parsed.type === "failure")
|
|
76
|
+
throw new Error(`invalid Cedar policy: ${parsed.errors.map((e) => e.message).join("; ")}`);
|
|
77
|
+
}
|
|
72
78
|
const unreplayable = options.unreplayable ?? [];
|
|
73
79
|
const report = {
|
|
74
80
|
runId: randomUUID(),
|
|
@@ -122,7 +128,7 @@ export function simulatePolicy(policyText, receipts, options = {}) {
|
|
|
122
128
|
}
|
|
123
129
|
digests.add(previous.policyDigest);
|
|
124
130
|
if (!receiptId || !tool || typeof original.agent.id !== "string" || !original.agent.id
|
|
125
|
-
|| !Number.isFinite(Date.parse(original.timestamp)) || !["sdk", "gateway"].includes(original.issuer.kind)) {
|
|
131
|
+
|| !Number.isFinite(Date.parse(original.timestamp)) || !["sdk", "gateway", "door"].includes(original.issuer.kind)) {
|
|
126
132
|
skip("malformed receipt: receipt id, tool, agent, timestamp, or issuer is invalid");
|
|
127
133
|
continue;
|
|
128
134
|
}
|
|
@@ -154,7 +160,8 @@ export function simulatePolicy(policyText, receipts, options = {}) {
|
|
|
154
160
|
args: p.request.args,
|
|
155
161
|
facts: Object.fromEntries(Object.entries(p.facts).map(([name, fact]) => [name, fact.value])),
|
|
156
162
|
};
|
|
157
|
-
|
|
163
|
+
// a door receipt carries a grant only when the arrival presented one; the policy then saw context.grant, else not
|
|
164
|
+
if (p.issuer.kind === "gateway" || (p.issuer.kind === "door" && p.delegation)) {
|
|
158
165
|
const envelope = p.delegation?.envelope;
|
|
159
166
|
const grant = envelope?.payloadType === DELEGATION_TYPE ? decodeDelegation(envelope) : null;
|
|
160
167
|
if (!grant || grant.agent !== p.agent.id || grant.principal !== p.principal.id) {
|
|
@@ -173,7 +180,8 @@ export function simulatePolicy(policyText, receipts, options = {}) {
|
|
|
173
180
|
}
|
|
174
181
|
let proposed;
|
|
175
182
|
try {
|
|
176
|
-
|
|
183
|
+
const request = { agentId: p.agent.id, tool, context };
|
|
184
|
+
proposed = rego?.policy ? evaluateRego(rego.policy, report.policyDigest, request) : evaluate(policyText, request);
|
|
177
185
|
}
|
|
178
186
|
catch (e) {
|
|
179
187
|
// An evaluator exception is a deny, just as at the gateway; it must never become an allow in a replay.
|
package/dist/verify.js
CHANGED
|
@@ -53,8 +53,8 @@ function verifyOriginalAuthorization(bundle, opts) {
|
|
|
53
53
|
add("structural parts in clear", !problem, problem ?? undefined);
|
|
54
54
|
if (problem)
|
|
55
55
|
return { ok: false, predicate: null, checks };
|
|
56
|
-
add("authorization issued by the gateway", p.issuer.kind === "gateway" && p.issuer.keyid === sig.keyid);
|
|
57
|
-
add("authorization operation is submitted", p.operation?.status === "submitted");
|
|
56
|
+
add("authorization issued by the gateway", (p.issuer.kind === "gateway" || p.issuer.kind === "door") && p.issuer.keyid === sig.keyid, p.issuer.kind === "door" ? "a door commits a request before relaying it, as a gateway commits a call" : undefined);
|
|
57
|
+
add("authorization operation is submitted", p.issuer.kind === "door" || p.operation?.status === "submitted", p.issuer.kind === "door" ? "a door has no operations" : undefined);
|
|
58
58
|
add("authorization permits the original call", p.policy?.decision === "allow" ? Array.isArray(p.policy.errors) && p.policy.errors.length === 0 : p.policy?.decision === "deny" && p.policy.enforced === false);
|
|
59
59
|
const del = p.delegation && verifyDelegation(p.delegation.envelope, opts.principalKeys);
|
|
60
60
|
add("delegation signature (principal key)", !!del?.ok);
|
|
@@ -184,7 +184,7 @@ export function verifyBundle(bundle, opts) {
|
|
|
184
184
|
if (!add("structural parts in clear", !broken, broken ?? undefined))
|
|
185
185
|
return done(null);
|
|
186
186
|
const p = st.predicate;
|
|
187
|
-
add("issuer kind is known", p.issuer.kind === "gateway" || p.issuer.kind === "sdk", `${p.issuer.kind}${p.issuer.framework ? ` / ${p.issuer.framework}` : ""}`);
|
|
187
|
+
add("issuer kind is known", p.issuer.kind === "gateway" || p.issuer.kind === "sdk" || p.issuer.kind === "door", `${p.issuer.kind}${p.issuer.framework ? ` / ${p.issuer.framework}` : ""}`);
|
|
188
188
|
add("issuer keyid matches signer", p.issuer.keyid === sig.keyid);
|
|
189
189
|
if (opts.requireStrict) {
|
|
190
190
|
add("strict mode in force", p.issuer.kind === "gateway" && p.issuer.strict === true, p.issuer.strict === true ? undefined : "the issuer does not say it ran in strict mode");
|
|
@@ -207,6 +207,9 @@ export function verifyBundle(bundle, opts) {
|
|
|
207
207
|
add("gateway receipt carries a delegation", p.delegation !== undefined);
|
|
208
208
|
add("gateway receipt carries a policy decision", p.policy !== null);
|
|
209
209
|
}
|
|
210
|
+
// A door decides every arrival by policy; an arrival carries a grant only when it chose to present one.
|
|
211
|
+
if (p.issuer.kind === "door")
|
|
212
|
+
add("door receipt carries a policy decision", p.policy !== null);
|
|
210
213
|
if (p.delegation) {
|
|
211
214
|
const del = verifyDelegation(p.delegation.envelope, opts.principalKeys);
|
|
212
215
|
add("delegation signature (principal key)", del.ok, del.ok ? `signed by ${short(del.keyid)}` : del.error);
|
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;
|
package/docs/compliance.md
CHANGED
|
@@ -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
|
-
##
|
|
46
|
+
## Regulations and frameworks for AI agents
|
|
45
47
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
|
51
|
-
|
|
|
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/configuration.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Configuring the gateway
|
|
2
2
|
|
|
3
|
-
Who may use which tools, and where those tools live, is set in three files and a few environment variables. This page is the map: what each one decides, how they fit together, a worked example with two agents on one shared gateway, how it all works in the Docker image, and how to check a config before you start. The full list of config keys is in [the gateway reference](/reference/gateway); the Cedar
|
|
3
|
+
Who may use which tools, and where those tools live, is set in three files and a few environment variables. This page is the map: what each one decides, how they fit together, a worked example with two agents on one shared gateway, how it all works in the Docker image, and how to check a config before you start. The full list of config keys is in [the gateway reference](/reference/gateway); the Cedar and Rego languages are in [policies.md](policies.md).
|
|
4
4
|
|
|
5
5
|
## What you configure, and where
|
|
6
6
|
|
|
@@ -22,7 +22,7 @@ For each call, in this order, and a refusal at any step is a signed receipt:
|
|
|
22
22
|
1. **The grant** is valid, signed by a trusted principal, inside its window, and not revoked.
|
|
23
23
|
2. **The tool** is one of the grant's scopes.
|
|
24
24
|
3. **Facts** the policy needs are fetched by the gateway from an upstream (`facts` in the config).
|
|
25
|
-
4. **The
|
|
25
|
+
4. **The policy** permits the call: Cedar, a Rego file, or an OPA server ([policies.md](policies.md#rego)). Nothing permitting it means deny.
|
|
26
26
|
5. **For `precommit` tools**, the authorization is committed to the log before anything is forwarded.
|
|
27
27
|
6. **The call** is forwarded to the upstream that owns the tool.
|
|
28
28
|
|
|
@@ -197,7 +197,7 @@ docker run --rm -v "$PWD/config:/config:ro" -v gateway-data:/data --env-file .en
|
|
|
197
197
|
| a key that is not in the schema (a typo such as `precomit` is otherwise silently ignored, and the setting stays at its default) | **error**, with the key it nearly is |
|
|
198
198
|
| the gateway key loads, and is not readable by other users | error, and a warning |
|
|
199
199
|
| every trusted principal key loads | error |
|
|
200
|
-
| the Cedar policy parses, and has at least one `permit` rule (a `permit(` in a comment does not count) | error, and a warning |
|
|
200
|
+
| the Cedar policy parses, and has at least one `permit` rule (a `permit(` in a comment does not count); a `.rego` file compiles; an OPA server answers for the package, and reports a bundle revision | error, and a warning |
|
|
201
201
|
| every credential variable the config names is set: upstream tokens and headers, the log's token, the capture key, the Splunk token, and the OpenTelemetry headers | **error**: the gateway does not start without it |
|
|
202
202
|
| a stdio `command` exists, and a script argument exists | error, and a warning |
|
|
203
203
|
| the receipts, log, revocation, operations database, and approvals paths can be written, and the revocation file is a JSON array | error |
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Door signals: what each one does and does not mean
|
|
2
|
+
|
|
3
|
+
The door records one fact for every arrival, `arrival`, and gives it to the policy as `context.facts.arrival`. Every field in it is a signal: something the door observed, labelled by how far it was checked. None of them is a verdict. This page says, for each signal, what it establishes, what it does not, and how a policy should read it. The door's guide is [the door](door.md); the contract is the [reference](https://agent-custody.dev/reference/door).
|
|
4
|
+
|
|
5
|
+
Three labels run through the table:
|
|
6
|
+
|
|
7
|
+
- **Checked.** The door verified it against a key it trusts or computed it itself. A policy may rely on it.
|
|
8
|
+
- **Observed.** The door saw it on the wire. It is true that it was sent; nothing about the sender follows.
|
|
9
|
+
- **A claim.** The caller asserted it and the door could not check it. A policy that relies on it relies on the caller.
|
|
10
|
+
|
|
11
|
+
## The signals
|
|
12
|
+
|
|
13
|
+
| signal | label | what it means | what it does not mean |
|
|
14
|
+
| --- | --- | --- | --- |
|
|
15
|
+
| `class: "verified"` | checked | A grant signed by a principal in `trustedPrincipalKeys`, inside its validity window, names this agent and lists this arrival's route among its scopes. The Cedar `principal` is that agent | That the agent is well-behaved, that the principal is who they say they are beyond holding the key, or that the request body is what the principal intended. The grant has no revocation list: it stands until it expires |
|
|
16
|
+
| `class: "claimed"` | a claim | Something was asserted that the door could not accept: a grant from a key it does not trust, an expired one, one for other routes, a declared agent name, or an HTTP signature header. `grant` and `grantError` say which | That the arrival is an agent, or that it is hostile. A misconfigured client, a grant for the wrong route, and an impostor all look the same here |
|
|
17
|
+
| `class: "unknown"` | observed | Nothing was presented | That the arrival is a person. A browser, a crawler, and a script that sends no headers are all `unknown`. There is no `human` class, and a policy that admits `unknown` on a route admits everything on that route |
|
|
18
|
+
| `grant: "verified"` | checked | As `class: "verified"` | |
|
|
19
|
+
| `grant: "out-of-scope"` | checked | The grant verified and is valid, but this route is not among its scopes. `subject` is the agent it names | That the agent may do anything here. The principal did not grant this route |
|
|
20
|
+
| `grant: "invalid"` | checked | The grant did not verify against a trusted key, did not decode, or is outside its window. `grantError` says which | Who signed it. A grant from an untrusted principal is `invalid` even when it is genuine |
|
|
21
|
+
| `grant: "absent"` | observed | No grant header | |
|
|
22
|
+
| `subject` | checked only when `class` is `verified` | The agent a verified grant names; else the declared name or the agent a rejected grant named; else `unknown` | For a `claimed` arrival, anything. It is recorded so the receipt shows what was asserted; the Cedar `principal` is `Agent::"unknown"` for it |
|
|
23
|
+
| `declared` | a claim | The `x-agent-custody-agent` header, as sent, cut at 200 characters | That the agent is that agent. Anyone can send the header. A permit on a declared name admits whoever types it |
|
|
24
|
+
| `signature: true` | a claim | An RFC 9421 `Signature-Input` header was present, so the arrival asserts a signature | That the signature is valid, or who signed. **The door does not check it yet.** It is recorded so that a later verifier, or a reader of the receipt, knows a signature travelled with the request |
|
|
25
|
+
| `remote` | observed | The socket's address, or with `trustProxy` the last address in `X-Forwarded-For`, the one your proxy appended | Who the person or program is. One address serves a whole office, a mobile carrier, or a cloud region; one program can use many |
|
|
26
|
+
| `challenge.outcome` | checked, against the provider | Only when `challenge` is configured. `passed`: Turnstile or hCaptcha confirmed the token this arrival sent, so the provider judged a person present when the token was made. `failed`: the provider refused the token itself (bad, expired, or already used; `error` carries the codes), the token was issued on a hostname not in `hostnames` or for another action, or it was too long to be a token. `unavailable`: the provider did not answer in time, answered a non-200, a redirect, or something that is not JSON, reported a fault of its own or of the operator's (a wrong or rotated secret, a site key that does not match it), or too many checks were already waiting, which is the provider's or the door's state, not the arrival's. `absent`: no token | That the arrival is a person now, or that the person is who they say: a token is made once and sent by whatever holds it, and the provider's own error rate applies. It does not change `class`. `unavailable` is not `failed`: a policy that treats it as one locks everyone out when the provider is down, and one that treats it as a pass admits everyone; say which, on purpose |
|
|
27
|
+
| `rate.burst`, `rate.minute` | checked | Arrivals from the same source in the last 10 and 60 seconds, this one included, whatever the policy decided about them, counted by this door process on a monotonic clock, so a step of the wall clock does not move the windows. `rate.by` says what the source is: `agent`, the verified agent's name, or `remote`, the address | That the source is a program, or that it is abusive. Twenty arrivals a minute is one page load for a site that fans out to its API, and one agent on a job. The count is one process's memory: it starts at one when the door starts, two doors do not share it, and an address shared by many people counts them together. It keeps at most 10,000 sources and forgets the least recently seen first, so a client that sends from many new addresses can make another source's count start again |
|
|
28
|
+
| `method`, `path`, `route` | observed | What arrived, the path percent-decoded once, and the route it fell under | |
|
|
29
|
+
|
|
30
|
+
## Reading them in a policy
|
|
31
|
+
|
|
32
|
+
The signals are attributes of `context.facts.arrival`. A permit for an agent requires the arrival to be verified, or the permit admits nothing but a header:
|
|
33
|
+
|
|
34
|
+
```cedar
|
|
35
|
+
permit(principal == Agent::"shopping-agent", action == Action::"api", resource)
|
|
36
|
+
when { context.facts.arrival.class == "verified" };
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
`agent-custody check` warns about a permit that names an agent without that condition.
|
|
40
|
+
|
|
41
|
+
Rate is a reason to slow a route down or to ask for more, not a reason to decide what the arrival is. A forbid on it refuses the arrivals past the limit and receipts each refusal, so the receipts show how often the limit was hit and by what:
|
|
42
|
+
|
|
43
|
+
```cedar
|
|
44
|
+
forbid(principal, action == Action::"refund", resource)
|
|
45
|
+
when { context.facts.arrival.rate.minute > 30 };
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
A limit by `remote` reaches everyone behind one address. Put it high enough that a shared address is not refused for one user's pace, or scope it to routes where a person's pace is slow in any case, as a refund form is. For a verified agent the count is by agent name across every address it uses, so a limit on a verified agent is a limit on the agent.
|
|
49
|
+
|
|
50
|
+
An `unknown` arrival that comes fast is still unknown. The honest policy for a route that should not take bursts from strangers is to refuse them and say why, and to route the agents you want through a grant, which makes them `verified` and counted by name.
|
|
51
|
+
|
|
52
|
+
A challenge is the way a person gets through a route that refuses `unknown`. The permit names the outcome, not the class, and a second permit lets the agents you trust through without the widget:
|
|
53
|
+
|
|
54
|
+
```cedar
|
|
55
|
+
permit(principal, action == Action::"refund", resource)
|
|
56
|
+
when { context.facts.arrival.challenge.outcome == "passed" };
|
|
57
|
+
|
|
58
|
+
permit(principal == Agent::"shopping-agent", action == Action::"refund", resource)
|
|
59
|
+
when { context.facts.arrival.class == "verified" };
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Decide what `unavailable` means for each route before the provider has its first outage: a forbid on `outcome != "passed"` closes the route then, and the receipts show that the provider, not the arrivals, was the reason.
|
|
63
|
+
|
|
64
|
+
## What is not a signal yet
|
|
65
|
+
|
|
66
|
+
Nothing in the arrival fact says whether the arrival is a program. Behavioural and fingerprint signals, HTTP message signature verification, and Web Bot Auth directory lookups are not built; when they are, each will arrive with a measured error rate beside it, and this page will say what it means. Until then a policy has the grant, the claims, the address, and the pace, and the receipt records which of them it used.
|