github angelnicolasc/graymatter v0.17.0
GrayMatter v0.17.0

latest releases: v0.21.0, cmd/graymatter/v0.21.0, v0.20.1...
3 months ago

GrayMatter v0.17.0

Persistent memory for Go AI agents. Single binary. Zero infra.

Quick install

go install github.com/angelnicolasc/graymatter/cmd/graymatter@v0.17.0

Prebuilt binaries for Linux, macOS and Windows are in the assets below,
with checksums.txt (sha256). Per-platform download commands are in the
README.


What users get

  • graymatter hooks — automatic memory for Claude Code, no tool calls required. The tool-based story had a structural gap: the model calls memory_search only when it decides to, which is almost never, so memory was only half the product. hooks install (also init --hooks) writes the hook block into .claude/settings.json — merge-never-overwrite like every other writer, foreign hooks preserved byte-for-byte in meaning, .bak on every rewrite, hand-edit drift detected and reported, unparseable settings never touched — and from the next session memory runs itself: SessionStart injects the freshest live facts and re-injects after /compact (memory survives compaction), UserPromptSubmit injects a short top-3 recall that is suppressed when identical to the previous turn, remember: <text> in any prompt is a deterministic instant save, PreCompact checkpoints, and SessionEnd checkpoints and spawns consolidation detached so it survives the editor closing. The failure contract is absolute: every hook error exits 0 with empty stdout and a receipt in <dataDir>/hooks.log — a broken memory degrades silently, never breaks the session. hooks doctor verifies registration, the recorded absolute binary path, and store latency; hooks uninstall removes exactly our entries and nothing else. All four runners, the merge writer and the drift detection are contract-tested, and the command records absolute binary paths so hooks resolve from any cwd.
  • benchmarks/hook_latency — the hooks' hot path is machine-checked against what the code controls, never against shared-CI hardware (every published number must be). The gate builds the real binary, seeds a 10k-fact store, fires the hook as a fresh OS process per sample through the daemon (the shape Claude Code uses). The gates are hardware-relative by design: the recall's marginal cost (user-prompt p99 minus this run's pre-compact baseline ≤ 200 ms), the detached-spawn delta (session-end ≤ baseline + 200 ms), and in-process scaling (Recall(10k) ≤ 2.5× of linear) — because absolute wall budgets proved a hardware lottery: the identical tree measured 121 ms p99 on the reference machine and 284-369 ms on Windows CI runners, with the spawn+connect baseline alone reaching 192-248 ms. Absolute numbers are still reported as reference data. Verified injections are counted so the benchmark cannot silently measure the throttle instead of recall, and graymatter bench --hooks audits the same gates against this binary itself — the CLI is the hook binary, nothing compiles. Getting under the gates took three behaviour-preserving optimizations to the recall path: keywordScore now tokenizes each fact once instead of twice (byte-identical scores), the pipeline decodes through a lite fact decoder that skips the fields ranking never reads (unmarshalFactLite, pinned against the full decoder by a 500-case agreement test), and recency ranks are read straight from the newest-first list order instead of being re-sorted — recency is strictly monotonic in CreatedAt, so the rank order was already there, and equal-CreatedAt facts (Windows clocks tick at ~15.6 ms) now resolve by ID deterministically instead of by sort.Slice's unspecified tie order.
  • recall --explain — receipts per fact, "receipts, not vibes" made literal. Provenance is the layer nobody in the space has shipped per query, and GrayMatter already computed everything needed internally — this is surface, not architecture. --explain returns the same ranking as a plain recall (one pipeline, identical order, dedup and access-metadata side effects; pinned by tests) with one receipt per fact: per-signal RRF ranks (vector_rank/keyword_rank/recency_rank, 0 = signal absent), the fused score that reproduces from those ranks and k using the documented arithmetic, stored weight, age in days, and provenance (fact_id, written_at, tombstone state, confidence, pin). The receipt shape (memory.RecallReceipt and friends, added in v0.17.0) is documented in docs/api-stability.md, byte-deterministic on the same store (golden test), and carried end-to-end through the daemon RPC protocol and the MCP server: memory_search gains an optional explain boolean whose structuredContent carries the same receipts under explained (schema additive, bare shape unchanged, text fallback updated).
  • graymatter kg render — the graph as a self-contained artifact. The KG was the claim most shown in its least dynamic form (a static screenshot in Obsidian). kg render --out graph.html writes one offline-first page — inline force-directed SVG, no CDN, no fonts, no scripts; node colour by entity type, size by weight, edge thickness by weight, tooltips carrying the edge's fact-ID receipts — deterministic bytes for the same graph (sorted inputs, fixed-seed layout). --out graph.dot emits Graphviz for people with their own layout; labels and IDs derived from stored text cannot break out of the embedded JSON (HTML-escaped by construction). doctor --graph --html attaches the same render to the analytics report.
  • graymatter demo — install-to-visible in one command. Reddit's "show me" culture makes every setup step a lost star. demo seeds a scratch store (.graymatter-demo, --tmp for a temp dir) with the four-agent sales/support/infra corpus, writes the KG sentinel, runs two consolidation cycles, and opens the TUI — no API keys, no Ollama (the keyword embedder is the default path). Idempotent by construction (append-only store, re-runs never duplicate), --fresh rebuilds and refuses to delete anything that does not look like a GrayMatter data dir, --script emits the exact equivalent shell script because there is no magic to hide.
  • docs/integrations.md — per-client verified configs for 25 MCP clients. "Every agent wants a different shape and fails silently" is measured pain: the page documents each client's real config shape (VS Code's root servers key, Codex TOML, OpenCode/Kilo's array command, Goose's extensions, Zed's context_servers), marks the seven init auto-wires as such, and accepts one-PR-per-client community verification for the rest.
  • scripts/kg-timelapse.sh — watch the graph build itself, reproducibly. The KG was the claim most shown in its least dynamic form (a static screenshot). The script replays a deterministic working-week corpus session by session, renders the graph per frame through kg render (its only GrayMatter primitive), rasterises with Graphviz and assembles a GIF with ImageMagick or ffmpeg — degrading with exact instructions when an assembler is missing, never failing. Frames are byte-identical across runs (sorted inputs, fixed-seed layout) and the whole pipeline reproduces on any machine via scripts/Dockerfile.kg-timelapse (Go + graphviz + ImageMagick, source and output bind-mounted, nothing baked in).

Changed

  • touchFacts writes back read-modify-write instead of the recall-time snapshot. The old shape marshalled its snapshot over the stored fact whole: correct only while every mutation was serialised by luck, and it silently stomped concurrent weight/tombstone/pin changes that landed between List and the write-back. It now re-reads the current fact inside the transaction, carries the tombstone-never-resurrect guard forward, and applies only the access bump. TestRecallExplain_SameStateAsRecall pins that an explained recall and a plain recall leave identical access footprints.
  • graymatter consolidate <agent-id> is a CLI command. It was the missing entry point the session-end hook spawns detached (consolidation may proxy an LLM round-trip, so it runs outside the hook's time budget); as a normal command it routes through the daemon's policy and is directly usable.
  • init gained --hooks. Same merge semantics as hooks install; runs last so a failure is reported after everything else is wired, and drift warnings print even under --quiet — overwriting a hand-edited file silently is the one thing this step must never do.

Fixed

  • The vector signal was silently dead on young stores. chromem-go v0.7.0 returns an error when asked for more results than the collection holds, and every recall asks for 2×topK — so any store with fewer facts than that (every store for its first days) lost the entire vector signal with the error swallowed by design. The wrapper now returns "at most n" the way the interface always promised. Found by the hardening round's vector-path receipt tests, which assert vector ranks exist.
  • Tied vector similarities made recall nondeterministic. chromem selects the top-n over an internal map, so with equal similarities even which documents came back differed call to call — violating the documented "same query, same store, same order" guarantee. Selection is now the same total order the ranking imposes everywhere else (similarity descending, then ID ascending), identical to chromem's pick when similarities are distinct and deterministic when they tie.
  • A UTF-8 BOM on stdin broke hook payload parsing. Nothing sane sends one, but a payload routed through a Windows text pipeline may carry it, and refusing to parse over three bytes silently disabled every hook. The parser strips it.

Don't miss a new graymatter release

NewReleases is sending notifications on new releases.