@agent-custody/state 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -23,7 +23,7 @@ await ledger.retract({ factId: a.fact.factId, actor: "user:admin", reason: "pois
23
23
  await ledger.asOf({ validAt: "2026-09-01T00:00:00Z", txAt: "2026-09-01T00:00:00Z" });
24
24
  ```
25
25
 
26
- Six runnable examples, all executed by the test suite. [06-actions-on-beliefs.ts](examples/06-actions-on-beliefs.ts) puts memory and a payments API behind one gateway and finds the refund in a belief's blast radius. [05-blast-radius.ts](examples/05-blast-radius.ts) walks from a retracted belief to everything that relied on it. [04-evals.ts](examples/04-evals.ts) scores the ledger and a naive store on the same memory incidents. [03-memory-behind-the-gateway.ts](examples/03-memory-behind-the-gateway.ts) runs the memory server as the gateway's upstream. [01-ledger.ts](examples/01-ledger.ts) walks through a wrong write and its undo. [02-receipt-to-belief.ts](examples/02-receipt-to-belief.ts) runs the whole loop with the receipts package: a tool call gets a signed receipt, the receipt is verified, the belief taken from it is recorded citing the receipt, and later retracted. Run them with `node examples/<file>` from this directory, after `bun run build` at the repository root.
26
+ Seven runnable examples, all executed by the test suite. [07-incomplete-evidence.ts](examples/07-incomplete-evidence.ts) makes the refund of example 06 private under a capture rule: blast radius without the customer's key lists the refund as INCOMPLETE rather than leaving it out, and with the key finds it. [06-actions-on-beliefs.ts](examples/06-actions-on-beliefs.ts) puts memory and a payments API behind one gateway and finds the refund in a belief's blast radius. [05-blast-radius.ts](examples/05-blast-radius.ts) walks from a retracted belief to everything that relied on it. [04-evals.ts](examples/04-evals.ts) scores the ledger and a naive store on the same memory incidents. [03-memory-behind-the-gateway.ts](examples/03-memory-behind-the-gateway.ts) runs the memory server as the gateway's upstream. [01-ledger.ts](examples/01-ledger.ts) walks through a wrong write and its undo. [02-receipt-to-belief.ts](examples/02-receipt-to-belief.ts) runs the whole loop with the receipts package: a tool call gets a signed receipt, the receipt is verified, the belief taken from it is recorded citing the receipt, and later retracted. Run them with `node examples/<file>` from this directory, after `bun run build` at the repository root.
27
27
 
28
28
  ## The memory server
29
29
 
package/dist/cli.js CHANGED
@@ -80,7 +80,7 @@ const USAGE = `agent-custody-memory <command>
80
80
  Serves on loopback; put it behind your own login if you expose it.
81
81
  review ... --out <dir> the same as static files, for a case file or a shared drive
82
82
  export --ledger <ledger.sqlite|postgres://…> --out <ledger.jsonl> the auditable JSONL of any ledger, one event per line; also the feed for a warehouse
83
- blast --ledger <ledger.jsonl> --receipts <dir> --fact <factId> [--json]
83
+ blast --ledger <ledger.jsonl> --receipts <dir> --fact <factId> [--capture-key-env NAME] [--json]
84
84
  everything that relied on a fact: later calls, derived beliefs, and whether it was retracted
85
85
  `;
86
86
  async function main(argv) {
package/dist/explain.js CHANGED
@@ -144,7 +144,9 @@ export function formatExplain(pack, verification, withLedger) {
144
144
  // under a capture rule a message is a commitment in the receipt; the explanation says so rather than printing it
145
145
  const text = (v) => (typeof v === "string" ? v : "(withheld under the capture rule)");
146
146
  const errors = Array.isArray(p.policy?.errors) ? p.policy.errors : p.policy?.errors ? [text(p.policy.errors)] : [];
147
- if (p.policy)
147
+ if (p.reconciliation)
148
+ more("no policy was evaluated: this receipt records a provider read that closes an earlier call");
149
+ else if (p.policy)
148
150
  more(`policy ${p.policy.policyDigest.slice(0, 12)} decided ${p.policy.decision}${p.policy.reasons.length ? ` by ${p.policy.reasons.join(", ")}` : ""}${errors.length ? `; errors: ${errors.join("; ")}` : ""}`);
149
151
  const facts = Object.entries(p.facts);
150
152
  row("WHAT THE AGENT SAW", facts.length ? facts.map(([k, f]) => `${k} = ${JSON.stringify(f.value)} (fetched by the gateway via ${f.tool})`).join("; ") : "no facts fetched for this call");
@@ -163,8 +165,11 @@ export function formatExplain(pack, verification, withLedger) {
163
165
  for (const id of pack.consumed.unknown)
164
166
  more(` ${id.slice(0, 8)} (not in this ledger)`);
165
167
  }
166
- row("WHAT IT DID", `${p.tool.name} ${JSON.stringify(p.request.args)} -> ${p.execution.status}${p.execution.status === "denied" ? `: ${text(p.execution.reason)}` : p.execution.status === "withheld" ? `: ${text(p.execution.reason)}` : p.execution.status === "error" ? `: ${text(p.execution.error)}` : ""}`);
167
- row("WHY", p.policy ? (p.policy.decision === "allow" ? `the policy permitted it${p.policy.reasons.length ? ` (${p.policy.reasons.join(", ")})` : ""}` : p.policy.enforced === false ? `the policy would have refused it, and was in observe mode, so the call went through: ${[...p.policy.reasons, ...errors].join("; ") || "no permit matched"}` : `the policy refused it: ${[...p.policy.reasons, ...errors].join("; ") || "no permit matched"}`) : "no policy was evaluated");
168
+ if (p.reconciliation)
169
+ row("WHAT IT DID", `reconciliation: the gateway read ${p.reconciliation.lookup.tool} for ${p.tool.name}; the operation is ${p.operation?.status ?? "unknown"} (the tool did not run again)`);
170
+ else
171
+ row("WHAT IT DID", `${p.tool.name} ${JSON.stringify(p.request.args)} -> ${p.execution.status}${p.execution.status === "denied" ? `: ${text(p.execution.reason)}` : p.execution.status === "withheld" ? `: ${text(p.execution.reason)}` : p.execution.status === "error" ? `: ${text(p.execution.error)}` : ""}`);
172
+ row("WHY", p.reconciliation ? "no policy was evaluated; the gateway read the provider record to close an earlier call" : p.policy ? (p.policy.decision === "allow" ? `the policy permitted it${p.policy.reasons.length ? ` (${p.policy.reasons.join(", ")})` : ""}` : p.policy.enforced === false ? `the policy would have refused it, and was in observe mode, so the call went through: ${[...p.policy.reasons, ...errors].join("; ") || "no permit matched"}` : `the policy refused it: ${[...p.policy.reasons, ...errors].join("; ") || "no permit matched"}`) : "no policy was evaluated");
168
173
  const th = pack.receipt.treeHead.signatures[0]?.keyid ?? "?";
169
174
  row("WHAT EVIDENCE", `receipt ${p.receiptId}, leaf ${pack.receipt.inclusion.leafIndex} of a log whose head is signed by ${th.slice(0, 12)}`);
170
175
  if (p.authorization)
package/dist/review.js CHANGED
@@ -19,7 +19,7 @@ export function listReceipts(o) {
19
19
  const bundle = JSON.parse(readFileSync(join(o.receiptsDir, f), "utf8"));
20
20
  const p = decodeStatement(bundle).predicate;
21
21
  const verified = o.keys ? verifyBundle(bundle, { issuerKeys: o.keys.issuerKeys, principalKeys: o.keys.principalKeys ?? [], ...(o.keys.logKeys ? { logKeys: o.keys.logKeys } : {}), ...(o.keys.logId ? { logId: o.keys.logId } : {}) }).ok : null;
22
- rows.push({ receiptId: p.receiptId, timestamp: p.timestamp, tool: p.tool.name, status: p.execution.status, agent: p.agent.id, principal: p.principal.id, issuer: p.issuer.kind, verified });
22
+ rows.push({ receiptId: p.receiptId, timestamp: p.timestamp, tool: p.tool.name, status: p.reconciliation ? "reconciled" : p.execution.status, agent: p.agent.id, principal: p.principal.id, issuer: p.issuer.kind, verified });
23
23
  }
24
24
  catch {
25
25
  // not a bundle; the index is of receipts
@@ -86,7 +86,7 @@ export function renderReceipt(pack, verification, o, backLink, rawLink) {
86
86
  const report = verification ? verification.checks.map((c) => `${c.ok ? "PASS" : "FAIL"} ${c.name}${c.detail ? ` (${c.detail})` : ""}`).join("\n") + `\n\nRESULT: ${verification.ok ? "VERIFIED" : "NOT VERIFIED"}` : "Not checked: start the review with --issuer-key and --principal-key to verify every receipt here.";
87
87
  const body = `
88
88
  <p><a href="${esc(backLink)}">All receipts</a></p>
89
- <h1>${esc(p.tool.name)} <span class="muted">${esc(p.execution.status)}</span></h1>
89
+ <h1>${esc(p.tool.name)} <span class="muted">${esc(p.reconciliation ? "reconciled" : p.execution.status)}</span></h1>
90
90
  <p class="sub">${esc(p.timestamp.replace("T", " ").slice(0, 19))} · receipt <span class="mono">${esc(p.receiptId)}</span> · ${verification ? (verification.ok ? '<span class="ok">verified</span>' : '<span class="bad">NOT VERIFIED</span>') : '<span class="muted">not checked</span>'}</p>
91
91
  <h2>What this action is</h2>
92
92
  ${explainHtml(formatExplain(pack, verification, !!o.ledger))}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-custody/state",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
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": {
@@ -33,7 +33,7 @@
33
33
  "node": ">=22"
34
34
  },
35
35
  "dependencies": {
36
- "@agent-custody/receipts": "0.7.0",
36
+ "@agent-custody/receipts": "0.8.0",
37
37
  "@modelcontextprotocol/sdk": "^1.30.0",
38
38
  "zod": "^4.5.4"
39
39
  },