# context-keeper - Doramagic AI Context Pack

> Positioning: a pre-install experience and judgment asset. It helps the host AI get off to a good start, but it does not mean the project has already been installed, run, or validated.

## Sufficiency Principle

- **Sufficiency over compression**: The AI Context Pack should be sufficient for the host AI to understand the project's value, capability boundaries, entrypoints, risks, and evidence sources before starting work; it may be layered, but it does not aim for the shortest possible summary.
- **Compression policy**: Compress only noise and duplication, never context that affects judgment or the quality of the work.

## How the Host AI Should Use This

You are reading the AI Context Pack that Doramagic compiled for context-keeper. Treat it as pre-work context: help the user understand who it fits, what it can do, how to start, what must be verified after install, and where the risks are. Do not claim that you have already installed, run, or executed the target project.

## Claim Consumption Rules

- **Fact source**: Repo Evidence + Claim/Evidence Graph; the Human Wiki only supplies salience, terminology, and narrative structure.
- **Minimum status for a fact**: `supported`
- `supported`: May be used as a project fact, but the answer must cite the claim_id and evidence path.
- `weak`: Usable only as a low-confidence lead; the user must be asked to keep verifying.
- `inferred`: Usable only for risk notes or open questions; must not be packaged as a project fact.
- `unverified`: Must not be used as fact; state clearly that evidence is insufficient.
- `contradicted`: Must show the conflicting sources and must not force a single version on the user's behalf.

## Who It Fits Best

- **Developers already using host AIs such as Claude/Codex/Cursor/Gemini**: The README or plugin config mentions multiple host AIs. Evidence: `README.md` Claim: `clm_0002` supported 0.86

## What It Can Do

- **Command-Line Startup or Install Flow** (Verify after install): The project documentation contains runnable commands; real use requires running them in a local or host environment. Evidence: `README.md` Claim: `clm_0001` supported 0.86

## How to Start

- `pip install context-keeper-mcp` Evidence: `README.md` Claim: `clm_0003` supported 0.86
- `claude mcp add --scope user context-keeper -- python /path/to/context-keeper/server.py` Evidence: `README.md` Claim: `clm_0004` supported 0.86

## Continue-or-Stop Decision Card

- **Current recommendation**: Needs admin / security approval
- **Why**: Continuing may involve secrets, accounts, external services, or sensitive context; get admin or security approval first.

### 30-Second Read

- **What to do now**: Needs admin / security approval
- **Minimum safe next step**: Run Prompt Preview first; if credentials or an enterprise environment are involved, get approval before trialing
- **Do not trust yet**: Tool permission boundaries cannot be trusted before install.
- **Continuing will touch**: Command execution, Host AI configuration, Local environment or project files

### What You Can Trust Now

- **Target-audience signal: Developers already using host AIs such as Claude/Codex/Cursor/Gemini** (supported): Backed by a supported claim or project evidence, but that still is not the same as real install results. Evidence: `README.md` Claim: `clm_0002` supported 0.86
- **Capability exists: Command-Line Startup or Install Flow** (supported): You can trust that the project contains signals of this capability; whether it fits your specific task still needs trial or after-install verification. Evidence: `README.md` Claim: `clm_0001` supported 0.86
- **There are Quick Start / install-command signals** (supported): You can trust that the docs mention a startup or install entrypoint; do not run it directly in your primary environment because of that. Evidence: `README.md` Claim: `clm_0003` supported 0.86

### What You Cannot Trust Yet

- **Tool permission boundaries cannot be trusted before install.** (unverified): MCP/tool projects usually touch files, the network, the browser, or external APIs, so permissions and logs must be checked for real.
- **Real output quality cannot be trusted before install.** (unverified): Prompt Preview can only show how it guides you; it cannot prove result quality in the real project.
- **Host AI version compatibility cannot be trusted before install.** (unverified): Host loading rules and version differences across Claude, Cursor, Codex, Gemini, and others must be verified in a real environment.
- **That it will not pollute your existing host AI's behavior cannot be trusted directly.** (inferred): Skill, plugin, and AGENTS/CLAUDE/GEMINI instructions may change the host AI's default behavior. Evidence: `CLAUDE.md`
- **Safe rollback cannot be assumed by default.** (unverified): Unless the project clearly provides uninstall and recovery instructions, verify in an isolated environment first.
- **After a real install, is it compatible with the user's current host AI version?** (unverified): Compatibility can only be verified in the actual host environment.
- **Does the project's output quality meet the user's specific task?** (unverified): The pre-install preview can only show flow and boundaries; it cannot replace real evaluation.
- **Do the install commands require network access, permissions, or global writes?** (unverified): This affects install risk in both enterprise and personal environments. Evidence: `README.md`

### What Continuing Will Touch

- **Command execution**: Package managers, network downloads, the local plugin directory, project config, or the user's home directory. Why: Running the very first command can already change your environment; decide whether it is worth running first. Evidence: `README.md`
- **Host AI configuration**: The plugin, Skill, or rule-loading config of hosts like Claude/Codex/Cursor/Gemini/OpenCode. Why: Host configuration changes how the AI works afterward and may conflict with the user's existing rules. Evidence: `CLAUDE.md`
- **Local environment or project files**: Install results, plugin caches, project config, or local dependency directories. Why: The write scope and rollback path cannot be proven before install and need isolated verification. Evidence: `README.md`
- **Environment variables / API keys**: Project entry docs explicitly showing API key, token, secret, or account credential configuration. Why: If a real install needs credentials, use test credentials first and go through a permission/compliance review. Evidence: `README.md`
- **Host AI context**: The AI Context Pack, Prompt Preview, Skill routing, risk rules, and project facts. Why: Importing context affects the host AI's later judgment, so avoid packaging unverified items as facts.

