DietCode is engineered using the Joy-Zoning architectural pattern. This pattern enforces strict isolation between different levels of concern, ensuring that the AI assistant remains manageable, testable, and resilient to technical drift.
The core of Joy-Zoning is the Horizontal Layer Isolation. Each layer represents a "Zone" where only specific types of logic are permitted.
- Role: Pure Business Logic.
- Constraints:
- Zero I/O: No filesystem, no networks, no external SDKs.
- Zero External Dependencies: Only standard TypeScript/Primitive types.
- High Testability: Must be testable with zero mocks.
- Contents: Task models, Tool interfaces, Agent contracts, Domain errors.
- Role: Application Orchestration.
- Constraints:
- Stateless Orchestration: Coordinate between Domain and Infrastructure.
- No Low-Level I/O: Use Infrastructure adapters instead.
- Contents: The
Orchestrator, Service Registries, Workflow logic.
- Role: Concrete Implementations (The "How").
- Constraints:
- Domain-Agnostic: Implement the interfaces defined in Domain.
- Low-Level I/O: This is where LLM SDKs (Anthropic/OpenAI), SQLite (BroccoliQ), and FS calls live.
- Contents:
AnthropicAdapter,FilesystemTool,BroccoliQPersistence.
- Role: Presentation (Sovereign CLI).
- Constraints:
- No Logic: Only rendering and dispatching user intentions.
- Contents:
TerminalUI, Cinematic renderers (insrc/ui/renderers), and terminal components.
- Role: Context-Free Utilities.
- Constraints:
- Zero context: Must be usable anywhere.
- Contents: String manipulation, date formatters, math helpers.
The hierarchy of dependencies is strictly one-way. A layer can only import from layers "below" it or to its "side" if defined by the protocol.
graph TD
UI[UI Layer] --> Core[Core Layer]
UI --> Domain[Domain Layer]
Core --> Domain
Core --> Infrastructure[Infrastructure Layer]
Infrastructure --> Domain
Plumbing[Plumbing Layer] --- ALL[All Layers]
style Domain fill:#f9f,stroke:#333,stroke-width:4px
style Plumbing fill:#ccf,stroke:#333,stroke-dasharray: 5 5
The Sovereign Hive utilizes BroccoliQ for all persistence needs. BroccoliQ is a hardened wrapper around SQLite that provides:
- Axiomatic Consistency: Strict schema enforcement.
- High Throughput: Optimized for rapid AI context storage.
- Sharded State: Prevention of database locking during long-running agent tasks.
Every tool executed by the AI (e.g., write_file) passes through the Sovereign Guardrail system:
- Pre-check: Domain validation of parameters.
- Hardening: Infrastructure-level path resolution and safety checks.
- Execution: Atomic execution with rollback capabilities provided by BroccoliQ transactions.
Important
Rule 1 of the Hive: Every file MUST start with a [LAYER] tag in the first line. This ensures automated linting tools can verify architectural integrity.
Build with Sovereignty. Build with Joy.