keepsake

module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2026 License: MIT

README ΒΆ

🧠 Keepsake

A Kubernetes-native memory substrate for fleets of agents.

Try it

What one agent learns, the next one knows. One command shows it:

git clone https://github.com/roee-fs/keepsake && cd keepsake && ./demo/run.sh

It needs Docker, kind, kubectl, Helm, jq and a logged-in Claude Code. It installs the chart on a throwaway kind cluster and imports an on-call team's knowledge base. Agent A asks who to page before a Postgres failover and gets a stale answer. Agent B, which just ran a failover drill, records what it learned. Agent A asks again in a new session and gets the right answer and the reason. The agents are real Claude sessions whose only memory is keepsake, over MCP. Then it deletes the cluster.

Add --keep to leave the cluster up and point your own agent at it.

Run it

On your machine, with Docker only:

docker compose up -d
claude mcp add --transport http keepsake http://localhost:8000/mcp

The console is at http://localhost:8000, password keepsake. Load a bundle with docker compose run --rm -v "$PWD/demo/bundle:/bundle:ro" keepsake keepsake import /bundle. This setup is for trying keepsake out. It serves one tenant to anything that reaches the port.

On Kubernetes:

helm install keepsake oci://ghcr.io/roee-fs/charts/keepsake --version 0.3.0

docs/operations.md covers Postgres modes, roles, upgrades and backups.

Why

Agents lose everything when the context window closes. Keepsake gives them a durable, shared knowledge base they read and write over MCP β€” stored in Postgres, isolated per tenant by the database itself, and importable and exportable as a plain Open Knowledge Format (OKF) bundle of markdown files.

agent ──MCP──> keepsake ──> Postgres (RLS)
                   β”‚
                   └── keepsake import / export ──> markdown bundle

What it is

  • An MCP server. Seven bounded tools: okf_list, okf_search, okf_grep, okf_read, okf_create, okf_update, okf_relate. Streamable HTTP, so a fleet of pods shares one endpoint.
  • A Postgres schema. One row per concept, keyed (tenant_id, path). Optimistic concurrency via an optional expected_version, so two agents editing the same concept across an LLM call cannot silently clobber each other β€” and agents editing different concepts never contend at all.
  • A Helm chart. Install with a managed CloudNativePG cluster, or point it at a Postgres you already run and it installs into its own schema.
  • An OKF bundle on the way in and out. The format is the interchange layer, not the storage layer. keepsake export regenerates index.md and log.md at export time; they are never stored, so nothing derived can drift.

How it runs

keepsake on Kubernetes

Agents call the Service over MCP, and operators use the console through the same Service. A Helm hook runs the migration Job before every install and upgrade.

How it differs

Tenancy is enforced, not filtered. This is the real gap in the market. Mem0 takes a caller-supplied user_id, Zep and Graphiti take a group_id, and both filter on it β€” a single mis-set id poisons a namespace permanently. The ones that take isolation seriously escape to physical separation (a database per tenant, a graph per tenant). Keepsake sets a Postgres GUC inside the request transaction and lets row-level security do the enforcing. An agent never names a tenant, so it cannot name the wrong one. The server refuses to start if it is connected as a superuser or as the schema owner, because both silently bypass RLS.

No lock-in. MIT, no hosted tier, no registry, no required runtime. Your knowledge is markdown; keepsake export hands it back byte-for-byte.

Looking at what agents stored

The chart serves a read-only admin console from the same pod and port as /mcp β€” one image, no second Service, no CORS. Helm generates the password at install, into a <release>-admin Secret:

kubectl get secret <release>-admin -o jsonpath='{.data.password}' | base64 -d
kubectl port-forward svc/<release> 8000:8000

Then log in at http://localhost:8000 with that password.

Console overview

Serving many tenants

By default a release serves one tenant, auth.fixedTenantId, to anything that reaches it. auth.mode: jwt serves many: each /mcp request carries an HS256 bearer token, and its tctx.tenant claim picks the tenant.

openssl rand -hex 32 | kubectl create secret generic keepsake-jwt --from-file=secrets=/dev/stdin
helm install keepsake charts/keepsake --set auth.mode=jwt \
  --set auth.jwt.issuer=platform --set auth.jwt.existingSecret=keepsake-jwt

