capsa

mcp
Security Audit
Fail
Health Pass
  • License — License: Apache-2.0
  • Description — Repository has a description
  • Active repo — Last push 0 days ago
  • Community trust — 45 GitHub stars
Code Fail
  • exec() — Shell command execution in internal/adminui/static/app.js
  • network request — Outbound network request in internal/adminui/static/app.js
  • rm -rf — Recursive force deletion command in scripts/install.sh
  • network request — Outbound network request in scripts/install.sh
  • rm -rf — Recursive force deletion command in scripts/smoke.sh
Permissions Pass
  • Permissions — No dangerous permissions requested

No AI report is available for this listing yet.

SUMMARY

Encrypted memory and knowledge base for AI agents: OKF markdown bundles in PostgreSQL with pgvector, served over MCP.

README.md

capsa

CI Release License Go Go Reference Codecov

ghcr.io/svetlovtech/capsa:latest MCP 2026-07-28 PRs welcome

capsa is a memory and knowledge base for AI agents over your own PostgreSQL. It stores OKF (Open Knowledge Format) markdown bundles that an agent searches by meaning and by words, reads whole, writes under a version check, remembers raw notes into, and consolidates into knowledge — all over MCP (Streamable HTTP at /mcp, or stdio through capsa mcp). capsa calls no model: a search is an embedding and a sort, and a consolidation is the agent's decision over a queue capsa proposes. It stores plaintext, as safe as your PostgreSQL — there is no encryption setting (where it went). Nothing is hosted but the database: the binary carries its schema and talks to any PostgreSQL with pgvector and pg_search. Landing page: svetlovtech.github.io/capsa.

Why capsa

Four choices, each of which is a decision rather than a feature checkbox:

  • Plaintext, and as safe as your PostgreSQL. PostgreSQL holds the knowledge in the clear, and capsa's safety is the database's — which is a lot, once it is hardened: loopback or a Unix socket, SCRAM, a dedicated role, an encrypted volume, encrypted backups (the recipe). Every feature works on it, search by words included, and there is no key to lose. capsa 0.1.0 could seal the text per value; the option was removed in 0.2.0 (where encryption went). The security model says exactly what the position gives.
  • Postgres only. No Qdrant, no Redis, no object store. One database to back up, one thing to operate; the vectors sit beside the rows the filters need, and so does the word search's index — BM25 through pg_search, an extension in the same PostgreSQL. Migrations are embedded and applied at start.
  • OKF is the format. A knowledge base is a directory of typed markdown files with YAML frontmatter and links: readable by agents, diffable by people, exportable 1:1 from the database with capsa export. capsa is a consumer of the format, not a lock-in.
  • No LLM in capsa. A search is an embedding, a cosine scan and a sort: no model call per query, no tokens, milliseconds. A remembered note becomes knowledge when an agent decides it does — capsa lists the queue and the nearest concepts, and records the decision; it never calls a model to make it. Point CAPSA_EMBEDDINGS_BASE_URL at a local Ollama or TEI and the text never leaves your host; point it at OpenRouter for the best-measured model. An optional cross-encoder reranker is a second stage you can switch on.

Get it

Way Command What you get
GitHub Releases releases/latest: capsa_<version>_<os>_<arch>.tar.gz (.zip on Windows), linux/darwin/windows amd64+arm64, an SBOM per archive and checksums.txt The binary, LICENSE and README.md; unpack into a directory on PATH
Docker Compose git clone https://github.com/svetlovtech/capsa.git && cd capsa && docker compose up -d PostgreSQL (ParadeDB's image: pg_search and pgvector) + capsa on http://127.0.0.1:8116, built from the clone; the CLI as docker compose exec capsa /capsa <command>. The embeddings endpoint, key, model, query instruction and timeout, the fallback endpoint, the reranker settings, the tool groups and the vector index's width reach the container from a .env next to the compose file. An Ollama on the host is CAPSA_EMBEDDINGS_BASE_URL=http://host.docker.internal:11434/v1 with CAPSA_EMBEDDINGS_MODEL=bge-m3 in that file. capsa stores plaintext.
go install go install github.com/svetlovtech/capsa/cmd/capsa@latest (Go 1.27) The binary in $(go env GOPATH)/bin
Container image docker pull ghcr.io/svetlovtech/capsa:latest The distroless image; it needs a database with pgvector and pg_search

Linux packages (.deb, .rpm, .apk), a Scoop manifest, a Homebrew cask and an install script are built by the release chain as of the next release; docs/releases.md has every system, the asset names and what a release contains. From that release every archive also carries THIRD-PARTY.md, the licences and notices of the modules the binary is built from.

You need PostgreSQL 15+ with pgvector 0.7+ and pg_search 0.27+ (ParadeDB): pgvector stores the vectors (halfvec arrived in 0.7.0), and pg_search is what search by words runs on. The easy way is ParadeDB's image, paradedb/paradedb:0.27.1-pg17 (tags for PostgreSQL 15 to 18), which has both installed and pg_search preloaded. On a server you already run, ParadeDB's packages for PostgreSQL 15+ are on its GitHub Releases (Debian 12/13, Ubuntu 24.04/26.04, RHEL 9/10, macOS 15/26), and pg_search must be in shared_preload_libraries before the server restarts (docs.paradedb.com, read 2026-12-04). Neither extension is "trusted": a superuser creates them once per database (capsa doctor --fix does that when the role may), and capsa doctor tells you what is missing and how to fix it, by platform. On pgvector 0.8.0 or newer the vector search also turns on the iterative scan, which keeps a search filtered to a small bundle filling its page.

