Skip to content
المشاريع

حول

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

الذكاء الاصطناعي وتعلّم الآلة

كيف تُقاس هذه الأرقام

النمو المقاس للنجوم

خلال 24 ساعة
جارٍ جمع السجل
خلال 7 أيام
جارٍ جمع السجل
خلال 15 يومًا
جارٍ جمع السجل
خلال شهر
جارٍ جمع السجل

تغيّر صافي النجوم خلال فترات متداخلة، وليس مجموعًا يوميًا. تبقى القياسات المفقودة فارغة. النجوم تقيس الاهتمام لا جودة البرمجيات.

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 HelixDB. 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 the one HelixDB server that holds it — there is no encryption setting (where it went). Nothing is hosted but the database: the binary builds a missing index of its graph at start and talks to one HelixDB server, named by CAPSA_HELIX_URL. 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 HelixDB server. The graph holds the knowledge in the clear, and capsa's safety is the server's and its host's — a server on loopback or behind a proxy you trust, a data directory on an encrypted volume, encrypted backups, telemetry off (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.
  • One server. No Qdrant, no Redis, no object store. One database to back up, one thing to operate; the vectors sit on the chunks the filters need, and so does the word search's index — the engine's own BM25. There are no migrations: a missing index of the graph is built 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 HelixDB (ghcr.io/helixdb/helixdb:v0.0.21, its graph on a named volume) + capsa on http://127.0.0.1:8116, built from the clone; the CLI as docker compose exec capsa /capsa <command> — except import --dir, which reads a directory of the machine the command runs on: point the host CLI at the published 127.0.0.1:6969, or docker compose cp the bundle in first. The embeddings endpoint, key, model, query instruction and timeout, the fallback endpoint, the reranker settings and the tool groups 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 HelixDB server, named by CAPSA_HELIX_URL

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 a HelixDB server — v0.0.21 is what capsa is tested on. The easy way is its image, ghcr.io/helixdb/helixdb:v0.0.21, on a loopback port; docker compose up -d runs one beside capsa, its graph on a volume. A server has no authentication of its own: keep it on loopback or behind a proxy you trust, and turn its telemetry off (HELIX_TELEMETRY_LEVEL=off). Give it a HELIX_DATA_DIR or it keeps its graph in memory and loses it at every stop. capsa doctor tells you whether the server is reached and ready, whether its indexes are built, and whether it keeps its data in memory only.

Licence note. The HelixDB server is a separate program: capsa links its Go client (Apache-2.0, docs/licenses/README.md) and neither links nor ships the server — its 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.

Measured on a scratch state (2026-12-05, the port's effort run P2a, each step timed): from zero — a fresh HelixDB server, no bundles, no tokens — to the first memory_search in 6.6 s along this path with no embeddings endpoint set (the search answered on the words alone), and in 44 s through docker compose up, the image build included (a warm Go build cache; from cold it is minutes, plus the HelixDB image's pull).

The five-minute path

