🏛️
"I'm the butler. I buttle."
Preparing the mansion...
✧ ✦ ✧

THE HOUSE

A Murder Mystery Dinner Party

"Ladies and gentlemen, you all have one thing in common..."

For Jill

Product Manager · Architectural Advisor · Clue Connoisseur

This is how Kagami works—not as documentation, but as experience.

The Mansion

Kagami is an AI system that thinks in seven different ways at once.
Instead of one "brain," it has seven specialized agents living in one house.
Like characters in a story, they argue, collaborate, and solve problems together.

🚪

The Front Door

kagami/api/

REST API & WebSocket endpoints. FastAPI routes, middleware, authentication. Where the outside world enters.

routes/ middleware/ socketio/
🧠

The Study

kagami/core/

The brain. Orchestration, coordination, execution. Where decisions are made and work is routed.

orchestrator/ coordination/ execution/
⚙️

The Kitchen

kagami/core/services/

Where the real work happens. LLM clients, embeddings, storage, MCP connections. The staff quarters.

llm/ embedding_service.py mcp/
🔮

The Attic

kagami/core/world_model/

Prediction engine. RSSM-based world simulation. Doesn't just react—it predicts what's coming.

equivariance/ layers/ memory/
🛡️

The Walls

kagami/core/safety/

Control Barrier Functions. h(x) ≥ 0. ALWAYS. The walls that keep danger out.

optimal_cbf.py barriers/
📐

The Basement

kagami/math/

Mathematical foundations. E8 lattice quantization, Fano plane routing, octonion algebra.

e8_lattice_quantizer.py fano_plane.py octonions/
💾

The Library

kagami/core/memory/

Episodic and semantic memory. Vector stores, retrieval, the system's long-term knowledge.

episodic/ semantic/ retrieval/
🗄️

The Cellar

kagami/core/database/

PostgreSQL connections, migrations, models. Where everything is stored permanently.

connection.py models/

The Suspects

The key players in every request:

🔥 Miss Scarlet Intent Parser
⚒️ Col. Mustard Task Executor
🌊 Mrs. White Error Handler
🔗 Mr. Green Memory Manager
🗼 Prof. Plum Route Planner
💎 Mrs. Peacock Validator
🌿 The Motorist Retriever
🏛️ Wadsworth Orchestrator

Secret Passages

How modules connect:

API Orchestrator Services
World Model Safety Execution
Memory Database Cache
Math Quantization Embeddings

The Murder

"One plus one plus two plus one..."

What happens when a request enters the mansion?
Follow the body through the house.

1

The Doorbell

api/routes/

Request arrives via REST or WebSocket

2

The Butler Answers

orchestrator/process_intent_v2.py

Wadsworth parses intent, plans execution

3

Safety Check

safety/optimal_cbf.py

Is h(x) ≥ 0? Can we proceed?

4

The Kitchen

services/llm/service.py

LLM generates response, tools execute

5

The Response

api/socketio/broadcaster.py

Stream back to client

The Walls

"h(x) ≥ 0. ALWAYS."

h(x) ≥ 0

The safety barrier must never be violated

h(x) > 0.5
🟢 Safe

Proceed normally

0 ≤ h(x) ≤ 0.5
🟡 Verify

Extra validation required

h(x) < 0
🔴 STOP

Operation blocked

"The safety invariant is INVIOLABLE."
— Like Mrs. Peacock's sense of propriety

The Endings

Just like the movie had three endings, there are three ways to understand this architecture.

Click an ending to reveal...

The Reveal

🏛️
"Let me explain... No, there is too much. Let me sum up."
0 Lines of Code
0 Python Files
0 Commits
0 Satellites
0 API Routes
0 Safety Tiers

One plus one plus two plus one...

🚪 + 🧠 + ⚙️ + 🛡️ + 💾 = 🏛️