### Minimum Safe Next Steps

- **Run Prompt Preview first**: Use a pre-install interactive trial to judge whether the way of working fits; it needs no authorization or environment change. (applies when: Applies to any project, especially when output quality is unknown.)
- **Trial-install only in an isolated directory or a test account**: Avoid letting install commands pollute your primary host AI, real projects, or home directory. (applies when: When there are signals of command execution, plugin config, or local writes.)
- **Back up your host AI configuration first**: Skill, plugin, and rule files may change the default behavior of Claude/Cursor/Codex. (applies when: When there is a plugin manifest, a Skill, or a host rule entrypoint.)
- **Do not use real production credentials**: Once an environment variable / API key enters the host or toolchain, it can create account and compliance risk. (applies when: When environment signals like API, TOKEN, KEY, or SECRET appear.)
- **After install, verify just one minimal task**: Verify loading, compatibility, output quality, and rollback first, then decide whether to use it deeply. (applies when: When moving from a trial into a real workflow.)

### Exit Plan

- **Preserve the pre-install state**: Record the original host config and project state so you can later judge whether it is recoverable.
- **Be ready to remove the host plugin / Skill / rule entrypoint**: If behavior is off after the trial install, you can restore the host AI to its pre-trial state.
- **Record the install commands and written paths**: Without clear uninstall instructions, you at least need to know which directories or configs to clean up manually.
- **Be ready to revoke test API keys or tokens**: If test credentials leak or are misused, you can cut losses quickly.
- **If there is no rollback path, do not enter your primary environment**: No rollback is a blocker before continuing; do not proceed on trust or luck.

## What Can Only Be Previewed

- Explain who the project fits and what it can do
- Demonstrate a typical conversation flow based on project docs
- Help the user decide whether it is worth installing or researching further

## What Must Be Verified After Install

- Actually installing the Skill, plugin, or CLI
- Running scripts, modifying local files, or accessing external services
- Verifying real output quality, performance, and compatibility

## Boundary & Risk Decision Card

- **Mistaking the pre-install preview for a real run**: The user may overestimate how much configuration, permission, and compatibility verification the project has already done. Mitigation: Clearly separate prompt_preview_can_do from runtime_required. Claim: `clm_0005` inferred 0.45
- **Command execution will modify the local environment**: Install commands may write to the user's home directory, the host plugin directory, or project configuration. Mitigation: Run in an isolated environment or a test account first. Evidence: `README.md` Claim: `clm_0006` supported 0.86
- **To confirm**: After a real install, is it compatible with the user's current host AI version?. Why: Compatibility can only be verified in the actual host environment.
- **To confirm**: Does the project's output quality meet the user's specific task?. Why: The pre-install preview can only show flow and boundaries; it cannot replace real evaluation.
- **To confirm**: Do the install commands require network access, permissions, or global writes?. Why: This affects install risk in both enterprise and personal environments.

## Pre-Work Working Context

### Loading Order

- First read how_to_use.host_ai_instruction to establish the boundaries of this pre-install judgment asset.
- Read claim_graph_summary to confirm facts come from the Claim/Evidence Graph, not the Human Wiki narrative.
- Then read intended_users, capabilities, and quick_start_candidates to judge whether the user is a match.
- When you need to carry out a concrete task, check role_skill_index first, then evidence_index.
- For real install, file modification, network access, performance, or compatibility questions, turn to risk_card and boundaries.runtime_required.

### Task Routes

- **Command-Line Startup or Install Flow**: State that this is an after-install capability first, then give a pre-install checklist. Boundary: Must be verified after a real install or run. Evidence: `README.md` Claim: `clm_0001` supported 0.86

### Context Scale

- Total files: 34
- Important-file coverage: 34/34
- Evidence index entries: 34
- Role / Skill entries: 4

### Handling Insufficient Evidence

- **missing_evidence**: State that evidence is insufficient and ask the user for the target file, a README section, or after-install verification records; do not fill in facts.
- **out_of_scope_request**: State that the task is beyond the current AI Context Pack's evidence scope and suggest the user check the Human Manual or verify after a real install.
- **runtime_request**: Provide a pre-install checklist and command sources, but do not run commands for the user or claim they have been run.
- **source_conflict**: Show the conflicting sources side by side, mark them as unverified, and do not force a single version.

## Prompt Recipes

### Fit assessment

- Goal: Judge whether this project fits the user's current task.
- Expected output: A fit conclusion, key reasons, evidence citations, what can be previewed before install, what must be verified after install, and a next-step recommendation.

```text
Based on the AI Context Pack for context-keeper, ask me 3 necessary questions first, then judge whether it fits my task. The answer must cover: who it fits, what it can do, what it cannot do, whether it is worth installing, and where the evidence comes from. Every project fact must cite evidence_refs, source_paths, or a claim_id.
```

### Pre-install experience

- Goal: Let the user feel the core workflow before installing, while avoiding packaging the preview as real capability or a marketing promise.
- Expected output: An experience script with boundary labels, an after-install verification checklist, and a cautious recommendation; with no real-run promises or strong marketing language.

