2.36 Knowledge Compression Plan — 7 Months of Accumulated Complexity — RAIA (Real estate Artificial Intelligence Agent) Documentation
A five-model panel review of the drift and token-burn problem caused by 1,850+ markdown rule files, and the phased plan to consolidate without losing what matters.
A five-model panel review of the drift and token-burn problem caused by 1,850+ markdown rule files, and the phased plan to consolidate without losing what matters.
Published 2026-08-10 · Architecture Decision · Phase 1 complete
In August 2026 we asked a panel of five AI models to independently review 7 months of accumulated markdown rules, ADRs, and skill files. The verdict was unanimous: the system had grown so many rule files that agents were getting lost. This page documents what we found, what the panel decided, and the phased plan to fix it.
Problem The Problem — How We Got Here
Seven months of active AI-assisted development leaves a trail. Every sprint produces ADRs, every agent dispatch produces skill files and reference documents, every planning session produces briefs. None of these are deleted when they are superseded. The result is a documentation ecosystem that has grown faster than any agent can read.
Yesterday's compact card work burned ~200k+ tokens because agents weren't told which docs to read for which component. The agent loaded DESIGN.md (70kb, ~17k tokens) unnecessarily, then queried multiple ADRs with unclear status, then spent tokens resolving contradictions between skill files. The component could have been built in 20k tokens with proper gates.
The Numbers (Verified from Live Filesystem)
| Layer | Count | Token Cost | Problem |
|---|---|---|---|
| CLAUDE.md | 64 lines (was 63) | ~400 tokens | ✓ Well-controlled |
| STATE.md | 404 lines | ~1k tokens | ✓ Acceptable |
| ADRs | 294 total — 62 superseded, 113 unclear status, 10 archived | Variable | ⚠ Status drift |
| Hermes Skills | 105 skills + 1,290 reference files | 984,061 words ≈ 1.3M tokens | ✗ Too large |
| raia-pa-workflow alone | 1,472 lines + 254 reference files | Hundreds of k-tokens | ✗ Monolithic |
| DESIGN.md | 70kb single file | ~17k tokens every accidental load | ✗ Accidentally loaded |
| Planning briefs | 97 briefs (22,648 lines) | Session artifacts never cleaned up | ✗ Stale noise (now deleted) |
| Portal .md files | 25 files | Accumulated inline docs | ⚠ Pending cleanup |
Diagram Accumulation Layers
The diagram below shows how documentation accumulated over 7 months. Each layer was added for good reasons. The problem is not that any layer is wrong — it is that agents must read all layers before writing any code.
flowchart TD
A["CLAUDE.md 63 lines ✅"] --> B["STATE.md 404 lines ✅"]
B --> C["294 ADRs — 62 superseded"]
C --> D["105 skills + 1290 references"]
D --> E["97 planning briefs"]
E --> F["25 portal .md files"]
F --> G["1.3M tokens of rules before any code"]
style A fill:#d1fae5,stroke:#059669,color:#064e3b
style B fill:#d1fae5,stroke:#059669,color:#064e3b
style C fill:#fef3c7,stroke:#d97706,color:#78350f
style D fill:#fee2e2,stroke:#dc2626,color:#7f1d1d
style E fill:#fee2e2,stroke:#dc2626,color:#7f1d1d
style F fill:#fef3c7,stroke:#d97706,color:#78350f
style G fill:#fee2e2,stroke:#dc2626,color:#7f1d1d,font-weight:bold
Panel The Panel — Five Models, Independent Review
Each model reviewed the same filesystem snapshot independently, then reported its findings. No model saw another's output before submitting. Claude Opus 4.6 acted as arbiter — it reviewed all four reports and produced the consensus decision.
| Model | Role | Token Burn Estimate | Primary Concern Raised |
|---|---|---|---|
| Kimi K3 | Panel member | 68–74% wasted | Skill reference file explosion — raia-pa-workflow alone has 254 references |
| DeepSeek R1 | Panel member | 25–35% wasted | ADR status ambiguity — 113 ADRs with no clear active/superseded status |
| GPT-5 | Panel member | 52–58% wasted | Planning brief accumulation — 97 session artifacts never purged |
| Gemini 3 Pro | Panel member | 38–45% wasted | DESIGN.md accidental loading — 17k token cost per frontend agent spawn |
| Claude Opus 4.6 | Arbiter | 40–55% wasted | Agreed with all four; produced the five-phase consensus plan |
Consensus Panel Consensus Points
All five models agreed on the following points before any phase planning began:
- Constraints exist on disk. The problem is retrieval, not storage. Adding another database table (tbl_kg_constraints) would not fix agent orientation — it would create a fourth source of truth.
- The
tbl_kg_constraintstable proposal would make things worse, not better. It competes with ADRs, pattern docs, and design tokens as a constraint authority. Rejected unanimously. - Layer 5 — the CLAUDE.md one-liner — is the highest ROI action. One sentence in the 64-line file that every agent reads unconditionally costs zero retrieval overhead.
- Skill consolidation is highest risk, should be measured first. Merged skills can cost more tokens than the originals if the merge is done carelessly. Do not merge without 10-session baseline data.
Plan The Decision — Five Phases
-
1Phase 1 — CLAUDE.md Gate + Planning Brief Purge DONE 2026-08-10
Added Rule 11 to CLAUDE.md: UniversalCompactCard enforcement gate. Deleted all 97 planning briefs (22,648 lines of session artifacts). CLAUDE.md is now 64 lines. Commit:
640a2fff. This is the highest ROI action — one unconditional read, zero retrieval overhead, prevents the most common component-build mistake. -
2Phase 2 — ADR Index + Archive Superseded ADRs Pending
Create
ADR-INDEX.md— a single-file lookup that maps topic → authoritative ADR number, with explicit "superseded by" annotations. Then archive the 62 explicitly superseded ADRs so they no longer appear in agent filesystem scans. The 113 with unclear status get a status review first. -
3Phase 3 — DESIGN.md Extraction + Portal .md Cleanup Pending
Extract DESIGN.md's 70kb into topic-specific files that agents load only when relevant. Clean up the 25 portal .md files — remove duplicates, add audience headers so agents know when NOT to load them. Estimated savings: 17k tokens per frontend agent spawn where DESIGN.md was previously loaded by default.
-
4Phase 4 — Skill Consolidation (Measured) Deferred
Measure skill loading patterns across 10 real sessions before merging anything. If skills load independently, don't merge them — just prune their reference files. The panel consensus: merged skills can cost more tokens than the originals if the merge pulls in content that was never loaded by the original pair. Measurement first, merge second.
-
5Phase 5 — Baseline Measurement + Verification Deferred
Run 10 sessions against the compressed system and measure actual token reduction vs pre-compression baseline. This is the verification gate — if measured savings don't match estimates, re-examine the compression decisions before declaring the plan complete.
Business Case The Business Case — UniversalCompactCard
Every time a developer builds a new inbox card without knowing UniversalCompactCard exists, they make the same three mistakes: wrong pill shape, wrong border, wrong navigation. Then someone reviews it and costs another session to fix. That's 53k tokens (£16) per component. With the rule in CLAUDE.md, the agent reads the pattern first and builds it right: 20k tokens (£6). Saving: £10 per component × 15 remaining components = £150–185.
The Exact Sentence Added to CLAUDE.md (Rule 11)
11. Universal compact card enforcement. Before building any dashboard/inbox component, check if UniversalCompactCard covers it. If building a new card-type component, it MUST use UniversalCompactCard as its base. See src/app/dashboard-v2/_components/inbox/COMPACT_CARD_PATTERN.md.
Savings Breakdown
| Scenario | Token Cost | Cost (£) | Notes |
|---|---|---|---|
| Without CLAUDE.md gate (build + review) | ~53k tokens | £16 | Build wrong → review session → fix session |
| With CLAUDE.md gate (build correctly first) | ~20k tokens | £6 | Agent reads pattern → builds correctly first time |
| Saving per component | ~33k tokens | £10 | 37.5% cost reduction per inbox component |
| Projected (15 remaining components) | ~495k tokens | £150–185 | Conservative estimate; actual savings likely higher |
Decisions What We Did NOT Do
The panel reviewed several proposals that were ultimately rejected or deferred. Understanding what was not done is as important as understanding what was.
-
tbl_kg_constraintsdatabase table — rejected by all 5 models unanimously. It would have created a fourth source of truth competing with ADRs, pattern docs, and design tokens. Adding a database read to every agent spawn would increase latency and token cost while solving the wrong problem. The constraints already exist on disk — the problem is retrieval routing, not storage. -
Automatic edge writing for
tbl_agent_graph_edges— deferred. The manual Sync Edges button is live and working. Automatic writing adds complexity and risk before we know whether the manual trigger is actually useful to the team. Prove the value manually first. - Knowledge graph as agent memory — deferred. The graph engineering investment surfaced the real problem (constraint retrieval routing), but the graph layer itself is not the solution. The ADR index + CLAUDE.md gates solve constraint retrieval at a fraction of the implementation cost. Revisit once Phases 2–3 are complete and we have real baseline measurements.
- Skill consolidation without measurement — deferred to next sprint. All 5 models warned explicitly that merged skills can cost MORE tokens than the originals if the merge is done without understanding actual loading patterns. Consolidation is the highest-risk phase and must be preceded by 10-session measurement data.
Status Current State of Graph Engineering
The graph engineering work that triggered this review produced real infrastructure. Here is what is live, what is deferred, and the honest verdict on the investment.
tbl_agent_graph_edges — live in Supabase. Manual trigger via the Sync Edges button in the UI. Stores agent → component dependency edges with provenance metadata.
AgentGraphPanel — live in the dashboard. Displays the agent graph with provenance-aware edge colouring (green = active data flow, amber = stale/warning, gray = passive). Clickable nodes route to the relevant ADR or component.
Automatic edge writing — deferred until manual Sync Edges proves its value. Writing edges automatically on every agent task creates noise if the edge data isn't actually consumed.
Knowledge graph memory layer — deferred. The constraint retrieval problem is solved cheaper by ADR-INDEX.md + CLAUDE.md gates.
Ratchet loop — deferred. The auto keep/revert loop requires the shadow comparison scheduler to be running first (currently paused; blocked on GCP console access).
The graph engineering investment paid for itself — not through the tbl_agent_graph_edges table itself, but through the red-team process it required. That process is what surfaced the real constraint retrieval problem and produced the five-phase compression plan. The table and panel are valuable outputs. The infrastructure built along the way is a bonus.
References References & External Sources
| Source | Type | Notes |
|---|---|---|
| KanikaBK thread on Karpathy/Anthropic graph engineering paper | X / Twitter post | The post that started this session — KanikaBK's synthesis of the Karpathy/Anthropic graph engineering paper and its implications for agentic memory systems. |
| Karpathy/Anthropic Paper Synthesis | Research synthesis (Google Drive) | The underlying paper synthesis that informed the graph engineering approach and the panel's rejection of a knowledge graph as the primary constraint retrieval mechanism. |
| ADR-283 | Architecture Decision Record | Railway-first control plane — standing rule §10, referenced in CLAUDE.md Phase 1 patch. |
| ADR-271 | Architecture Decision Record | Roster collapse — 3-seat architecture (PA, Programmer/Scribe, on-demand). Context for why skill consolidation requires careful measurement. |
| ADR-141 | Architecture Decision Record | Intelligent inbox UX — foundational ADR for the Universal Inbox, context for the UniversalCompactCard pattern requirement. |
| ADR-272 | Architecture Decision Record | Inbox email UX — one of the ADRs that informed the inbox card design pattern now enforced by CLAUDE.md Rule 11. |
| ADR-298 | Architecture Decision Record | Comms hot-window — recent ADR on communication prioritisation, one of the active (non-superseded) ADRs in the inbox stack. |
src/app/dashboard-v2/_components/inbox/COMPACT_CARD_PATTERN.md |
Pattern document | Source of truth for UniversalCompactCard — the document that CLAUDE.md Rule 11 points agents to. Contains pill shape, border, and navigation specifications. |
Commit 640a2fff |
Git commit | Phase 1 implementation — CLAUDE.md Rule 11 added, 97 planning briefs deleted. The concrete output of the five-model panel decision. |