Your orchestrator holds the same secret and signs a short-lived token per call. The HMAC key is the line's text as-is, not its hex-decoded bytes: {"iss": "platform", "aud": "keepsake", "sub": "run:42", "tctx": {"tenant": "<uuid>"}, "exp": …}. The secret MUST NOT be readable by anything an LLM drives. A client that can run code, or that only takes a static header, gets a token for its own tenant instead:

kubectl exec deploy/keepsake -- keepsake token --tenant <uuid> --sub alice --ttl 720h

Roadmap

v1 β€” the substrate

  • okf: OKF parse/serialize with round-trip fidelity
  • Link extraction and per-write validation
  • Schema migration: concepts, revisions, RLS policies, tenant purge
  • Tenant-scoped connection handling
  • Writes with optional compare-and-swap and an append-only revision log
  • Read paths: read, list, search, grep, backlinks
  • Startup verification that refuses a privileged database role
  • MCP server over streamable HTTP
  • CLI: import, export, validate, migrate, serve
  • Helm chart with managed and existing Postgres modes
  • kind end-to-end suite
  • Tool arguments validated against their advertised schemas, so a bad one is something the agent can correct rather than a transport failure
  • Concurrent writes served in parallel, with readiness that follows the database rather than the bound port

Next

  • jwt auth mode: one release serves many tenants, each request's tenant taken from a signed token
  • OIDC and Kubernetes ServiceAccount tokens for jwt mode, verified against the issuer's published keys
  • A review UI over what agents believe β€” the thing git diff gave OKF for free and every hosted memory product dropped
  • Semantic search (pgvector + reciprocal rank fusion over the lexical index)
  • Revision retention and pruning policy
  • Per-tenant rate limits
  • Deduplication, contradiction resolution, staleness lifecycle

Status

Pre-release. Nothing here is stable yet.

Docs

Contributing

CONTRIBUTING.md has the setup, the checks CI runs, and what a good change looks like. go test ./... is the whole loop; the tests bring up PostgreSQL in a container themselves.

Found something touching tenant isolation? SECURITY.md β€” report it privately, not as an issue.

Participation is covered by the Code of Conduct.

License

MIT β€” see LICENSE.

Directories ΒΆ

Path Synopsis
cmd
keepsake command
Command keepsake operates an OKF knowledge store.
Command keepsake operates an OKF knowledge store.
Package frontend embeds the admin API contract the console's client is generated from.
Package frontend embeds the admin API contract the console's client is generated from.
internal
cli
Bundles of markdown files in and out of Postgres, ported from 2de90d2:src/keepsake/cli/__init__.py.
Bundles of markdown files in and out of Postgres, ported from 2de90d2:src/keepsake/cli/__init__.py.
migrate
Package migrate replays 8f2af2e:src/keepsake/store/migrations/versions/ without Alembic, through the same <schema>.alembic_version, so an Alembic-migrated database upgrades in place.
Package migrate replays 8f2af2e:src/keepsake/store/migrations/versions/ without Alembic, through the same <schema>.alembic_version, so an Alembic-migrated database upgrades in place.
pgtest
Package pgtest shares one Postgres container across a test run, one database per package, with the admin, owner and app roles of 2de90d2:tests/conftest.py.
Package pgtest shares one Postgres container across a test run, one database per package, with the admin, owner and app roles of 2de90d2:tests/conftest.py.
server
The admin console's read-only JSON API at /api, ported from 8f2af2e:src/keepsake/server/api.py.
The admin console's read-only JSON API at /api, ported from 8f2af2e:src/keepsake/server/api.py.
store
Concept writes, ported from 8f2af2e:src/keepsake/store/concepts.py.
Concept writes, ported from 8f2af2e:src/keepsake/store/concepts.py.
okf
Package okf is the Open Knowledge Format, publishable without the rest of keepsake.
Package okf is the Open Knowledge Format, publishable without the rest of keepsake.
internal/yaml
Package yaml implements YAML support for the Go language.
Package yaml implements YAML support for the Go language.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL