@zanii/memory
v0.1.1
Published
Provable agent memory: a memory.write receipt that hash-chains what an agent remembered and when (salted content commitments, tamper-evident links) so an auditor can prove 'why did it decide that?'.
Readme
@zanii/memory
Provable agent memory. A memory.write receipt hash-chains what an agent remembered
and when — so an auditor can answer "why did it decide that?" and prove the memory
wasn't edited after the fact.
Each entry commits its content with a salt (the raw memory never leaves your system) and
links to the previous entry's entry_hash — a tamper-evident chain. The entry_hash is an
RFC 8785 canonical hash (@zanii/core), so a chain written in TypeScript verifies
byte-identically in Python.
npm install @zanii/memory @zanii/coreUsage
import { appendMemory, verifyMemoryChain, verifyContent } from '@zanii/memory';
// write a chain — appendMemory auto-links prev + increments seq:
const a = appendMemory(null, { content: 'user asked for a refund', kind: 'observation', ts });
const b = appendMemory(a, { content: 'policy allows refund within 30 days', kind: 'fact', ts });
const c = appendMemory(b, { content: 'issued the refund', kind: 'decision', ts });
await agent.record(c.target, c.payload); // keep c.salt to prove the content later
// audit: the chain is intact (nothing inserted, deleted, or edited):
verifyMemoryChain([a, b, c]).ok; // true
// prove what a specific entry actually remembered:
verifyContent('issued the refund', c.salt, c.payload.content_commitment); // truebuildMemoryWrite(input) builds a single entry when you manage prev/seq yourself.
verifyMemory(payload) checks one entry's entry_hash is self-consistent (catches an
edited entry); verifyMemoryChain(entries) also checks the links and that seq increments.
Changelog
- 0.1.0 — initial release:
commitContent/verifyContent,buildMemoryWrite,appendMemory,verifyMemory,verifyMemoryChain.
License
Apache-2.0.
