Files
proffesor-for-testing__agen…/docs/implementation/specs/SPEC-031-C-implementation-plan.md
Profa 2253d05618 feat: flatten project structure — archive v2, promote v3 to root
Remove the nested v3/ subdirectory by moving all active source code,
tests, configs, and assets directly to the project root. Archive v2/
(dead code, 847MB) to v2-archive.tar.gz.

Key changes:
- Move v3/src/ → src/, v3/tests/ → tests/, v3/packages/ → packages/
- Move v3/tsconfig.json, v3/vitest.config.ts to root
- Merge v3/package.json into root package.json (ESM, scripts, deps, exports)
- Merge v3/scripts/ into scripts/, v3/implementation/ into docs/implementation/
- Update all CI workflows to remove "cd v3 &&" and v3/ path prefixes
- Fix all init installer path resolution (3-level-up → 2-level-up)
- Fix hooks to use "node ./dist/cli/bundle.js" instead of bare "aqe"
- Update settings.json ADR/DDD directories to docs/implementation/
- Fix helper scripts (statusline, adr-compliance, ddd-tracker, guidance-hooks)
- Update 58 agent definitions: aqe/v3/ → aqe/ memory namespaces
- Update 15 guidance shards: v3/src/ → src/ path references
- Fix sync interfaces: remove v3/ and v2/ path references
- Fix test path calculations (process.cwd() + '..' no longer needed)
- Fix flaky perf test threshold (500ms → 1000ms for CI environments)
- Fix complexity-analyzer test to match ADR-051 keyword-based eligibility

Build passes, 17,901 tests pass, CLI and MCP bundles verified.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 11:35:41 +00:00

3.6 KiB

SPEC-031-C: Implementation Plan

Field Value
Specification ID SPEC-031-C
Parent ADR ADR-031
Version 1.0
Status Accepted
Last Updated 2026-01-10
Author Architecture Team

Overview

Defines the phased implementation plan for Strange Loop self-awareness, including file structure, success metrics, and integration points with existing swarm coordinators.


Specification Details

Section 1: File Structure

v3/src/strange-loop/
+-- index.ts
+-- types.ts
+-- swarm-observer.ts        # Collect swarm state
+-- topology-analyzer.ts     # Analyze graph structure
+-- min-cut-calculator.ts    # Find bottlenecks
+-- self-model.ts            # SwarmSelfModel
+-- trend-analyzer.ts        # Predict vulnerabilities
+-- history-store.ts         # Observation persistence
+-- healing-controller.ts    # SelfHealingController
+-- action-executor.ts       # Execute healing actions
+-- strange-loop.ts          # StrangeLoopOrchestrator

Section 2: Implementation Phases

Phase 1: Observer Module (Days 1-2)

  • swarm-observer.ts - Collect swarm state
  • topology-analyzer.ts - Analyze graph structure
  • min-cut-calculator.ts - Find bottlenecks
  • types.ts - Core type definitions

Phase 2: Self-Model (Day 3)

  • self-model.ts - SwarmSelfModel implementation
  • trend-analyzer.ts - Predict vulnerabilities
  • history-store.ts - Observation persistence

Phase 3: Self-Healing (Days 4-5)

  • healing-controller.ts - SelfHealingController
  • action-executor.ts - Execute healing actions
  • strange-loop.ts - StrangeLoopOrchestrator
  • index.ts - Barrel exports

Section 3: Success Metrics

Metric Target
Swarm observation frequency Every 5 seconds
Bottleneck detection latency <100ms
Self-healing action execution <1s
Trend prediction accuracy >70%
Human intervention required 0 for common issues
Unit test coverage 60+ tests

Section 4: Integration Points

Queen Coordinator Integration

// In queen-coordinator.ts
import { StrangeLoopOrchestrator } from '../strange-loop';

export class QueenCoordinator {
  private strangeLoop: StrangeLoopOrchestrator;

  async initialize(): Promise<void> {
    this.strangeLoop = new StrangeLoopOrchestrator(this.swarm);
    await this.strangeLoop.start();
  }

  async onSelfBottleneckDetected(): Promise<void> {
    console.log('[Queen] I am a bottleneck. Promoting workers to sub-coordinators.');
    await this.promoteWorkersToCoordinators();
  }
}

Validation Rules

Rule ID Description Severity
SPEC-031-C-001 All phases must complete before production deployment Error
SPEC-031-C-002 60+ unit tests required before approval Error
SPEC-031-C-003 Integration tests with Queen Coordinator required Warning

Spec ID Title Relationship
SPEC-031-A Self-Observation Protocol Technical specification
SPEC-031-B Self-Healing Controller Controller specification

Changelog

Version Date Author Changes
1.0 2026-01-10 Architecture Team Initial specification

References