💡 1. The Core Failure Mode: Why Toy Vector RAG Fails Coding Agents

In early 2026, as autonomous coding agents transitioned from experimental novelties into daily production drivers, engineers encountered a frustrating, universal bottleneck: Agent Amnesia.

Every time a developer opened a new IDE chat session in Cursor, invoked Claude Code in the CLI, or launched an Antigravity agent, the model started from an epistemological blank slate. The agent would:

  1. Burn thousands of tokens re-discovering the same project conventions, asking questions the developer had answered three times the previous day.
  2. Forget architectural decisions and previous debugging breakthroughs, frequently re-introducing a race condition, syntax incompatibility, or schema deadlock that had already been diagnosed and fixed.
  3. Violate implicit project invariants (e.g., "All database operations must go through parameterized transactions" or "Never write directly to disk without a 2PC staged sandbox") unless the human painstakingly re-pasted those rules into the prompt.

The common industry reaction was to connect an external vector database—Pinecone, Qdrant, Chroma, or naive Milvus wrappers—and dump conversational summaries into a flat collection. But software engineering is not a generic prose QA problem. Toy vector RAG catastrophically fails on real-world codebases for three structural reasons:

The Three Traps of Naive Agent Memory:
  • The Temporal Collapse Trap: A six-month-old note advising "Use temporary in-memory mock for authentication" matches a cosine similarity query just as strongly as yesterday's production invariant "Use PostgreSQL connection pool". Flat vector stores have zero concept of time, lineage, or obsolescence.
  • The Memory Rot Trap: As architectural patterns evolve, contradictory notes accumulate unchecked. The agent pulls both into its prompt, experiences cognitive dissonance, and begins hallucinating hybrid compromises that break production.
  • The Unbounded Token Burn Trap: Naive memory tools return arbitrary chunks without a hard token ceiling. A single broad retrieval query can inject 6,000 tokens of unstructured memories, crowding out the agent's reasoning capacity and developer code snippets.

krusch-context-mcp was built from the ground up to solve these traps: transforming agent memory from an unconstrained dump of strings into a structured, governed, and temporally anchored lifecycle.

🎯 2. The Tool Overload Tax: Why Exposing 60 Tools Breaks LLMs

The second massive failure mode in modern agent systems is tool overload. When developers construct Model Context Protocol (MCP) servers, the natural instinct is to expose every utility function—dozens of granular inspection, deletion, pagination, search, and debugging endpoints. Earlier versions of our own stack once exposed 13 to 26 tools.

Exposing dozens of tools directly to an LLM induces severe, measurable performance degradation:

In v1.8.0, krusch-context-mcp implemented a radical product correction: The 5-Verb Discipline.

⚡ 3. The 5-Verb Discipline: Radical Ergonomics for Agents

Instead of exposing dozens of ad-hoc tools, krusch-context-mcp compresses the entire episodic memory lifecycle into strictly five canonical verbs:

Verb MCP Tool Name Lifecycle Phase Core Responsibility
retrieve krusch_context_retrieve Session Start & Query Hydrate working context & consolidated state briefings packed strictly within an exact token budget (default: 4,000 tokens).
remember krusch_context_remember During Work Store lasting architectural commitments, invariants, bugs, or lessons using a closed taxonomy. Guarded by automated near-duplicate detection.
revise krusch_context_revise Decision Evolution Supersede outdated rules with lineage links (supersede), or retire obsolete conventions with mandatory justification (invalidate).
nudge krusch_context_nudge Pre-Commit Gate Audit proposed code diffs or actions against active project invariants before committing (capped at 1–3 high-signal findings).
health krusch_context_health Hygiene & Diagnostics Inspect store operational health, memory counts by closed category, storage mode, and review memories older than 30 days.
The Prompt Footprint Payoff: By condensing the surface to five canonical verbs, the tool schema footprint dropped from ~3,500 tokens to ~350 tokens. Host models (Claude 3.7 Sonnet, Gemini 2.5 Flash, GPT-4o) call the correct tool with near-100% precision on turn 1.

🏷️ 4. The Closed Write Taxonomy: Governing Memory Quality

Unconstrained text dumps quickly degenerate into garbage. If an agent can write arbitrary notes with arbitrary tags, the database fills with conversational fluff ("User said hello", "I looked at file X").