# 1. a HelixDB server (docker compose up -d helix runs one on 127.0.0.1:6969). --fix builds a missing index
export CAPSA_HELIX_URL=http://127.0.0.1:6969
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: the graph's indexes 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 server's (the recipe). Without an embeddings endpoint the server starts too, and search falls back to the words alone — BM25, the engine's own index: a fallback, not a peer. Its recall on the graph is not measured yet; the numbers under Retrieval quality were measured on the store the graph replaced. 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 a HelixDB server 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["vector search over the graph's chunk index<br/>the engine's own; the model that made each vector is checked"]
  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 20 concepts, one chunk each"]
  R -- no --> A
  X --> A["answer: JSON"]
  E -. "no provider, or it failed" .-> F["word search fallback, mode fts<br/>BM25 on the engine's own index: 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 prefilter shared by both modes — the traversal starts at the bundles a token may read — 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 on the engine's own index over a chunk's text, one index of the whole installation: the engine's tokeniser splits the query — lowercased runs of letters and digits, no language named; _, - and an apostrophe split an identifier, camelCase is not split, a run of Han or kana characters is one term — and a chunk carrying any of the terms is a match. A word is matched whole, with no stemming and no prefix, and the index's statistics are the installation's, not a bundle's. Neither search's recall is measured on the graph yet; docs/helixdb.md says what was read and measured on the image.

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["Concept nodes<br/>the parsed properties, the frontmatter,<br/>the file verbatim; unchanged files are skipped"]
  concepts --> chunks["Chunk nodes under each concept<br/>cut by headings, 700 to 1400 bytes"]
  concepts --> edges["link edges<br/>one edge per link between two concepts"]
  chunks -->|"capsa index, or the worker"| vectors["the vectors on the chunks,<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 graph keeps is a projection: parsed properties 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 — content properties, in plaintext like every value — and written in the concept's own request 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 guarded request 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 is four properties of the task's node — a token id,
    a holder, lease_until — and no content.
  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 CITES edge 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 request, 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?, derived_from?[] (1–200 episode ids the task comes from) {bundle, path, title, status, version}. Creates the task, open; it does not claim it.
task_list read bundle (required), status? (default open: the work that waits; in_progress, done, failed, cancelled, or all), 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 request: 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 store ensures the graph's indexes first — a missing one is built — so import works before the server has ever started.

Command Flags What it does
capsa none Prints help.
capsa serve none Runs the server: the graph's indexes ensured, 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; accepted — a missing index is built with or without it) Examines the HelixDB server the way every process of capsa will use it: reached and ready (server), its mode (mode), its storage (storage), the graph's indexes (indexes — a missing one is built here as at every start) and what the server's own diagnostics report. An index that exists with another definition is refused, never dropped: that is a person's decision, and the doctor names it. A warn status leaves ready true and names what to run — a server that keeps every write in memory only (storage: all of it is lost when the server stops; give it HELIX_DATA_DIR, a volume), or a query without the index it wants. A server that does not answer makes ready false. Exit 1 when capsa cannot start against this server.
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 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_HELIX_API_KEY, CAPSA_EMBEDDINGS_API_KEY, CAPSA_EMBEDDINGS_FALLBACK_API_KEY, CAPSA_RERANK_API_KEY), and CAPSA_HELIX_URL is masked wherever capsa quotes it — an address may carry a password. Needs a configuration that loads; talks to no server.
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 store to behave the same — as one env file for another machine: the HelixDB server's address and key, the embeddings block, the reranker block, CAPSA_TOOLS, 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: reaches the server, sees it ready and its indexes built, and answers one document — the server reached, the indexes built there, 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, and a wrong one is made again; the instruction and the prefix are not recorded, and another instruction changes the vectors silently). Exit 1 when the server could not be reached or is not ready.
capsa eval run, score, compare Measures retrieval through the product and sets one run against another with a gate on a drop — Measure.
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_HELIX_URL none (required) The HelixDB server capsa talks to, http://127.0.0.1:6969 for the one docker compose up -d helix runs. It holds the whole knowledge base in plaintext: when capsa and the server are not on one host, put TLS in front of it — an authenticating proxy, whose bearer key is CAPSA_HELIX_API_KEY — or tunnel the connection; the server has no authentication of its own. Masked wherever capsa quotes it: an address may carry a password. A server with no data directory keeps its graph in memory and loses it at its stop — capsa doctor warns; give it HELIX_DATA_DIR, a volume.
CAPSA_HELIX_API_KEY (empty) The bearer key of an authenticating proxy in front of the server; empty for a server reached directly.
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 on the engine's own index).
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 The width of the model's vectors, from 64 to 4096: what the provider is asked for, the width the two vector indexes are built at and every stored vector has. A vector's identity is the model, the recipe and the width — at 1024 it is what it always was (the bare model's name, <model>@v2), so a graph already stored stays valid; at another width a chunk records <model>@512, and a vector of another width is never ranked with the configured one. A change of width on a graph that holds vectors is not supported yet: on HelixDB v0.0.21 an index is not built over vectors of another width and the blocked build cannot be dropped, so the old vectors must be cleared first — and no path of capsa clears them. A fresh server, or one whose vectors are the configured width, is fine.
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_EMBEDDINGS_RECIPE v1 What text a chunk is embedded as. v1: the section's breadcrumb and the chunk's text. v2: the concept's title before the chunk's text (title: … | text: …); a query's text is the same under both. A vector's identity is the model and the recipe — under v2 a chunk records <model>@v2 — so switching the recipe makes every vector again at the next index pass (capsa index, or the worker) and the old ones are not ranked meanwhile; a graph stored under v1 stays valid as it is.
CAPSA_FTS_NORM 0 The word search's opt-in normalisation. 1: a chunk's heading and text are stored normalised as a second property under a BM25 index of its own — lower case, ё → е, a Russian word reduced to its stem, an identifier as it is — and mode: fts reads it, the query made the same way, so a question in another case finds its document; the heading's words are matched too. A chunk stored before it was turned on is not found by that search until capsa index has made its normalised text. 0 (the default): the engine's own index over the text, a word matched whole in the form it was written.
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 server's 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 concepts the reranker sees: the best chunk of each.
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). No CAPSA_* variable takes a key: there is none to give. The tests find their server through HELIX_URL and HELIX_BIN instead (Development says how).

Upgrade notes

There are no migrations on the graph: the binary builds a missing index at every start, and an index that exists with another definition is refused instead of dropped — that is a person's decision, and capsa doctor names it.

  • A database of capsa 0.2.x does not carry over to the graph, except through files. Bundles and skills go capsa export there (a 0.2.x binary) and capsa import here; episodes, tokens, the audit log and the query log have no export, and start empty. A 0.1.0 database — the one that could seal its text with a content key — is one step further: a 0.2.x binary's capsa decrypt --yes opens the values first. Nothing here reads a value 0.1.0 sealed, and no setting takes a key (Upgrade from 0.1.0).
  • 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 server's address, 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 server's address and the API keys: 0600, never committed
# carry capsa.env (and the binary) to the other machine; edit CAPSA_HELIX_URL and
# CAPSA_EMBEDDINGS_BASE_URL there if the server or the embeddings endpoint is not at the same address
ENV_FILE=~/capsa.env capsa config check             # the server reached and ready, its indexes built
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 writes to the store:

# 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 server's address 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 the best chunk of each of its first CAPSA_RERANK_CANDIDATES (default 20) concepts 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. Measured through the product on the benchmark corpus (2026-12-04, docs/eval/rerank.md): rerank-3-lite takes the vector order from 80 % to 89 % R@5 and MRR from 0.634 to 0.746, at about $0.00014 a query; the reranker is given the best chunk of each of its first twenty concepts, because the first twenty chunks are some thirteen documents. An installation with no embeddings endpoint gets from 56 % to 69 % with the same reranker over the word search's candidates. An LLM as the reranker was measured once at +2 p.p. R@5 for 5–30 s per query, which is why nothing in the retrieval path calls a generative model.

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), and nothing on the graph reads a database of either: a store from before HelixDB comes over through files alone.

  • From 0.2.x: capsa export there (its own binary) writes every bundle as the files it imported — --skills writes the skills — and capsa import here stores them. Episodes, tokens, the audit log and the query log have no export: they start empty, and the first token is minted again with the CLI.
  • From 0.1.0 without a key: the same, through a 0.2.x binary.
  • From 0.1.0 with a key: one step more, on the 0.2.x binary — capsa decrypt --yes with the key that sealed the values, then the key removed from the environment — and then capsa export and capsa import here.