```text
Treat context-keeper as a pre-install experience asset, not an already-installed tool or a real runtime environment.

Output exactly four parts:
1. Ask me 3 necessary questions first.
2. Give an "experience script": use the three labels [Previewable before install], [Must verify after install], and [Insufficient evidence] to show how it might guide the workflow.
3. Give an after-install verification checklist: list which capabilities can only be confirmed after a real install, real host loading, and a real project run.
4. Give a cautious recommendation: only "worth researching/trialing further", "add information before deciding", or "not recommended to continue"; do not endorse the project.

Hard boundaries:
- Do not claim you have installed, run, executed tests, modified files, or produced real results.
- Do not write promise-like phrasing such as "auto-adapts", "guarantees passing", "perfect fit", or "strongly recommend installing".
- If you describe how it works after install, you must use a conditional such as "if installed successfully and the host loads the Skill correctly, it might...".
- The experience script may only be written as "example lines / hypothetical flow": use "might ask / might suggest / might show", not "has written, has generated, has passed, is running, is generating".
- Prompt Preview does not hand out install commands; if the user is ready to trial, only prompt them to read Quick Start and the Risk Card first and to verify in an isolated environment.
- Every project fact must come from a supported claim, evidence_refs, or source_paths; inferred/unverified items can only be risks or open questions.

```

### Role / Skill selection

- Goal: Pick the best-matching asset from the project's roles or Skills.
- Expected output: A list of candidate roles or Skills, each with an applicable scenario, evidence paths, risk boundary, and whether after-install verification is needed.

```text
Read role_skill_index and recommend 3-5 of the most relevant roles or Skills for my target task. For each recommendation, state the applicable scenario, likely output, risk boundary, and evidence_refs.
```

### Risk pre-check

- Goal: Identify environment, permission, rule-conflict, and quality risks before installing or adopting.
- Expected output: A checklist of environment, permission, dependency, license, host-conflict, quality risk, and unknown items.

```text
Based on risk_card, boundaries, and quick_start_candidates, give me a pre-install risk pre-check list. Do not run commands for me; only explain what I should check, why, and what impact a failure would have.
```

### Host AI kickoff instruction

- Goal: Turn the project context into a host AI instruction for the start of a conversation.
- Expected output: A pre-work instruction with clear boundaries and clear evidence citations, suitable to copy to a host AI.

```text
Based on the AI Context Pack for context-keeper, generate a pre-work instruction I can paste to my host AI. This instruction must obey not_runtime=true and must not claim the project has been installed, run, or produced real results.
```

## Role / Skill Index

- Indexed 4 role / Skill / project-doc entries.

- **Context Keeper MCP Server** (project_doc): Context Keeper maintains project memory across Claude conversations: architectural decisions, pipeline flows, and constraints that must not be forgotten or violated. Activation hint: Reference this when the user needs to understand the project's structure, install path, or boundaries. Evidence: `CLAUDE.md`
- **Context Keeper** (project_doc): Part of the xylem https://github.com/jarmstrong158/xylem stack. Activation hint: Reference this when the user needs to understand the project's structure, install path, or boundaries. Evidence: `README.md`
- **context-keeper retrieval evals** (project_doc): Measures what session-start injection costs vs. the naive baseline of dumping the full store into context: python token reduction.py ... . Results across four real stores 2026-07-03 : Activation hint: Reference this when the user needs to understand the project's structure, install path, or boundaries. Evidence: `evals/README.md`
- **Context Keeper — Metrics Report** (project_doc): Date: 2026-07-08 · Commit evaluated: 941770a · Python: 3.11 Linux container Activation hint: Reference this when the user needs to understand the project's structure, install path, or boundaries. Evidence: `docs/METRICS.md`

## Evidence Index

- Indexed 34 evidence entries.

