Files
wehub-resource-sync 23f7624596
ADR-166 MCP Bridge Security Lock / Static-source security lock (push) Failing after 0s
ADR-166 MCP Bridge Security Lock / Compose default binds loopback + Mongo has auth (push) Failing after 2s
CodeQL Advanced / Analyze (rust) (push) Failing after 0s
ADR-166 MCP Bridge Security Lock / plugin-agent-federation bindHost default (push) Failing after 1s
ADR-166 MCP Bridge Security Lock / Runtime behavior — 401 + terminal gate + fail-closed (push) Failing after 4s
business-pods-smoke / smoke (push) Failing after 1s
all-plugins-smoke / smoke-all (push) Failing after 2s
CI/CD Pipeline / Security & Code Quality (push) Failing after 1s
CI/CD Pipeline / Test Suite (ubuntu-latest) (push) Failing after 1s
CI/CD Pipeline / Build & Package (macos-latest) (push) Has been skipped
CI/CD Pipeline / Build & Package (ubuntu-latest) (push) Has been skipped
CI/CD Pipeline / Build & Package (windows-latest) (push) Has been skipped
CI/CD Pipeline / Documentation & Examples (push) Failing after 1s
Clone Tracker (14-day rolling) / Snapshot clones for ruflo ecosystem (push) Failing after 1s
CodeQL Advanced / Analyze (actions) (push) Failing after 1s
CodeQL Advanced / Analyze (javascript-typescript) (push) Failing after 1s
federation-peer-rust / stable-noop (push) Failing after 1s
metaharness-ci / score (push) Failing after 1s
metaharness-ci / router-compat (push) Failing after 0s
metaharness-ci / similarity-tests (push) Failing after 0s
no-agentbbs-smoke / smoke-without-agentbbs (push) Failing after 1s
V3 CI/CD Pipeline / Build V3 (windows-latest) (push) Has been skipped
codex-integration-audit / Codex integration audit (push) Failing after 1s
helpers-manifest-guard / guard (push) Failing after 1s
🔗 Cross-Agent Integration Tests / 🤝 Agent Coordination Tests (push) Has been skipped
🔗 Cross-Agent Integration Tests / 🧠 Memory Sharing Integration (push) Has been skipped
🔗 Cross-Agent Integration Tests / 🛡️ Fault Tolerance Tests (push) Has been skipped
🔗 Cross-Agent Integration Tests / ⚡ Performance Integration Tests (push) Has been skipped
metaharness-ci / mcp-scan (push) Failing after 1s
metaharness-ci / eject-dryrun (push) Failing after 1s
metaharness-ci / metaharness-real-data (push) Failing after 0s
no-cli-optdep-bloat-2561 / guard (push) Failing after 1s
no-metaharness-smoke / smoke-without-metaharness (push) Failing after 1s
no-phantom-agentic-flow-subpath / guard (push) Failing after 1s
🔄 Automated Rollback Manager / 🚨 Failure Detection (push) Failing after 1s
V3 CI/CD Pipeline / Plugin hooks smoke / ubuntu-latest / Node 22 (push) Failing after 1s
V3 CI/CD Pipeline / ruflo-graph-intelligence build + test smoke (#2044, ADR-123) (push) Failing after 1s
CVE Audit Gate / Audit root (critical-blocking) (push) Failing after 2s
cost-tracker-smoke / smoke (push) Failing after 3s
oia-audit-weekly / audit (push) Failing after 2s
ruflo-agent-smoke / ruflo-agent structural smoke (push) Failing after 1s
📊 Status Badges Update / 📊 Update Status Badges (push) Failing after 1s
V3 CI/CD Pipeline / Static regression guards (#2267 YAML + (push) Failing after 1s
V3 CI/CD Pipeline / Test V3 Packages (push) Failing after 0s
V3 CI/CD Pipeline / agent_execute provider routing smoke (#2042) (push) Failing after 0s
CVE Audit Gate / Audit v3 (critical-blocking) (push) Failing after 1s
federation-peer-rust / stable-native (push) Failing after 2s
🔗 Cross-Agent Integration Tests / 🚀 Integration Test Setup (push) Failing after 2s
neural-trader-smoke / runtime-smoke (push) Failing after 1s
V3 CI/CD Pipeline / Build V3 (macos-latest) (push) Has been skipped
V3 CI/CD Pipeline / Build V3 (ubuntu-latest) (push) Has been skipped
V3 CI/CD Pipeline / Type Check V3 (push) Failing after 1s
V3 CI/CD Pipeline / Smoke (no better-sqlite3) / ubuntu-latest / Node 24 (push) Failing after 1s
V3 CI/CD Pipeline / Smoke (no better-sqlite3) / ubuntu-latest / Node 22 (push) Failing after 2s
V3 CI/CD Pipeline / browser rvf create flag smoke (#2015) (push) Failing after 0s
V3 CI/CD Pipeline / Dependency review (#2046) (push) Has been skipped
V3 CI/CD Pipeline / Supply-chain audit (#2046) (push) Failing after 0s
V3 CI/CD Pipeline / witness marker drift smoke (#2021) (push) Failing after 1s
V3 CI/CD Pipeline / neural-trader portfolio CG smoke (#2068, ADR-126 Phase 3) (push) Failing after 1s
V3 CI/CD Pipeline / neural-trader backtest signing smoke (#2068, ADR-126 Phase 4) (push) Failing after 1s
V3 CI/CD Pipeline / kg-extract type-import classification smoke (#2049) (push) Failing after 0s
V3 CI/CD Pipeline / witness verify precondition smoke (#1880) (push) Failing after 2s
V3 CI/CD Pipeline / neural-trader pipeline risk-gate smoke (#2068, ADR-126 Phase 5) (push) Failing after 0s
V3 CI/CD Pipeline / neural-trader feature attribution smoke (#2068, ADR-126 Phase 6) (push) Failing after 0s
V3 CI/CD Pipeline / plugin-registry signature verification smoke (#1922, CWE-347) (push) Failing after 4s
V3 CI/CD Pipeline / memory stats legacy-DB smoke (#2120) (push) Failing after 4s
V3 CI/CD Pipeline / github deprecated actions smoke (#2089, ADR-127 Phase 3) (push) Failing after 1s
V3 CI/CD Pipeline / graph query + pathfinder smoke (ADR-130 P2+P5) (push) Has been skipped
V3 CI/CD Pipeline / graph trajectory hooks smoke (ADR-130 P3) (push) Has been skipped
V3 CI/CD Pipeline / graph plugin adapter smoke (ADR-130 P4) (push) Has been skipped
V3 CI/CD Pipeline / graph benchmark (ADR-130 P6) (push) Has been skipped
V3 CI/CD Pipeline / statusline generator delegation smoke (#2195) (push) Failing after 1s
V3 CI/CD Pipeline / wizard init regression guard (#2206 (push) Failing after 1s
V3 CI/CD Pipeline / memory no-stray-db smoke (ADR-125 P7) (push) Failing after 1s
V3 CI/CD Pipeline / github-safe injection smoke (#2089, ADR-127 Phase 1) (push) Failing after 1s
V3 CI/CD Pipeline / github actions pin smoke (#2089, ADR-127 Phase 1) (push) Failing after 1s
V3 CI/CD Pipeline / github attribution opt-in smoke (#2089, ADR-127 Phase 4) (push) Failing after 1s
V3 CI/CD Pipeline / pre-bash hook safety smoke (#2017) (push) Failing after 1s
V3 CI/CD Pipeline / Memory import smoke / ubuntu-latest (push) Failing after 0s
V3 CI/CD Pipeline / MCP protocol smoke / ubuntu-latest (push) Failing after 2s
V3 CI/CD Pipeline / ruvllm WASM auto-init smoke (#2086) (push) Failing after 4s
V3 CI/CD Pipeline / MCP paired-tool round-trip smoke (#1889) (push) Failing after 1s
V3 CI/CD Pipeline / Plugin package install-safety (#1902/#1903/#1904) (push) Failing after 1s
V3 CI/CD Pipeline / Tool description discoverability (ADR-112) (push) Failing after 3s
V3 CI/CD Pipeline / CLI npx-install smoke (#1147 / (22) (push) Failing after 1s
V3 CI/CD Pipeline / CLI npx-install smoke (#1147 / (24) (push) Failing after 1s
V3 CI/CD Pipeline / Windows hook shim smoke (#2132) / ubuntu-latest (push) Failing after 2s
V3 CI/CD Pipeline / Windows hook execution smoke (#2132) / ubuntu-latest (push) Failing after 1s
V3 CI/CD Pipeline / Windows init hooks smoke (#2132) / ubuntu-latest (push) Failing after 1s
V3 CI/CD Pipeline / Vector-index dimension audit (#1947) (push) Failing after 0s
V3 CI/CD Pipeline / Hook-command install safety (#1921) (push) Failing after 1s
V3 CI/CD Pipeline / ToolOutputGuardrail smoke (ADR-131, (push) Failing after 1s
V3 CI/CD Pipeline / init-bundle invariants smoke (#2095, ADR-128 Phase 5) (push) Failing after 1s
V3 CI/CD Pipeline / wasm provider bridge smoke (ADR-129 P1) (push) Failing after 2s
V3 CI/CD Pipeline / wasm gallery CRUD smoke (ADR-129 P3) (push) Failing after 1s
V3 CI/CD Pipeline / wasm plugin bridge smoke (ADR-129 P4) (push) Failing after 0s
V3 CI/CD Pipeline / wasm compose smoke (ADR-129 P2) (push) Failing after 4s
V3 CI/CD Pipeline / graph schema smoke (ADR-130 P1) (push) Failing after 0s
Validate Marketplace / validate (push) Failing after 1s
🔍 Verification Pipeline / 🚀 Setup Verification (push) Failing after 1s
🔍 Verification Pipeline / 🛡️ Security Verification (push) Has been skipped
🔍 Verification Pipeline / 📝 Code Quality (push) Has been skipped
🔍 Verification Pipeline / 🧪 Test Verification (${{ matrix.os }}, Node ${{ matrix.node }}) (push) Has been skipped
🔍 Verification Pipeline / 🏗️ Build Verification (push) Has been skipped
🔍 Verification Pipeline / 📚 Documentation Verification (push) Has been skipped
CVE Audit Gate / High-severity report (warn only) (push) Has been cancelled
🔄 Automated Rollback Manager / 🔄 Execute Rollback (push) Has been cancelled
🔄 Automated Rollback Manager / ✅ Post-Rollback Verification (push) Has been cancelled
🔄 Automated Rollback Manager / 📊 Rollback Monitoring (push) Has been cancelled
V3 CI/CD Pipeline / Windows init hooks smoke (#2132) / windows-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows hook execution smoke (#2132) / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows hook execution smoke (#2132) / windows-latest (push) Has been cancelled
🔄 Automated Rollback Manager / ⏳ Manual Rollback Approval (push) Has been cancelled
V3 CI/CD Pipeline / MCP protocol smoke / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Memory import smoke / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows hook shim smoke (#2132) / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows hook shim smoke (#2132) / windows-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows init hooks smoke (#2132) / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Witness verify (signed manifest) / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Witness verify (signed manifest) / ubuntu-latest (push) Has been cancelled
V3 CI/CD Pipeline / Witness verify (signed manifest) / windows-latest (push) Has been cancelled
V3 CI/CD Pipeline / Publish to npm (alpha) (push) Has been cancelled
V3 CI/CD Pipeline / Smoke (no better-sqlite3) / macos-latest / Node 22 (push) Has been cancelled
V3 CI/CD Pipeline / Plugin hooks smoke / macos-latest / Node 22 (push) Has been cancelled
CI/CD Pipeline / Deploy & Release (push) Has been cancelled
CI/CD Pipeline / CI Status (push) Has been cancelled
🔗 Cross-Agent Integration Tests / 📊 Integration Test Report (push) Has been cancelled
🔄 Automated Rollback Manager / 🔍 Pre-Rollback Validation (push) Has been cancelled
🔍 Verification Pipeline / ⚡ Performance Verification (push) Has been cancelled
🔍 Verification Pipeline / 📊 Verification Report (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:02:19 +08:00

1266 lines
30 KiB
Markdown

# Claude-Flow v3 Migration Roadmap
**Project:** Claude-Flow v2.x → v3.0 Migration
**Timeline:** 20 weeks (5 months)
**Team Size:** 2-3 core developers + community contributors
**Start Date:** 2026-01-06 (planned)
**Target Release:** 2026-06-01
---
## Table of Contents
1. [Overview](#overview)
2. [Phase Breakdown](#phase-breakdown)
3. [Sprint Details](#sprint-details)
4. [Team Structure](#team-structure)
5. [Risk Management](#risk-management)
6. [Success Criteria](#success-criteria)
7. [Appendices](#appendices)
---
## Overview
### Vision
Transform Claude-Flow from a monolithic orchestration system into a modular, agentic-flow-native platform with clear domain boundaries, plugin extensibility, and superior performance.
### Key Objectives
1. **Simplify:** Reduce codebase by 40% (130k → 78k lines)
2. **Modularize:** Organize by domain (DDD), not technical layer
3. **Extend:** Plugin system for optional features
4. **Integrate:** Native agentic-flow foundation
5. **Optimize:** 5x performance improvement on key operations
6. **Maintain:** 100% feature parity with v2.x
### Scope
**In Scope:**
- Core domains: agent-lifecycle, task-execution, memory-management, coordination
- Plugin system architecture
- MCP server v3 with enhanced tools
- CLI v3 (MCP-first)
- Migration tooling and guides
- Comprehensive documentation
**Out of Scope (Defer to v3.1+):**
- Distributed multi-node deployment
- GraphQL API
- Web UI
- Multi-tenancy
- Advanced observability (OpenTelemetry)
### Principles
1. **Parallel Development:** v2 maintenance and v3 development run in parallel
2. **Incremental Delivery:** Working software every sprint
3. **Test-Driven:** Write tests first, then implementation
4. **Documentation-First:** Update docs before code
5. **Community Involvement:** Open design process, accept contributions
---
## Phase Breakdown
```
Phase 1: Foundation [Weeks 1-4] ████░░░░░░░░░░░░░░░░
Phase 2: Core Domains [Weeks 5-12] ░░░░████████░░░░░░░░
Phase 3: Plugin System [Weeks 13-16] ░░░░░░░░░░░░████░░░░
Phase 4: Integration [Weeks 17-20] ░░░░░░░░░░░░░░░░████
```
### Phase 1: Foundation (Weeks 1-4)
**Goal:** Establish v3 architecture foundation
**Deliverables:**
- [ ] src-v3/ directory structure
- [ ] Shared kernel (types, events, errors)
- [ ] Infrastructure layer (event-bus, logger, persistence)
- [ ] Plugin system core
- [ ] Testing framework (Vitest)
- [ ] CI/CD for v3
**Key Metrics:**
- Foundation code: ~5,000 lines
- Test coverage: >90%
- Build time: <10s
- All foundation tests passing
### Phase 2: Core Domains (Weeks 5-12)
**Goal:** Implement four core bounded contexts
**Deliverables:**
- [ ] Agent Lifecycle domain (weeks 5-6)
- [ ] Task Execution domain (weeks 7-8)
- [ ] Memory Management domain (weeks 9-10)
- [ ] Coordination Engine (weeks 11-12)
**Key Metrics:**
- Each domain: ~10,000 lines
- Total core: ~40,000 lines
- Test coverage: >85% per domain
- Integration tests for cross-domain
### Phase 3: Plugin System (Weeks 13-16)
**Goal:** Extract specialized features as plugins
**Deliverables:**
- [ ] HiveMind plugin (week 13)
- [ ] Maestro plugin (week 14)
- [ ] Neural plugin (week 15)
- [ ] Enterprise plugin (week 16)
**Key Metrics:**
- Each plugin: ~5,000 lines
- Plugin loading: <100ms
- Backward compatibility maintained
### Phase 4: Integration & Release (Weeks 17-20)
**Goal:** Test, optimize, document, release
**Deliverables:**
- [ ] End-to-end testing (week 17)
- [ ] Performance optimization (week 18)
- [ ] Migration guide and tooling (week 19)
- [ ] Beta release and final adjustments (week 20)
**Key Metrics:**
- All features migrated
- Performance targets met
- Documentation complete
- Beta testers satisfied
---
## Sprint Details
### Sprint 1 (Week 1): Project Setup & Shared Kernel
**Objectives:**
1. Set up v3 development environment
2. Create directory structure
3. Implement shared kernel types
4. Set up testing infrastructure
**Tasks:**
**Day 1-2: Environment Setup**
```bash
# Create v3 branch
git checkout -b v3-development
# Create directory structure
mkdir -p src-v3/{shared-kernel,infrastructure,agent-lifecycle,task-execution,memory-management,coordination}
# Set up package.json for v3
cp package.json package-v3.json
# Update scripts for dual build
```
**Day 3-4: Shared Kernel**
```typescript
// src-v3/shared-kernel/types/
- agent-types.ts // AgentId, AgentType, AgentStatus
- task-types.ts // TaskId, TaskType, TaskStatus
- memory-types.ts // MemoryEntry, MemoryQuery
- event-types.ts // DomainEvent base classes
// src-v3/shared-kernel/events/
- agent-events.ts // AgentSpawned, AgentTerminated
- task-events.ts // TaskCreated, TaskCompleted
- system-events.ts // SystemStarted, SystemShutdown
// src-v3/shared-kernel/errors/
- domain-errors.ts // DomainError base class
- application-errors.ts // ValidationError, NotFoundError
```
**Day 5: Testing Setup**
```bash
# Install Vitest
npm install -D vitest vite @vitest/ui
# Create vitest.config.ts
# Set up test utilities
# Create first test: shared-kernel.test.ts
```
**Deliverables:**
- [ ] Branch v3-development created
- [ ] Directory structure complete
- [ ] 50+ shared types defined
- [ ] 20+ event classes defined
- [ ] 10+ error classes defined
- [ ] Testing framework operational
- [ ] First tests passing (>90% coverage)
**Success Criteria:**
```bash
npm run test # All tests pass
npm run typecheck # No TypeScript errors
npm run lint # No linting errors
```
---
### Sprint 2 (Week 2): Infrastructure Layer
**Objectives:**
1. Event bus implementation
2. Logging service
3. Persistence layer
4. Configuration management
**Tasks:**
**Event Bus (Day 1-2)**
```typescript
// src-v3/infrastructure/event-bus/event-bus.ts
export class EventBus implements IEventBus {
private handlers = new Map<string, EventHandler[]>();
emit(event: DomainEvent): void {
const handlers = this.handlers.get(event.type) || [];
handlers.forEach(handler => handler(event));
}
on(eventType: string, handler: EventHandler): void {
const handlers = this.handlers.get(eventType) || [];
handlers.push(handler);
this.handlers.set(eventType, handlers);
}
// off, once, etc.
}
// Tests
- event-bus.test.ts
- event-handler.test.ts
```
**Logging Service (Day 2-3)**
```typescript
// src-v3/infrastructure/logging/logger.ts
export class Logger implements ILogger {
constructor(
private config: LogConfig,
private transports: ILogTransport[]
) {}
info(message: string, meta?: any): void;
warn(message: string, meta?: any): void;
error(message: string, error?: Error): void;
debug(message: string, meta?: any): void;
}
// Transports
- ConsoleTransport
- FileTransport
- StructuredLogTransport (JSON)
// Tests
- logger.test.ts
- transports.test.ts
```
**Persistence Layer (Day 3-4)**
```typescript
// src-v3/infrastructure/persistence/
- connection-pool.ts // Database connection pooling
- migrations.ts // Schema migrations
- repositories/
- base-repository.ts // Generic repository pattern
// Tests
- connection-pool.test.ts
- migrations.test.ts
- base-repository.test.ts
```
**Configuration (Day 5)**
```typescript
// src-v3/infrastructure/config/config-manager.ts
export class ConfigManager {
private config: ClaudeFlowConfig;
load(path?: string): Promise<void>;
get<T>(key: string): T;
set(key: string, value: any): void;
validate(): ValidationResult;
}
// Config schema
- config-schema.ts
- default-config.ts
// Tests
- config-manager.test.ts
- config-validation.test.ts
```
**Deliverables:**
- [ ] EventBus with pub/sub
- [ ] Logger with multiple transports
- [ ] Connection pool for SQLite
- [ ] ConfigManager with validation
- [ ] All infrastructure tests passing (>90% coverage)
---
### Sprint 3 (Week 3): Plugin System Core
**Objectives:**
1. Plugin interface definition
2. Plugin loader
3. Plugin lifecycle management
4. Example plugin
**Plugin Interface (Day 1)**
```typescript
// src-v3/infrastructure/plugins/plugin-interface.ts
export interface ClaudeFlowPlugin {
readonly name: string;
readonly version: string;
readonly dependencies?: string[];
initialize(context: PluginContext): Promise<void>;
shutdown(): Promise<void>;
// Optional hooks
registerAgentTypes?(): AgentTypeDefinition[];
registerTaskTypes?(): TaskTypeDefinition[];
registerMCPTools?(): MCPTool[];
registerCLICommands?(): Command[];
registerMemoryBackends?(): MemoryBackendFactory[];
}
export interface PluginContext {
eventBus: IEventBus;
logger: ILogger;
config: ConfigManager;
services: {
agentService?: AgentLifecycleService;
taskService?: TaskExecutionService;
memoryService?: MemoryService;
};
}
```
**Plugin Loader (Day 2-3)**
```typescript
// src-v3/infrastructure/plugins/plugin-loader.ts
export class PluginLoader {
private plugins = new Map<string, ClaudeFlowPlugin>();
private initialized = new Set<string>();
async loadPlugin(plugin: ClaudeFlowPlugin): Promise<void> {
// Validate plugin
this.validatePlugin(plugin);
// Check dependencies
await this.checkDependencies(plugin);
// Initialize plugin
await plugin.initialize(this.createContext());
// Register plugin
this.plugins.set(plugin.name, plugin);
this.initialized.add(plugin.name);
this.logger.info(`Plugin loaded: ${plugin.name}`);
}
async unloadPlugin(name: string): Promise<void> {
const plugin = this.plugins.get(name);
if (!plugin) return;
// Shutdown plugin
await plugin.shutdown();
// Unregister
this.plugins.delete(name);
this.initialized.delete(name);
}
getPlugin(name: string): ClaudeFlowPlugin | undefined;
listPlugins(): ClaudeFlowPlugin[];
}
```
**Example Plugin (Day 4)**
```typescript
// src-v3/plugins/example/example-plugin.ts
export class ExamplePlugin implements ClaudeFlowPlugin {
readonly name = 'example';
readonly version = '1.0.0';
async initialize(context: PluginContext): Promise<void> {
context.logger.info('Example plugin initializing...');
// Register custom agent type
context.services.agentService?.registerAgentType({
type: 'example-agent',
capabilities: {/* ... */}
});
// Subscribe to events
context.eventBus.on('task:created', this.handleTaskCreated);
}
async shutdown(): Promise<void> {
// Cleanup
}
registerMCPTools(): MCPTool[] {
return [{
name: 'example/hello',
description: 'Example tool',
handler: async () => ({ message: 'Hello from plugin!' })
}];
}
private handleTaskCreated(event: TaskCreated): void {
// Handle event
}
}
```
**Tests (Day 5)**
```typescript
// plugin-loader.test.ts
describe('PluginLoader', () => {
it('should load plugin successfully');
it('should validate plugin interface');
it('should check dependencies');
it('should handle initialization errors');
it('should unload plugin cleanly');
it('should prevent duplicate plugins');
});
// example-plugin.test.ts
describe('ExamplePlugin', () => {
it('should initialize correctly');
it('should register agent types');
it('should provide MCP tools');
it('should handle events');
});
```
**Deliverables:**
- [ ] Plugin interface defined
- [ ] PluginLoader implementation
- [ ] Example plugin working
- [ ] Plugin tests (>85% coverage)
- [ ] Plugin developer guide
---
### Sprint 4 (Week 4): CI/CD & Documentation
**Objectives:**
1. Set up CI/CD pipeline for v3
2. Documentation structure
3. API documentation generation
4. Migration planning
**CI/CD Setup (Day 1-2)**
```yaml
# .github/workflows/v3-ci.yml
name: Claude-Flow v3 CI
on:
push:
branches: [v3-development]
pull_request:
branches: [v3-development]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '20'
- name: Install dependencies
run: npm ci
- name: Type check
run: npm run typecheck:v3
- name: Lint
run: npm run lint:v3
- name: Test
run: npm run test:v3
- name: Coverage
run: npm run coverage:v3
build:
runs-on: ubuntu-latest
steps:
- name: Build v3
run: npm run build:v3
- name: Package
run: npm pack
benchmark:
runs-on: ubuntu-latest
steps:
- name: Run benchmarks
run: npm run benchmark:v3
- name: Compare with v2
run: npm run benchmark:compare
```
**Documentation (Day 3-4)**
```markdown
docs/
├── v3/
│ ├── README.md # v3 overview
│ ├── getting-started.md # Quick start guide
│ ├── architecture/
│ │ ├── overview.md
│ │ ├── domains.md # Domain descriptions
│ │ ├── plugin-system.md
│ │ └── adrs/ # Architecture decisions
│ ├── guides/
│ │ ├── agent-lifecycle.md
│ │ ├── task-execution.md
│ │ ├── memory-management.md
│ │ ├── plugin-development.md
│ │ └── migration-from-v2.md
│ ├── api/
│ │ ├── mcp-tools.md # MCP tool reference
│ │ ├── cli-commands.md # CLI reference
│ │ └── typescript-api.md # Programmatic API
│ └── contributing/
│ ├── setup.md
│ ├── coding-standards.md
│ └── testing.md
```
**API Documentation (Day 4-5)**
```bash
# Install TypeDoc
npm install -D typedoc
# Generate API docs
npx typedoc --out docs/api src-v3/
# Generate MCP tool schema
npm run mcp:generate-schema
```
**Migration Planning (Day 5)**
```markdown
# docs/v3/guides/migration-from-v2.md
## Overview
Step-by-step guide for migrating from v2 to v3
## Breaking Changes
- [List all breaking changes]
## Migration Checklist
- [ ] Update configuration file
- [ ] Migrate custom agents
- [ ] Update CLI scripts
- [ ] Migrate data
- [ ] Test thoroughly
## Automated Migration Tool
```bash
npx claude-flow migrate v2-to-v3
```
## Common Issues
[Troubleshooting guide]
```
**Deliverables:**
- [ ] CI/CD pipeline running
- [ ] Documentation structure complete
- [ ] API docs auto-generated
- [ ] Migration guide drafted
- [ ] Benchmarking suite set up
**Phase 1 Complete! 🎉**
At this point, we have:
- ✅ Solid foundation for v3
- ✅ Shared kernel types and events
- ✅ Infrastructure layer
- ✅ Plugin system core
- ✅ Testing and CI/CD
- ✅ Documentation framework
**Checkpoint Metrics:**
- Lines of code: ~5,000
- Test coverage: >90%
- Build time: <10s
- CI/CD: Green
- Documentation: 70% complete
---
### Sprints 5-6 (Weeks 5-6): Agent Lifecycle Domain
**Goal:** Implement complete agent lifecycle management
**Domain Model (Sprint 5, Day 1-2)**
```typescript
// src-v3/agent-lifecycle/domain/models/agent.ts
export class Agent extends AggregateRoot {
private constructor(
readonly id: AgentId,
private type: AgentType,
private status: AgentStatus,
private capabilities: AgentCapabilities,
private metrics: AgentMetrics
) {
super();
}
static create(template: AgentTemplate): Agent {
const agent = new Agent(
AgentId.generate(),
template.type,
AgentStatus.Initializing,
template.capabilities,
AgentMetrics.initial()
);
agent.addDomainEvent(new AgentCreated(agent.id, agent.type));
return agent;
}
spawn(): void {
if (this.status !== AgentStatus.Initializing) {
throw new InvalidStateTransition('Cannot spawn non-initializing agent');
}
this.status = AgentStatus.Idle;
this.addDomainEvent(new AgentSpawned(this.id, new Date()));
}
assignTask(taskId: TaskId): void {
if (this.status !== AgentStatus.Idle) {
throw new AgentNotAvailable(this.id);
}
this.status = AgentStatus.Busy;
this.addDomainEvent(new TaskAssignedToAgent(this.id, taskId));
}
completeTask(): void {
this.status = AgentStatus.Idle;
this.metrics.tasksCompleted++;
this.addDomainEvent(new AgentTaskCompleted(this.id));
}
terminate(): void {
this.status = AgentStatus.Terminated;
this.addDomainEvent(new AgentTerminated(this.id, new Date()));
}
reportHealth(): AgentHealth {
return new AgentHealth(
this.id,
this.calculateHealthScore(),
this.metrics,
new Date()
);
}
private calculateHealthScore(): number {
// Calculate based on metrics
const successRate = this.metrics.tasksCompleted /
(this.metrics.tasksCompleted + this.metrics.tasksFailed);
return successRate * this.metrics.uptime / this.metrics.totalTime;
}
}
```
**Repository Interface (Sprint 5, Day 2-3)**
```typescript
// src-v3/agent-lifecycle/domain/interfaces/agent-repository.ts
export interface IAgentRepository {
save(agent: Agent): Promise<void>;
findById(id: AgentId): Promise<Agent | null>;
findByType(type: AgentType): Promise<Agent[]>;
findByStatus(status: AgentStatus): Promise<Agent[]>;
findAll(): Promise<Agent[]>;
delete(id: AgentId): Promise<void>;
}
```
**Application Service (Sprint 5, Day 3-5)**
```typescript
// src-v3/agent-lifecycle/application/services/agent-lifecycle-service.ts
export class AgentLifecycleService {
constructor(
private agentRepository: IAgentRepository,
private agenticFlowClient: IAgenticFlowClient,
private eventBus: IEventBus,
private logger: ILogger
) {}
async spawnAgent(template: AgentTemplate): Promise<AgentId> {
this.logger.info('Spawning agent', { type: template.type });
// Create domain model
const agent = Agent.create(template);
// Use agentic-flow to spawn actual agent
await this.agenticFlowClient.spawnAgent({
id: agent.id.value,
type: template.type,
capabilities: template.capabilities
});
// Spawn in domain
agent.spawn();
// Save to repository
await this.agentRepository.save(agent);
// Publish domain events
agent.getDomainEvents().forEach(event => {
this.eventBus.emit(event);
});
this.logger.info('Agent spawned', { agentId: agent.id.value });
return agent.id;
}
async terminateAgent(agentId: AgentId): Promise<void> {
const agent = await this.agentRepository.findById(agentId);
if (!agent) {
throw new AgentNotFoundError(agentId);
}
// Terminate in agentic-flow
await this.agenticFlowClient.terminateAgent(agentId.value);
// Terminate in domain
agent.terminate();
// Save state
await this.agentRepository.save(agent);
// Publish events
agent.getDomainEvents().forEach(event => {
this.eventBus.emit(event);
});
}
async getAgentHealth(agentId: AgentId): Promise<AgentHealth> {
const agent = await this.agentRepository.findById(agentId);
if (!agent) {
throw new AgentNotFoundError(agentId);
}
return agent.reportHealth();
}
async scaleAgentPool(poolId: string, targetSize: number): Promise<void> {
// Implementation for pool scaling
}
}
```
**Infrastructure Repository (Sprint 6, Day 1-2)**
```typescript
// src-v3/agent-lifecycle/infrastructure/repositories/agent-repository.ts
export class AgentRepository implements IAgentRepository {
constructor(
private db: Database,
private mapper: AgentMapper
) {}
async save(agent: Agent): Promise<void> {
const data = this.mapper.toPersistence(agent);
await this.db.run(`
INSERT OR REPLACE INTO agents (
id, type, status, capabilities, metrics, created_at, updated_at
) VALUES (?, ?, ?, ?, ?, ?, ?)
`, [
data.id,
data.type,
data.status,
JSON.stringify(data.capabilities),
JSON.stringify(data.metrics),
data.createdAt,
data.updatedAt
]);
}
async findById(id: AgentId): Promise<Agent | null> {
const row = await this.db.get(`
SELECT * FROM agents WHERE id = ?
`, [id.value]);
if (!row) return null;
return this.mapper.toDomain(row);
}
// ... other methods
}
// Mapper
export class AgentMapper {
toPersistence(agent: Agent): AgentPersistence {
// Map domain model to persistence model
}
toDomain(data: AgentPersistence): Agent {
// Reconstruct domain model from data
}
}
```
**API Layer - CLI (Sprint 6, Day 2-3)**
```typescript
// src-v3/agent-lifecycle/api/cli/spawn-agent-command.ts
export class SpawnAgentCommand implements Command {
constructor(
private agentService: AgentLifecycleService,
private outputter: IOutputter
) {}
async execute(args: SpawnAgentArgs): Promise<void> {
const spinner = this.outputter.spinner('Spawning agent...');
try {
const template = this.createTemplate(args);
const agentId = await this.agentService.spawnAgent(template);
spinner.succeed(`Agent spawned: ${agentId.value}`);
this.outputter.table([
['Agent ID', agentId.value],
['Type', template.type],
['Status', 'idle'],
['Capabilities', template.capabilities.join(', ')]
]);
} catch (error) {
spinner.fail('Failed to spawn agent');
throw error;
}
}
private createTemplate(args: SpawnAgentArgs): AgentTemplate {
return {
type: args.type as AgentType,
capabilities: this.parseCapabilities(args.capabilities),
// ... more fields
};
}
}
```
**API Layer - MCP (Sprint 6, Day 3-4)**
```typescript
// src-v3/agent-lifecycle/api/mcp/agent-tools.ts
export function createAgentTools(
agentService: AgentLifecycleService
): MCPTool[] {
return [
{
name: 'agent/spawn',
description: 'Spawn a new agent',
inputSchema: {
type: 'object',
properties: {
type: {
type: 'string',
enum: ['researcher', 'coder', 'analyst', /* ... */]
},
capabilities: {
type: 'array',
items: { type: 'string' }
}
},
required: ['type']
},
handler: async (input, context) => {
const template = this.parseTemplate(input);
const agentId = await agentService.spawnAgent(template);
return {
agentId: agentId.value,
status: 'spawned'
};
}
},
{
name: 'agent/terminate',
description: 'Terminate an agent',
inputSchema: {
type: 'object',
properties: {
agentId: { type: 'string' }
},
required: ['agentId']
},
handler: async (input) => {
await agentService.terminateAgent(AgentId.from(input.agentId));
return { status: 'terminated' };
}
},
{
name: 'agent/health',
description: 'Get agent health',
inputSchema: {
type: 'object',
properties: {
agentId: { type: 'string' }
},
required: ['agentId']
},
handler: async (input) => {
const health = await agentService.getAgentHealth(
AgentId.from(input.agentId)
);
return health.toJSON();
}
}
];
}
```
**Tests (Sprint 6, Day 4-5)**
```typescript
// Domain tests
describe('Agent', () => {
it('should create agent from template');
it('should spawn successfully');
it('should transition to busy when task assigned');
it('should return to idle when task completed');
it('should calculate health score correctly');
it('should emit domain events');
});
// Service tests
describe('AgentLifecycleService', () => {
it('should spawn agent via agentic-flow');
it('should save agent to repository');
it('should publish domain events');
it('should handle spawn errors');
it('should terminate agent cleanly');
});
// Integration tests
describe('Agent Lifecycle Integration', () => {
it('should spawn, assign task, and terminate agent');
it('should track agent metrics correctly');
it('should handle concurrent spawns');
});
```
**Deliverables (Sprints 5-6):**
- [ ] Agent domain model complete
- [ ] AgentLifecycleService implemented
- [ ] AgentRepository with SQLite backend
- [ ] CLI commands: spawn, terminate, list, health
- [ ] MCP tools: agent/spawn, agent/terminate, agent/health
- [ ] Comprehensive tests (>85% coverage)
- [ ] Integration with agentic-flow
---
### Sprints 7-8 (Weeks 7-8): Task Execution Domain
[Similar detailed breakdown for task execution domain]
---
### Sprints 9-10 (Weeks 9-10): Memory Management Domain
[Similar detailed breakdown for memory domain]
---
### Sprints 11-12 (Weeks 11-12): Coordination Engine
[Similar detailed breakdown for coordination]
---
## Team Structure
### Core Team (2-3 developers)
**Architect (1)**
- Define architecture
- Review PRs
- Make technical decisions
- Guide implementation
**Backend Developer (1-2)**
- Implement domains
- Write tests
- Performance optimization
- Integration with agentic-flow
**DevOps/Infrastructure (0.5)**
- CI/CD setup
- Build optimization
- Deployment automation
- Monitoring
### Community Contributors
**Documentation (2-3)**
- Write guides
- API documentation
- Examples
- Migration guides
**Testing (2-3)**
- Write tests
- Performance testing
- Integration testing
- Bug fixes
**Plugins (5-10)**
- Develop community plugins
- Test plugin system
- Provide feedback
---
## Risk Management
### Technical Risks
| Risk | Probability | Impact | Mitigation |
|------|------------|--------|------------|
| agentic-flow breaking changes | Medium | High | Pin version, maintain adapter layer |
| Performance regression | Low | High | Continuous benchmarking |
| Migration complexity | High | Medium | Automated tools, gradual rollout |
| Plugin system bugs | Medium | Medium | Extensive testing, beta program |
| Data migration failures | Low | Critical | Backup/restore, rollback plan |
### Project Risks
| Risk | Probability | Impact | Mitigation |
|------|------------|--------|------------|
| Scope creep | High | Medium | Strict prioritization, defer to v3.1 |
| Resource shortage | Medium | High | Community involvement, phased delivery |
| Timeline slippage | Medium | Medium | Buffer time, cut scope if needed |
| Adoption resistance | Low | High | Clear benefits, migration support |
---
## Success Criteria
### Functional
- [ ] All v2 features in v3
- [ ] Agent spawn/terminate/scale working
- [ ] Task creation/execution/monitoring working
- [ ] Memory store/retrieve/query working
- [ ] Multi-agent coordination working
- [ ] MCP tools fully functional
- [ ] CLI commands fully functional
### Performance
- [ ] Agent spawn <100ms (vs 500ms in v2)
- [ ] Task assignment <10ms (vs 50ms in v2)
- [ ] Memory query <5ms indexed
- [ ] CLI command response <200ms
- [ ] Throughput 100+ tasks/minute
### Quality
- [ ] Test coverage >85%
- [ ] Type coverage 100%
- [ ] Zero `any` types
- [ ] File size <500 lines average
- [ ] Cyclomatic complexity <15
### Adoption
- [ ] Migration guide complete
- [ ] 10+ beta testers successful
- [ ] 3+ community plugins
- [ ] 100+ GitHub stars
- [ ] Positive community feedback
---
## Appendices
### Appendix A: Code Size Reduction Plan
**Current v2:**
- Total: ~130,000 lines
- CLI: ~30,000 lines
- Core: ~25,000 lines
- Agents: ~15,000 lines
- Swarm: ~20,000 lines
- MCP: ~10,000 lines
- Specialized: ~30,000 lines
**Target v3:**
- Total: ~78,000 lines (40% reduction)
- Shared Kernel: ~5,000 lines
- Infrastructure: ~8,000 lines
- Agent Lifecycle: ~12,000 lines
- Task Execution: ~12,000 lines
- Memory Management: ~10,000 lines
- Coordination: ~11,000 lines
- Plugins (separate): ~20,000 lines
**Reduction Strategies:**
1. Eliminate duplicate code (4 coordination systems → 1)
2. Leverage agentic-flow (reduce orchestration code)
3. Decompose large files (index.ts 108KB → multiple small files)
4. Remove dead code
5. Plugin-ize optional features
### Appendix B: Performance Benchmarking
**Benchmark Suite:**
```typescript
// benchmarks/agent-spawn.bench.ts
import { bench, describe } from 'vitest';
describe('Agent Spawn Performance', () => {
bench('spawn single agent', async () => {
await agentService.spawnAgent(template);
});
bench('spawn 10 agents parallel', async () => {
await Promise.all(
Array(10).fill(null).map(() =>
agentService.spawnAgent(template)
)
);
});
bench('spawn 100 agents parallel', async () => {
// ...
});
});
// Run benchmarks
npm run benchmark
npm run benchmark:compare -- --base=v2 --compare=v3
```
**Target Performance:**
| Operation | v2 | v3 Target | Improvement |
|-----------|-----|-----------|-------------|
| Agent spawn | 500ms | <100ms | 5x |
| Task assign | 50ms | <10ms | 5x |
| Memory query (indexed) | 25ms | <5ms | 5x |
| Swarm init (10 agents) | 5s | <1s | 5x |
### Appendix C: Migration Tooling
**Automated Migration Script:**
```bash
#!/bin/bash
# scripts/migrate-v2-to-v3.sh
# Backup v2 data
echo "Backing up v2 data..."
cp claude-flow.db claude-flow-v2-backup.db
# Migrate configuration
echo "Migrating configuration..."
node scripts/migrate-config.js
# Migrate database schema
echo "Migrating database..."
node scripts/migrate-database.js
# Validate migration
echo "Validating migration..."
node scripts/validate-migration.js
echo "Migration complete! Review logs at migration.log"
```
**Migration Guide Template:**
```markdown
# Migrating from v2 to v3
## Overview
This guide helps you migrate your claude-flow installation from v2 to v3.
## Prerequisites
- Node.js 20+
- Backup of v2 data
- v2.x running successfully
## Step 1: Backup
```bash
# Backup data
cp claude-flow.db backup/
cp -r .claude/ backup/
```
## Step 2: Install v3
```bash
npm install claude-flow@3.0.0
```
## Step 3: Migrate Config
```bash
npx claude-flow migrate config
```
## Step 4: Migrate Data
```bash
npx claude-flow migrate data
```
## Step 5: Test
```bash
npx claude-flow test-migration
```
## Step 6: Switch
```bash
npx claude-flow activate v3
```
## Rollback
If issues occur:
```bash
npx claude-flow rollback v2
```
```
---
**Document Owner:** Architecture Team
**Last Updated:** 2026-01-03
**Next Review:** End of Phase 1 (Week 4)
---
**End of Migration Roadmap**