KUMBUKUMBU: memory
KUMBUKUMBU is Ngamia’s memory engine. It keeps durable, per-end-user memory for agents.
It is a standalone Rust service (kumbukumbu) with its own MongoDB database.
It is private: nothing on https://api.ngamia.com exposes it directly.
Other engines call its HTTP API. They never read its collections.
KUMBUKUMBU is a development baseline. It is approved for a sandbox beta with synthetic or reviewed non-sensitive data only. It is not yet approved for production personal data. See Known limits.
How agents use it
You turn memory on per agent with memory: true in the agent definition.
The platform does not call KUMBUKUMBU itself. NAK, the agent runtime, does.
- Your app starts a run with
POST /v1/agents/{slug}/runs. With an API key, passuserso each end user gets their own memory. - The platform calls NAK with a service assertion for (workspace, subject, app
platform). - When the agent has
memory: true, NAK recalls up to 5 facts for the run’s user and adds them to the prompt. The query is the latest user message. It callsPOST /v1/recallwithmin_score0.3. - For agents with
memory: true, and unlessNAK_KUMBU_FORWARD_EVENTS=false, NAK forwards each turn’s user input and final answer toPOST /v1/events. The extraction worker can later turn these events into memories.
Details of the NAK side:
- Every call carries a fresh NAK service assertion (
nak-te-assertion-v1, Ed25519 JWT, audiencengamia-kumbukumbu). It names the tenant, the user (sub) and the app. KUMBUKUMBU accepts eachjtionce. - The app in the assertion must equal
KUMBU_APP_ID. In the platform stack this isplatform. - The subject is the run’s end user:
kida:<user>for people,ext:<user>orkey:<id>for API keys. Each end user has a separate memory. - The workspace ID (KIDA tenant UUID) is the KUMBUKUMBU tenant.
- Forwarded text is cut to 16 KiB. Forwarding runs in the background through a bounded queue. Turns are dropped, not blocked, when memory is slow.
- Idempotency keys are
nak:<run_id>:<seq>, so a retried forward is deduplicated. The session is the conversation thread, or the run when it starts a new one. - Memory calls time out after 3 seconds. An unreachable memory service never fails a run: recall returns no facts.
- Both recall and forwarding happen only for agents defined with
memory: true. In platform mode NAK checks the agent of each run before forwarding its turns; runs of other agents send nothing to memory. Operators can also turn forwarding off for the whole deployment withNAK_KUMBU_FORWARD_EVENTS=false.
Data model
| Record | What it is |
|---|---|
| Event | An input observation: a user message, assistant answer, or tool result. Immutable and idempotent. Expires after KUMBU_EVENT_RETENTION_SECONDS (MongoDB TTL index). |
| Memory | A fact, preference, episode, procedure or relation. Has text, type, confidence, importance, sensitivity, provenance, source event IDs, a content hash and temporal fields. |
| Memory operation | History of each create, correction and forget. |
| Entity | Names resolved within app, tenant and subject, linked to memories by ID. |
| Session summary | A short, replaceable digest of a session with links to source events. |
| Profile | A deterministic view of a subject’s facts. |
Scope: every record is scoped by app, tenant and subject. Credentials fix the tenant; callers cannot choose it in the request body.
Memory types: episodic, semantic, procedural, relational. Status: active, archived, deleted, conflict, pending_review. Callers cannot set status through PATCH.
Trust comes from the event role, never from the caller:
| Role | Trust |
|---|---|
user, system | High |
tool | Medium |
assistant, web | Low |
systemevents need theadminscope. Events more than five minutes in the future are rejected.- Direct writes (
POST /v1/memories, MCPremember_memory) get tool/medium-trust provenance and cannot create procedural memories. - A correction does not overwrite. It creates a replacement and archives the old version in one transaction.
- Time has two axes: valid time (
valid_fromincluded,valid_toexcluded) and record time. Recall can askas_ofa past instant.
Sensitive categories
Sensitivity is none, personal or sensitive. Sensitive categories are health, religion, politics, sexual_orientation, ethnicity, finances, children and government_identifier.
They are denied by default. A sensitive memory is stored only when both allow its category:
- the deployment list
KUMBU_SENSITIVE_CATEGORIES(what its Vault setup may hold), and - the tenant’s published policy (
PUT /v1/admin/policy). No policy means no categories.
The extraction worker never stores sensitive candidates. Sensitive memories have no embedding and never appear in recall or profiles.
Redaction
Common-pattern rules run before events and memories are stored, and before extraction. The built-in rules replace phone numbers ([REDACTED_PHONE]), email addresses ([REDACTED_EMAIL]) and government ID numbers ([REDACTED_GOVERNMENT_ID]).
Override them with a JSON array of { "name", "pattern", "replacement" } in KUMBU_REDACTION_RULES_FILE. Set the same file on serve, worker and mcp-stdio.
Limits: 64 rules, 2 KiB per pattern, 64 KiB per file. Bad rules stop startup.
Redaction is best-effort. It does not find every kind of personal data and does not redact records already stored.
Privacy
What is stored. Events (until retention expires), memories, their history, entities, summaries, profiles, and audit records. Event idempotency keys are stored as app/tenant-scoped HMAC-SHA256 digests. API keys are stored as hashes. Logs hold only request ID, method, status and duration, never bodies or memory text.
Vault Transit encryption. With KUMBU_KMS_PROVIDER=vault-transit, each sensitive memory gets its own data key from Vault (transit/datakey/plaintext on a derived=true key, context bound to app, tenant and category). The text is encrypted locally with AES-256-GCM, bound to app, tenant, subject and memory ID. Only the wrapped key is stored; the text field holds [encrypted].
- Reads and exports decrypt. Sensitive memories cannot be patched; forget and re-create them.
- Without a working KMS, sensitive reads and writes return 503. Moved or tampered ciphertext returns 403.
- Rotation: rotate the Transit key, run
kumbukumbu kms-rewrapuntil nothing is skipped, then raisemin_decryption_version.
Export. Both need the forget scope and are audited.
GET /v1/subjects/{subject}/export: synchronous, Relaxed Extended JSON, at most 10,000 records and 8 MiB (else 413).POST /v1/subjects/{subject}/exports: asynchronous NDJSON, up to 1,000,000 records and 512 MiB. Runs insideserve. Download ends with atrailerline; without it the file is incomplete. Exports expire after 24 hours.
Deletion. DELETE /v1/subjects/{subject} (forget) fences new writes, waits for reads to drain, removes the subject’s records for that app and tenant, and verifies zero counts. It is resumable: retry the same request if it fails. Reads and recall reject a subject being deleted.
Subject deletion is not production-accepted. In-flight read races, Atlas index propagation and backup/restore replay are unverified.
API surface
Protected routes take Authorization: Bearer <credential>: a KUMBUKUMBU API key, an optional KIDA user token, or a NAK assertion. admin satisfies any scope.
| Route | Scope | Purpose |
|---|---|---|
GET /healthz | public | Liveness |
GET /readyz | public | MongoDB, Atlas Search/Vector Search and KMS readiness |
GET /openapi.json | public | OpenAPI document |
POST /v1/events | write | Ingest 1-100 events for one subject |
POST /v1/memories | write | Create an explicit memory |
GET /v1/memories/{id} | read | Read one memory |
PATCH /v1/memories/{id} | write | Correct content (supersedes) |
DELETE /v1/memories/{id} | forget | Forget one memory |
GET /v1/memories/{id}/history | read | Operation history |
POST /v1/recall | read | Recall, with optional bounded context |
GET /v1/subjects/{subject}/profile | read | Deterministic profile |
GET /v1/subjects/{subject}/export | forget | Synchronous export |
POST /v1/subjects/{subject}/exports, GET .../exports/{id}, GET .../exports/{id}/download | forget | Asynchronous export |
DELETE /v1/subjects/{subject} | forget | Delete a subject |
POST /v1/sessions/{id}/summarize, GET /v1/sessions/{id}/summary | write / read | Session summaries |
POST/DELETE /v1/admin/api-keys | admin | Create or revoke API keys |
GET/PUT /v1/admin/policy, GET /v1/admin/policy/revisions | tenant admin | Sensitive-category policy |
GET /v1/admin/jobs, POST /v1/admin/jobs/{id}/replay | tenant admin | List jobs, replay dead letters |
GET /metrics | metrics token | Prometheus metrics |
POST /mcp | per tool | MCP Streamable HTTP (opt-in) |
Recall accepts query, limit (default 20), min_score (default 0.5), type and agent filters, context, and the filters since, until, as_of and entity_ids. tags is rejected: memories have no tags.
MCP tools, over kumbukumbu mcp-stdio or /mcp with X-Kumbu-Subject:
| Tool | Scope |
|---|---|
recall_memories | read |
get_profile | read |
remember_memory | write |
summarize_session | write |
forget_memory | forget (needs confirmed: true) |
Scopes: NAK assertions get KUMBU_NAK_ASSERTION_SCOPES (default read,write). KIDA tokens get KUMBU_KIDA_SCOPES and reach only their own user. Neither can ever get admin.
Configuration
| Variable | Meaning |
|---|---|
KUMBU_MONGO_URI, KUMBU_DB | MongoDB replica set or Atlas, and database name |
KUMBU_APP_ID | The one app this process serves; platform in the platform stack |
KUMBU_EVENT_RETENTION_SECONDS | Required, positive. Raw event lifetime |
KUMBU_IDEMPOTENCY_HMAC_KEY | Required by serve. 64 hex characters, same on all replicas. Changing it needs a migration |
KUMBU_BIND | Listen address, default 127.0.0.1:8080 (plain HTTP) |
KUMBU_TENANT_REQUESTS_PER_MINUTE | Shared per-tenant limit, default 600 (then 429) |
KUMBU_REQUEST_TIMEOUT_SECONDS, KUMBU_MAX_CONCURRENT_REQUESTS | Default 30 (then 503) and 256 |
KUMBU_SEARCH_INDEX_WAIT_SECONDS | Wait for Atlas indexes at startup, 1-3600, default 300 |
KUMBU_NAK_ASSERTION_ISSUER, KUMBU_NAK_ASSERTION_KEYS | Enable NAK assertions; issuer ngamia-nak, 1-8 Ed25519 public keys by key ID (JSON) |
KUMBU_NAK_ASSERTION_AUDIENCE, KUMBU_NAK_ASSERTION_SCOPES | Default ngamia-kumbukumbu and read,write |
KUMBU_KIDA_ISSUER, KUMBU_KIDA_JWKS_URL, KUMBU_KIDA_AUDIENCE, KUMBU_KIDA_SCOPES | Optional KIDA user tokens; set all four |
KUMBU_KMS_PROVIDER, KUMBU_SENSITIVE_CATEGORIES | vault-transit or none (default), and allowed categories |
KUMBU_VAULT_ADDR, KUMBU_VAULT_TOKEN_FILE, KUMBU_VAULT_TRANSIT_MOUNT, KUMBU_VAULT_TRANSIT_KEY, KUMBU_VAULT_NAMESPACE | Vault; mount and key default to transit and kumbukumbu |
KUMBU_LLM_PROVIDER, KUMBU_LLM_ENDPOINT, KUMBU_LLM_MODEL, KUMBU_LLM_API_KEY | Extraction model; none (default) or openai_compatible |
KUMBU_SESSION_SUMMARIES, KUMBU_SUMMARY_EVENT_THRESHOLD | enabled to summarise; worker auto-summarises every 50 new events by default |
KUMBU_EMBED_PROVIDER, KUMBU_EMBED_ENDPOINT, KUMBU_EMBED_MODEL, KUMBU_EMBED_DIM | none (default) or loopback-only ollama; dimension 512 or 768 |
KUMBU_REDACTION_RULES_FILE | Custom redaction rules |
KUMBU_MCP_HTTP, KUMBU_MCP_ALLOWED_HOSTS, KUMBU_MCP_ALLOWED_ORIGINS | Enable /mcp; host and origin allowlists |
KUMBU_METRICS_TOKEN | 32-256 characters; enables /metrics |
KUMBU_WORKER_DRAIN_SECONDS | Worker shutdown grace, default 60 |
KUMBU_LOG_LEVEL | error, warn or info |
On the NAK side: NAK_KUMBU_ENDPOINT (HTTPS, or plain HTTP on loopback; needs NAK_ASSERTION_KEY_FILE and NAK_ASSERTION_KEY_ID), NAK_KUMBU_AUDIENCE and NAK_KUMBU_FORWARD_EVENTS.
The CLI reads process environment only; it does not load .env.
Operations
- MongoDB. A replica set is required: corrections, job leases and deletion use transactions. Atlas Search and Atlas Vector Search are required. A plain local replica set runs tests but cannot make
serveready. - Indexes. Run
kumbukumbu ensure-indexes, thenkumbukumbu serve.servewaits for the search indexes (memories_text_v3,memories_vec_v3) before listening. Drop the_v2indexes once no older replica runs. - Worker.
kumbukumbu workeris a separate process and off by default. It leases jobs per subject, renews leases every 20 seconds, checks cited source events, redacts, and retries into dead letters. Enable it only after reviewing the model provider and its data terms. - Health.
/healthzis liveness./readyzchecks MongoDB, search indexes and, when configured, Vault. - Metrics. Prometheus at
/metricswith the metrics token: status classes, latency, 401/403/429/503 counts, dependency reachability, jobs by state, oldest pending job age, exports. No tenant or subject labels. Alert onkumbu_dependency_up == 0and on a growingkumbu_jobs{state="dead_lettered"}. - Network. The service does not terminate TLS. In the platform stack it runs on private networks only, under the
memoryCompose profile. - First admin key.
kumbukumbu bootstrap-admin-keywrites a one-time, short-lived key to a mode-0600 file. Not needed for NAK traffic.
Known limits and status
- Sandbox beta only. No production personal data.
- Deletion and backup/restore are not accepted. No restore drill across a Vault key rotation yet.
- Relationship extraction, conflict review, consolidation, scheduled decay and purge, and re-embedding are not implemented.
- No storage or compute quotas, route-specific limits or tracing spans. No load or staging evidence on real Atlas.
- NAK-to-KUMBUKUMBU assertions are tested locally, not yet in staging.
- No remote embedding provider. Changing embedding dimensions needs a migration.
- A KIDA token stays valid until it expires, even after a membership change.
Repository docs
| Path | Content |
|---|---|
KUMBUKUMBU/README.md | Overview, build, run |
KUMBUKUMBU/docs/USING_KUMBUKUMBU.md | What works today, sandbox walkthrough |
KUMBUKUMBU/docs/RUNBOOKS.md | Operations: Vault, export, deletion, NAK assertions, metrics |
KUMBUKUMBU/docs/IMPLEMENTATION_STATUS.md | Shipped behavior and blockers |
KUMBUKUMBU/docs/BETA_DEPLOYMENT_GATE.md | Beta restrictions |
KUMBUKUMBU/docs/DECISIONS.md | Recorded decisions |
KUMBUKUMBU/docs/SRS.md | Target requirements (not all shipped) |
KUMBUKUMBU/docs/PRODUCTION_READINESS_PLAN.md | Ordered backlog |
KUMBUKUMBU/docs-site/ | Engine docs site |
NAK/crates/runtime/src/integrations.rs | NAK’s memory client and turn forwarding |
deploy/compose.yaml | Platform stack (kumbukumbu service) |