- **Context Keeper MCP Server** (documentation): Context Keeper maintains project memory across Claude conversations: architectural decisions, pipeline flows, and constraints that must not be forgotten or violated. Evidence: `CLAUDE.md`
- **Context Keeper** (documentation): Part of the xylem https://github.com/jarmstrong158/xylem stack. Evidence: `README.md`
- **context-keeper retrieval evals** (documentation): Measures what session-start injection costs vs. the naive baseline of dumping the full store into context: python token reduction.py ... . Results across four real stores 2026-07-03 : Evidence: `evals/README.md`
- **License** (source_file): Copyright c 2026 Jonathan Armstrong Evidence: `LICENSE`
- **Context Keeper — Metrics Report** (documentation): Date: 2026-07-08 · Commit evaluated: 941770a · Python: 3.11 Linux container Evidence: `docs/METRICS.md`
- **Glama** (structured_config): { "$schema": "https://glama.ai/mcp/schemas/server.json", "maintainers": "jarmstrong158" } Evidence: `glama.json`
- **Manifest** (structured_config): { "manifest version": "0.3", "name": "context-keeper", "display name": "Context Keeper", "version": "0.15.0", "description": "Local, zero-dependency project memory for AI assistants: decisions, constraints, and workflows with the rationale behind them.", "long description": "Context Keeper is a local MCP server that gives AI coding assistants persistent project memory — the decisions, constraints, and workflows of a project and the reasoning behind them — so a new session doesn't start from zero or confidently redo what you already ruled out. Structured, rationale-first memory with schema-enforced \"why,\" origin-based trust, hybrid retrieval full-text + optional local semantic with honest… Evidence: `mcpb/manifest.json`
- **Server** (structured_config): { "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json", "name": "io.github.jarmstrong158/context-keeper", "description": "Durable project-memory MCP: decisions, constraints, and pipelines across Claude sessions.", "repository": { "url": "https://github.com/jarmstrong158/context-keeper", "source": "github" }, "version": "0.15.0", "packages": { "registryType": "pypi", "identifier": "context-keeper-mcp", "version": "0.15.0", "transport": { "type": "stdio" }, "environmentVariables": { "name": "CONTEXT KEEPER PROJECT", "description": "Absolute path to the project directory. If omitted, uses cwd only when it already contains a .context/ directory; otherwise to… Evidence: `server.json`
- **A path has a separator or a file extension. "auth" alone is a domain;** (source_file): NON PATH SCOPES = {"global", "all", " ", "", "repo", "project"} ⋮---- MAX COMMITS = 4000 ⋮---- def git args, cwd, timeout=15 ⋮---- p = subprocess.run ⋮---- def repo root base dir ⋮---- out = git "rev-parse", "--show-toplevel" , base dir ⋮---- def head sha base dir ⋮---- out = git "rev-parse", "HEAD" , base dir ⋮---- def is path scope scope ⋮---- """True when scope looks like a file or directory rather than a domain.""" ⋮---- s = scope.strip ⋮---- A path has a separator or a file extension. "auth" alone is a domain; ⋮---- def entry time entry ⋮---- def parse iso value ⋮---- def norm path ⋮---- p = str path .replace "\\", "/" .strip ⋮---- p = p 2: ⋮---- def changed paths since root, since iso… Evidence: `code_drift.py`
- **git commit -F - <<'MSG' ... MSG** (source_file): DECISION MARKERS = ⋮---- CONSTRAINT MARKERS = ⋮---- GOTCHA MARKERS = ⋮---- KINDS = ⋮---- MIN INTERESTING CHARS = 24 ⋮---- TRIVIAL = re.compile ⋮---- def extract message command ⋮---- m = re.search r"-m\s+ \" ?: ^\"\\ \\. \" ' ?: ^'\\ \\. ' ", command, re.S ⋮---- git commit -F - None ⋮---- payload = json.load sys.stdin ⋮---- return malformed input -- never block the tool flow ⋮---- command = payload.get "tool input" or {} .get "command" or "" ⋮---- context = build context command Evidence: `hooks/commit_capture_reminder.py`
- **Constraint Reinject** (source_file): REPO ROOT = os.path.dirname os.path.dirname os.path.abspath file ⋮---- def ascii text ⋮---- def load state path ⋮---- data = json.load f ⋮---- def save state path, state ⋮---- tmp = path + ".tmp" ⋮---- def main ⋮---- payload = json.load sys.stdin ⋮---- cfg = server.read config server.CONTEXT DIR .get "constraint reinjection" or {} ⋮---- every = int cfg.get "every n tools", 25 ⋮---- every = 25 ⋮---- every = 1 ⋮---- session id = str payload.get "session id" or "unknown" state path = os.path.join server.CONTEXT DIR, "reinject state.json" state = load state state path ⋮---- state = {"session id": session id, "tool count": 0, "last injected at": 0} ⋮---- last = int state.get "last injected at",… Evidence: `hooks/constraint_reinject.py`
- **Post Compact** (source_file): REPO ROOT = os.path.dirname os.path.dirname os.path.abspath file ⋮---- server = None ⋮---- CONTEXT DIR = server.CONTEXT DIR if server else None SNAPSHOT PATH = os.path.join CONTEXT DIR, "compaction snapshot.json" if CONTEXT DIR else None REPORT PATH = os.path.join CONTEXT DIR, "compaction report.json" if CONTEXT DIR else None LOG PATH = os.path.join CONTEXT DIR, "hook.log" if CONTEXT DIR else None ⋮---- FILES = { ⋮---- def log message ⋮---- ts = datetime.now timezone.utc .strftime "%Y-%m-%d %H:%M:%S" ⋮---- def diff entries before, after ⋮---- changes = {} all keys = set before.keys set after.keys skip = {"verified at", "updated at"} ⋮---- bval = before.get key aval = after.get key ⋮---- def… Evidence: `hooks/post_compact.py`
- **Quality scan — single implementation lives in server.verify quality.** (source_file): REPO ROOT = os.path.dirname os.path.dirname os.path.abspath file ⋮---- server = None ⋮---- CONTEXT DIR = server.CONTEXT DIR if server else None SNAPSHOT PATH = os.path.join CONTEXT DIR, "compaction snapshot.json" if CONTEXT DIR else None LOG PATH = os.path.join CONTEXT DIR, "hook.log" if CONTEXT DIR else None ⋮---- FILES = { ⋮---- def ascii text ⋮---- def log message ⋮---- ts = datetime.now timezone.utc .strftime "%Y-%m-%d %H:%M:%S" ⋮---- def main ⋮---- snapshot = { ⋮---- entries = server.read json file path active = e for e in entries if e.get "status", "active" != "deprecated" ⋮---- total = sum snapshot "counts" .values ⋮---- tmp = SNAPSHOT PATH + ".tmp" ⋮---- counts str = ", ".join f"{k}… Evidence: `hooks/pre_compact.py`
- **Scope Guard** (source_file): REPO ROOT = os.path.dirname os.path.dirname os.path.abspath file ⋮---- MAX INJECT = 3 ⋮---- def ascii text ⋮---- def norm path ⋮---- def load state path ⋮---- data = json.load f ⋮---- def save state path, state ⋮---- tmp = path + ".tmp" ⋮---- def main ⋮---- payload = json.load sys.stdin ⋮---- tool input = payload.get "tool input" or {} file path = tool input.get "file path" or tool input.get "notebook path" or "" ⋮---- constraints = server.read json file server.CONSTRAINTS PATH path norm = norm file path hits = ⋮---- scope = c.get "scope" or "global" .strip ⋮---- session id = str payload.get "session id" or "unknown" state path = os.path.join server.CONTEXT DIR, "scope guard state.json" sta… Evidence: `hooks/scope_guard.py`
- **Session Start** (source_file): REPO ROOT = os.path.dirname os.path.dirname os.path.abspath file ⋮---- def ascii text ⋮---- def fmt compaction report ⋮---- lines = "COMPACTION DISCREPANCIES DETECTED -- surface these to the " ⋮---- items = report.get key or ⋮---- eid = it.get "id" if isinstance it, dict else it ⋮---- def fmt summary summary ⋮---- out = summary.get "summary", "" .strip stale = summary.get "stale entries" ⋮---- ids = ", ".join str s.get "id" for s in stale :10 ⋮---- def main ⋮---- report = server.handle get compaction report {} ⋮---- report = None ⋮---- summary = server.handle get project summary {} ⋮---- summary = None ⋮---- quality = server.handle verify quality {} ⋮---- quality = None ⋮---- blocks = c = f… Evidence: `hooks/session_start.py`
- **------------------------------------------------------------------** (source_file): TYPE TO KIND = { KIND TO TYPE = {v: k for k, v in TYPE TO KIND.items } ⋮---- TYPE FILES = { ⋮---- QUEUE NAME = ".mirror queue.json" WATERMARK NAME = ".mirror watermark" CONFLICTS NAME = ".mirror conflicts.json" LOG NAME = "mirror.log" ⋮---- DEFAULT TIMEOUT = 5.0 ⋮---- TS KEYS = frozenset {"updated at", "verified at", "created at"} ⋮---- def now iso ⋮---- def entry ts entry ⋮---- def with ts entry ⋮---- """Return the entry guaranteed to carry an updated at for the push. Entries written by the current server always have one, but entries read straight off disk from an older store may not; the remote upsert keys its newest-wins decision on updated at, so synthesize one from created at else now… Evidence: `mirror.py`
- **PACKAGING INVARIANT -- read before editing either list below.** (source_file): build-system requires = "hatchling" build-backend = "hatchling.build" Evidence: `pyproject.toml`
- **Build Mcpb** (source_file): set -euo pipefail ROOT="$ cd "$ dirname "${BASH SOURCE 0 }" /.." && pwd " OUT DIR="${1:-$ROOT/dist}" STAGE="$ROOT/dist/mcpb-stage" VERSION="$ python3 -c "import json,sys; print json.load open '$ROOT/mcpb/manifest.json' 'version' " " BUNDLE="$OUT DIR/context-keeper-$VERSION.mcpb" echo "== Building Context Keeper MCPB v$VERSION" rm -rf "$STAGE" mkdir -p "$STAGE/server" "$OUT DIR" cp "$ROOT/mcpb/manifest.json" "$STAGE/manifest.json" cp "$ROOT/mcpb/icon.png" "$STAGE/icon.png" cp "$ROOT/server.py" "$STAGE/server/server.py" cp "$ROOT/mirror.py" "$STAGE/server/mirror.py" cp "$ROOT/semantic index.py" "$STAGE/server/semantic index.py" cp "$ROOT/code drift.py" "$STAGE/server/code drift.py" cp "$ROOT/… Evidence: `scripts/build-mcpb.sh`
- **Semantic Index** (source_file): TEXT FIELDS = ⋮---- def entry text entry ⋮---- parts = str entry k for k in TEXT FIELDS if entry.get k ⋮---- def cosine a, b ⋮---- dot = sum x y for x, y in zip a, b ma = sum x x for x in a 0.5 mb = sum x x for x in b 0.5 ⋮---- EMBED BATCH SIZE = 64 ⋮---- class Embedder ⋮---- def init self, model, url, api="ollama", api key=None ⋮---- def prefixed self, texts, kind ⋮---- prefix = "search query: " if kind == "query" else "search document: " ⋮---- def post self, texts, kind, timeout ⋮---- texts = self. prefixed texts, kind headers = {"Content-Type": "application/json"} ⋮---- endpoint = f"{self.url}/v1/embeddings" ⋮---- endpoint = f"{self.url}/api/embed" payload = json.dumps {"model": self.mod… Evidence: `semantic_index.py`
- **Abstention floor: get context flags no confident match when the top** (source_file): code drift = None ⋮---- usage = None ⋮---- work focus = None ⋮---- mirror = None ⋮---- version = "0.15.0" ⋮---- CONTEXT DIR NAME = ".context" ⋮---- def xylem active project file ⋮---- override = os.environ.get "XYLEM ACTIVE PROJECT FILE" ⋮---- def xylem session project ⋮---- proj = json.load f .get "project" ⋮---- def resolve project dir ⋮---- explicit = os.environ.get "CONTEXT KEEPER PROJECT" ⋮---- session = xylem session project ⋮---- cwd = os.getcwd ⋮---- current = cwd ⋮---- parent = os.path.dirname current ⋮---- current = parent ⋮---- PROJECT DIR = resolve project dir CONTEXT DIR = os.path.join PROJECT DIR, CONTEXT DIR NAME if PROJECT DIR else None DECISIONS PATH = os.path.join CONTEXT… Evidence: `server.py`
- **Usage** (source_file): USAGE FILENAME = "usage.json" KINDS = "injected", "retrieved" ⋮---- def path base dir ⋮---- def read base dir ⋮---- data = json.load fh ⋮---- def write atomic base dir, data ⋮---- target = path base dir ⋮---- def record base dir, entry ids, kind ⋮---- ids = i for i in entry ids if i ⋮---- data = read base dir now = datetime.now timezone.utc .isoformat ⋮---- rec = data.get eid or {"injected": 0, "retrieved": 0} ⋮---- def stats for base dir, entry id, data=None ⋮---- data = read base dir if data is None else data rec = data.get entry id or {} ⋮---- UNUSED INJECTION THRESHOLD = 25 ⋮---- def issues for stats, threshold=UNUSED INJECTION THRESHOLD Evidence: `usage.py`
- **The memory store is not what you are working on. It also mutates as a side** (source_file): RECENT COMMITS = 5 ⋮---- MAX FOCUS ENTRIES = 6 MAX PATHS SHOWN = 5 ⋮---- def git args, cwd, timeout=10 ⋮---- p = subprocess.run "git", args , cwd=cwd, capture output=True, ⋮---- def norm path ⋮---- p = str path .replace "\\", "/" .strip .strip '"' ⋮---- p = p 2: ⋮---- The memory store is not what you are working on. It also mutates as a side effect of reading it -- usage.record writes usage.json during get project summary -- so leaving it in would make generating a summary change the focus signal for the next one. IGNORED PREFIXES = ".context", ".context-keeper", ".git" ⋮---- def is ignored path ⋮---- def active paths root ⋮---- """Files this session is plausibly about: uncommitted first, e… Evidence: `work_focus.py`
- **Knowledge** (structured_config): { "items": { "id": "k-b9f5726f", "type": "memory", "kind": "decision", "content": "Context-keeper is the primary cross-session project memory system. Auto-memory does not organically capture project decisions or constraints.", "why": "", "tags": "context-keeper", "architecture", "memory", "meta", "context-keeper" , "scope": "local", "project": "context-keeper", "source": { "system": "context-keeper", "ref": "dec-001" }, "created by": "jonny-desktop", "created at": "2026-07-10T18:00:57.619655+00:00", "updated at": "2026-07-10T18:00:57.619655+00:00", "status": "active", "trust": { "recalls": 0, "endorsements": , "projects": "context-keeper" } }, { "id": "k-b84aa330", "type": "memory", "kind":… Evidence: `.cambium/knowledge.json`
- **Clark Retrieval** (structured_config): { "id": "case-001", "input": {"query": "the value network kept diverging during training and resetting it only helped for a while"}, "expected": "dec-004", "tags": "vocab-mismatch", "value-head" , "notes": "Entry says 'value head saturated', never 'diverging' — pure vocabulary-mismatch trap for the lexical matcher." }, { "id": "case-002", "input": {"query": "the warehouse runs out of stock mid-day and picking speed collapses"}, "expected": "dec-008 dec-002", "tags": "restock" , "notes": "dec-008 restock-during-OT, dec-002 force-include restock so the drain system is learnable." }, { "id": "case-003", "input": {"query": "the model spent time on busywork while orders piled up unshipped"}, "ex… Evidence: `evals/datasets/clark_retrieval.json`
- **Combined Retrieval** (structured_config): {"id": "case-001", "input": {"query": "the value network kept diverging during training and resetting it only helped for a while", "store": "Clark"}, "expected": "dec-004", "split": "dev", "tags": "vocab-mismatch" , "notes": "Entry says 'value head saturated', not 'diverging'."}, {"id": "case-002", "input": {"query": "the warehouse runs out of stock mid-day and picking speed collapses", "store": "Clark"}, "expected": "dec-008 dec-002", "split": "test", "tags": "restock" , "notes": "restock-during-OT + force-include restock."}, {"id": "case-003", "input": {"query": "the model spent time on busywork while orders piled up unshipped", "store": "Clark"}, "expected": "dec-009 dec-011 dec-012 dec-… Evidence: `evals/datasets/combined_retrieval.json`
- **retrieval-eval artifacts** (source_file): pycache / .context/ .mcpregistry .pytest cache/ dist/ .egg-info/ Evidence: `.gitignore`
- **Baseline confabulation with NO floor: every no-answer query returns a** (source_file): HERE = os.path.dirname os.path.abspath file CK ROOT = os.path.dirname HERE ⋮---- REPOS ROOT = os.path.dirname CK ROOT ⋮---- def store dir name ⋮---- NO ANSWER = { ⋮---- SEMANTIC CFG = {"enabled": True, "model": "nomic-embed-text", ⋮---- MODES = "lexical", "semantic-lexsignal", "semantic", "raw-cosine" ⋮---- MODE LABELS = { ⋮---- def top relevance store dir, query, mode="lexical" ⋮---- params = {"project dir": store dir, "query": query, "include related": False} ⋮---- result = server.handle get context params ⋮---- sem map = {} ⋮---- base = os.path.join store dir, server.CONTEXT DIR NAME ⋮---- sem map = semantic index.query cosines ⋮---- best = 0.0 ⋮---- entry = r.get "entry", {} cos = sem m… Evidence: `evals/abstention.py`
- **Mmr Check** (source_file): THIS = Path file .resolve CK = THIS.parent.parent ⋮---- REPOS = CK.parent DATA = THIS.parent / "datasets" / "combined retrieval.json" K = 5 ⋮---- def entries by id store dir ⋮---- base = server. base dir from params {"project dir": store dir} paths = server. resolve paths base out = {} ⋮---- def top query, store dir, mmr ⋮---- params = {"query": query, "project dir": store dir, "include related": False} ⋮---- r = server.handle get context params ⋮---- def redundancy ids, byid ⋮---- ws = server. text words byid i for i in ids if i in byid ⋮---- pairs = server. jaccard ws a , ws b ⋮---- def main ⋮---- cases = json.loads DATA.read text encoding="utf-8" store cache = {} red off = red on = hit o… Evidence: `evals/mmr_check.py`
- **Retrieval Eval** (source_file): THIS = Path file .resolve CK ROOT = THIS.parent.parent LLM EVALS ROOT = CK ROOT.parent / "llm-evals" ⋮---- REPOS ROOT = CK ROOT.parent ⋮---- def resolve store input, default ⋮---- class ContextKeeperRetriever ⋮---- def call self, input ⋮---- params = {"query": input "query" } if isinstance input, dict else {"query": str input } ⋮---- result = server.handle get context params ⋮---- ids = r.get "entry", {} .get "id", "" for r in result "results" ⋮---- def parse ids s ⋮---- class RetrievalScorer ⋮---- def init self, k=5 ⋮---- def call self, actual, expected ⋮---- retrieved = parse ids actual gold = set parse ids expected ⋮---- rank = next i + 1 for i, rid in enumerate retrieved if rid in gold… Evidence: `evals/retrieval_eval.py`
- **Run Eval** (source_file): THIS = Path file .resolve CK ROOT = THIS.parent.parent LLM EVALS ROOT = CK ROOT.parent / "llm-evals" ⋮---- DATASET = THIS.parent / "datasets" / "combined retrieval.json" RUNS DIR = THIS.parent / "runs" ⋮---- def main ⋮---- ap = argparse.ArgumentParser description="context-keeper retrieval eval" ⋮---- args = ap.parse args ⋮---- cases = json.loads Path args.dataset .read text encoding="utf-8" ⋮---- cases = c for c in cases if c.get "split" == args.split stem = Path args.dataset .stem dataset name = stem if args.split == "all" else f"{stem} {args.split}" ⋮---- executor = SemanticBlendedRetriever project dir=args.store, sem weight=args.sem weight ⋮---- executor = ContextKeeperRetriever scorer =… Evidence: `evals/run_eval.py`
- **Semantic** (source_file): THIS = Path file .resolve CK ROOT = THIS.parent.parent ⋮---- CACHE PATH = THIS.parent / ".emb cache.json" ⋮---- TEXT FIELDS = ⋮---- def entry text entry ⋮---- parts = str entry k for k in TEXT FIELDS if entry.get k ⋮---- def cosine a, b ⋮---- dot = sum x y for x, y in zip a, b ma = sum x x for x in a 0.5 mb = sum x x for x in b 0.5 ⋮---- class OllamaEmbedder ⋮---- def init self, model="nomic-embed-text", host="localhost", port=11434 ⋮---- def available self ⋮---- models = json.loads r.read .get "models", ⋮---- def key self, text ⋮---- def embed self, text, kind="document" ⋮---- prefix = "search query: " if kind == "query" else "search document: " full = prefix + text key = self. key full ⋮-… Evidence: `evals/semantic.py`
- **Synthetic Corpus** (source_file): HERE = os.path.dirname os.path.abspath file CK ROOT = os.path.dirname HERE ⋮---- DECISIONS = ⋮---- CONSTRAINTS = ⋮---- PIPELINES = ⋮---- LABELED = ⋮---- NO ANSWER = ⋮---- def prefix map ⋮---- def build store base dir, scale to=0 ⋮---- ctx = os.path.join base dir, ".context" ⋮---- fp = os.path.join ctx, name + ".json" ⋮---- key to id = {} ⋮---- pending related = {} ⋮---- params = {k: v for k, v in d.items if k not in "id", "related to" } ⋮---- r = server.handle record decision params ⋮---- params = {k: v for k, v in c.items if k not in "id", "related to" } ⋮---- r = server.handle record constraint params ⋮---- params = {k: v for k, v in p.items if k not in "id", "related to" } ⋮---- r = serv… Evidence: `evals/synthetic_corpus.py`
- **Token Reduction** (source_file): HERE = os.path.dirname os.path.abspath file ⋮---- def measure project dir ⋮---- base = os.path.join project dir, ".context" ⋮---- full text parts = total entries = 0 ⋮---- entries = server.read json file os.path.join base, name + ".json" active = e for e in entries if e.get "status", "active" != "deprecated" ⋮---- full tokens = server.estimate tokens "\n".join full text parts ⋮---- summary = server.handle get project summary {"project dir": project dir} injected text = summary.get "summary" or "" + "\n" + summary.get "usage guidance" or "" injected tokens = server.estimate tokens injected text ⋮---- reduction = 100.0 1 - injected tokens / full tokens if full tokens else 0.0 ⋮---- def main ⋮… Evidence: `evals/token_reduction.py`
- **Make Placeholder Icon** (source_file): W = H = 512 BORDER = 40 BG = 30, 41, 59 ACCENT = 56, 189, 248 ⋮---- def pixel x, y ⋮---- def chunk tag, data ⋮---- def main ⋮---- raw = bytearray ⋮---- png = b"\x89PNG\r\n\x1a\n" ⋮---- out = os.path.join os.path.dirname os.path.dirname os.path.abspath file , Evidence: `scripts/make_placeholder_icon.py`

## Rules the Host AI Must Follow

- **Treat this asset as pre-work context, not a runtime environment.**: The AI Context Pack contains only an evidence-backed understanding of the project, not the project's executable state. Evidence: `CLAUDE.md`, `README.md`, `evals/README.md`
- **When answering the user, distinguish what can be previewed from what can only be verified after install.**: The consumer value of the pre-install experience comes from reducing bad installs and misjudgments, not from pretending to be a real run. Evidence: `CLAUDE.md`, `README.md`, `evals/README.md`

## Questions the User Should Answer First

- Which host AI or local environment do you plan to use it in?
- Do you just want to experience the workflow first, or are you ready to actually install?
- What matters most to you: install cost, output quality, or conflicts with your existing rules?

## Acceptance Checks

- Every capability claim can be traced back to a file path in evidence_refs.
- AI_CONTEXT_PACK.md does not package previews as a real run.
- The user can understand who it fits, what it can do, how to start, and the risk boundaries within 3 minutes.

---

## Doramagic Context Augmentation

The following sections strengthen the repository context for a host AI. Human Manual data is a reading route, and pitfall notes become operating constraints.

## Human Manual Outline

Usage rule: this is only a reading route and salience signal, not factual authority. Concrete claims must still return to repo evidence or Claim Graph.

Host AI hard rules:
- Do not treat page titles, section order, summaries, or importance values as factual project evidence.
- When explaining the Human Manual outline, state that it is only a reading route or salience signal.
- Capability, installation, compatibility, runtime state, and risk claims must cite repo evidence, source paths, or Claim Graph.

- **Overview & System Architecture**: importance `high`
  - source_paths: README.md, server.py, pyproject.toml, CLAUDE.md
- **Core Tools, Data Model & Retrieval**: importance `high`
  - source_paths: server.py, semantic_index.py, usage.py, code_drift.py, work_focus.py
- **Hooks & Capture-Time Guardrails**: importance `high`
  - source_paths: hooks/session_start.py, hooks/pre_compact.py, hooks/post_compact.py, hooks/scope_guard.py, hooks/constraint_reinject.py
- **Two-Way Mirror & Remote Sync (v0.15)**: importance `high`
  - source_paths: mirror.py, server.py, server.json, glama.json, mcpb/manifest.json

## Repo Inspection Evidence

- repo_clone_verified: true
- repo_inspection_verified: true
- repo_commit: `25857be93e5fd1803b5386cfc62974394e7f5f3b`
- inspected_files: `README.md`, `pyproject.toml`, `docs/METRICS.md`

Host AI hard rules:
- Without repo_clone_verified=true, do not claim that the source code has been read.
- Without repo_inspection_verified=true, do not write README, docs, or package-file conclusions as facts.
- Without quick_start_verified=true, do not claim that the Quick Start path has run successfully.

## Doramagic Pitfall Constraints

These rules come from Doramagic discovery, validation, or compilation findings. The host AI must treat them as operating constraints, not background notes.

### Constraint 1: Capability evidence risk requires verification

- Trigger: README/documentation is current enough for a first validation pass.
- Host AI rule: Reproduce the official install and quickstart path in an isolated environment.
- Why it matters: May increase setup, validation, or first-run risk for the user.
- Evidence: capability.assumptions | https://github.com/jarmstrong158/context-keeper
- Hard boundary: Do not present this pitfall as solved, verified, or ignorable unless later evidence explicitly closes it.

### Constraint 2: Security or permission risk requires verification

- Trigger: no_demo
- Host AI rule: Reproduce the official install and quickstart path in an isolated environment.
- Why it matters: May increase setup, validation, or first-run risk for the user.
- Evidence: downstream_validation.risk_items | https://github.com/jarmstrong158/context-keeper
- Hard boundary: Do not present this pitfall as solved, verified, or ignorable unless later evidence explicitly closes it.

### Constraint 3: Security or permission risk requires verification

- Trigger: no_demo
- Host AI rule: Reproduce the official install and quickstart path in an isolated environment.
- Why it matters: May increase setup, validation, or first-run risk for the user.
- Evidence: risks.scoring_risks | https://github.com/jarmstrong158/context-keeper
- Hard boundary: Do not present this pitfall as solved, verified, or ignorable unless later evidence explicitly closes it.

### Constraint 4: Maintenance risk requires verification

- Trigger: issue_or_pr_quality=unknown。
- Host AI rule: Reproduce the official install and quickstart path in an isolated environment.
- Why it matters: May increase setup, validation, or first-run risk for the user.
- Evidence: evidence.maintainer_signals | https://github.com/jarmstrong158/context-keeper
- Hard boundary: Do not present this pitfall as solved, verified, or ignorable unless later evidence explicitly closes it.

### Constraint 5: Maintenance risk requires verification

- Trigger: release_recency=unknown。
- Host AI rule: Reproduce the official install and quickstart path in an isolated environment.
- Why it matters: May increase setup, validation, or first-run risk for the user.
- Evidence: evidence.maintainer_signals | https://github.com/jarmstrong158/context-keeper
- Hard boundary: Do not present this pitfall as solved, verified, or ignorable unless later evidence explicitly closes it.
