Skip to content

Commit 1649873

Browse files
committed
docs: Add comprehensive architecture analysis
Deep dive analysis of StringRay framework: - 490 TypeScript files - 99 test files with 85%+ coverage - 27 agents, 32 MCP servers - 60-term codex - Complete architecture diagram - Data flow examples - Technical debt identified - Extension points documented
1 parent 2bdc3e8 commit 1649873

1 file changed

Lines changed: 250 additions & 0 deletions

File tree

Lines changed: 250 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,250 @@
1+
# StringRay Framework - Deep Architecture Analysis
2+
## Generated: $(date)
3+
4+
---
5+
6+
## Executive Summary
7+
8+
StringRay has evolved from a monolithic AI orchestration framework into a modular, self-improving, production-ready platform with:
9+
10+
- **490 TypeScript source files**
11+
- **99 test files with 85%+ coverage**
12+
- **27 specialized agents**
13+
- **32 MCP servers**
14+
- **60-term Universal Development Codex**
15+
- **99.6% systematic error prevention**
16+
17+
---
18+
19+
## Architecture Overview
20+
21+
```
22+
┌─────────────────────────────────────────────────────────────────────────────┐
23+
│ StringRay Framework v1.10.0+ │
24+
├─────────────────────────────────────────────────────────────────────────────┤
25+
│ Interface Layer │
26+
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
27+
│ │ OpenCode │ │ Plugin │ │ MCP │ │ Agents │ │
28+
│ │ Platform │←→│ Injection │←→│ Servers │←→│ (27) │ │
29+
│ └──────────────┘ └──────────────┘ └──────────────┘ └──────────────┘ │
30+
│ ↑ │
31+
├─────────────────────────────────────────────────────────────────────────────┤
32+
│ Orchestration Layer (The Brain) │
33+
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
34+
│ │ Boot │ │ Delegation │ │ Routing │ │Agent Spawn │ │
35+
│ │ Orchestrator │ │ System │ │ Engine │ │ Governor │ │
36+
│ └──────────────┘ └──────────────┘ └──────────────┘ └──────────────┘ │
37+
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
38+
│ │Multi-Agent │ │ Complexity │ │ Estimation │ │ Pattern │ │
39+
│ │Coordinator │ │ Analyzer │ │ Validator │ │ Learning │ │
40+
│ └──────────────┘ └──────────────┘ └──────────────┘ └──────────────┘ │
41+
├─────────────────────────────────────────────────────────────────────────────┤
42+
│ Processing Pipeline │
43+
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
44+
│ │ Pre-Proc │ │ Post-Proc │ │ Validation │ │ Enforcement │ │
45+
│ │ (Hooks) │ │ (Processor) │ │ (8 Types) │ │ (60 Rules) │ │
46+
│ └──────────────┘ └──────────────┘ └──────────────┘ └──────────────┘ │
47+
├─────────────────────────────────────────────────────────────────────────────┤
48+
│ Infrastructure Layer │
49+
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
50+
│ │ State │ │ Session │ │ Security │ │ Logger │ │ Config │ │
51+
│ │ Manager │ │ Mgmt │ │ Hardening│ │ │ │ Loader │ │
52+
│ └──────────┘ └──────────┘ └──────────┘ └──────────┘ └──────────┘ │
53+
└─────────────────────────────────────────────────────────────────────────────┘
54+
```
55+
56+
---
57+
58+
## Key Components
59+
60+
### 1. Boot Orchestration System
61+
- **Location**: src/core/boot-orchestrator.ts (32KB)
62+
- **Purpose**: Orchestrator-first initialization with 11-phase dependency chain
63+
- **Key Features**: Graceful shutdown, memory monitoring, error recovery
64+
65+
### 2. Agent Spawn Governor
66+
- **Location**: src/orchestrator/agent-spawn-governor.ts (732 lines)
67+
- **Purpose**: Prevents infinite spawning, enforces limits
68+
- **Limits**: 8 concurrent total, per-type limits, 10/min rate, 80MB memory
69+
70+
### 3. Delegation System
71+
- **Location**: src/delegation/agent-delegator.ts (33KB)
72+
- **Purpose**: Intelligent task routing with complexity analysis
73+
- **27 Agents**: From enforcer to storyteller, each with defined capabilities
74+
75+
### 4. Routing Engine
76+
- **Location**: src/delegation/routing/
77+
- **Purpose**: Multi-strategy task-to-agent matching
78+
- **Strategies**: Release detection → Keyword → History → Complexity → Fallback
79+
80+
### 5. Estimation Validator (NEW)
81+
- **Location**: src/validation/estimation-validator.ts
82+
- **Purpose**: Tracks estimates vs actuals, learns calibration
83+
- **Features**: Real-time tracking, accuracy reports, calibration learning
84+
85+
### 6. Post-Processor Pipeline
86+
- **Location**: src/postprocessor/PostProcessor.ts (49KB)
87+
- **Purpose**: CI/CD loop - monitor, fix, validate, redeploy
88+
- **Components**: 7 specialized engines for continuous improvement
89+
90+
---
91+
92+
## Data Flow: Task Execution
93+
94+
```
95+
User Request
96+
97+
[OpenCode Plugin] - Load framework, inject codex
98+
99+
[TaskSkillRouter] - Analyze keywords, calculate complexity
100+
101+
[AgentSpawnGovernor] - Check limits, authorize spawn
102+
103+
[MultiAgentOrchestrator] - Spawn appropriate agent
104+
105+
[Agent Execution] - Perform specialized task
106+
107+
[PostProcessor] - Validate, test, report
108+
109+
Result to User
110+
```
111+
112+
---
113+
114+
## Architectural Patterns
115+
116+
### ✅ Consistent Patterns
117+
1. **Singleton** - Shared state (agentSpawnGovernor, frameworkLogger)
118+
2. **Dependency Injection** - Constructor-based dependencies
119+
3. **Pipeline** - Sequential processor execution
120+
4. **Observer** - Event-driven monitoring
121+
5. **Strategy** - Pluggable routing and delegation
122+
6. **Factory** - Agent/connector creation
123+
124+
### ⚠️ Technical Debt
125+
1. **Code Duplication** - Multiple complexity analyzers
126+
2. **Config Sprawl** - 5+ scattered configuration files
127+
3. **Mixed Error Handling** - console.error vs frameworkLogger
128+
4. **Test Gaps** - Some MCP servers lack tests
129+
130+
---
131+
132+
## Extension Points
133+
134+
### Adding New Components
135+
136+
**New Agent:**
137+
1. Create in src/agents/new-agent.ts
138+
2. Implement AgentConfig interface
139+
3. Export from src/agents/index.ts
140+
4. Add spawn limits to governor
141+
142+
**New MCP Server:**
143+
1. Create in src/mcps/new.server.ts
144+
2. Implement Server class with tool handlers
145+
3. Register in server-config-registry.ts
146+
4. Add to boot sequence if needed
147+
148+
**New Validation Rule:**
149+
1. Add to .opencode/strray/codex.json
150+
2. Create validator in src/enforcement/validators/
151+
3. Register in validator-registry.ts
152+
153+
---
154+
155+
## Security Model
156+
157+
```
158+
Security Layers (Defense in Depth):
159+
┌─────────────────────────────────────┐
160+
│ 7. Dependency Scanning │
161+
│ 6. Audit Logging │
162+
│ 5. File Permission Hardening │
163+
│ 4. Secret Detection │
164+
│ 3. Secure Headers │
165+
│ 2. Rate Limiting (100/min) │
166+
│ 1. Input Validation │
167+
└─────────────────────────────────────┘
168+
```
169+
170+
---
171+
172+
## Intelligence Systems
173+
174+
### What Makes StringRay Self-Improving
175+
176+
1. **Estimation Validator**
177+
- Tracks every task's estimate vs actual
178+
- Builds calibration factors per category
179+
- Warns about consistent over/under estimation
180+
181+
2. **Pattern Learning**
182+
- Routing learns from successful matches
183+
- Delegation improves with usage
184+
- Complexity scoring adjusts over time
185+
186+
3. **Governance**
187+
- Spawn limits prevent runaway agents
188+
- Rate limiting prevents abuse
189+
- Memory monitoring prevents crashes
190+
- Infinite loop detection
191+
192+
---
193+
194+
## Testing Strategy
195+
196+
- **99 test files** across 5 categories
197+
- **85%+ coverage** enforced by CI
198+
- **Vitest** with 4 workers, 30s timeout
199+
- **Integration tests** for end-to-end workflows
200+
- **Mocking strategy** for isolated unit tests
201+
202+
---
203+
204+
## File Statistics
205+
206+
| Directory | Files | Purpose |
207+
|-----------|-------|---------|
208+
| src/core/ | 22 | Boot, orchestration, config |
209+
| src/agents/ | 27 | Agent definitions |
210+
| src/mcps/ | 32 | MCP servers |
211+
| src/delegation/ | 14 | Routing and delegation |
212+
| src/enforcement/ | 20 | Codex validation |
213+
| src/security/ | 12 | Security hardening |
214+
| src/state/ | 8 | State management |
215+
| src/validation/ | 8 | Various validators |
216+
| src/__tests__/ | 99 | Test suite |
217+
218+
---
219+
220+
## What StringRay Has Become
221+
222+
StringRay has evolved from a simple agent framework into:
223+
224+
> **An intelligent, self-improving, modular AI orchestration platform that learns from its own work, documents its journey, and protects code quality through systematic enforcement.**
225+
226+
Key Differentiators:
227+
- ✅ Self-calibrating time estimates
228+
- ✅ 60-term codex with 99.6% error prevention
229+
- ✅ Comprehensive governance (spawn limits, rate limiting, memory monitoring)
230+
- ✅ 27 specialized agents with intelligent routing
231+
- ✅ 32 MCP servers for tool integration
232+
- ✅ Deep reflections and narrative documentation
233+
- ✅ Production-ready with 85%+ test coverage
234+
235+
---
236+
237+
## Next Steps
238+
239+
Potential improvements:
240+
1. Consolidate complexity analyzers (reduce duplication)
241+
2. Centralize configuration (single source of truth)
242+
3. Add OpenTelemetry for distributed tracing
243+
4. Generate API documentation from types
244+
5. Create Architecture Decision Records (ADRs)
245+
246+
---
247+
248+
*Analysis generated by StringRay Explorer*
249+
*Date: $(date)*
250+
*Version: 1.10.0+*

0 commit comments

Comments
 (0)