krusch-context-mcp requires every memory to declare a valid category from a strictly enforced closed taxonomy:

Because every entry is classified, retrieve({ include_state: true }) can construct an instantly legible, organized project briefing at session start:

# 🧠 Compiled Project State: my-project

## 🎯 Decisions & Priorities (3)
- #1: Standardized on Node 22 built-in node:sqlite over better-sqlite3
- #4: Decoupled codebase RAG into krusch-git for AST and symbol graphs

## 🛡️ Project Invariants (2)
- #2: All HTTP API errors must use RFC 7807 problem details envelopes
- #5: Test suite must run standalone via npm test without requiring .env

## 🐛 Known Bugs & Blockers (0)
- Zero active blockers.

⏳ 5. Temporal Lineage & Audited Invalidation

How does a software team handle changing architectural decisions? In naive vector systems, you either overwrite history blindly (destroying context) or let contradictory notes coexist without explanation.

krusch-context-mcp implements First-Class Temporal Lineage:

1. Near-Duplicate Guard
When remember is called, if a new memory matches an existing active record (cosine ≥ 0.85), the server warns the agent and returns the candidate ID, suggesting a supersede operation instead of inserting a twin.
2. Lineage Superseding
Calling revise(action: 'supersede', target_id: 14) marks the old record SUPERSEDED and links the new memory via supersedes_id: 14. Active queries only see the latest truth, while history is preserved.

Mandatory Invalidation Justification

When an engineer or agent retires a rule, revise(action: 'invalidate') strictly rejects empty reasons. The caller must provide a mandatory justification:

// Invalidation requires explicit reason
await krusch_context_revise({
  action: "invalidate",
  target_id: 8,
  reason: "Replaced custom file mutex with SQLite atomic transaction locks in v1.8."
});

When future agents ask why a historical pattern was abandoned, the revocation rationale is permanently recorded in the lineage audit log, preventing teams from endlessly re-litigating old debates.

📦 6. Token-Budgeted State Packing: Deterministic Hydration

Language models have finite context windows. Asking an agent to read a sprawling memory store causes prompt overflow, pushes actual code out of the context window, and inflates API costs.

krusch_context_retrieve accepts a strict limit_tokens budget (default: 4,000 tokens) and performs greedy pack reranking:

  1. Compiled Project State: Active invariants (highest priority), recent architectural decisions, open blockers, and core lessons.
  2. Ranked Semantic Matches: Hybrid semantic vector similarities and lexical keyword matches.
  3. Decay Review Candidates: Flagged memories older than 30 days for proactive human/agent review.

The engine computes exact token boundaries and packs items greedily until the budget is saturated, ensuring that session start context is rich, relevant, and mathematically bounded.

💻 7. Zero-Docker, Zero-Compilation Local First (Node 22 SQLite)

Many developer tools fail before they begin because of installation friction: demanding Docker daemons, complex environment variables, or native C++ node-gyp compilation (e.g. better-sqlite3) that breaks across platforms.

krusch-context-mcp v1.8.0 was rebuilt for Zero-Docker, Zero-Native-Compilation Local First:

🌲 8. The Great Decoupling: Why Codebase RAG Became krusch-git

Earlier iterations of our context stack attempted to do everything in a single package: AST code parsing, Git commit DAG traversal, symbol call graphs, external documentation, and decision memory.

In practice, bundling codebase search into an episodic memory server created a severe architectural contradiction. In v1.8.0, Codebase RAG was decoupled into its own authoritative server: krusch-git (v1.2.1).

The Architectural Rationale for Separation:
  • Divergent Mutation Lifecycles:
    • Code Structure (krusch-git) mutates with every Git commit, branch checkout, or file edit. It requires AST parsers, Git object traversals, and symbol edge extractors.
    • Decision Memory (krusch-context-mcp) mutates with human/agent commitments, debugging breakthroughs, and policy shifts.
  • Eliminating Agent Tool Ambiguity: When code search (search_code, search_symbols, symbol_graph) lived alongside memory tools, host LLMs frequently suffered from tool ambiguity—calling code search when they needed architectural memory, or calling memory retrieval when they needed an AST call graph.
  • The Clean Division of Labor:
    • krusch-context-mcp: Answers WHY code was written (decisions, invariants, bugs, blockers).
    • krusch-git: Answers HOW code is structured (Git DAG, AST symbols, inbound callers, outbound imports).