A database of 0.1.0 or of 0.2.x is not read, migrated or imported by anything here: no setting takes a key, and no value a key sealed is opened on the graph.

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 store's own protection — the recipe below.
  • Who loses: an installation that needs its text closed to whoever administers the store. capsa no longer answers that requirement, and a database's own encryption 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.

Nothing here reads that form: a 0.1.0 database reaches the graph through files only, opened by a 0.2.x binary first (Upgrade from 0.1.0).

The database's protection

capsa is as safe as the one HelixDB server that holds it. The concepts, their chunks and vectors, the episodes, the tokens' hashes and the two logs are that server's data, in plaintext: anyone who can reach the server 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 server is hardened, and each of these is a setting of the server's or of its host's:

  • Loopback or a private network for the server: reachable from the host capsa runs on and nowhere else. It has no authentication of its own — never expose it. capsa's own CAPSA_HTTP_ADDR is loopback by default.
  • An authenticating proxy where the server must leave the host: its bearer key is CAPSA_HELIX_API_KEY, and TLS between capsa and the server when they are not on one host — the connection carries the knowledge in the clear.
  • A data directory that persists — HELIX_DATA_DIR, a volume. A server without one keeps its graph in memory and loses everything at its stop; capsa doctor warns while it sees one.
  • An encrypted volume for that directory — 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; it does not protect against attacks while the file system is mounted.
  • Encrypted backups. A copy of the server's data directory is the knowledge base itself, in the clear: a backup without a cipher is the whole knowledge base to whoever holds it. capsa export writes a bundle as plaintext markdown — treat the directory as you treat the server's data.
  • Telemetry off (HELIX_TELEMETRY_LEVEL=off, as the compose file has it). docker-compose.yml is the smallest example.

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 property lists, how tokens are stored, and how to report a vulnerability.

  1. As safe as the one HelixDB server that holds it. capsa stores plaintext and has no encryption (where it went). Anyone who can reach the server 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 server 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 server 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 best chunk of each of its 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. Nothing here reads a value capsa 0.1.0 sealed, and no setting takes a key: there is none to give. A 0.1.0 database reaches the graph through files only (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 product's rows through memory_search on the graph are measured on 2026-12-05, with vectors the product made over its own 5,758 chunks (docs/eval/helixdb.md, HelixDB v0.0.21); the same three arms on 2026-12-04, on the store the graph replaced, stand beneath them as history (docs/eval/rerank.md); the first experiment's two vector rows are recomputed from its own hit lists, over its own chunks. No arm finds less on the graph than it did on the store before it: the vectors find the same 56 questions of 70 at R@5, the reranked arm one more, the word search two more. The table:

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 on the graph — the product (2026-12-05) 30 % 50 % 59 % 67 % 0.419
vectors, qwen3-embedding-8b (the default), no rerank — the product on the graph 51 % 74 % 80 % 86 % 0.641
the same with a cross-encoder, rerank-3-lite — the product on the graph 64 % 89 % 90 % 90 % 0.761
search by words: BM25 (2026-12-04, on the store before the graph) 29 % 47 % 56 % 60 % 0.390
the same with a cross-encoder, rerank-3-lite, over the word search (the same day) 49 % 69 % 69 % 69 % 0.583
vectors, qwen3-embedding-8b, no rerank (the same day and store) 51 % 71 % 80 % 86 % 0.634
the same with a cross-encoder, rerank-3-lite (the same day and store) 63 % 87 % 89 % 89 % 0.746
the first experiment's vectors over its own chunks, no rerank 57 % 80 % 87 % 93 % 0.698
the same with a cross-encoder (qwen3-reranker-8b) 74 % 91 % 91 % 91 % 0.826

On the graph the first three rows cost, at the store, p50 / p95: a page 3.0 / 3.8 ms, the vector search 293 / 324 ms, the word search 55 / 65 ms, a write awaited 101 / 102 ms and unawaited 1.1 / 1.5 ms — and through the product the vector arm is slower than it was on the store before it (829 ms at p50 against 312–458 ms), a difference that is measured and not explained (docs/eval/helixdb.md).

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 product's vectors with no rerank against the word search: exact identifiers 67 % 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, 80 % against 20 %. A word search does not cross a language; that is why an installation gets an embeddings endpoint.
  • The reranker judges documents, and it is worth its call. Given the best chunk of each of the first twenty concepts, rerank-3-lite takes the product's vector order from 80 % to 89 % R@5 — on the graph, from 80 % to 90 %; under the first-twenty-chunks rule — thirteen distinct documents — it gave 84 %. It receives twenty texts either way, so the bill is the same: about $0.00014 a query (docs/eval/rerank.md, journal 024).
  • The first experiment's 87 % was never the product's. Its vectors were made over its own chunking; over the product's 5,758 chunks the same model gives 75.7 % before the service's lexical pass and 80 % through the product. What was tried on those chunks and did not move R@5 — the provider, the width, four chunk sizes, the embedding input, a hybrid — is in docs/eval/rerank.md; one thing did, the concept's title before the chunk's text, on every model, and it re-embeds every stored chunk: the roadmap's next item.
  • The word search is a fallback, and a real one. The word search as BM25 — measured on 2026-12-04, before the graph, through the store it replaced — 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 %. On the graph, through the product on 2026-12-05, it finds 59 % — the same as the engine's own index gave outside the product the day before: the product adds nothing to the engine's ranking (docs/eval/helixdb.md). The store before it gave the same ranking in Qdrant (57 %) 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 is not better, only different. On the product's chunks, with its own BM25, a chunk-level fusion gives 80 % R@5 against the vector order's 75.7 % on the default model, with the first place lower and MRR unchanged — the same shape on three other embedding models; with the first experiment's vectors it measured lower altogether (74–79 % against 87 %). 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).

Measure

capsa eval measures retrieval through the product — the call memory_search makes, in process — and scores it by the definitions of docs/eval/recompute_agentops.py: file-level R@1/3/5/10, MRR@10 and R@5 by category.

  • capsa eval run --corpus DIR --questions SET.json --slug NAME --mode vector|fts [--rerank MODEL|none] [--no-import] [-o DIR] imports the corpus under the slug, asks every question and scores the answers: <UTC time>-<mode>.json and last.json under --out — aggregates and ids only (the arm with its configuration, the import's counts and wall, the metrics, the rank of the gold per question id, p50/p95 of a search). The answers themselves are written only with --raw FILE (mode 0600).
  • capsa eval score --questions SET.json HITS.json [-o FILE.json] scores a kept answer in the runner's shape (what --raw writes) into the same document.
  • capsa eval compare BEFORE.json [AFTER.json] [--json] [--max-drop-r5 N] sets one document against another — every metric with its difference, R@5 by category, the paired counts at R@1, R@5 and R@10 — and exits 1 when R@5 or MRR@10 dropped by more than N questions: 1 by default, the noise of a second import; 0 for a gate on one import. AFTER defaults to last.json beside BEFORE.

A question set is a JSON list of {id, question, category, gold} and it references private documents: it is passed by path and never written to the tree — the set behind the tables above is not published. score and compare read files alone: no server, no configuration.

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; it never speaks to the graph"]
  api --> svc
  cli["the capsa CLI<br/>import, lint, token, config"] --> svc
  subgraph boundary["the content boundary: the only code that reads and writes content"]
    store["internal/store<br/>every request to the graph; every content property's read and write"]
  end
  svc --> store
  store --> hxdb["internal/helixdb<br/>the client of one server"]
  hxdb --> hx[("one HelixDB server<br/>concepts, chunks, versions, links, leases — a graph with a vector index and BM25")]
  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 server. Every request passes internal/bearer once; the handlers hold no logic; the service never speaks to the graph; and only internal/store reads or writes content — and builds a request. The graph's contract — every label, property and index — is the package comment of internal/helixdb/schema.go.

cmd/capsa/          the CLI (cobra): serve, ready, doctor, token, import, export, index, stats, lint, mcp, config
config.go server.go package capsa: CAPSA_* settings + .env, the routes, the door every process passes (the graph's indexes, built when missing), the worker (lease janitor, pending chunks, waiting episodes)
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/helixdb/  the client of one HelixDB server: the request sender, the retry policy, the graph's indexes ensured at every start
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/     the store on the graph: the only package that reads or writes content and builds a request; vector and word search; task leases
internal/testdb/    the tests' HelixDB: one server per test binary, from the pinned image, a binary (HELIX_BIN) or HELIX_URL; without one a test skips

Dependencies: the HelixDB Go client (github.com/helixdb/helix-db/sdks/go v0.5.0), 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 node — every value stored as written. The write is one request to the graph whose audit row is its last entry: a write carries its row 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 HelixDB
  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: write the concept at its expected version
  R->>D: one request: the version checked on the lane, then the node — title, description, frontmatter, body — in plaintext
  R->>D: a Version node when the content changed, built from the request's parameters
  S->>R: replace the chunks that changed, the rest keep their vectors
  R->>D: each chunk's heading and text; their words are in the engine's index from the write
  S->>E: the chunk texts, in plaintext
  E-->>S: vectors, 1024 wide, 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: the links as edges, then the audit row as the request's last entry
  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 prefilter 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: the vector search, then read the chunks' text and titles
  R-->>S: the candidates
  opt a reranker is configured
    S->>X: the query and the best chunk of each of the first CAPSA_RERANK_CANDIDATES concepts
    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, the content stored in the clear, vector search or not, the episodes waiting, stale vectors), 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= (default open; all for every 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, "episodes_waiting": K, "stale_embeddings": S}: whether vector search is available, 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 store 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 HelixDB server: the pinned image is copied out once (Docker), or HELIX_BIN names a binary
# or HELIX_URL a server that keeps its graph in memory; without any of the three they skip, and say so
go test -race -shuffle=on -count=1 ./...
make cover                         # 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 (starts the image itself, or takes SMOKE_HELIX_URL)

Every test gets an empty graph: the server's graph is emptied before each test. 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; search by words as BM25; 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 server's protection is the documented one, and nothing here reads a value 0.1.0 sealed. 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).
  • The storage is HelixDB, the standalone server (journal 026). The relational store that came before leaves; the OKF bundle is laid on the graph — the file is the record, the links are edges, the lease is the task's state on its node (journal 028) — and every page is a native read, every write one request (journal 029). What the store stands on, read and measured on the image, is docs/helixdb.md. The port is done on feat/helix-store (2026-12-05): its gates are green — lint, vet, 1 238 tests with a server, the smoke test — and the product is measured on the graph, where no arm finds less than on the store before it (docs/eval/helixdb.md); a write without expected_version is optimistic and a sequence has no transaction across it (journal 030). Until the branch lands, main still runs on the relational store.
  • The admin console is a React application behind a login, with a Kanban board (journal 027): users and sessions in the same store, the server bound to loopback, the columns of the board the task statuses.

Next, in this order:

  1. The embedding recipe v2: the concept's title before the chunk's text. Measured on 2026-12-04 on four embedding models — 3 to 9 points of R@5 with no reranker (docs/eval/rerank.md) — and not built: it re-embeds every stored chunk, so it comes with an identity of the recipe beside the model's. 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.

استكشف مشاريع مشابهة ومرتبطة

جارٍ التحميل…