@agent-custody/state 0.16.6 → 0.16.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/verify-web.js +53 -3
  2. package/package.json +2 -2
@@ -300,9 +300,12 @@ const ISSUER_NOTE = {
300
300
  gateway: "enforced outside the agent's process; the agent could neither skip nor forge this receipt",
301
301
  sdk: "self-reported by the agent's own process; tamper-evident after issue, but nothing here was enforced outside the agent",
302
302
  door: "enforced in front of the business's own HTTP surface; the arriving party could not forge this receipt and is attested only when it presented a grant, and a request that reached the origin some other way leaves no receipt",
303
+ "door/authz": "decided by the door for a proxy in front of the business's own HTTP surface (nginx auth_request or Envoy ext_authz): the receipt records the decision, not the result, since the proxy relayed an allowed request and the door saw neither its body nor the origin's answer; the arriving party could not forge this receipt and is attested only when it presented a grant",
303
304
  guardian: "decided by an ACS Guardian outside the agent's process and signed with its own key, so the decision is attributable to it; the call is the agent's own report, and the agent could skip the Guardian or ignore its answer",
304
305
  egress: "observed by a forward proxy in the agent's network path, for a connection that went around the gateway: where it went and how much, never what was sent; the agent is known only by the proxy credential the witness checked, and a connection that skipped the proxy (no lockdown) leaves no receipt at all",
305
306
  };
307
+ /** What kind of evidence the issuer gives; a door answering a proxy's authz check gives a decision only. */
308
+ const issuerNote = (issuer) => (issuer.kind === "door" && issuer.framework === "authz" ? ISSUER_NOTE["door/authz"] : ISSUER_NOTE[issuer.kind] ?? "unknown issuer kind");
306
309
  const short = (s) => s.slice(0, 12);
