Skip to content

GrayMatter v0.3.0

Choose a tag to compare

@angelnicolasc angelnicolasc released this 15 Apr 00:11
· 443 commits to main since this release

Breaking changes

This is a pre-1.0 release. The following breaking changes harden the API and are the right long-term design.

ctx-first API (all public Memory methods)

Every Remember, Recall, RememberShared, RecallShared, RecallAll method now accepts context.Context as the first argument. The redundant *Ctx variants (RememberCtx, RecallCtx, etc.) are removed. Consolidate was already ctx-first — all methods are now consistent.

Before:

mem.Remember("agent", "observation")
facts, _ := mem.Recall("agent", "query")

After:

ctx := context.Background()
mem.Remember(ctx, "agent", "observation")
facts, _ := mem.Recall(ctx, "agent", "query")

Store() → Advanced()

Memory.Store() *memory.Store is removed. Use Memory.Advanced() AdvancedStore instead. AdvancedStore is a narrow interface (List, Delete, Stats, DB, UpdateFact, PendingVectorCount, …) that exposes only what CLI/MCP/TUI callers need. Internal *memory.Store refactors no longer break the public API surface.


New features

Health observability

New() preserves the never-panic convenience contract but now makes degraded state detectable:

mem := graymatter.New(".graymatter")
if !mem.Healthy() {
    log.Fatalf("graymatter: %v", mem.Status().InitError)
}
  • Healthy() bool — false when the underlying store failed to open
  • Status() Status — {Healthy, Mode, InitError, DataDir} for structured diagnostics

Durable vector reconciliation

Closes the inconsistency window between bbolt (durable source of truth) and the chromem-go vector index.

  • A new bucketPendingVector bbolt bucket is written in the same transaction as each fact. It is cleared only after the vector upsert confirms success.
  • A background vectorReconcileLoop (default 30s, configurable via Config.VectorReconcileInterval; 0 disables) continuously drains the pending queue. The inconsistency window shrinks from "until next process restart" to "until next reconcile tick".
  • Store.PendingVectorCount() int — exposed on AdvancedStore for health monitoring.
  • Config.OnVectorIndexError callback — mirrors the existing OnConsolidateError pattern; called when inline indexing fails so you can route the event to your APM stack.
  • reconcileVectors() at startup is now O(pending) instead of O(all facts).

ConsolidateThreshold default: 100 → 20

The previous default meant consolidation (the headline token-saving feature) never fired for demos or early production use. 20 facts fires within a realistic first week of agent usage while still giving the LLM enough material to summarise meaningfully.


Migration guide

# Find all call sites in one grep:
grep -rn "\.Remember(\|\.Recall(\|\.RememberShared(\|\.RecallShared(\|\.RecallAll(\|\.Store()\|RememberCtx\|RecallCtx" .
  1. Add ctx context.Context as first arg to every Remember/Recall/RememberShared/RecallShared/RecallAll call.
  2. Replace mem.Store() with mem.Advanced(). The returned AdvancedStore interface covers all methods CLI/MCP/TUI callers need; if you called a method not on the interface, open an issue.
  3. If you used RememberCtx/RecallCtx (the old ctx variants), collapse them — they are now the canonical methods.
  4. Add if !mem.Healthy() { log.Fatal(...) } after New() in production entrypoints.