Files
proffesor-for-testing__agen…/docs/implementation/specs/SPEC-047-A-mincut-architecture.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

7.8 KiB

SPEC-047-A: MinCut Architecture

Field Value
Specification ID SPEC-047-A
Parent ADR ADR-047
Version 1.0
Status Implemented
Last Updated 2026-01-17
Author Architecture Team

Overview

Defines the architecture for integrating RuVector MinCut patterns into AQE v3, including integration points with Queen Coordinator, 12 DDD domains, GOAP Planner, and Dream Engine.


Specification Details

Section 1: RuVector MinCut Patterns

Pattern Performance Core Capability
Strange Loop ~50us updates Self-observation -> Model -> Decide -> Act cycle
Morphogenetic Networks O(log n) scaling Bio-inspired growth via signal diffusion
Temporal Attractors Real-time Networks evolving toward stable states
Causal Discovery STDP-based Granger causality for root cause identification
Time Crystal Coordination Self-sustaining Periodic patterns without external schedulers
Neural Optimizer 100x faster Hybrid ML + exact algorithms

Section 2: Integration Architecture

+----------------------------------------------------------------+
|                     AQE v3 + MinCut Architecture                |
+----------------------------------------------------------------+
|                                                                 |
|  +----------------------------------------------------------+  |
|  |                   Queen Coordinator                       |  |
|  |                   (ADR-008)                               |  |
|  |  +-----------------------------------------------------+  |  |
|  |  |  MinCut Health Monitor (P0)                         |  |  |
|  |  |  - Swarm topology graph                             |  |  |
|  |  |  - Real-time MinCut calculation                     |  |  |
|  |  |  - Connectivity threshold alerts                    |  |  |
|  |  +-----------------------------------------------------+  |  |
|  |                          |                                |  |
|  |  +-----------------------------------------------------+  |  |
|  |  |  Strange Loop Self-Healer (P1)                      |  |  |
|  |  |  - SwarmObserver (observe topology)                 |  |  |
|  |  |  - SelfModel (predict weaknesses)                   |  |  |
|  |  |  - HealingController (spawn agents)                 |  |  |
|  |  +-----------------------------------------------------+  |  |
|  +----------------------------------------------------------+  |
|                              |                                  |
|           +------------------+------------------+               |
|           v                  v                  v               |
|  +------------+    +------------+    +------------+             |
|  | Test Gen   |    | Test Exec  |    | Coverage   |             |
|  | Domain     |    | Domain     |    | Domain     |             |
|  |            |    |            |    |            |             |
|  | Morpho-    |    | Time       |    | Causal     |             |
|  | genetic    |    | Crystal    |    | Discovery  |             |
|  | Growth (P3)|    | Sched (P4) |    | (P2)       |             |
|  +------------+    +------------+    +------------+             |
|                              |                                  |
|  +----------------------------------------------------------+  |
|  |                    GOAP Planner (ADR-046)                 |  |
|  |  +-----------------------------------------------------+  |  |
|  |  |  Neural Plan Optimizer (P5)                         |  |  |
|  |  |  - Q-learning for action costs                      |  |  |
|  |  |  - Replay buffer for plan improvement               |  |  |
|  |  +-----------------------------------------------------+  |  |
|  +----------------------------------------------------------+  |
|                              |                                  |
|  +----------------------------------------------------------+  |
|  |                   Dream Engine (ADR-046)                  |  |
|  |  +-----------------------------------------------------+  |  |
|  |  |  Dream x Strange Loop Meta-Learning (P6)            |  |  |
|  |  |  - Hypothetical scenario generation                 |  |  |
|  |  |  - Strange Loop hypothesis testing                  |  |  |
|  |  |  - Temporal Attractor convergence                   |  |  |
|  |  +-----------------------------------------------------+  |  |
|  +----------------------------------------------------------+  |
|                                                                 |
+----------------------------------------------------------------+

Section 3: Key Algorithms

MinCut Calculation

// Approximate min-cut using minimum weighted degree
function approxMincut(graph: SwarmGraph): number {
  return Math.min(...graph.vertices.map(v => graph.weightedDegree(v)));
}

Strange Loop Cycle

// Observe -> Model -> Decide -> Act
function think(swarm: MetaSwarm): boolean {
  // Step 1: Observe self
  const mincut = swarm.graph.approxMincut();
  const weakVertices = swarm.graph.findWeakVertices();

  // Step 2: Update self-model
  swarm.selfModel.update(mincut, weakVertices);

  // Step 3: Decide reorganization
  const action = swarm.decide();

  // Step 4: Apply action
  swarm.applyAction(action);

  return swarm.checkConvergence();
}

Morphogenetic Growth

// Bio-inspired growth rules
function grow(node: TestNode, signal: number): GrowthAction {
  const degree = node.connections.length;

  // Low connectivity -> spawn new test
  if (signal > 0.5 && degree < 3) return { type: 'spawn' };

  // High degree -> branch/specialize
  if (signal > 0.6 && degree > 5) return { type: 'branch' };

  // Weak cut -> reinforce
  if (signal > 0.4 && node.localMincut < 2.0) return { type: 'reinforce' };

  return { type: 'stable' };
}

File Structure

v3/src/coordination/mincut/
+-- mincut-calculator.ts      # Graph algorithms
+-- mincut-health-monitor.ts  # Queen integration
+-- strange-loop-healer.ts    # Self-healing controller
+-- index.ts

v3/src/domains/test-generation/morphogenetic/
+-- growth-signals.ts         # Signal diffusion
+-- test-spawner.ts           # Organic test creation
+-- index.ts

v3/src/domains/defect-intelligence/causal/
+-- causal-graph.ts           # Failure propagation
+-- root-cause-finder.ts      # STDP-enhanced discovery
+-- index.ts

v3/src/planning/neural-optimizer/
+-- q-value-planner.ts        # RL for GOAP costs
+-- plan-replay-buffer.ts     # Experience replay
+-- index.ts

Validation Rules

Rule ID Description Severity
SPEC-047-A-001 MinCut calculation must complete in <50us Error
SPEC-047-A-002 Strange Loop cycle must complete in <100ms Error
SPEC-047-A-003 All modules must have corresponding tests Warning

Spec ID Title Relationship
SPEC-047-B Phase Implementation Implementation details
SPEC-047-C Performance Metrics Achieved metrics

Changelog

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

References