Concise reference for AI agents working on the MONITOR codebase.
FIRST: Read
SYSTEM.md,STRUCTURE.md,ARCHITECTURE.md, andCLAUDE.mdat the repo root.
<repo-root>/
├── SYSTEM.md ← Product vision and goals
├── STRUCTURE.md ← Folder ownership and layout
├── ARCHITECTURE.md ← Layer rules
├── CLAUDE.md ← AI instructions
├── docs/ # Canonical documentation
├── infra/ # Docker infrastructure
├── packages/ # Core layers + user-facing surfaces
│ ├── data-layer/ # Layer 1: MCP Server + DB clients
│ ├── agents/ # Layer 2: AI Agents
│ ├── cli/ # Layer 3: Terminal interface
│ └── ui/ # Browser-facing backend/frontend
└── scripts/ # Dev utilities
┌─────────────────────────────┐
│ Layer 3: CLI │ packages/cli/
│ Depends on: agents ONLY │
└──────────────┬──────────────┘
│ imports
▼
┌─────────────────────────────┐
│ Layer 2: AGENTS │ packages/agents/
│ Depends on: data-layer │
└──────────────┬──────────────┘
│ imports
▼
┌─────────────────────────────┐
│ Layer 1: DATA-LAYER │ packages/data-layer/
│ Depends on: external only │
└─────────────────────────────┘
RULES:
- Dependencies flow DOWNWARD only
- No skip-layer imports (CLI cannot import data-layer directly)
- Each layer has its own
pyproject.toml
This is a quick navigation reference for contributors and AI agents. It is not the full system specification.
| Document | Use it for |
|---|---|
SYSTEM.md |
Product vision, modes, objectives |
STRUCTURE.md |
Repo layout and folder ownership |
ARCHITECTURE.md |
Layer boundaries and allowed dependencies |
docs/README.md |
Documentation map and placement rules |
docs/USE_CASES.md |
Current use-case catalog and target UX |
docs/architecture/* |
Active subsystem design references |
docs/ontology/* |
Data model and taxonomy definitions |
- Interactive play:
packages/ui/backend/src/monitor_ui/routers/chat.py - Current CLI commands:
state,rules,mechanics,ingest,playtest - Live MCP registry:
monitor_data.serverauto-discoversneo4j_*,mongodb_*,qdrant_*, andingest_*
packages/cli/src/monitor_cli/main.pyis the source of truth for the currently wired CLI surface.
- CanonKeeper is the only Neo4j writer — including thin mechanic reference nodes (
:AbilitySystem,:Track,:Condition) - Scenes are the primary canonization boundary
- Qdrant is derived index data, never the source of truth
- Layer boundaries are strict:
cli → agents → data-layer - Historical planning notes belong in
docs/archive/and are non-canonical - DSPy 3.1.3:
TypedChainOfThoughtdoes not exist; standardChainOfThoughthandles typed list output fields natively - Ingestion uses three passes: PDF structure extraction → LLM section categorization + mindscape synthesis → typed DSPy extraction
The pipeline is implemented across three layers:
| Stage | Layer | Key files |
|---|---|---|
| PDF structure extraction | data-layer | ingest_tools.py (extract_pdf_structure(), SectionBlock) |
| 1024-token chunking (rulebooks) | data-layer | ingest_tools.py (chunk_text(is_rulebook=True)) |
| Section categorization | agents | prompts/analyzer.py (SectionCategorizationSignature) |
| Section + source mindscape synthesis | agents | prompts/analyzer.py + utils/analyzer_support.py |
| Typed extraction (entities, rules, mechanics) | agents | prompts/analyzer.py (all signatures use typed Pydantic output fields) |
| Mechanic schemas | data-layer | schemas/game_systems.py (TrackDefinition, TieredAbilitySystem, ResolutionMechanic, etc.) |
| Mindscape artifacts | data-layer | schemas/knowledge_packs.py (ChunkSummaryArtifact, SectionSummaryArtifact, SourceMindscapeArtifact) |
| Thin mechanic nodes in Neo4j | data-layer | tools/neo4j_tools/mechanics.py |
| CanonKeeper mechanic writes | agents | canonkeeper.py (apply_pack_to_universe()) |
Design spec:
docs/superpowers/specs/2026-04-13-ingestion-revamp-design.mdFuture retrieval plans:docs/architecture/futures/
| If you need to change... | Start here |
|---|---|
| Data-layer tools or schemas | packages/data-layer/src/monitor_data/ |
| Agent logic or loops | packages/agents/src/monitor_agents/ |
| CLI command wiring | packages/cli/src/monitor_cli/ |
| Web play/chat behavior | packages/ui/backend/src/monitor_ui/routers/chat.py |
| Documentation structure | docs/README.md + the canonical root docs |
- Prefer linking to canonical docs over copying the same explanation.
- Keep target workflows and live repo reality clearly separated.
- Archive stale planning snapshots under
docs/archive/. - Delete docs that are redundant and add no useful context.
SYSTEM.mdSTRUCTURE.mdARCHITECTURE.mddocs/README.md- The specific subsystem doc you are modifying