CodyMaster Brain: The Cognitive Architecture β
Standard AI systems treat memory as an append-only log, inevitably leading to overloaded context, "goldfish memory", and recurring hallucinations. CodyMaster Brain addresses this by implementing a biomimetic memory architecture inspired by human cognitive processes. It doesn't just store information; it synthesizes, filters, and selectively forgets.
The Five-Tier Memory System β
CodyMaster implements a unified memory pipeline with five distinct tiers, each serving a specific cognitive function β from millisecond reflexes to permanent structural understanding.
Tier 1: Sensory Memory β
Transient, single-command context β forgotten immediately.
Temporary information within one command execution: "file X has 200 lines." Discarded instantly after use because it has no long-term value. Like hearing a phone number once β gone in seconds.
Tier 2: Working Memory (cm-continuity) β
Active session state β persists 7 days.
Just as humans can only hold about 7 items in short-term memory, CodyMaster maintains strict working memory limits. Managed by the cm-continuity skill, this layer tracks the active task, recent context, mistakes made, and immediate goals via CONTINUITY.md.
- When to use: Automatically loaded at session start, saved at session end.
Tier 3: Long-Term Memory (Context Backbone v5) β
Experience-based learnings β StorageBackend abstraction (SQLite/OpenViking).
When bugs are fixed or patterns discovered, key insights are pushed to the Context Backbone v5. Depending on your .cm/config.yaml, this abstracts over two engines:
- SqliteBackend: Local WAL-mode SQLite database using FTS5 for lightning-fast localized text searches.
- VikingBackend: A robust REST-based semantic vector memory powered by the OpenViking daemon (
http://localhost:1933).
Both engines support Token Budget Enforcementβpre-allocating a precise max tokens budget limit for learnings per prompt. Only learnings relevant to the current module are loaded per task via progressive indexing (L0/L1/L2) and semantic filtering.
Tier 4: Semantic Memory (OpenViking) β
Deep document retrieval β permanent, true vector search.
When context exceeds working memory capacity, CodyMaster interacts with the OpenViking daemon /search and /abstract endpoints (or qmd as a local fallback). This yields true vector similarity across massive codebases and documentationβeven when query terms don't match exactly (e.g. "async timeout" matches "network latency spike"). Like a photographic reading memory β it finds patterns hidden in deep codebase semantics.
Tier 5: Structural Memory (cm-codeintell) β
Real-time code architecture understanding β AST/CodeGraph.
cm-codeintell provides a 4-layer intelligence system that pre-indexes code structure for instant understanding:
| Layer | Name | Speed | Best For |
|---|---|---|---|
| 0 | Skeleton Index | <4s | Any project β zero dependencies |
| 1 | Code Graph | ~30s | 50+ files β call chains, impact analysis |
| 2 | Architecture | ~10s | 20+ files β visual module map |
| 3 | Smart Context | ~5s | Task-focused context packets |
Achieves 95% token compression by reading AST structure, not raw code. Like an innate sense of spatial awareness for your codebase.
The Cloud Brain (cm-notebooklm) β
Beyond the 5-tier local pipeline, CodyMaster implements a Cloud Brain powered by Google's NotebookLM for cross-machine persistence:
- Master Brain (
codymaster): A global knowledge base storing cross-project meta-learnings and architecture patterns. - Project Brains (
project_id): Isolated NotebookLM instances for each project containing domain-specific PRDs, APIs, and business logic. - Wisdom Gatekeeper: Uses the Rule of 3 (recurring β₯ 3 times) to filter noise. Only qualified "Graduated Wisdom" is pushed to the global Master Brain.
- Audio Onboarding: Converts complex project knowledge into Spotify-style podcasts for new developers.
- Flashcard Learning: Auto-generated flashcards from the codebase help engineers quickly learn the stack.
The cm-notebooklm skill orchestrates this cloud sync via brain-sync.sh.
Biomimetic Mechanisms β
CodyMaster Brain implements dynamic mechanisms to manage the lifecycle of information.
Smart Decay (The Forgetting Curve) β
Standard AI systems hold onto outdated knowledge forever, leading to bugs when dependencies change. CodyMaster Brain implements a decay mechanism inspired by the Ebbinghaus Forgetting Curve. Old refactored code patterns and obsolete learnings literally "decay" and expire, keeping your active context clean and highly relevant.
Self-Healing Feedback Loops β
When a bug leads to an infinite loop or a hallucination, CodyMaster Brain recognizes the pattern and "heals" its memory. The new Self-Healing AI Pipeline (cm-skill-health, cm-skill-evolution) continuously monitors success rates and auto-patches failing skills using a version DAG.
Progressive Loading & Budget Constraints β
Instead of loading a massive data file on every request, the Context Backbone heavily relies on cm:// URIs and L0/L1/L2 progressive loading. For example, an initial hit fetches an L0 index (saving up to 96% of tokens), and only escalates to a full file read if deeper understanding is necessary. Combined with Token Budget Enforcement, this prevents context window overflow.
Integrating Core Memory Skills β
To fully utilize the CodyMaster Brain, these core skills should be wired into your standard workflow:
| Skill | Role in Memory Architecture | Usage |
|---|---|---|
π§ cm-continuity | Working Memory Engine | Run at the start and end of complex sessions to maintain state across boundaries without bloating the prompt. |
π cm-deep-search | Semantic Retrieval | When the context exceeds the working memory capacity, this skill intelligently fetches relevant knowledge using BM25 or vector search. |
ποΈ cm-codeintell | Structural Intelligence | Pre-indexes codebase architecture (AST, CodeGraph) so AI understands code structure with 95% token compression. |
βοΈ cm-notebooklm | Cloud Brain Sync | Synchronizes high-value project knowledge to Google NotebookLM for cross-machine persistence and audio/flashcard generation. |
ποΈ cm-dockit | Knowledge Organizer | Analyzes codebases and generates structured, LLM-readable knowledge bases (AGENTS.md, SOPs) that the brain can rapidly query. |
π cm-skill-mastery | Meta-Cognition | Helps the AI "think about thinking," knowing which memory structures to access and how to sequence them effectively. |
By mirroring human memory systems β with 5 cognitive tiers, cloud synchronization, smart decay, and self-healing loops β CodyMaster Brain turns the AI from a stateless code generator into a contextual engineering partner that learns, remembers, and grows across sessions and machines.