Skip to content

Commit 2aa2698

Browse files
author
StackMemory Bot (CLI)
committed
docs: create THEORY.MD with project operating principles
1 parent f7e9919 commit 2aa2698

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

THEORY.MD

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# StackMemory — Operating Theory
2+
3+
## Core Thesis
4+
5+
AI coding tools forget everything between sessions. StackMemory makes context durable, searchable, and actionable — turning ephemeral chat into persistent project knowledge.
6+
7+
> Memory is storage. Context is a compiled view.
8+
9+
## Design Principles
10+
11+
### 1. Context is a Call Stack, Not a Log
12+
Frames nest hierarchically like function calls. A bug fix frame lives inside a feature frame. This structure enables scoped retrieval — ask for context about "auth" and get the relevant subtree, not a flat list of everything.
13+
14+
### 2. Serialize to Disk, Not to Context Window
15+
Context windows compress and vanish. State serialized to JSON/Markdown on disk survives indefinitely. Any fresh session can resume from serialized state — compaction-proof by design.
16+
17+
### 3. Standardize the Intersection, Expose the Union
18+
The core API works identically across Claude, Codex, and OpenCode. Provider-specific capabilities (extended thinking, code interpreter) are available through explicit opt-in, never hidden behind abstraction.
19+
20+
### 4. Automate the Tedious, Don't Automate the Thinking
21+
Hooks handle mechanical work: checkpointing every 25 tool calls, syncing Linear on exit, capturing theory updates. The agent decides *what* to work on; StackMemory ensures nothing is lost along the way.
22+
23+
### 5. Reject Complexity You Don't Need
24+
Every rejected integration (Dolt, VibeTunnel, ChromaDB) followed the same pattern: large binary, narrow use case, maintenance burden exceeding value. SQLite + FTS5 covers 95% of needs at 0 operational cost.
25+
26+
## Architecture Bets
27+
28+
- **SQLite over Postgres for local**: Zero-config, file-based, FTS5 built-in. No server process. Works offline.
29+
- **Hooks over daemons for capture**: PostToolUse hooks fire synchronously with near-zero overhead. Daemons poll and drift.
30+
- **BM25 over embeddings for search**: FTS5 BM25 scoring is fast, deterministic, and requires no external model. Embeddings are optional opt-in behind a feature flag.
31+
- **CLI wrappers over IDE plugins**: `claude-sm`, `codex-sm`, `opencode-sm` wrap existing CLIs with context injection. No IDE lock-in, works everywhere a terminal works.
32+
33+
## What We've Learned
34+
35+
- **FTS5 BM25 scores differ fundamentally from LIKE scores** — never apply the same thresholds to both. BM25 values are orders of magnitude smaller.
36+
- **Timer leaks in Promise.race kill test suites** — always clearTimeout in a finally block. A leaked timer keeps the entire vitest worker alive.
37+
- **execSync blocks everything** — including vitest timeouts. Always pass a timeout option to execSync in tests.
38+
- **Feature flags > feature removal** — disable first, remove after one release cycle. ChromaDB removal was clean because it was already flagged off.
39+
40+
## Current Direction
41+
42+
- **Theory skill + auto-capture**: THEORY.MD as living documentation, captured as frames on edit
43+
- **Model routing**: Multi-provider routing (Claude/Qwen/OpenAI/Ollama) based on task complexity
44+
- **Prompt Forge (GEPA)**: Evolutionary optimization of system prompts via eval-driven feedback
45+
- **Cord**: Agent-to-agent communication protocol for multi-agent orchestration
46+
47+
## Anti-Patterns to Avoid
48+
49+
- Don't add integrations that require a separate server process
50+
- Don't add native bindings unless gated behind a feature flag
51+
- Don't apply scoring thresholds from one search method to another
52+
- Don't use `--no-verify` to bypass failing hooks — fix the underlying issue
53+
- Don't build for hypothetical multi-user scenarios — we're single-user, local-first

0 commit comments

Comments
 (0)