⚡ 9. Inside krusch-git: Git DAG, AST Symbols & Hybrid RRF

While krusch-context-mcp acts as Tier 1 working memory, krusch-git (v1.2.1) serves as Tier 2 codebase intelligence. Built on pure PostgreSQL 16 + pgvector, it indexes raw Git objects and exposes 7 canonical MCP tools:

Tool Name Primary Function Underlying Technology
krusch_git_list_repos List all indexed repositories & branch metadata PostgreSQL repositories table
krusch_git_read_tree Inspect Git DAG tree hierarchy at commit/branch Git tree SHA object graph in SQL
krusch_git_read_blob Fetch content-addressed file blob or pointer file Content-addressed blob storage with monorepo pointer-mode
krusch_git_semantic_search Hybrid semantic search with exponential recency decay Cosine similarity + BM25 (tsvector) + RRF ($k=60$)
krusch_git_search_symbols Search authoritative function, class & interface symbols AST symbol index (code_symbols)
krusch_git_file_symbols List all declared symbols in a specific file or blob Ordered line-range AST symbol definitions
krusch_git_dependency_graph Multi-hop caller/callee traversal around target symbol Recursive CTEs over code_symbol_edges

Mathematical Exponential Temporal Decay

In fast-moving codebases, recent code commits must be prioritized over legacy branches. krusch-git implements mathematical recency decay directly into its search engine:

$$\text{FinalScore} = \text{CosineSimilarity} \times e^{-0.01 \times \text{age\_in\_days}}$$

Under this mathematical model:

Empirical Retrieval Ablation on Foreign Code (`expressjs/express`)

To ensure objectivity, the hybrid search engine was evaluated against frozen benchmark queries on the third-party repository expressjs/express (206 files, 3,354 symbols):

Strategy Recall@1 Recall@10 MRR Exact Identifiers R@1 Semantic Concepts R@1
BM25 Lexical (ts_rank_cd) 10.0% 10.0% 0.100 20.0% 0.0%
Dense Cosine (bge-large 1024d) 60.0% 90.0% 0.733 40.0% 80.0%
Hybrid RRF ($k=60$) 70.0% 90.0% 0.783 60.0% (+20% gain) 80.0%
Key Retrieval Finding: Fusing dense embeddings with BM25 via Reciprocal Rank Fusion ($k=60$) delivers a +20 percentage point gain on exact code identifiers (e.g. res.clearCookie) over pure dense vectors, while maintaining full 80% Recall@1 on conceptual queries.

🛡️ 10. The 3-Tier Coding Agent MCP Ecosystem

By separating concerns cleanly, the modern Krusch dev ecosystem provides agents with an authoritative 3-tier operational standard:

┌─────────────────────────────────────────────────────────────┐
│ 1. SESSION START & INVARIANTS                               │
│    krusch-context-mcp: retrieve, remember, revise, nudge     │
└──────────────────────────────┬──────────────────────────────┘
                               │
                               ▼
┌─────────────────────────────────────────────────────────────┐
│ 2. CODE EXPLORATION & ARCHITECTURE                          │
│    krusch-git: search_symbols, dependency_graph, read_blob   │
└──────────────────────────────┬──────────────────────────────┘
                               │
                               ▼
┌─────────────────────────────────────────────────────────────┐
│ 3. STAGED EXECUTION & VERIFICATION                          │
│    krusch-harness: run, task_status, diff, apply_diff        │
└─────────────────────────────────────────────────────────────┘
Tier 1: Working Memory
krusch-context-mcp
SQLite-first store governing decisions, invariants, lessons, and pre-commit nudges.
Tier 2: Code Intelligence
krusch-git
Postgres + pgvector engine indexing Git DAGs, AST symbols, and multi-hop dependency graphs.
Tier 3: Staged Execution
krusch-harness
PostgreSQL state machine holding diffs safely in staging until sandboxed unit tests pass.

🤖 11. Drop-In Agent Protocols (Cursor, Claude Code, Antigravity)

An MCP server is only as valuable as the model's protocol adherence. Both krusch-context-mcp and krusch-git ship with standardized, copy-paste AGENTS.md rules:

The Universal Agent Operating Routine:
  1. Turn 1: Zero-Trust Hydration: Run krusch_context_retrieve({ query: "*", include_state: true, limit_tokens: 4000 }) to ground context with active decisions and invariants.
  2. Before Modifying Functions: Call krusch_git_dependency_graph({ repo: "...", symbol: "..." }) to check inbound callers and avoid breaking downstream consumers.
  3. Before Committing: Run krusch_context_nudge({ trigger: "pre_commit", code: "<diff>" }) to audit proposed edits against active invariants.
  4. After Breakthroughs: Commit newly established patterns using krusch_context_remember({ category: "decision|invariant|bug|lesson|blocker", content: "..." }).

🔬 12. Official ICLR 2026 BEAM 100K Closed-System Validation

Self-reported agent memory benchmarks are notorious for subtle leakage: tiny 90-character turn stubs that fit whole conversations into 8K tokens, regex ingestion hints tuned to test queries, handicapped baselines, or frontier cloud models grading their own outputs. To eliminate every one of those failure modes, krusch-context-mcp (v1.8.1) was evaluated across all 400/400 validated probing questions (20 multi-session conversations, ~3.06M corpus tokens) of the official ICLR 2026 Mohammadta/BEAM (100K) benchmark inside a hermetic single-box 96 GB NVIDIA RTX PRO 6000 Blackwell environment.

Every embedding, retrieval call, reader completion, and dual cross-family referee judgment ran strictly over 127.0.0.1:11434 loopback with zero cloud API keys (GEMINI_API_KEY="") and four open-weights models co-located simultaneously in GPU VRAM (90.5 GB / 97.9 GB, 100% GPU): bge-large:latest (embeddings), unmodified gpt-oss:120b (Reader), qwen2.5:32b (32B dense primary Referee), and hermes3:latest (8B Llama-3.1 continuity Referee).

Evaluation Track (ICLR 2026 BEAM 100K) Baseline / Leaderboard Reference krusch-context-mcp (v1.8.1)
9-Category Primary-Turn Recall
Table A · n = 360 ground-truth Qs · ~8K token budget
30.74% Un-Condensed Lexical (~7.5 turns)
91.48% Condensed Dense bge-large (~75.7 turns)
91.99% Hybrid unifiedRetrieve (~61.7 turns)
100.00% on Temporal Reasoning & Contradiction Resolution
Full 400/400 Closed-System E2E QA
Table B · Unmodified Stock gpt-oss:120b Reader
MEMIR (48.26%) · Honcho (63.00%)
Exabase M-1 (76.90%) · past.dev (92.08%, cloud)
69.19% (hermes3:latest 8B Referee)
63.92% (qwen2.5:32b 32B Referee · 87.00% binary agreement)
Contradiction Resolution (n = 40/40)
Table B & Table C · Stock vs. In-Place QLoRA Fusion
past.dev (78.13%) 80.94% / 85.63% (Stock gpt-oss:120b)
85.31% / 93.75% (gpt-oss-120b-sre-lora, 1.71s GGUF fusion)
Zero-Leakage & Canary Integrity
npm run bench:beam:verify · Conv 14 KU Q1 Trap
0.00 Canary = Blind / Un-Gamed 0.00 Canary · 5/5 Cryptographic Checks Passed
Bottleneck Transparency & Independent Reproducibility: Excluding Event Ordering (5.64% — where relevance-sorted packing scrambles chronological turn sequences across 100K-token dialogues) and passive Knowledge Update (36.25% — uniform blind ingestion without explicit krusch_context_revise lineage pointers), Stock gpt-oss:120b averages 74.66% (qwen2.5:32b) / 77.25% (hermes3:latest) across the remaining 320/400 questions. Anyone with the public Hugging Face dataset can recompute every turn-ID recall and dual-judge tally offline via benchmarks/BEAM_EMPIRICAL_REPORT.md and benchmarks/verify_zero_leakage.js.

🚀 13. Architectural Horizon & Open-Source Ecosystem

Software engineering is evolving from one-off chat completions into long-running, autonomous engineering loops.

In this new era, developer productivity is not determined simply by foundation model parameter count. It is governed by contextual fidelity and architectural boundaries:

Together, this 3-tier ecosystem demonstrates that with disciplined systems engineering, coding agents can operate with human-grade precision, long-term memory, and architectural safety.