Licence note. pg_search Community is AGPL-3.0 (ParadeDB's README, read 2026-12-04). It is a separate program installed into the database: capsa is Apache-2.0, speaks SQL to it, and neither links nor ships it — the ParadeDB image is referenced by name in docker-compose.yml and in CI, and pulled by whoever runs them.

Bare capsa prints help. The server is capsa serve.

The five-minute path

# 1. a database with pgvector and pg_search (paradedb/paradedb:0.27.1-pg17 has both). --fix creates the extensions when the role may
export CAPSA_DATABASE_URL='postgres://capsa:[email protected]:5432/capsa?sslmode=disable'
capsa doctor --fix

# 2. an embeddings endpoint: what search by meaning runs on. Local, no key (Ollama):
export CAPSA_EMBEDDINGS_BASE_URL=http://127.0.0.1:11434/v1 CAPSA_EMBEDDINGS_MODEL=bge-m3
#    Or hosted, with the default model:
# export CAPSA_EMBEDDINGS_BASE_URL=https://openrouter.ai/api/v1 CAPSA_EMBEDDINGS_API_KEY=sk-or-…

# 3. the server: migrations first, then /mcp, /api/admin, /admin/, /healthz, /readyz
capsa serve &

# 4. a token for an agent; the plaintext is shown once
capsa token create --name agent --scopes read,write

# 5. put some knowledge in and make sure it was embedded
capsa import --dir testdata/smoke --slug smoke     # a tiny OKF bundle to try; --wrap also takes plain markdown
capsa stats                                       # pending_chunks should be 0

This run stores plaintext — the only way capsa stores (where encryption went); what protects it is the database's (the recipe). Without an embeddings endpoint the server starts too, and search falls back to the words alone — BM25 through pg_search: a fallback, not a peer. On the benchmark corpus it finds 56 % of the answers in the top five, where the vectors find 87 % (Retrieval quality). Chunks left pending wait for an endpoint; with one, a chunk the model cannot take does not hold the others back — each pass embeds what it can, leaves that chunk pending and tries it again on the next, counting it as failed.

Every setting can also live in a .env file in the working directory (copy .env.example); the file wins over the environment. Hand the whole setup to the agent that will use the memory with skills/capsa-setup/SKILL.md: preflight, three install paths (Docker Compose, binary, fully native with PostgreSQL and Ollama on the host and a service unit), tokens, clients, import, the hand-over to another machine, troubleshooting.

Connect an MCP client

The URL is http://127.0.0.1:8116/mcp, the header Authorization: Bearer mem_…. Claude Code:

claude mcp add --transport http capsa http://127.0.0.1:8116/mcp --header "Authorization: Bearer mem_…"

capsa token create --client opencode prints this entry with the token in it — also --client claude-code, claude-desktop, cursor, codex, and --transport stdio for the local form below (the CLI reference).

Claude Desktop, Cursor, Windsurf, Cline: a JSON entry under mcpServers. Clients call the transport http or streamable-http; some take url alone.

{
  "mcpServers": {
    "capsa": {
      "type": "http",
      "url": "http://127.0.0.1:8116/mcp",
      "headers": { "Authorization": "Bearer mem_…" }
    }
  }
}

OpenCode V2 keeps its servers under mcp.servers:

{
  "mcp": {
    "servers": {
      "capsa": {
        "type": "remote",
        "url": "http://127.0.0.1:8116/mcp",
        "oauth": false,
        "headers": { "Authorization": "Bearer {env:CAPSA_TOKEN}" }
      }
    }
  }
}

oauth: false because capsa takes a static bearer token, not an OAuth flow; {env:CAPSA_TOKEN} because OpenCode does not expand $CAPSA_TOKEN. Then, in the agent's words: search the memory before you guess. The tools answer JSON.

A client on the same host can also run the server as a process: capsa mcp speaks the same tools over stdio, every call made as the one token in CAPSA_TOKEN. It reads the service's configuration like every command — a .env, or the file ENV_FILE names — so a client's entry carries the configuration by reference and none of its secrets. OpenCode's local form, as capsa token create --client opencode --transport stdio prints it:

{
  "mcp": {
    "servers": {
      "capsa": {
        "type": "local",
        "command": ["/usr/local/bin/capsa", "mcp"],
        "environment": { "ENV_FILE": "/home/me/.config/capsa.env", "CAPSA_TOKEN": "mem_…" }
      }
    }
  }
}

The token is in the process's environment, so every process that client spawns can read it: give a stdio server the least token that suffices ({env:CAPSA_TOKEN} keeps it out of the file, where the client expands it). That entry is the one the MCP Registry publishes (server.json).

How a search answers

One memory_search, from the query to the answer. No LLM anywhere on the path; the dashed edge is the fallback when no embedding provider is configured or it fails.

flowchart LR
  Q["query"] --> E["embed the query"]
  E --> V["cosine scan over halfvec(1024)<br/>exact; an HNSW index past 100,000 chunks"]
  V --> K["key-term boost: +0.02 per term, cap +0.06"]
  K --> D["at most 2 chunks per concept in the top 5"]
  D --> R{"reranker configured?"}
  R -- yes --> X["cross-encoder re-orders the top 20"]
  R -- no --> A
  X --> A["answer: JSON"]
  E -. "no provider, or it failed" .-> F["word search fallback, mode fts<br/>BM25 through pg_search: the query's words, any of them"]
  F --> A

The filter (bundle, type, tags, current concepts only, and the token's bundle restriction) is one WHERE clause shared by both modes, so the restriction holds whether or not the request names a bundle. A vector another model made is never mixed into the scan: the model is recorded per chunk, and such a chunk is pending until it is embedded again (a vector made before the model was recorded keeps being ranked, and is made again in the background). In vector mode the key-term boost keeps identifiers findable whatever the model makes of them; the per-concept cap keeps one long document from filling the answer in both modes. The word search is BM25 over one index of the whole installation, inside PostgreSQL: pg_search tokenises the query with its default tokeniser (word boundaries by UAX #29, lowercased — no language is named), a chunk carrying any of the terms is a match, and pdb.score ranks it. A word is matched whole — an underscore keeps an identifier one token, text without spaces is one token a character — and the index's statistics are the installation's, not a bundle's.

What the agent sees

A real answer for memory_search with the query how does a deployed instance register with the fleet, over the three concepts of testdata/smoke, with bge-m3 on a local Ollama (a plaintext run; measured 2026-12-03). The first hit's long text and the other two hits are trimmed here; the keys are the tool's, in its order; nothing else is changed.

{
  "hits": [
    {
      "bundle": "smoke",
      "description": "The beacon service of the Harbor stack that keeps the registry of every deployed instance.",
      "heading": "Harbor Lighthouse",
      "path": "concepts/harbor-lighthouse",
      "score": 0.613495,
      "stale": false,
      "status": "stable",
      "text": "The lighthouse is the beacon service of the Harbor monitoring stack. Every\ndeployed instance registers with the lighthouse once a minute, …",
      "title": "Harbor Lighthouse",
      "trust_tier": "human-reviewed",
      "type": "Service",
      "version": 1
    },
    {"bundle": "smoke", "path": "concepts/deploys", "score": 0.5965346, "title": "Deploys", "type": "Convention", "version": 1, …},
    {"bundle": "smoke", "path": "concepts/telemetry-pipeline", "score": 0.4657294, "title": "Telemetry pipeline", "version": 1, …}
  ],
  "low_confidence": false,
  "mode": "vector"
}

The same search with fields: ["path", "score"] — the projection an agent uses to search, then memory_get what it wants — is one line, 207 bytes (the same run; the whole answer above is 2 351):

{"hits":[{"path":"concepts/harbor-lighthouse","score":0.613495},{"path":"concepts/deploys","score":0.5965346},{"path":"concepts/telemetry-pipeline","score":0.4657294}],"low_confidence":false,"mode":"vector"}

score is the cosine similarity (in fts mode it is the BM25 score; the two are not comparable). low_confidence is true for a vector answer with no hits, a best score under 0.3, or a top-two gap under 0.01; it is advisory, because no model abstains on cosine. The agent reads the chunks, then calls memory_get for a concept's whole file. A search is logged (query text, mode, latency, result count, top score).

OKF in 15 lines

A concept is a markdown file with YAML frontmatter. Only type is required; the rest is what capsa reads into filters and the reader. This file imports as the concept harbor-lighthouse of its bundle:

---
type: Service
title: Harbor Lighthouse
description: "The beacon service that keeps the registry of every deployed instance."
status: stable
tags: [harbor, beacon]
generated:
  by: process:deploy-bot
  at: 2026-11-01T10:00:00Z
---

# Harbor Lighthouse

Every deployed instance registers with the lighthouse once a minute.
See [the telemetry pipeline](telemetry-pipeline.md) for who reads the registry.
capsa lint --dir ~/notes/kb                 # 46 rules against OKF v0.3; an error means not conformant
capsa import --dir ~/notes/kb --slug kb      # every .md with a type under the directory
capsa import --dir ~/skills --slug kb --skills   # a directory of Agent Skills, each <name>/SKILL.md with its files
capsa export --slug kb --dir /tmp/kb         # the same files back, plus a generated index.md

status absent means stable; draft and stable are current knowledge and searchable, deprecated is kept for links and history. The trust tier comes from verified events (human: verifiers make human-reviewed, anything else machine-confirmed); a verified event that is added or changed takes the admin scope, and a text that changes under a badge reads as unverified until a person confirms it again. Links between concepts become a graph that memory_get returns as neighbours. Unknown keys and types are kept as written. Plain markdown without frontmatter comes in with --wrap, which synthesizes the frontmatter.

flowchart LR
  dir["a directory of OKF markdown"] -->|"capsa lint --dir"| lint["46 rules; an error is<br/>non-conformance only"]
  dir -->|"capsa import --dir --slug"| scan["scan the directory<br/>index.md and log.md are reserved"]
  scan --> counts["lint counts in the import's JSON<br/>never block it"]
  scan --> concepts["memory_concepts<br/>the parsed columns, the frontmatter,<br/>the file verbatim; unchanged files are skipped"]
  concepts --> chunks["memory_chunks<br/>cut by headings, 700 to 1400 bytes"]
  concepts --> edges["memory_edges<br/>one row per link between two concepts"]
  chunks -->|"capsa index, or the worker"| vectors["embeddings, halfvec(1024),<br/>the model recorded per chunk"]
  concepts -->|"capsa export --slug --dir"| out["the same files, byte for byte,<br/>plus a regenerated index.md"]

A bundle goes in as files and comes back out as the same files. What the database keeps is a projection: parsed columns to filter on, the frontmatter and the file verbatim to export, chunks to search, and the edges between concepts.

Tasks, skills and the episode queue

Three things carry a meaning beyond a document.

A task is type: Task with its lifecycle in the OKF status field and its dependencies in the extension key x-capsa-depends-on; two agents that claim the same task get exactly one winner, and a task never stays in_progress because a worker died — and while a lease is live, no write path changes the task but its holder's.

A skill is type: Skill with a name and a description — the keys of an Agent Skills SKILL.md — whose body is the instruction text an agent follows; writing one takes the skills scope, so an agent cannot rewrite the skills it runs under. A skill is a folder: <name>/SKILL.md and the files it needs travel together — UTF-8 text, at most 64 KiB a file and 64 files a skill, binary assets in a later release — stored with the skill concept — a content column like any other — and written in one transaction with it (docs/skills.md is the reference).

The episode queue is what an agent remembers. memory_remember appends a raw note; nothing searches the log. memory_inbox lists the notes that wait, in clusters of like ones, each next to the concepts it is nearest to — suggestions, not decisions; an agent decides, writes with derived_from citing the notes, and memory_consolidate marks them handled. capsa calls no model in any of it. The procedure is the skill skills/capsa-consolidate/SKILL.md; a consolidation never edits a human-reviewed concept and never deprecates.

Tasks are not current knowledge (their status is outside draft | stable | deprecated): memory_search and the default memory_list leave them out, task_list shows them. The model, the scopes rule and what is wired are in docs/tasks-skills.md.

stateDiagram-v2
  direction LR
  [*] --> open: task_create
  open --> in_progress: task_claim takes the lease
  in_progress --> in_progress: the holder renews the lease, no version
  in_progress --> done: task_update complete
  in_progress --> failed: task_update fail, with a reason
  in_progress --> open: task_update release
  in_progress --> open: the lease ran out, the janitor writes open
  open --> cancelled: memory_put with status cancelled
  done --> [*]
  failed --> [*]
  cancelled --> [*]
  note right of open
    Two agents call task_claim at once: one INSERT wins,
    the other changes nothing and is told the task is claimed.
    Ready means open, every dependency done, no live lease.
  end note
  note right of in_progress
    Every transition is a new version of the concept,
    with one audit row.
    The lease row holds a token id, a holder and lease_until:
    no content column.
  end note

The lease lasts CAPSA_TASK_LEASE_SECONDS (900 by default) and is renewed by calling task_claim again with the task's path; the server's worker returns an in_progress task whose lease ran out to open at start and at every CAPSA_INDEX_INTERVAL_SECONDS; a failed or cancelled dependency blocks the tasks that wait for it until an agent replans.

MCP tools

Twenty tools in five groups, over Streamable HTTP at /mcp and over stdio (capsa mcp), protocol revision 2026-07-28: a stateless core with no sessions, every answer one JSON object in structuredContent and as the text, with an output schema; a tool's error is an isError answer naming the tool and the cause. What a token sees in tools/list is two filters, an allow-list and a grant: the tool groups the configuration enables — CAPSA_TOOLS, among memory, consolidate, tasks, skills and lint; all by default, and memory always on — and what the token's scopes allow. With every group on, a read token sees 10 tools, read + write 18, every scope 20; with CAPSA_TOOLS=memory, 5 and 9. The list is in a fixed order and cached for a minute, private to the token. Its size is paid on every turn in a Code Mode client, which prints the catalog into the model's context: 26 190 B with every scope (20 tools), 23 936 B for a read,write token (18), 15 011 B for read (10), 11 001 B for memory alone with read,write (9), 15 435 B for memory,consolidate (11) — measured 2026-12-03 with TestCatalogTable in internal/mcp (docs/mcp.md §3 has the table per profile). CAPSA_TOOLS is the lever: a memory server that is only a memory server pays 11 KB where every tool costs 24 KB, for a read,write token. docs/mcp.md is the contract.

No answer is larger than CAPSA_MCP_MAX_RESULT_BYTES (32 KiB by default) as JSON: a file comes back as a window with truncated and next_offset, a search keeps every hit but shortens the chunk texts with a marker that says how many bytes were left out (and drops the lowest-ranked ones, counted in hits_dropped, only when even their metadata does not fit), a page is cut with a cursor. Paths are OKF concept ids: the bundle-relative file path without .md (for example services/chat). To add a tool, add a row.

Tool Scope Parameters Returns
memory_search read query (required), bundle, type, tags[], limit (1–50, default 8), include_deprecated, fields[] (the keys each hit carries; at least one) {mode, hits[], low_confidence, fallback_reason?, reranker?, truncated?, hits_dropped?}; a hit: bundle, path, type, title, description, status, trust_tier, stale, heading, text, score, version. Does not search the episode log. fields is a projection applied before the byte budget, so more hits fit — path and score is the search-then-get pattern: 8 hits of 700-byte chunks are 7 232 B with every key and 376 B with those two (measured 2026-12-03 with the fake embedder, docs/mcp.md §6). An unknown key is refused.
memory_get read bundle, path (required), offset, limit (bytes of content) The concept: content, type, title, description, tags, status, trust_tier, stale, stale_after, superseded_by, version, neighbors ({path, kind, out} — out true when the link leaves the concept); truncated, next_offset, content_bytes, neighbors_total when the byte budget cut it — call again with next_offset.
memory_list read bundle (required), prefix, include_deprecated, limit (1–500, default 100), cursor, fields[] (the keys each row carries) {concepts: […], next_cursor?}: bundle_id, path, type, title, description, status, version, updated_at. Pages of 100 through the service; the cursor is opaque, bound to the listing's filters, and refused with another. Tasks are not listed: task_list. fields projects each row as on the search.
memory_put write bundle, path, content (required; the whole file), expected_version, derived_from[] (1–200 episode ids) {bundle, path, version, created, status, trust_tier, changed}. The tool for knowledge an agent must find later. expected_version has three meanings: absent is no check, 0 creates only (an existing path is refused with its version), n must be the stored version (another is a conflict naming both; nothing changes). A write of what is already stored is a no-op success — changed: false — never a conflict. derived_from records that the write consolidates those episodes (in the file's x-capsa-derived-from, in a link row and in the audit row); a write that cites episodes onto a human-reviewed concept is refused. A type: Skill file needs the skills scope; a claimed task is its holder's to write.
memory_edit write bundle, path, section (required), content, append, delete, rename, expected_version (minimum 1), derived_from[] {bundle, path, version, changed, op} — one section of a body, by its heading (Rollback, or Parent > Child when the text appears twice): replace its text up to the first subsection, append a new section at the end (a heading that exists is refused), delete it with its subsections, rename it keeping the text. The frontmatter never moves (memory_put); changed is always said. A type: Task is refused: the task tools write it.
memory_deprecate write bundle, path (required), superseded_by, expected_version (minimum 1; absent: no check) {bundle, path, status, superseded_by, version, changed}. Rewrites only the status and superseded_by lines, as a new version; nothing is deleted. A stale version is refused naming both; deprecating what is deprecated changes nothing (changed: false).
memory_remember write bundle, text (required; at most 64 KiB) {episode_id}. Appends a raw note to the bundle's episode log: append-only, and memory_search does not search it. The notes become knowledge when an agent consolidates the queue (memory_inbox, a write with derived_from, memory_consolidate).
memory_inbox read bundle (required), limit (1–100, default 50), cursor; or episode (an id), offset, limit_bytes {bundle, remaining, oldest_at?, next_cursor?, truncated?, mode, fallback_reason?, clusters[], episodes[], candidates[]}: the unconsolidated episodes, oldest first, in clusters of like ones, each with its nearest current concepts as candidates — suggestions, not decisions. An episode comes whole to 4 096 bytes and in windows after; limit: 1 is a cheap poll for remaining and oldest_at. Without an embeddings provider, mode: time: one cluster an episode, no candidates.
memory_consolidate write bundle, episodes (required, 1–200 ids), outcome (required: applied, noop or review), paths (with applied), task (with review) {bundle, marked[], already[], remaining, oldest_at}. Marks episodes handled — one outcome a call; review names the task that holds them. Changes no concept and deletes nothing: the writes are memory_put and memory_edit. An id marked already is already, never twice; the audit row episode.consolidate is written in the same transaction, with identifiers only.
memory_changes read since (an integer: the last page's next_cursor; 0 the beginning; absent: a baseline at the head, so a client hears only what comes next), limit (1–500, default 100), bundle {changes[{cursor, at, kind, actor?, bundle, path?, version?}], next_cursor, has_more}, oldest first: the feed over the audit log, identifiers and versions only, never content. Fifteen kinds: concept.put, concept.edit, concept.deprecate, concept.delete, task.create, task.claim, task.complete, task.fail, task.release, skill.put, skill.replace_files, bundle.import, bundle.import_skills, bundle.delete, episode.consolidate. actor is the token's name, so a client can skip its own writes.
memory_whoami any valid token none {name, scopes, bundles, all_bundles, version, catalog_hash}. The bundles as slugs; version is the server's and catalog_hash covers what decides the catalog — a changed hash means tools/list again.
okf_lint read; write for fix: "apply" bundle (a stored bundle), path? (that concept only), content? (a draft, with path as its id), fix?: none (the default), dry_run, apply The report — {errors, warnings, infos, files, findings[]} with rule, severity, path, line, message and the fix offered — and fixes[] with a fix; truncated, findings_total when cut. It never refuses a concept and changes nothing unless fix is apply, which is for a whole stored bundle; a draft cannot be fixed. Not read-only, so a host does not auto-approve it.
task_create write bundle, title (required), description?, path? (default tasks/<slug of the title>), depends_on?[] (ids of tasks of the bundle), body? {bundle, path, title, status, version}. Creates the task, open; it does not claim it.
task_list read bundle (required), status? (open, in_progress, done, failed, cancelled), prefix?, limit? (1–200, default 50), cursor? {tasks: [{path, title, status, version, depends_on[], blocked_by[], ready, lease?{holder, expires_at}}], next_cursor?}
task_claim write bundle (required), and path (that task) or next: true with prefix? (the next ready task under it); holder? (at most 100 characters) {task: {bundle, path, title, status, version, content, truncated, next_offset?, content_bytes?, holder, lease_expires_at}, renewed?} — what a worker needs, the work in a window of the byte budget; task: null when nothing is ready, which is not an error. Called again with path while the token holds the task, it renews the lease: renewed: true, no version.
task_update write bundle, path, action (required): complete, fail, release; reason? (with fail: stored under ## Outcome in the body) {bundle, path, status, version}. Only the token that holds the lease may; the lease ends with it.
skill_list read bundle (required) {skills: [{path, name, description, version, updated_at}]} in name order; a deprecated skill is left out; truncated, skills_total when cut.
skill_get read bundle, name (required; a concept id works for a skill stored under another path), file, offset, limit The skill as a concept — content is its SKILL.md, windowed by the byte budget like a concept's — and files: [{path, media_type, size, sha256}], its other files. With file: content is that file's text, and file: {path, media_type, size, sha256} names it.
skill_put skills bundle, name (required; 1–64 of a-z0-9-), description, body (required), files[]: {path, content} (at most 64, each UTF-8 text of at most 64 KiB), expected_version? {bundle, path, name, version, created, files} — files is how many the skill holds after the write. files is the whole set: omitted leaves them, [] removes them. The concept and its files are one transaction: a refused file (not text, too large, a bad path) names its path and changes nothing. expected_version: absent is no check, 0 the skill must not exist, n must be the stored version; another version is a conflict and changes nothing.
skill_deprecate skills bundle, name (required), superseded_by? {bundle, path, status, superseded_by, version}. It leaves skill_list and stays readable.

Scopes: read covers the readers (memory_search, memory_get, memory_list, memory_changes, memory_inbox, task_list, skill_list, skill_get, and the report of okf_lint); write the writers (memory_put, memory_edit, memory_remember, memory_deprecate, memory_consolidate, the task tools, and okf_lint with fix: "apply"); skills writes Skill concepts (skill_put, skill_deprecate) — write does not imply it and neither does admin, and skills alone writes nothing else; admin is the REST API and the admin page. A tool the scopes leave out is not in the token's tools/list, and called by name it answers with the scope it needs; a tool of a disabled group is an unknown tool. write does not imply read on the listing: a write-only token sees the write tools and memory_whoami.

How an agent learns about changes

Several agents write to one memory, and every client caches what it reads. capsa sends no push today; what exists is pull, and docs/mcp.md §6a has the whole evaluation. Four things:

  • The feed. memory_changes lists what changed since a cursor — the audit log's row id, an integer — each change with its cursor, time, kind, actor, bundle, path and the version after it; identifiers and versions only, never content; oldest first, with next_cursor and has_more. An agent that keeps its last cursor asks for everything since, then fetches the changed paths with memory_get and compares versions before it edits. An absent since is a baseline at the head: nothing of the past is replayed. Every write commits with its audit row or not at all, and the rows' ids follow commit order, so the feed cannot skip a change.
  • Versions and a cheap revalidation of the catalog. memory_get and skill_get return version, and every write takes expected_version: a write against a concept that moved on is refused and changes nothing. server/discover and tools/list carry a time to live of a minute, private to the token, and memory_whoami carries the server's version and a catalog_hash: one call tells a client that the catalog it cached — from before an upgrade, or from before CAPSA_TOOLS was edited — is not the one this server offers, and to run tools/list again.
  • An OpenCode automation for the feed. Nothing has to push for this: an automation runs a Code Mode script every few minutes with no model, keeps its cursor between runs, and send.prompt steers the session when something changed; a run with nothing to say costs one small read. The script is in docs/mcp.md §6a, verified end to end on 2026-12-03.
  • An automation for the inbox. The same pattern, every 30 minutes: memory_inbox with limit: 1 is one small read — remaining and oldest_at, no model call — and the session is steered to run the consolidation procedure when 20 episodes wait or the oldest has waited a day (docs/mcp.md §6b). Without a scheduler, consolidation happens when the user asks for it.

Server push waits for the SDK: OpenCode's events are the MCP Events extension, whose push needs a server's own notification, and the official Go SDK v1.9.0 cannot send one; the automation is the pattern that works today, and no private protocol is built. MCP resources are not exposed either — docs/mcp.md says why each was evaluated and left.

CLI reference

Cobra: flags take two dashes, with a one-letter shorthand where listed. Every command reads the CAPSA_* settings (environment, a .env in the working directory, or the file ENV_FILE names). Output is indented JSON on stdout; diagnostics go to stderr. Exit codes: 0 success, 1 failure, 2 usage error. Every command that opens the database applies the migrations first, so import works before the server has ever started.

Command Flags What it does
capsa none Prints help.
capsa serve none Runs the server: migrations, then /mcp, /api/admin, /admin/, /healthz, /readyz, and the worker — at start and then every CAPSA_INDEX_INTERVAL_SECONDS: the lease janitor always, the pending chunks and the waiting episodes when there is an embeddings provider — until SIGINT or SIGTERM.
capsa ready none Probes /readyz of a running server and prints ok; the container healthcheck. Loopback only (READINESS_ADDR overrides the address).
capsa doctor --fix (default false) Examines the database the way the server will use it: URL, connection, PostgreSQL version (13+), pgvector present, new enough (0.7.0+) and created in this database; pg_search present, new enough (0.27.0+), preloaded by the server (shared_preload_libraries) and created in this database; the role's privilege to create tables, and the schema. --fix creates an extension when the server has it and the role may — pg_search brings pgvector with it; nothing else is changed. Each fix is named by platform: the ParadeDB image, the packages on ParadeDB's GitHub Releases, shared_preload_libraries, a restart. A warn status leaves ready true and names what to run: chunks with no recorded embedding model. A database that capsa 0.1.0 sealed makes ready false and names capsa decrypt. Exit 1 when the server cannot start against this database.
capsa token create --name/-n, --scopes/-s (default read; read,write,admin,skills), --bundles/-b (slugs; empty = all), --client/-c (opencode, claude-code, claude-desktop, cursor, codex), --transport/-t (http, the default; stdio — for claude-desktop the only one), --url/-u Creates a token. The secret is shown once. With --client the answer also carries client_config: the entry that connects that client with this token — over HTTP (--url, or http://<host>:<port>/mcp from CAPSA_HTTP_ADDR; a loopback address gets a line on stderr), or as a process (capsa mcp, pointed at the env file in use through ENV_FILE, so no secret of the configuration enters a client's file; there must be one — a usage error otherwise). Each shape is the one the vendor documents; claude-desktop has stdio only, and codex reads the bearer from CAPSA_TOKEN of its environment. --url on stdio is a usage error.
capsa token revoke --name/-n Revokes the token with that name.
capsa import --dir/-d and --slug/-s (required), --prune/-p (remove concepts the directory no longer holds; with --skills, the skills it no longer holds), --index/-i (default true: embed the chunks left pending), --wrap/-w (also import plain markdown as concepts with synthesized frontmatter), --skills/-k (the directory is one of Agent Skills: every subdirectory with a SKILL.md becomes a skill under skills/<name>, its files stored with it) Stores a bundle directory — or a directory of skills. Unchanged concepts (same content hash) are left alone. A claimed task is left alone: a file that differs from a task a live lease sits on is not written, --prune does not delete such a task, and the bundle's graph takes the stored file for it — the import counts what it left and names the paths on stderr, and still exits 0. Prints one JSON document: the import's stats (concepts, created, updated, unchanged, claimed_left, removed, edges, lint: {errors, warnings} — what the linter found, which never blocks the import) with its indexing step inside (embedded, failed when the provider refused chunks, pending_chunks). A chunk the model cannot take does not end the step: the rest are embedded, it stays pending, and stderr names its concept. A skills import answers skills, created, updated, unchanged, removed, files, pending_chunks, embedded.
capsa export --slug/-s and --dir/-d (required), --skills/-k (write the skills back as <name>/SKILL.md folders with their files, byte for byte), --yes/-y Writes a bundle back as an OKF directory, each concept exactly as stored, plus a generated index.md. The directory must be empty or not there yet; a non-empty one is refused — exit 1, nothing written — unless --yes writes into it, replacing the files of the same name. Files 0600: the knowledge in plaintext — treat the directory as you treat the database.
capsa lint --dir/-d or --slug/-s (one of them), --format/-f (text, the default; json; sarif 2.1.0 for code scanning), --rules/-r, --strict, --fix, --yes/-y Checks an OKF bundle — a directory (no database needed) or a stored bundle — against OKF v0.3 and the Task and Skill model: 46 rules, and an error is non-conformance only. --fix without --yes is a dry run: it says what would change and exits 1 when something would; with --yes it writes the directory, or a new version of each fixed concept (actor cli:lint) — refused on a task another holder has claimed. Exit 0 without errors; 1 with errors, with warnings under --strict, or when a dry run would change something. See docs/lint.md.
capsa index none Embeds every pending chunk — one a write left, or one whose vector another model made. One document answers whatever happened, {"embedded": M, "failed": K}, printed before any failure. A chunk the provider refuses stays pending and is counted (failed); the command was asked to embed every one, so it exits 1 while any does, naming the concepts on stderr. Without an embeddings endpoint the command exits 1, and the reason is the error on stderr. A chunk's words need nothing from it: they are in the word search index from the write.
capsa stats none Bundles with indexing state (pending_chunks: the chunks waiting for the configured model — no vector yet, or one another model made), stale_embeddings, query-log aggregates per tool, token count.
capsa decrypt --dry-run, --yes/-y Opens every value capsa 0.1.0 sealed, in place — the way out of a sealed database (Upgrade from 0.1.0). The only reader of CAPSA_CONTENT_KEY / CAPSA_CONTENT_KEY_FILE; every other command refuses while either is set. Proves the key against the first sealed value of every table before it touches a row. --dry-run counts and exits 0; without --yes it counts and exits 1; --yes rewrites in one transaction; the word search index follows the text back. The answer carries next: remove the key from the environment.
capsa mcp none; reads the service's configuration and CAPSA_TOKEN The MCP server over stdio for a client on the same host: the same tools as /mcp — and the same reranker and lease — every call made as the token in CAPSA_TOKEN. Exit 2 without the token (a usage error that says how to mint one), exit 1 for a token that is not active. The configuration is read like every command's, so an entry can name an env file through ENV_FILE. Only the protocol reaches stdout; diagnostics go to stderr. It ends when the client closes the stream.
capsa config show --json/-j (default false) Prints every CAPSA_* the server reads with the value in effect: a table, or one JSON document. Secrets are set or empty (CAPSA_EMBEDDINGS_API_KEY, CAPSA_EMBEDDINGS_FALLBACK_API_KEY, CAPSA_RERANK_API_KEY), the database password is ***. Needs a configuration that loads; opens no database.
capsa config export --out/-o (the file; mode 0600), --redact/-r (default false), --format/-f (env, the default; json), --force Writes the shared settings — what must be the same for the same database to behave the same — as one env file for another machine: the database URL, the embeddings block, the reranker block, CAPSA_TOOLS, CAPSA_VECTOR_EF_SEARCH, CAPSA_MCP_MAX_RESULT_BYTES, CAPSA_TASK_LEASE_SECONDS, CAPSA_INDEX_INTERVAL_SECONDS; CAPSA_INSTRUCTIONS_FILE commented out when set. Left out, and named in the header as the machine's own: CAPSA_HTTP_ADDR, CAPSA_LOG_LEVEL, CAPSA_LOG_FORMAT, READINESS_ADDR. The file holds secrets in clear, so without --redact --out is required and an existing file is refused unless --force; with --redact the placeholders (<set>, <empty>, <password>) may go to stdout. stdout carries one JSON document: the path, the keys written, the keys redacted, the keys left out.
capsa config check none On the other machine, with ENV_FILE naming the export: opens the database (migrated), runs the startup content check, and answers one document — the database reached, the schema version, content: plaintext | sealed | empty with sealed_values and plaintext_values, the embedding model this machine would use — with a warning on every run to compare the embeddings block with the export of the machine that indexed it. (The model itself is recorded per chunk since migration 000005, and a wrong one is re-embedded; the instruction and the prefix are not recorded, and another instruction changes the vectors silently.) Exit 1 when the database could not be opened or holds a value capsa 0.1.0 sealed, which the server refuses to start on until capsa decrypt has opened it.
capsa version, capsa --version none Print the version.

Configuration

Settings come from the environment with the CAPSA_ prefix and, when it exists, from a .env file in the working directory: the file wins (ENV_FILE names another file). Copy .env.example to start. Validation is at load: a wrong value is an error at start, not a silent fallback.

Variable Default Meaning
CAPSA_DATABASE_URL none (required) postgres://user:password@host:5432/capsa?sslmode=…. The database capsa owns; it needs pgvector and pg_search (PostgreSQL 15+ with pgvector 0.7+ and pg_search 0.27+). The binary creates and migrates the schema itself. When capsa and the database are not on one host, sslmode=require or stricter: the connection carries the knowledge in the clear.
CAPSA_HTTP_ADDR 127.0.0.1:8116 Where the server listens. Loopback by default: expose it deliberately, behind TLS.
CAPSA_LOG_LEVEL info debug, info, warn or error.
CAPSA_LOG_FORMAT text text for a terminal, json for a log pipeline.
CAPSA_EMBEDDINGS_BASE_URL (empty) An OpenAI-compatible /embeddings base, any provider (see Embeddings). Empty turns vector search off: the words alone answer (mode: fts, BM25 through pg_search).
CAPSA_EMBEDDINGS_API_KEY (empty) Bearer key for a hosted provider; empty for a local endpoint.
CAPSA_EMBEDDINGS_MODEL qwen/qwen3-embedding-8b The winner of the retrieval benchmark, and the default whatever the endpoint is: set it for any other provider (OpenRouter is the one that serves this name). Recorded per chunk with every vector: a model switch is CAPSA_EMBEDDINGS_MODEL changed and capsa index run, and a vector of another model is never ranked.
CAPSA_EMBEDDINGS_DIM 1024 Must be 1024, the stored halfvec(1024) width. Other sizes are refused with a clear message.
CAPSA_EMBEDDINGS_QUERY_INSTRUCTION what the named model needs Unset: a model of the Qwen3-Embedding family gets Qwen's instruction before every query, any other model gets none — bge-m3 needs nothing set. An explicit value is sent as written; an explicitly empty one sends none. The template quotes the value on purpose: a \n becomes a newline only inside quotes, and the trailing space is part of the instruction.
CAPSA_EMBEDDINGS_DOC_PREFIX (empty) Put before every document text (e5 wants passage:).
CAPSA_EMBEDDINGS_INPUT_TYPE true Sends input_type: query|document with each request. Perplexity's embeddings refuse to answer without it; set false for a provider that rejects the field.
CAPSA_EMBEDDINGS_FALLBACK_URL (empty) A second OpenAI-compatible /embeddings base, asked once when the first fails in a way that can change — a connection error, a timeout, a rate limit, a server error. A 4xx from the first is final. It must serve the same model (it is sent the first one's model name, dimensions and prefixes) under its own key (CAPSA_EMBEDDINGS_FALLBACK_API_KEY). With CAPSA_EMBEDDINGS_BASE_URL set. It sees every text the first one does, in plaintext.
CAPSA_EMBEDDINGS_FALLBACK_API_KEY (empty) The fallback endpoint's key; empty for a local one.
CAPSA_EMBEDDINGS_TIMEOUT_SECONDS 30 How long one embeddings request gets, in seconds; at least 1. Both endpoints get it. A request that runs out of it is split in halves and each half asked again, down to one text — a local model on a CPU answers a few chunks where it cannot answer a batch of 64 — and only a single text that still runs out of time fails the call. Raise it for a slow model; a request that goes nowhere holds a write this long.
CAPSA_EMBEDDINGS_DATA_COLLECTION (empty) deny: sends provider.data_collection: deny with every embeddings call — OpenRouter only, which then routes the text only to providers that do not collect user data; the default qwen/qwen3-embedding-8b and baai/bge-m3 are OpenRouter ids at $0.010 per 1M tokens, with contexts of 40 960 and 8 194 tokens (OpenRouter's catalogue, 2026-12-03). A request to the providers, not a guarantee. Empty for any other endpoint: it may refuse a field it does not know. With a fallback endpoint set, the second must accept the field too.
CAPSA_VECTOR_EF_SEARCH 100 How many candidates the vector index walks per search (hnsw.ef_search); at least 1. More is a better recall at a slower search. It applies once the index exists — from 100,000 chunks on, it is built at start; below that every search is an exact scan and the setting does nothing. The researcher's run: 93 % of the exact top-10 at 100 against 83.5 % at pgvector's default of 40, 99 % at 400 (16,384 perturbed bge-m3 vectors, 760 title queries); on a harder corpus of near-copies 80 % at 100 and 98 % at 400 (2026-12-03; internal/database/database.go names both runs).
CAPSA_INDEX_INTERVAL_SECONDS 120 How often the worker embeds the chunks and the episodes left pending and returns in_progress tasks whose lease ran out to open.
CAPSA_TASK_LEASE_SECONDS 900 How long a claim holds a task; must be greater than 0. The database clock decides when a lease has run out.
CAPSA_INSTRUCTIONS_FILE (empty) A file whose text replaces the MCP server's built-in instructions — what capsa is and how to pick a tool, read by every client. Empty: the built-in text. The file must hold something; at most 16 KiB.
CAPSA_MCP_MAX_RESULT_BYTES 32768 No MCP answer is larger than this as JSON; a longer one is cut and says so: a file as a window with truncated and next_offset, a search with shortened chunks, a page with a cursor. At least 1024.
CAPSA_TOOLS (empty: all five) The MCP tool groups exposed, comma-separated: memory, consolidate, tasks, skills, lint. memory is always on; an unknown name is refused at start. A token sees these groups its scopes allow. consolidate is a group of its own so that an installation whose agents never consolidate leaves 4.4 KB out of every turn: CAPSA_TOOLS=memory,tasks,skills,lint.
CAPSA_RERANK_BASE_URL (empty) Optional reranker endpoint, any provider with an HTTP /rerank route. Empty: no reranking. See Reranking.
CAPSA_RERANK_API_KEY (empty) Key for a hosted reranker; empty for a local one.
CAPSA_RERANK_MODEL (empty) The reranker's model name, as the provider spells it.
CAPSA_RERANK_API inferred from the host Request shape: generic, voyage or cohere. Inferred: OpenRouter, Jina, vLLM, TEI become generic; api.voyageai.com voyage; api.cohere.com cohere.
CAPSA_RERANK_CANDIDATES 20 How many top vector candidates the reranker sees.
CAPSA_RERANK_MIN_SCORE 0 (off) Drop reranked candidates below this relevance; 0 keeps everything the provider scored.

Three more variables, not server settings: ENV_FILE (another env file than .env), READINESS_ADDR (what capsa ready probes) and CAPSA_TOKEN (the token capsa mcp acts as). Two more are read by capsa decrypt alone — CAPSA_CONTENT_KEY and CAPSA_CONTENT_KEY_FILE, the key that sealed a 0.1.0 database (Upgrade from 0.1.0); while either is set, every other command refuses. The tests read DB_PORT, DB_USER, DB_PASSWORD, DB_HOST, DB_NAME, DB_SSLMODE; see Development.

Upgrade notes

The schema moves by embedded migrations, in pairs, and every command applies them before it does its work. From 0.1.0:

  • A database that ran with a content key. capsa stores plaintext now and no setting takes a key: Upgrade from 0.1.0 is the one step — capsa decrypt --yes with that key, then the key removed.
  • 000004 — a skill's files. A new content column.
  • 000005 — the model per chunk. Every vector is stored with the name of the model that made it. A vector made before the migration has no recorded model: it keeps being ranked — as if the configured model made it, which in the common case it is — and is pending, so the worker and capsa index make it again with the model recorded; capsa doctor warns while any remain, and if the model was changed before the upgrade, run capsa index first and search again after. From then on a model switch is CAPSA_EMBEDDINGS_MODEL changed and capsa index run, and nothing else.
  • 000006 — the full-text vectors. They were rebuilt for plaintext rows at the first start (4.4 s for the benchmark's 5,758 rows; docs/eval/fts_neutral.md). Their columns are gone again in 000008.
  • 000007 — the episode queue. A temporary vector on an episode while it waits (dropped at the mark), its outcome, and the table that says which concepts were written from which episodes. No content column.
  • 000008 — the word search. The tsvector columns and their GIN index are dropped — a catalog change, whatever the table holds. What replaces them is not in the ledger: the ParadeDB index memory_chunks_search is built CONCURRENTLY at the first start after the migration, whatever the table holds (0.51 s for the benchmark's 5,758 chunks), and at a later start only when it finds none. The database needs pg_search before that start — PostgreSQL 15+ with pgvector 0.7+ and pg_search 0.27+, Get it. The binary creates the extension when the role may; a role that may not needs a superuser to run CREATE EXTENSION pg_search CASCADE; once, and capsa doctor says so by platform. CAPSA_FTS_CONFIG is no setting any more: an env file that still names it is ignored. Word search changes with it — a word is matched whole (no prefix, no stemming; an underscore keeps an identifier one token) and ranks by BM25 over the whole installation: 56 % R@5 on the benchmark corpus, where the tsvector search found 24 % (docs/eval/fts_bm25.md).
  • CAPSA_EMBEDDINGS_QUERY_INSTRUCTION follows the model when it is left unset. Anyone who set a model other than Qwen3-Embedding's and relied on the variable being unset to get Qwen's text now gets none — which is what that model wanted.

The same database from another machine

The configuration travels as one file. capsa config show says what is in effect here (secrets masked); capsa config export writes the shared settings — the database, the embedding model and the policy settings — to a 0600 file; carry it to the other machine, point ENV_FILE at it and check it there:

capsa config show                                   # what this machine uses; secrets masked
capsa config export --out capsa.env                 # holds the database password and the API keys: 0600, never committed
# carry capsa.env (and the binary) to the other machine; edit CAPSA_DATABASE_URL and
# CAPSA_EMBEDDINGS_BASE_URL there if the database or the embeddings endpoint is not at the same address
ENV_FILE=~/capsa.env capsa config check             # the database reached, nothing sealed left
ENV_FILE=~/capsa.env capsa serve                    # or copy the file as .env next to the binary

A client connects in one of two ways, and token create prints the entry either way. Mint it where the client runs — a stdio entry names the env file of that machine — with ENV_FILE set, since minting needs the database:

# the server at a URL (the default transport): --url, or http://<host>:<port>/mcp from CAPSA_HTTP_ADDR
ENV_FILE=~/capsa.env capsa token create --name laptop-opencode --client opencode --url https://capsa.example.com/mcp
# the server as a process: `capsa mcp`, handed the configuration by reference (ENV_FILE)
ENV_FILE=~/capsa.env capsa token create --name laptop-claude --client claude-desktop --transport stdio

--client is opencode, claude-code, claude-desktop (stdio only), cursor or codex; the answer's client_config carries the entry the vendor documents, with the token in it, and — for opencode, claude-code and codex — the command that adds it. The export file holds the database password and the API keys in clear: never commit it, and keep it readable by its owner alone.

Embeddings

Any OpenAI-compatible /embeddings endpoint works. The stored vectors are 1024-wide, so the model must produce 1024 dimensions (MRL models take dimensions: 1024); other sizes are refused at startup. A model switch is CAPSA_EMBEDDINGS_MODEL changed and capsa index run: the old vectors are not ranked meanwhile, and the new ones are made in the background. (The scores in the table are the first experiment's, on its own corpus — docs/eval/models_strict.md. On agentops-okf, the corpus of Retrieval quality, the default model finds 87 % R@5 with no reranker: docs/eval/agentops_okf.md.)

Provider CAPSA_EMBEDDINGS_BASE_URL CAPSA_EMBEDDINGS_MODEL Key Notes
OpenRouter https://openrouter.ai/api/v1 qwen/qwen3-embedding-8b (default) yes The best-measured model (strict R@5 93 %, MRR 0.804). 1024 dims through MRL; keeps the default query instruction. $0.010 per 1M tokens, context 40 960 (OpenRouter's catalogue, 2026-12-03). CAPSA_EMBEDDINGS_DATA_COLLECTION=deny asks its providers not to keep the text.
Ollama, native or Docker http://127.0.0.1:11434/v1 (http://host.docker.internal:11434/v1 for capsa under Docker Compose) bge-m3 or qwen3-embedding:0.6b no Both 1024 dims. bge-m3 takes no query instruction and needs nothing set: unset means none for it. The Qwen3 model keeps the default. Check with ollama show <model>. A local model on a CPU can be slower than the time a request gets: a batch that runs out of it is split in halves down to one text, so the chunks go through a few at a time; a chunk the model cannot embed in time on its own ends the import with context deadline exceeded after the bundle is stored, and the chunks wait for the worker (CAPSA_EMBEDDINGS_TIMEOUT_SECONDS gives more time; the setup skill's troubleshooting has the row).
Text Embeddings Inference http://127.0.0.1:8080/v1 whatever TEI serves no Local; no external dependency.
OpenAI https://api.openai.com/v1 text-embedding-3-small or -large yes Both take dimensions: 1024, which is already the default.

A local endpoint keeps every chunk text, every waiting episode and every query on your host; a hosted one sees them — both endpoints, when a fallback is configured.

Reranking (optional)

With CAPSA_RERANK_BASE_URL set, memory_search sends its top CAPSA_RERANK_CANDIDATES (default 20) vector candidates to the rerank provider, a cross-encoder that scores each chunk against the query, and returns them in the provider's order; the result reports "mode": "vector+rerank" and the reranker's name. CAPSA_RERANK_MIN_SCORE (default 0, off) drops candidates the provider scored below it. A failing reranker never fails the search: it falls back to the vector order and the result's fallback_reason says so.

The request shape is inferred from the host (CAPSA_RERANK_API overrides it). Off by default: vectors alone measured well, a reranker is one more network call per query, and it is a second provider that sees the query and the candidate texts in plaintext. Ollama has no rerank endpoint, so a local reranker is TEI or vLLM. The cross-encoder stage has no benchmark report under docs/eval yet — expect no measured gain. The measurement on record is an LLM reranker at +2 p.p. R@5 for 5–30 s per query, which is why nothing in the retrieval path calls a model by default.

Upgrade from 0.1.0

capsa 0.1.0 could seal the text at rest with a content key. 0.2.0 stores plaintext and has no such setting (the next section says why). If your 0.1.0 ran without a key there is nothing to do beyond the migrations, which every command applies before it works. If it ran with one, the database still holds sealed values (enc1:… in ten columns): the server refuses to start on them, and so does every command while the key is still in the environment —

N content values are sealed; capsa 0.2.0 and later store plaintext only; run `capsa decrypt --yes` with the key that sealed them (CAPSA_CONTENT_KEY for that one command), then remove the key and start again

The way out is one command, then the key removed:

capsa decrypt --dry-run     # with the key in the environment: values_to_change, sealed_values, plaintext_values; exits 0
capsa decrypt --yes         # opens every value — the words are findable again; its `next` says the rest
# then remove CAPSA_CONTENT_KEY and CAPSA_CONTENT_KEY_FILE from the environment and the env file
capsa doctor && capsa serve

capsa decrypt is the last reader of CAPSA_CONTENT_KEY and CAPSA_CONTENT_KEY_FILE (a chmod 600 file, which wins over the variable). It proves the key against the first sealed value of every table before it touches a row: a key that does not open what is stored is refused with nothing written. Without --yes it only counts and exits 1, so a script notices that nothing was written. --yes rewrites in one transaction with FOR UPDATE on every content row — a write that lands meanwhile waits and then sees the plaintext row — and gives up after 30 s with a message if a connection holds them: run it when agents are idle. A sealed chunk's text is ciphertext in the word search index until the decrypt puts it back; then search by words finds it again. Without the key there is no way back: a sealed database stays sealed.

Where encryption went

It was removed, in principle, on 2026-12-03 — journal 020 has the record, and journal 018 the measurements behind the first half of the decision.

  • What it protected: the text of the concept, the chunk, the version, the episode and the logged query in a dump of the files or a backup read without the key — AES-256-GCM per value — from a DBA or a storage provider reading the rows.
  • What it never protected: the structure (paths, types, tags, bundle titles, the link graph) and the vectors. A vector is a function of its text, with the model's name beside it: 92.0 % of 32-token inputs were recovered exactly from GTR-base (Vec2Text, arXiv 2310.06816, 2023), 47.4 % of short English instructions from text-embedding-3-small (arXiv 2611.05716, 2026), and 47–65 % of 32-token French, German and Spanish texts from a multilingual encoder of the family bge-m3 belongs to (arXiv 2401.12192, ACL 2024). Nothing has been measured on bge-m3, Qwen3-Embedding or Russian. Treat a stored vector as its text.
  • What it cost: no search by words (a sealed row had no full-text index, which made the embeddings endpoint a hard dependency); a key to lose — a lost key was a lost database; a second path on every read and write (13 call sites that sealed, 32 that opened) and every content path tested twice (38 tests).
  • What replaces it: the database's own protection — the recipe below.
  • Who loses: an installation that needs its text closed to a DBA with SQL access. capsa no longer answers that requirement, and "encrypt Postgres" does not either: every meaning of it encrypts the storage, and the server decrypts to answer a query (journal 018). If the requirement returns, it returns as a design with its own journal.

What stays is the read side: for as long as a 0.1.0 database can exist, a sealed value opens with the key that sealed it, and capsa decrypt is its way out.

The database's protection

capsa is as safe as your PostgreSQL. Anyone who can SELECT from its tables reads everything; the encryption in play is the disk's and the backups', and it stops at a mounted file system and a valid password. That is a real position only if the database is hardened, and each of these is a setting of PostgreSQL's own:

  • Loopback or a Unix socket for the database: reachable from the host capsa runs on and nowhere else (unix_socket_directories with peer auth, or listen_addresses on loopback and pg_hba.conf refusing the rest). capsa's own CAPSA_HTTP_ADDR is loopback by default.
  • SCRAM: scram-sha-256 in pg_hba.conf, which the manual calls "the most secure of the currently provided methods"; md5 is "deprecated and will be removed in a future release" (postgresql.org/docs/current/auth-password.html, read 2026-12-03).
  • A dedicated role that owns capsa's tables and nothing else. The one exception is the two extensions, pgvector and pg_search, which are not "trusted": a superuser creates them once per database (capsa doctor --fix when the role may). Both read the text inside the database — the word search index is a derived copy of every chunk's heading and text — and pg_search is AGPL-3.0, a separate program capsa neither links nor ships (Get it).
  • An encrypted volume — LUKS, or a provider's disk encryption. It "prevents unencrypted data from being read from the drives if the drives or the entire computer are stolen" and "does not protect against attacks while the file system is mounted" (postgresql.org/docs/current/encryption-options.html, the 19.0 manual on 2026-12-03 — its levels are password hashing, pgcrypto columns, the data partition, the network and the client: the community build has no transparent data encryption of its own).
  • Encrypted backups. Neither of the two usual tools encrypts by default. pgBackRest: repo-cipher-type is none unless set — aes-256-cbc is the other value — and repo-cipher-pass is the passphrase; "encryption is always performed client-side even if the repository type (e.g. S3) supports encryption" (pgbackrest.org/configuration.html, read 2026-12-03, the day its latest release was 2.60.1). WAL-G: "By default, no encryption is used"; it takes WALG_LIBSODIUM_KEY (a 32-byte key), WALG_PGP_KEY (OpenPGP) or, on S3, WALG_CSE_KMS_ID for a client-side AWS KMS key (its docs/README.md and docs/STORAGES.md on master at c0b1eed, read 2026-12-03, the day its latest release was v3.0.10). In this mode an unencrypted backup is the whole knowledge base in the clear.
  • TLS between capsa and the database when they are not on one host: sslmode=require or stricter in CAPSA_DATABASE_URL.

That is the whole of it: no key, nothing to rotate, no rewrite — and every backup is the knowledge base in the clear unless its cipher is on.

Security model in ten lines

The short form; SECURITY.md has the threat model, the exact column lists, how tokens are stored, and how to report a vulnerability.

  1. As safe as your PostgreSQL. capsa stores plaintext and has no encryption (where it went). Anyone who can SELECT from the tables reads everything; the encryption in play is the disk's and the backups', which stop at a mounted file system and a valid password. Harden the database and encrypt the backups (the recipe is under The database's protection).
  2. The structure is in the clear — paths, types, tags, statuses, bundle titles and the link graph — and incidents/2026-04-churn says a lot on its own. It was in capsa 0.1.0 too, whatever that version sealed.
  3. The vectors are plaintext: a function of the text, stored so a similarity test against them always works, and embedding inversion reconstructs part of a chunk's text. Measured on other models and languages — 47.4 % of health-related instructions and 24.5 % of general ones of 60–80 characters were recovered exactly from OpenAI's text-embedding-3-small (arXiv 2611.05716, BlackboxNLP 2026; English only). Nothing has been measured on bge-m3, Qwen3-Embedding or Russian, and capsa's short chunks are the easy case for the attack. Treat a stored vector as the text it came from, with the formatting lost.
  4. The capsa process works with plaintext in memory; anyone who can run code as that user reads the knowledge and reaches the database as capsa.
  5. The embeddings provider sees every chunk, every episode while it waits and every query in plaintext — the first endpoint and the fallback alike; the reranker, when on, sees the query and the top candidates. CAPSA_EMBEDDINGS_DATA_COLLECTION=deny is a request to the providers, not a guarantee. A local endpoint keeps the text on your host.
  6. capsa calls no model — not in retrieval, not in consolidation. An agent decides what a remembered note becomes, and a consolidation never deprecates and never edits a human-reviewed concept: a write that cites episodes onto one is refused, and its path is a new draft and a review task. A verified event is an admin's to write, and a text that changes under the badge reads as unverified.
  7. Anyone with a valid token reads plaintext: tokens are the access control. A token is mem_ plus 32 random base64url characters, shown once, stored as a SHA-256 with the first 12 characters for display; no default token exists, the first is minted with the CLI.
  8. Scopes are read, write, skills and admin, with an optional bundle restriction that holds in every search mode and on every read and write; a foreign bundle answers 404 on reads, 403 on writes. A bundle-restricted admin token sees its bundles only — the routes of the whole installation answer 403.
  9. The server speaks plain HTTP on loopback and has no TLS: expose it only behind a TLS reverse proxy. JSON bodies are capped at 4 MiB; there is no rate limiting.
  10. A database that capsa 0.1.0 sealed refuses to start until capsa decrypt --yes has opened it with the key that sealed it; without that key it stays sealed. Nothing else in capsa needs a key (Upgrade from 0.1.0).

Retrieval quality

75 blind questions over one real OKF bundle (agentops-okf: 899 files, 5,758 chunks): 70 answerable with a gold file each, 5 unanswerable. The questions were written by a separate agent that knew nothing of the retrieval methods; the question set is not published because it references private documents. The metric is file-level recall (a hit is a gold file in the top-k) and MRR over ranks 1 to 10. Strict gold set. Every row below is on this one corpus; docs/eval/agentops_okf.md has the methods and the dates — the vector rows recomputed on 2026-12-04 from the first experiment's own hit lists, the two word-search rows through memory_search with no embeddings provider:

Method R@1 R@3 R@5 R@10 MRR@10
grep, literal 13 % 27 % 36 % 51 % 0.236
the word search until 0.2.x: tsvector, the five-character cut (2026-12-03) 9 % 16 % 24 % 29 % 0.142
search by words: BM25 through pg_search (2026-12-04) 29 % 47 % 56 % 60 % 0.390
vectors, qwen3-embedding-8b (the default), no rerank 57 % 80 % 87 % 93 % 0.698
the same vectors with a cross-encoder reranker (qwen3-reranker-8b) 74 % 91 % 91 % 91 % 0.826

Until 2026-12-04 a table here mixed two corpora: vectors at 91–93 % and grep at 37 % from the first experiment's repository-docs corpus (docs/eval/models_strict.md), beside a word-search row from this one. docs/eval/agentops_okf.md says which is which, and holds every other arm measured on this corpus.

What it means:

  • Dense vectors find what the words cannot. R@5 by category, the vectors with no rerank against the word search: exact identifiers 87 % against 47 %, another inflection of the same word 73 % against 53 %, paraphrases 87 % against 73 %, an answer spread over several documents 100 % against 80 % — and a question in one language whose answer is written in another, 100 % against 20 %. A word search does not cross a language; that is why an installation gets an embeddings endpoint.
  • The word search is a fallback, and a real one. BM25 through pg_search finds 56 % R@5 on this corpus where the tsvector build found 24 % — paired question by question, 26 won and 4 lost — and grep finds 36 %. The product's answer is its SQL's: the same ranking was measured in Qdrant (57 %), HelixDB (59 %) and an offline BM25 over the same texts (59 %) on 2026-12-04 (docs/eval/fts_bm25.md, journal 023).
  • A hybrid of vectors and words measured lower than the vectors alone (reciprocal-rank fusion 74–79 % against 87 %; the owner's comparison of 2026-12-04), so nothing merges the two.
  • The earlier reports under docs/eval/ carry an fts-chunk row at 69 % R@5. That was the first experiment's spike on its own corpus and loader — never the product's door; through the product the tsvector search answered 24 % here (docs/eval/fts_neutral.md).
  • Nothing abstains on a score. The top-1 similarity of an unanswerable question overlaps that of an answerable one (0.679 against 0.676 in the first experiment's notes), and the word search always answers: each of the five unanswerable questions got an answer from every arm. low_confidence is advisory, and the tool tells the agent to read the chunks.

On the first experiment's corpus, and on that one only: the lenient gold set (docs/eval/models_strict_lenient.md) — grep 50 % R@5, bge-m3 94 %, the default 96 %; a multimodal candidate that also embeds images, docs/eval/models_pplx_v2.md, 90 % and MRR 0.784; and the full comparison of ten models (cost and time per full indexation, paired wins/ties/losses with confidence intervals), where embedding the whole corpus costs about $0.01. bge-m3 has no number on agentops-okf (about 1.5 hours on this machine's CPU; not run).

Architecture

flowchart LR
  agent["agent<br/>(an MCP client)"] --> bearer["internal/bearer<br/>one gate: token, scopes,<br/>bundle restriction"]
  bearer --> mcp["internal/mcp<br/>/mcp"]
  bearer --> api["internal/api<br/>/api/admin"]
  console["the admin console<br/>/admin/ (static files)"] --> api
  mcp --> svc["internal/service<br/>the domain logic, no SQL"]
  api --> svc
  cli["the capsa CLI<br/>import, lint, decrypt, token"] --> svc
  subgraph boundary["the content boundary: the only code that reads and writes a content column"]
    store["internal/store<br/>all the SQL; every content column's read and write"]
  end
  svc --> store
  store --> pg[("PostgreSQL + pgvector + pg_search<br/>concepts, chunks, versions, edges, leases")]
  svc -. "chunk, episode and query texts, in plaintext" .-> embed["an embedding provider<br/>Ollama, TEI, OpenRouter"]
  svc -. "the query and the top candidates" .-> rerank["a reranker, optional<br/>TEI, vLLM, Voyage, Cohere"]

One process over one database. Every request passes internal/bearer once; the handlers hold no logic; the service holds no SQL; and only internal/store reads or writes a content column — it is also the one package that opens a value capsa 0.1.0 sealed.

cmd/capsa/          the CLI (cobra): serve, ready, doctor, token, import, export, index, stats, lint, mcp, decrypt, config
config.go server.go package capsa: CAPSA_* settings + .env, the routes, the startup content check, the worker (lease janitor, pending chunks)
okf/                public OKF v0.3 package: bundle scan, concept parsing, links, trust tier, the heading chunker,
                    the Task and Skill vocabulary, the linter (46 rules) and its fixes
internal/adminui/   the admin console at /admin/: embedded static files, strict CSP, talks to the admin API
internal/api/       admin REST handlers under /api/admin
internal/bearer/    the one auth gate: Authorization: Bearer → token → scope (MCP and admin both)
internal/database/  pool with the vector settings on every connection, the HNSW index past 100,000 chunks, embedded migrations, doctor
internal/embed/     Provider interface, the OpenAI-compatible client, the query-vector cache, a failover endpoint, a deterministic fake for tests
internal/httpx/     JSON and error writers, the 4 MiB body cap
internal/mcp/       the MCP server: the schemas, one file per tool family (memory, tasks, skills, lint), the byte budget, the cursors
internal/rerank/    optional cross-encoder stage: generic / voyage / cohere request shapes
internal/service/   domain: import/export, put/edit/deprecate, the change feed, search + fallback + re-scoring, tasks, skills, the consolidation queue, lint, tokens, indexing, logs
internal/store/     pgx repository: the only package that reads content columns, and the one that opens a value 0.1.0 sealed; vector and word search; task leases
migrations/         embedded SQL, NNNNNN_name.up.sql / .down.sql pairs (eight today)

Dependencies: pgx v5, golang-migrate v4, the official MCP SDK (github.com/modelcontextprotocol/go-sdk v1.9.0), cobra, testify, go.yaml.in/yaml/v3. Stdlib net/http, no framework. scripts/thirdparty.sh lists every module the binary bundles with its licence; CI fails on one it does not know.

A write and a read, end to end

A memory_put, from the agent's call to the stored row — the order of the writes — every value stored as written. The audit row is the write's last statement: a write commits with it or not at all, and the feed reads it.

sequenceDiagram
  autonumber
  participant A as agent
  participant S as internal/service
  participant R as internal/store
  participant D as PostgreSQL
  participant E as embedding provider
  A->>S: memory_put(bundle, path, content, expected_version?)
  S->>S: parse the file: refuse one without a type, and a Skill needs the skills scope
  S->>R: upsert the concept, under the bundle's lock and the row's
  R->>D: the version check, then the row: title, description, frontmatter, body, content, in plaintext
  R->>D: a version row when the content changed<br/>AAD memory:version:<concept id>:<version>:content
  S->>R: replace the chunks that changed, the rest keep their vectors
  R->>D: each chunk's heading and text; the word search index follows the write
  S->>E: the chunk texts, in plaintext
  E-->>S: vectors, halfvec(1024), the model recorded per chunk
  S->>R: store the embeddings
  Note over S,E: no provider, or it failed: the chunks stay pending,<br/>and the worker embeds them at its next pass
  S->>R: rebuild the edges of the bundle, then the audit row as the write's last statement
  S-->>A: bundle, path, version, created, status, trust_tier, changed

A memory_search, from the call to the answer — who embeds, where the one filter lives, and where the chunk texts are read:

sequenceDiagram
  autonumber
  participant A as agent
  participant S as internal/service
  participant E as embedding provider
  participant R as internal/store
  participant X as reranker (optional)
  A->>S: memory_search(query, bundle?, type?, tags?)
  S->>E: the query, in plaintext (a cached vector when it repeats)
  E-->>S: the query vector
  S->>R: SearchVector with one filter
  Note over R: the WHERE clause both search modes share: bundle, type, tags,<br/>current concepts only, the token's bundle restriction,<br/>and the model that made each vector
  R->>R: cosine scan, LIMIT limit x 4, then read the chunks' text and titles
  R-->>S: the candidates
  opt a reranker is configured
    S->>X: the query and the top CAPSA_RERANK_CANDIDATES texts
    X-->>S: a relevance score per candidate
  end
  S->>S: the reranker's order, or lexRerank: a key-term boost of 0.02 per term, cap 0.06,<br/>then at most 2 chunks per concept among the first 5, then cut to the limit
  S->>R: one row in the query log (the query text, mode, latency) and touch the token
  S-->>A: mode, hits, low_confidence, fallback_reason, reranker
  Note over S,E: no provider, or it failed: the word search, mode fts

Admin page and admin API

The admin page at /admin/ is served by the binary (embedded static files, no build step, a CSP without inline). It opens with a status strip (health, version, how the stored content sits, vector search or not, pending chunks, the episodes waiting), and works by task: browse bundles and read or edit concepts, preview a search exactly as an agent gets it, see the episode queue and mark junk handled, mint and revoke tokens (the form offers the four scopes), read the query log and the audit log. The token is kept in the browser tab's session storage and sent only as a bearer header. A bundle-restricted admin token gets the sections it may use: Browse and Search.

All routes are under /api/admin and need a bearer token with the admin scope (Authorization: Bearer mem_…); a write is audited as admin:<token name>. Errors are JSON {"detail": "…"}: 401 no header, 403 invalid or revoked token, missing scope, or a bundle-restricted token on a whole-installation route; 404 unknown bundle or row (a bundle outside a restricted token's list reads the same way); 400 invalid concept, path, scope or query; 409 a taken slug, a claimed task or a version conflict; 422 malformed body; 413 body over 4 MiB; 503 token store unavailable.

Method and path Body / query Response
GET /api/admin/bundles none Bundles with concept and pending-chunk counts; a restricted token sees its own only.
POST /api/admin/bundles {"slug", "title", "description"} 201; creates an empty bundle.
DELETE /api/admin/bundles/{slug} none {"deleted": "slug"}: the bundle and everything in it.
GET /api/admin/bundles/{slug}/concepts ?prefix=services/, ?include_deprecated=true {"concepts": [...]}: path, type, title, description, status, version.
GET /api/admin/bundles/{slug}/concepts/{path...} none One concept: the whole file, neighbours, version, staleness.
PUT /api/admin/bundles/{slug}/concepts/{path...} {"content": "…"}, optional "expected_version": N Stores the whole file as memory_put would; 201 when created, else 200, with {bundle, path, version, created, status, trust_tier}. The bundle must exist (404). With expected_version (0 for a concept that must not exist yet) a concept at another version answers 409 and is left alone.
GET /api/admin/bundles/{slug}/episodes ?limit=50 (20–200) {"episodes": [...], "remaining"}: the raw notes, newest first, each with its state — consolidated_at, outcome, cited_by (the concepts written from it) — and how many still wait.
POST /api/admin/bundles/{slug}/episodes/consolidate memory_consolidate's body: episodes, outcome, paths, task The mark, as the tool makes it — for a person clearing junk from the queue.
GET /api/admin/bundles/{slug}/lint none The lint report of the stored bundle, as okf_lint answers it.
POST /api/admin/bundles/{slug}/lint/fix {"apply": false} (the default: a dry run) The report and fixes[]; with apply the fixes are stored as new versions (audit bundle.lint_fix).
GET /api/admin/bundles/{slug}/tasks ?status=, ?prefix=, ?limit=, ?cursor= {tasks: [...], next_cursor}: as task_list.
POST /api/admin/bundles/{slug}/tasks task_create's body: title, description?, path?, depends_on?[], body? The new task.
POST /api/admin/bundles/{slug}/tasks/claim {"path": …} The claimed task with its lease; 409 when another holder has it.
POST /api/admin/bundles/{slug}/tasks/claim-next {"prefix?": …, "holder?": …} {task: …}, or {task: null} when nothing is ready.
POST /api/admin/bundles/{slug}/tasks/renew {"path": …} The task with the extended lease; the caller must hold it.
POST /api/admin/bundles/{slug}/tasks/complete, …/fail, …/release {"path": …}, with {"reason": …} for fail The task after the transition. The action is in the path and the task in the body because Go's router cannot follow a {...} wildcard with a literal.
GET /api/admin/bundles/{slug}/skills none {skills: [...]}: as skill_list.
GET /api/admin/bundles/{slug}/skills/{name...} none The skill: its file, status and version.
PUT /api/admin/bundles/{slug}/skills/{name...} {"description", "body", "expected_version"?} The skill after the write; a version conflict is 409.
POST /api/admin/bundles/{slug}/skills/deprecate {"name": …, "superseded_by"?} The skill after the transition.
GET /api/admin/search ?q= (required), ?bundle=, ?limit= (1–50) The memory_search answer: {mode, hits[], low_confidence, fallback_reason?, reranker?}, with the admin token as the caller, so its bundle restriction holds. Logged in the query log like any search.
GET /api/admin/status none {"embeddings": bool, "sealed_values": N, "plaintext_values": M, "episodes_waiting": K, "stale_embeddings": S}: whether vector search is available, how the stored content sits, how many episodes wait and how many chunks carry a vector of another model.
GET /api/admin/tokens none {"tokens": [...]}: name, prefix, scopes, bundles, last use, revoked at. Never the hash.
POST /api/admin/tokens {"name", "scopes": ["read"], "bundles": ["a","b"]} 201 with the plaintext, shown once.
DELETE /api/admin/tokens/{id} none {"revoked": "id"}.
GET /api/admin/stats none Bundles, per-tool query aggregates (calls, vector calls, average latency and results, last use), token count.
GET /api/admin/queries ?limit=100 (max 1000) {"queries": [...]}: the newest searches.
GET /api/admin/audit ?limit=100 (max 1000) {"audit": [...]}: the newest writes.

The first token cannot come from the API (a fresh database has none): mint it with capsa token create --name admin --scopes admin. The task, skill, lint and episode routes answer the shapes the MCP tools answer; a bundle outside a restricted token's list reads as 404 and refuses a write with 403, like every other route.

Development

go build ./... && go vet ./...
golangci-lint fmt --diff ./...     # gofmt + goimports: exits 1 on a file it would rewrite
golangci-lint run ./...            # .golangci.yml; the CI gate (new code is linted against origin/main)
scripts/thirdparty.sh              # the licences of what the binary bundles; non-zero on a problem

# the tests need a PostgreSQL with pgvector and pg_search; without DB_PORT they skip silently: a skip is not a pass
docker run -d -p 5432:5432 -e POSTGRES_PASSWORD=postgres paradedb/paradedb:0.27.1-pg17
DB_PORT=5432 DB_USER=postgres DB_PASSWORD=postgres go test -race -shuffle=on -count=1 ./...
make cover DB_PORT=5432            # the same with a profile: the coverage of every package and the total
make smoke                         # end-to-end: build, doctor, serve, import, MCP search, export, decrypt

Every database test gets a fresh scratch database and drops it. testdata/smoke/ is a tiny OKF bundle for the end-to-end smoke test, and testdata/skills/ three skills with their files for the round trip. CONTRIBUTING.md has the conventions (testify, table-driven, -race, Conventional Commits); AGENTS.md says the same for coding agents; docs/design.md is the design and the decisions; docs/journal/ records why things changed.

A release

flowchart LR
  tag["a tag vX.Y.Z on main"] --> gr["GoReleaser<br/>six archives, checksums.txt, an SBOM each,<br/>six Linux packages, the release notes"]
  gr --> rel[("the GitHub Release<br/>+ capsa.json and Casks/capsa.rb<br/>committed back to main")]
  tag --> img["the image job<br/>linux/amd64 and arm64,<br/>provenance, SBOM, THIRD-PARTY.md"]
  img --> ghcr[("ghcr.io/svetlovtech/capsa<br/>X.Y.Z, X.Y, X, latest")]
  tag --> reg["the registry job<br/>server.json, stamped with the version"]
  img --> reg
  reg --> mcp[("the MCP Registry<br/>io.github.svetlovtech.capsa")]
  main["a push to main"] --> edge["the image job again"] --> ghcr2[("the same image, tag edge")]

A tag vX.Y.Z on main runs .github/workflows/release.yml: GoReleaser builds six archives (.zip on Windows), six Linux packages (.deb, .rpm, .apk), checksums.txt, an SBOM per archive and the release notes, and commits the Scoop manifest and the Homebrew cask back into the repository; the image job pushes the multi-platform image to GHCR; the registry job publishes server.json to the MCP Registry. A tag with a pre-release suffix (v1.2.3-rc1) publishes a pre-release and skips the cask and the registry entry. The whole chain, and what is still open (a Homebrew tap, signing, winget), is in docs/releases.md.

Roadmap

On main, for the next release: the MCP server on the official SDK as revision 2026-07-28 — stateless, structured content, isError, tools/list filtered by scope and by CAPSA_TOOLS, a byte budget on every answer — and capsa mcp over stdio; twenty tools in five groups, among them memory_edit, memory_changes, expected_version and changed on every write, fields on the search and the list; the consolidation queue; tasks with a lease; skills as folders with their files; the OKF linter (capsa lint, 46 rules); the embedding model recorded per chunk and the HNSW index past 100,000 chunks; search by words as BM25 through pg_search, an extension beside pgvector; capsa config show | export | check; the admin console; the distribution chain (packages, Scoop, Homebrew cask, install script, MCP Registry); CI under a 44-linter gate.

Decided, not built:

  • Encryption — removed in 0.2.0 (journal 020). capsa stores plaintext, the database's protection is the documented one, and capsa decrypt is the migration out of a 0.1.0 sealed database. Sealed search is not built either (journal 018): an index over sealed vectors inside the capsa process was measured — about a second to open every vector at start and 400 MB of RAM at 100,000 chunks, plus a coherence protocol nothing provides — and is not built (journal 018).
  • Push. OpenCode's events are the MCP Events extension, whose push needs a server's own notification, and the official Go SDK v1.9.0 cannot send one; the feed and the automation carry it, and no private protocol is built (docs/mcp.md §6a).

Next, in this order:

  1. The reranker evaluation arm in docs/eval: the stage exists, its numbers do not. With it, the fallback's ranking lever — the terms that match most of the corpus, measured at 29–31 % R@5 in a diagnostic and not yet in the product.
  2. Files and assets: content-addressed blobs (zstd), text extraction, upload. A skill's binary files wait for it.
  3. Consolidation's second slice: memory_restore (no tool restores a version today) and reopening an episode; the built-in worker behind an opt-in CAPSA_LLM_BASE_URL — a second caller of the same service methods, whose paragraph goes into docs/design.md §5 and SECURITY.md before any of its code.
  4. Native loading: Skills over MCP (io.modelcontextprotocol/skills) with a thin resource layer, and capsa skill install into .agents/skills/; the embedding recipe v2, with the title and the description in the vector.

License

Apache-2.0. Every release carries THIRD-PARTY.md with the licences and notices of the modules it bundles (scripts/thirdparty.sh, docs/licenses/); the landing page's fonts are under the SIL Open Font License 1.1.

Reviews (0)

No results found