Purpose: Technical architecture documentation for the Coding system
This section contains architectural documentation for developers who need to understand or modify the Coding system's internal structure.
Note: Most system architecture is already covered in other sections:
- System Overview - High-level architecture
- Core Systems - Individual system architectures
- Integrations - Integration component architectures
Already documented in other sections:
- 4-Layer Monitoring - System health monitoring architecture
- LSL Classification - Conversation classification and routing
- Constraint Monitoring - Real-time constraint enforcement
The following architecture files are preserved for reference but have been superseded by the consolidated documentation:
- agent-agnostic.md - Agent-agnostic design (see System Overview)
- agent-detection.md - Agent detection implementation details
- cross-project-knowledge.md - Cross-project knowledge sharing (see Knowledge Management)
- fallback-services.md - Fallback services for CoPilot integration
- unified-knowledge-flow.md - Knowledge flow architecture
- unified-memory-systems.md - Multi-database synchronization
- unified-system-overview.md - Unified system architecture
These files will be moved to .obsolete/docs/architecture/ during Phase 2H cleanup.
The system supports multiple AI coding assistants through a unified adapter pattern with shared infrastructure:
Architecture Layers:
- Agent Layer - AI coding assistants (Claude, CoPilot, OpenCode, future agents)
- Tmux Wrapper Layer - All agents wrapped in tmux sessions via shared
tmux-session-wrapper.shfor unified status bar (with optional pipe-pane capture for non-native agents) - Config Layer - Agent definitions in
config/agents/<name>.sh(10-30 lines each) - Orchestration Layer -
launch-agent-common.shhandles all shared startup logic (Docker detection, service startup, monitoring, session management) - Common Setup Layer - Shared initialization (
agent-common-setup.sh) for LSL, monitoring, gitignore - Shared Services - VKB, Semantic Analysis, Constraint Monitor, LSL
- Adapter Layer - Abstract interface + agent implementations (dynamic import by convention)
Benefits:
- No vendor lock-in
- Consistent features across agents
- Team flexibility
Multi-tier knowledge storage for reliability and performance:
Runtime (Fast):
- MCP Memory (Claude)
- Graphology Graph (CoPilot)
Persistence (Reliable):
- shared-memory-*.json (git-tracked)
- .specstory/history/*.md (session logs)
PreToolUse hooks intercept tool calls BEFORE execution:
Claude attempts tool → PreToolUse Hook → Constraint Monitor
↓
Violation? → Block
↓
No → Allow
4-layer health monitoring with progressive escalation:
Layer 4: Service-Level Health (ukb, vkb, semantic-analysis)
Layer 3: System Verifier (LSL, constraints)
Layer 2: System Coordinator (overall health, metrics)
Layer 1: System Watchdog (critical failures, alerts)
Define constraints before implementation:
constraints:
- id: no-parallel-versions
pattern: /(v\d+|enhanced|improved|new|fixed)_/
severity: CRITICAL
message: Never create parallel versions - edit originalsAutomatic detection with fallback:
const detector = new AgentDetector();
const available = await detector.detectAll();
// { claude: true, copilot: false }
const best = await detector.getBest();
// 'claude'Structured insight capture:
# Auto-analysis from git commits
ukb
# Structured interactive capture
ukb --interactive
# Visualization
vkbAdding a new agent requires only a single config file — zero changes to shared code.
Minimum integration (1 file):
- Create
config/agents/<name>.shdefiningAGENT_NAME,AGENT_COMMAND,AGENT_REQUIRES_COMMANDS, and optional hook functions
That's it. Agent detection, launcher routing, and tmux wrapping all happen automatically.
Optional enhancements:
lib/agent-api/adapters/<name>-adapter.js— for programmatic API access (memory, browser, logging)scripts/launch-<name>.sh— thin wrapper if you need to customize sourcing order
Proof: The OpenCode agent (config/agents/opencode.sh) is a 25-line file that provides full integration with zero shared code changes.
See the Agent Integration Guide for detailed instructions and API contract.
The Coding system supports two deployment modes:
MCP servers run as native stdio processes, started and managed by Claude CLI:
- Pros: Simple setup, no Docker required, lower memory footprint
- Cons: Processes restart with each session
- Best for: Individual developers, single-machine setups
MCP servers run as HTTP/SSE services in Docker containers:
Architecture:
- Host: Claude CLI + lightweight stdio proxies
- Container: MCP SSE servers (semantic-analysis:3848, constraint-monitor:3849, code-graph-rag:3850)
- Databases: Qdrant:6333, Redis:6379, Memgraph:7687
Pros:
- Persistent services across sessions
- Shared browser automation across parallel Claude sessions
- Better resource isolation
- Easy database management
Cons: Docker required, slightly higher memory footprint
Best for: Teams, multi-session workflows, CI/CD environments
Enable Docker mode:
# Create marker file
touch .docker-mode
# Or set environment variable
export CODING_DOCKER_MODE=true
# Start services
coding --claudeSee docker/README.md for detailed Docker deployment instructions.
Key architecture diagrams are located in docs/puml/:
- Docker Architecture - puml | png
- Agent-Agnostic Architecture (Components) - puml | png
- Agent-Agnostic Architecture (Sequence) - puml | png
- Agent Integration Flow - puml | png
- 4-Layer Monitoring - puml
- LSL Classification - puml
- Constraint Monitor - puml
Additional diagrams available in docs/puml/:
- 4-layer-monitoring-architecture.png - Health monitoring layers
- lsl-4-layer-classification.png - LSL classification system
- constraint-monitor-components.png - Constraint monitoring architecture
- status-line-system.png - Status line architecture
- statusline-architecture.png - Detailed status line flow
All diagrams have corresponding PlantUML sources in docs/puml/.
- System Overview - High-level system architecture
- Core Systems - Individual system documentation
- Integrations - Integration component architectures
- Getting Started - Installation and configuration


