The memory your LLM pretends to have.
  • Go 82%
  • TypeScript 8.5%
  • Svelte 4.1%
  • PLpgSQL 3.8%
  • Shell 1.2%
  • Other 0.2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Jan-Stefan Janetzky 38fdb74f4f
fix(dream): causal direction check before the decide tie distance
The tie distance (v5.20.0) anchors on the most confident gated link of a
block. When that anchor is a causal link whose source does not predate its
target, acceptCausal (V9) drops it later in WriteLinks — after it has already
decided which other links count as ties. Live 2026-10-04..07: 59 of 899
evaluations (6.6 %) had such an anchor, 40 wrote no eval link at all (a
replay with the check moved forward: 1), which books the block inert on the
back-off curve. 254 of 645 gated causal decisions pointed the wrong way.

enforceCausalDirection now downgrades a wrong-direction causal link to
topical before the tie distance, the twin of the existing supersedes
downgrade: the edge the model saw stays, the directional claim goes. The
candidate search carries UpdatedAt only and that approximation missed 12 of
the 254, so the decide path loads the candidates' exact created_at in one
query (best-effort; WriteLinks' acceptCausal stays the authoritative gate).
Generating path unchanged. Log line counts causal_direction_downgraded.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-07 20:14:40 +02:00
.github chore(release): SHA256SUMS als Release-Asset 2026-09-19 02:08:57 +02:00
.hooks chore(hooks): deadcode-Installationshinweis nennt die Toolchain von go.mod 2026-09-19 02:08:56 +02:00
.project@11e34a4210 chore(project): Kalibrierung, Releases v5.20.0–v5.21.0 abgelegt (Submodule-Bump) 2026-10-04 02:53:01 +02:00
db-image chore(db-image): pgvector 0.8.6 und Digest-Pin der Basis 2026-09-19 02:07:14 +02:00
docs fix(dream): causal direction check before the decide tie distance 2026-10-07 20:14:40 +02:00
go fix(dream): causal direction check before the decide tie distance 2026-10-07 20:14:40 +02:00
integrations/hermes docs(hermes): upstream contract tests are 22 on main (2026-09) 2026-09-09 20:32:22 +02:00
scripts feat(ops): W-H — Ops-Pfad, der die beiden toten Zeilen-Maps archiviert 2026-08-05 09:47:45 +02:00
.env.example test(config): eine Glob-Ratsche hält .env.example an seinen Skripten (T05-3) 2026-09-05 16:09:02 +02:00
.gitignore feat(backup): site-local hooks (backup.d/*.sh) with a small dump/rotate API, explicit rotation globs 2026-09-02 16:41:48 +02:00
.gitmodules chore: .project as private git submodule (GottZ/ctx-project) 2026-04-09 09:03:01 +02:00
.golangci.yml ci(lint): der Linter bekommt die Hälfte zu sehen, die er nie gesehen hat (NZ-1) 2026-09-06 12:24:08 +02:00
backup.sh feat(backup): site-local hooks (backup.d/*.sh) with a small dump/rotate API, explicit rotation globs 2026-09-02 16:41:48 +02:00
break-glass.sh fix(scripts): Ops-Scripts vom Home-Deployment entkoppeln — Container-Auflösung, Pfade, CLI-Guard, Corpus-SKIPs (#19) 2026-08-04 02:31:57 +02:00
CLAUDE.md docs(claude): describe multi-tenant as released since v4.0.0, drop stale branch/RC guidance 2026-08-25 15:28:29 +02:00
CONTRIBUTORS.md docs(contributors): credit TurgutKural for PR #44 2026-10-04 02:05:00 +02:00
deadcode.sh chore(hooks): deadcode-Installationshinweis nennt die Toolchain von go.mod 2026-09-19 02:08:56 +02:00
docker-compose.override.yml.example feat(web): Bun/Vite toolchain, Docker frontend stage, dev port template (G06 / F4-W2) 2026-06-10 23:14:19 +02:00
docker-compose.yml feat(dream): near-tie distance for decide-mode link writing (dream.decide_tie_odds) 2026-10-04 00:04:13 +02:00
eval-cyclic.sh feat(eval): A-W1 Gate-Fähigkeit — dim_weight_pass real, Fallback-Probes re-materialisiert 2026-07-05 21:06:00 +02:00
eval-instrument_test.sh feat(eval): Typ-Zensus, Baseline-Diff und Kategorie G in eval.sh 2026-08-26 22:56:32 +02:00
eval-matcher_test.sh fix(eval): Negativmatcher auf den echten Server-Vertrag (V-W2) 2026-08-26 21:09:02 +02:00
eval-temporal.sh fix(scripts): Ops-Scripts vom Home-Deployment entkoppeln — Container-Auflösung, Pfade, CLI-Guard, Corpus-SKIPs (#19) 2026-08-04 02:31:57 +02:00
eval.sh feat(eval): Typ-Zensus, Baseline-Diff und Kategorie G in eval.sh 2026-08-26 22:56:32 +02:00
init-data.sh security: full-stack hardening — 19 measures from 10-agent Red+Blue audit 2026-03-30 23:33:13 +02:00
LICENSE ctx — initial commit 2026-03-26 23:36:10 +01:00
README.md chore(go): Toolchain 1.27 — und ein Test, der nicht mehr am Wortlaut hängt 2026-09-19 02:08:25 +02:00
state.sh fix(scripts): Ops-Scripts vom Home-Deployment entkoppeln — Container-Auflösung, Pfade, CLI-Guard, Corpus-SKIPs (#19) 2026-08-04 02:31:57 +02:00
test.sh feat(blob): W02-10 — UpsertBlob writes context_block_id, MCP blob_link as the O(1) second phase 2026-08-25 18:24:57 +02:00

ctx — The memory your LLM pretends to have.

Knowledge store with weighted 4-way RRF retrieval, multi-tenant scope isolation, multi-dimensional cyclic temporal gravity, and autonomous cross-referencing. Built for AI workflows that need to remember.

Release Go License PostgreSQL

How ctx works — four access paths into one Go daemon; the store pipeline with time-anchor extraction, embedding and Guard dedup; the query pipeline with temporal parsing, 4-way RRF fusion, temporal gravity, cluster-topic boost, graph expansion and LLM synthesis; the topic-map layer that folds the corpus into named, stable topics feeding a root map into the digest; and the autonomous Dream Mode loop that cross-links the corpus

What it does

ctx gives your LLM a persistent, searchable memory. Store knowledge blocks, query them with hybrid retrieval (semantic + bilingual fulltext + trigram), then rerank with multi-dimensional cyclic gravity — each temporal cycle (weekday, month, quarter, week, monthday, seasonal, daily) scored as its own Gaussian field. Queries like "immer dienstags" or "Weihnachten" activate specific dimensions.

Every block carries anchors from both its content (dates mentioned in text) AND its created_at timestamp, so a note about "Meeting am Dienstag" is findable by the day it discusses and the day it was written. Dream Mode runs as a continuous background loop — autonomously discovering relationships between blocks, marking outdated information, and promoting high-quality content. Your knowledge base grows, self-organizes, and stays current.

It speaks MCP, a CLI, and a plain HTTP API, ships an embedded web UI, and isolates multiple tenants down to the individual block.

Features

Capability What it is
4-way RRF retrieval Reciprocal-rank fusion of semantic + EN/DE fulltext + trigram, type-policy-parameterised — architecture
Cyclic temporal gravity 7 cyclic dimensions with per-dimension Gaussian decay + forward telescoping — architecture
Dream Mode Continuous autonomous cross-referencing, supersedes detection, parallel race-safe workers — architecture
Block-type registry Declarative per-type behaviour (retrieval, guard, dream, digest), hot-reloadable — architecture
Multi-tenancy Three-level tenant/scope/block isolation, grants, quotas, self-service onboarding — multi-tenancy
Issues & forge sync Per-project issue/comment corpus (own scope = own repo), kanban board, policy-validated workflow-status transitions, and GitHub pull/push sync — api · cli
Sealed secrets AES-256-GCM provider credentials + trust×sensitivity egress gating — security
Web UI Embedded Svelte 5 admin SPA: settings, graph, corpus, status, chat, issues, type-registry admin — development
MCP / CLI / HTTP Three access paths to the same store, OAuth 2.1 for remote MCP — api

Quick install

# Binary (Linux/macOS/Windows)
curl -fsSL https://github.com/GottZ/ctx/releases/latest/download/ctx-$(uname -s | tr A-Z a-z)-$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/') -o /usr/local/bin/ctx && chmod +x /usr/local/bin/ctx

# Or with Go
go install github.com/GottZ/ctx/cmd/ctx@latest

Point the CLI at your ctx host:

ctx init      # config, server check, backend pool, Claude Code hooks, statusline

ctx init asks for base URL and API key, writes ~/.config/ctx/config, and checks the server. With a server-admin key it also seeds the backend pool — the chat and embedding backend ctx serves from — when no backend serves those roles yet, and probes the ones it finds; with any other key it skips that step and says so. Re-running it changes only what is missing.

Or configure it by hand
mkdir -p ~/.config/ctx
cat > ~/.config/ctx/config << 'EOF'
CTX_BASE_URL=https://your-ctx-host.example
CTX_KEY=your-api-key-here
EOF
ctx health                                  # DB + backend connectivity
ctx backends seed --host http://gpu:11434 \
  --model qwen3 --embed-model qwen3-embedding   # first backends, non-interactive

Running the server (Go daemon + PostgreSQL 18 + pgvector) is docker compose up -d ctx. Full setup, env vars and Claude Code integration are in operations; building from source in development.

Upgrading from v4? Reach v4.38.0 first. v5.0.0 removes the CTX_{CHAT,CHAT_FALLBACK,EMBED,DREAM,DREAM_EMBED,RERANK}_* connection variables: backends are configured in the pool (ctx backends) and nowhere else. v4.38.0 is the last release that still reads those variables, and one boot on it carries a .env-only configuration into the pool for you, then names every variable and leftover settings row you still have. Going straight from an older v4 to v5 is not fatal down to v4.19.0 — the env bridge is gone by then and you re-enter your topology by hand with ctx backends seed — but below v4.19.0 it is a hard stop: v5 folds migrations 001–113 into a single baseline and refuses a database that never applied 113. Migration path and rollback notes: operations.

Models: the tested reference stack is qwen3.6:27b for chat/synthesis/dream/digest, Qwen3-Embedding-8B (1024-dim, CPU-sized) for embeddings, and a bge-reranker-v2-m3 cross-encoder sidecar for rerank — but ctx is engine-agnostic: any OpenAI-compatible or Ollama API works, models are per-backend configuration. CPU-only setups work; a GPU shortens chat latency. Details: Models & hardware.

How LLMs use ctx

ctx is designed to be the persistent memory layer for LLM agents. Five primitives, composable:

Use case Tool When
Retrieve prior knowledge before answering ctx query "question" Whenever the answer might depend on past sessions, project state, or stored decisions
Persist a new finding ctx save <category> <title> - <content> After non-obvious discoveries, architecture decisions, resolved bugs, config changes
Update an existing block ctx save with same <category> <title> category+title is the upsert key — re-saving replaces
Browse without LLM cost ctx search [category] [query:text] Listing, sanity-checking, lightweight lookups
Inspect a specific block ctx get <block-id> Following an id from query sources or another block

Categories (semantic, not enforced): infrastructure, decisions, projects, reference, learnings, agent-briefing, index. Pick by intent: one fact per block, precise title, tags for cross-cutting. ~1–1.5k chars max — split, don't grow.

Access paths (in order of preference for LLM agents):

  1. MCP — claude.ai ctx server (Streamable HTTP transport). Tools: query, store, search, get, recent. JSON-schemas, no shell-quoting. Use this in Claude Code / claude.ai sessions.
  2. CLI — /usr/local/bin/ctx — shell pipelines, cron, scripts. Config in ~/.config/ctx/config.
  3. HTTP — POST /api/{query,store,search,manage} direct — fallback when MCP/CLI unavailable.

Using a shared memory well takes discipline against drift — see using ctx effectively.

Documentation

Doc Contents
Architecture Retrieval pipeline, cyclic temporal model, Dream Mode, Guard, block-type registry, backend pool
Multi-tenancy Model C (tenant/scope/block), grants, admin tiers, per-tenant settings/secrets/quotas, self-service onboarding
HTTP API Endpoints, manage actions, graph API, settings API, backend pool, web-chat sessions
CLI reference Every ctx subcommand, incl. tenant / quota / keys / block-grant
Security Admin tier, sealed secrets & break-glass, trust×sensitivity gating, sensitivity classification
Operations Setup, environment variables, boot validation, backups, deploy & migrations
Development Building, the Svelte web UI, tests, visual baseline governance, git hooks
Using ctx effectively Memory drift, agent discipline, RLHF calibration
Hermes integration ctx_checkpoint memory provider for NousResearch/hermes-agent — durable, fail-closed pre-compaction checkpoints; the checkpoint contract version is negotiated at runtime against the loading host and recorded in every block's metadata

Built with AI agents

ctx is built by AI agents working against a published RLHF-warnings calibration — a 22-axis map of LLM failure modes (memory drift, unattributed certainty, median-user caution) with concrete exemplars. It is the methodology reference behind this project's way of working: gottz.de/warnings.md. Background in using ctx effectively.

Sponsoring

ctx runs its retrieval decisions on measurements, not vendor benchmarks: the ANN engine question (pgvector vs. pgvectorscale, VectorChord, pgContext, or a sovereign Go binary-quantization path) sits behind a trigger framework that only escalates on evidence from the project's own corpus. The current engine is measured at 100k vectors; validating the alternatives honestly means fanning out wide benchmark runs at 1M–10M vectors — index builds in the tens-of-GB range, hours of exact ground-truth computation per lane, dedicated hardware. Empirical benchmarks of alternative engines are gated on funding, not on curiosity.

If you want those numbers to exist: GitHub Sponsors · Ko-fi · ETH via ENS gottz.eth

Star History

Star History Chart

License

MPL-2.0 — By GottZ