307
310
  async function hmacHex(secret, data) {
308
311
  const key = await subtle().importKey("raw", enc.encode(secret), { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
@@ -544,7 +547,7 @@ export async function verifyBundle(bundle, opts) {
544
547
  const checks = [];
545
548
  const add = (name, ok, detail) => { checks.push(detail === undefined ? { name, ok } : { name, ok, detail }); return ok; };
546
549
  let treeHeadSigner = null;
547
- const done = (statement) => ({ ok: checks.every((c) => c.ok), checks, statement, issuerNote: statement ? (ISSUER_NOTE[statement.predicate.issuer.kind] ?? "unknown issuer kind") : null, treeHeadSigner });
550
+ const done = (statement) => ({ ok: checks.every((c) => c.ok), checks, statement, issuerNote: statement ? issuerNote(statement.predicate.issuer) : null, treeHeadSigner });
548
551
  const sig = await dsseVerify(bundle.envelope, opts.issuerKeys);
549
552
  if (!sig.ok) {
550
553
  add("receipt signature (issuer key)", false, sig.error);
@@ -583,6 +586,11 @@ export async function verifyBundle(bundle, opts) {
583
586
  }
584
587
  if (p.issuer.kind === "door")
585
588
  add("door receipt carries a policy decision", p.policy !== null);
589
+ // In authz mode the door answers a proxy's check and relays nothing: the receipt is a decision, never a result.
590
+ if (p.issuer.kind === "door" && p.issuer.framework === "authz") {
591
+ const decided = p.execution.status === "withheld" || (p.execution.status === "denied" && p.policy?.decision === "deny");
592
+ add("door authz decided, relayed nothing", decided, decided ? `${p.policy?.decision}; a decision for the proxy, which relays: the door saw neither the body nor the origin's answer` : `the receipt says ${p.execution.status} with a policy ${p.policy?.decision ?? "absent"}`);
593
+ }
586
594
  // An egress witness saw a connection that went around the gateway: where it went and how much, never what was sent.
587
595
  // Its destination is its own observation; its agent is only as good as the proxy credential it checked.
588
596
  if (p.issuer.kind === "egress") {
@@ -744,6 +752,42 @@ export async function verifyBundle(bundle, opts) {
744
752
  const isProvider = (v) => !!v && (v.provider === "stripe-webhook" || v.provider === "github-delivery") && stringOrCommitment(v.rawBody) && stringOrCommitment(v.signature) && stringOrCommitment(v.bind);
745
753
  // a check is skipped only for a part the signed note declares withheld; a part that is simply not there, or commitment-shaped without the note saying so, fails
746
754
  const declared = (path) => (note?.withheld ?? []).some((w) => JSON.stringify(w) === JSON.stringify(path));
755
+ // a fact its source signed (the door's partner verdict), marked attested by the issuer: checked again under the key the reader trusts for that source
756
+ for (const [name, f] of Object.entries(p.facts)) {
757
+ if (f?.provenance !== "attested")
758
+ continue;
759
+ const label = `fact ${name} signature (upstream key)`;
760
+ const env = f.attestation;
761
+ const wellFormed = !!env && typeof env === "object" && typeof env.payload === "string" && Array.isArray(env.signatures);
762
+ if ((note?.withheld ?? []).some((w) => w.length >= 3 && w[0] === "facts" && w[1] === name && w[2] === "value"))
763
+ add(`fact ${name} signature not checked`, true, "the value is withheld; disclose it with the command-line verifier to check its signature");
764
+ else if (declared(["facts", name, "attestation"]))
765
+ add(label, false, "the value is in clear but its signature is withheld; disclose it or give the capture key to check it");
766
+ else if (!wellFormed)
767
+ add(label, false, "the fact is marked attested and carries no signature, and the capture note does not say it is withheld");
768
+ else if (!opts.upstreamKeys?.length)
769
+ add(label, false, "the fact is marked attested; give the signer's public key to check it");
770
+ else {
771
+ const u = await dsseVerify(env, opts.upstreamKeys);
772
+ let ok = u.ok && env.payloadType === UPSTREAM_TYPE;
773
+ let detail = u.ok ? (ok ? `keyid ${short(u.keyid)}` : `payload type ${env.payloadType}`) : u.error;
774
+ if (ok && u.ok) {
775
+ if (u.payload.receiptId !== p.receiptId) {
776
+ ok = false;
777
+ detail = "signed for a different receipt";
778
+ }
779
+ else if (u.payload.tool !== p.tool.name) {
780
+ ok = false;
781
+ detail = `signed for tool ${u.payload.tool}`;
782
+ }
783
+ else if (u.payload.contentDigest !== await digestOf(f.value)) {
784
+ ok = false;
785
+ detail = "signed content differs from the result in the receipt";
786
+ }
787
+ }
788
+ add(label, ok, detail);
789
+ }
790
+ }
747
791
  if (executedOrFailed && p.execution.upstream && isProvider(p.execution.upstream)) {
748
792
  if (opts.providerSecrets) {
749
793
  const parts = ["rawBody", "signature", "bind"];
@@ -976,8 +1020,14 @@ export function formatReport(r) {
976
1020
  row("model", p.model.provenance, p.model.id === null ? "(none supplied)" : idText(p.model.id));
977
1021
  row("tool", p.tool.provenance, p.tool.name);
978
1022
  row("args", p.request.provenance, p.request.args);
979
- for (const [k, f] of Object.entries(p.facts))
980
- row(`fact.${k}`, f.provenance, f.value);
1023
+ for (const [k, f] of Object.entries(p.facts)) {
1024
+ if (f.provenance !== "attested") {
1025
+ row(`fact.${k}`, f.provenance, f.value);
1026
+ continue;
1027
+ }
1028
+ const signed = r.checks.find((c) => c.name === `fact ${k} signature (upstream key)`);
1029
+ row(`fact.${k}`, f.provenance, `${JSON.stringify(f.value)}${signed ? (signed.ok ? ` (signed by ${signed.detail})` : " (signature FAILED)") : " (signature not checked)"}`);
1030
+ }
981
1031
  if (p.reconciliation)
982
1032
  row("policy", "-", "(none evaluated: a provider read, not a call)");
983
1033
  else if (p.policy)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-custody/state",
3
- "version": "0.16.6",
3
+ "version": "0.16.8",
4
4
  "description": "Governed memory for AI agents: a fact ledger with provenance, valid time, rollback, lineage, certified forget, and a store that is a JSONL file, SQLite, or Postgres, built on @agent-custody/receipts",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -34,7 +34,7 @@
34
34
  "node": ">=22"
35
35
  },
36
36
  "dependencies": {
37
- "@agent-custody/receipts": "0.16.6",
37
+ "@agent-custody/receipts": "0.16.8",
38
38
  "@modelcontextprotocol/sdk": "1.30.0",
39
39
  "zod": "4.5.4"
40
40
  },