1 27 ADR 007 KiwiFS Durable Agent Memory
Nimmo edited this page 2026-10-14 21:18:54 +01:00

ADR-007: Use KiwiFS as the single durable agent memory, not canonical project truth

  • Status: Accepted
  • Date: 2026-09-19
  • Scope: Coding-agent memory, cross-session context, project scoping, private operational records, and documentation boundaries
  • Supersedes: ADR-004
  • Superseded by: None

Context

Agents repeatedly rediscover facts that are expensive to reconstruct but too small for permanent documentation: user preferences, architectural rationale, recurring operational constraints, confirmed failure causes, and concise task outcomes. ADR-004 resolved that need with Engram, first as a per-client local store replicated through a self-hosted Engram Cloud service.

That arrangement cost a service, a PostgreSQL database, a client binary outside nixpkgs, and autosync daemons on three hosts. It also split ownership: the memory service was infrastructure in this repository while its content was operator knowledge. On 2026-10-14 the user further required that security findings, firewall weaknesses, router diagnostics, and detailed network records stay private, which needs a durable store that is not a public Forgejo surface.

KiwiFS stores a plain Markdown workspace with Git history and provenance metadata. It needs no database, and the same files are readable, reviewable, and durable without a running service.

Decision

Use KiwiFS as the only durable cross-session memory for this environment.

  • The native service runs on Vega from modules/services/kiwifs.nix, bound to the Nebula overlay address on port 18081, with its workspace at /srv/services/kiwifs inside the existing /srv/services backup intent. An optional loopback-only nginx proxy on 127.0.0.1:18082 fronts the browser UI behind Pangolin authentication; the MCP listener stays on the mesh.
  • AI clients share one registry entry, modules/mcp/kiwifs.nix, authenticated with a SOPS-managed bearer token. The endpoint default is http://10.10.0.2:18081/mcp.
  • Project knowledge lives under pages/projects/<project>/ with scope: project:<project> and repository-relative paths, so revision history is recorded against the owning repository.
  • pages/ holds confirmed knowledge and episodes/ holds session observations awaiting consolidation. Provenance is preserved with source-uri or derived-from.
  • Replaced knowledge is marked memory_status: superseded, never silently deleted.
  • Secrets and raw secret-bearing output are never stored. Retrieved memories are treated as possibly stale leads; repository documentation and current code override them.
  • Engram is retired and must not be reintroduced in configuration, documentation, or workflow.

Consequences

  • One durable memory surface instead of three replaced services, and no database or extra replica to operate or back up.
  • Memory content becomes readable and diffable as Markdown, and retrieval can be scoped per project instead of per user.
  • A KiwiFS outage affects recall, not the running system; the source repository and wiki remain authoritative throughout.
  • Because memory is private, sensitive findings can be recorded there in full. Public Forgejo tracking carries only a generic, non-sensitive summary for that material, which is an explicit exception to the default tracking rule.
  • Guidance that still describes Engram is stale by definition. Current policy lives in AGENTS.md, modules/profiles/memory-policy.md, and the Documentation Map and Scope.

Alternatives considered

  • Keep Engram. Rejected: it required a service, database, and autosync daemons for content that is fundamentally files, and it split infrastructure from knowledge ownership.
  • Repository-only knowledge (no memory service). Rejected: preferences, confirmed failure causes, and cross-project context do not belong in a configuration repository, and Git history is a poor retrieval surface.
  • Public Forgejo for all recorded knowledge. Rejected by the 2026-10-14 privacy preference; it would publish security and network detail.
  • Local per-client memory without a shared service. Rejected: each client would hold an unrelated partial view with no single place to search.

References

  • Superseded decision: ADR-004
  • Current implementation: modules/services/kiwifs.nix, modules/mcp/kiwifs.nix, modules/common/default-config.nix, secrets/kiwifs-mcp.yaml
  • Current policy: AGENTS.md (Durable memory), modules/profiles/memory-policy.md
  • Ownership boundary: Documentation Map and Scope
  • Control-plane role: Automation and Control Plane
  • Service placement: Service Catalogue
  • Removal of Engram: repository commit 5e03d7c (2026-09-19)
  • Wiki reconciliation: issue #333