Files
proffesor-for-testing__agen…/docs/implementation/stream-d-quick-reference.md
Dragan Spiridonov 346438f0de Release v2.0.0: Claude 4.5 Optimization, QUIC Transport, 29 Agent Compaction (#100)
* SwarmMemoryManager Refactoring Plan

* fix: add missing directories to npm package (v1.9.3)

Added templates/, .claude/helpers/, and docs/reference/ to package.json
files array. These were missing from the npm distribution, causing
`aqe init` to fail with "Template file not found" errors.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* checkpoint improvements

* fix: critical memory/learning system fixes for v1.9.4

## Critical Fixes
- Vector embeddings now stored correctly (was storing NULL)
- SQL parameter style fixed for agentdb's SqlJsDatabase wrapper
- HNSW index schema mismatch resolved with pattern_id column
- Hooks now save to correct database (.agentic-qe/agentdb.db)

## New Features
- Added 5 SwarmMemoryManager methods for learning data retrieval:
  - getBestAction() - Q-learning best action selection
  - getRecentLearningExperiences() - Recent experience retrieval
  - getLearningExperiencesByTaskType() - Task-filtered experiences
  - getHighRewardExperiences() - Successful experience extraction
  - getLearningStats() - Aggregate learning statistics
- Added comprehensive integration test for memory/learning loop
- Added RuVector pattern store integration (experimental)

## Technical Details
- Vector embeddings: 384 dimensions × 4 bytes = 1,536 bytes per pattern
- All 12 integration tests pass
- HNSW index: 150x faster vector search enabled

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: move ARM64-only ruvector packages to optionalDependencies

Fixes CI failures caused by platform-specific dependencies:
- @ruvector/node-linux-arm64-gnu (ARM64 only)
- ruvector-core-linux-arm64-gnu (ARM64 only)

These packages caused npm ci to fail on x64 CI runners with:
"EBADPLATFORM - wanted linux/arm64, current linux/x64"

Solution: Move ARM64 packages to optionalDependencies and add
x64 variants for cross-platform compatibility.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* chore: regenerate package-lock.json with x64 ruvector packages

Updates lockfile to include optional x64 platform packages for
CI compatibility:
- @ruvector/node-linux-x64-gnu@0.1.17
- ruvector-core-linux-x64-gnu@0.1.15

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: replace fake QUIC with proper implementation and clean up skills manifest

QUIC Transport:
- Remove fake HTTP/2-based QUICTransport.ts that pretended to be QUIC
- Add proper QUIC implementation via Rust/WASM (@agentic-flow/quic-wasm)
- Add WebSocket fallback transport for when WASM unavailable
- Add dedicated type declarations for optional WASM module
- Features: 0-RTT connection, stream multiplexing, TLS 1.3 built-in

Skills Manifest:
- Rewrite skills-manifest.json with only QE skills (41 skills)
- Remove Claude Flow platform skills (agentdb-*, flow-nexus-*, github-*, etc.)
- Organize into proper categories: qe-core, testing-methodologies, etc.

Bug Fixes:
- Fix UnifiedMemoryCoordinator.ts TypeScript errors
- Use Logger.getInstance() instead of private constructor
- Use swarmMemory.query() instead of non-existent list() method
- Use correct close() method signatures for backends

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* feat: add QX Partner agent, compact subagents, fix CLAUDE.md dynamic counts

- Add QX Partner agent for Quality Experience analysis combining QA + UX perspectives
- Compact 9 subagent definitions to ~80 lines each (88% reduction)
- Fix CLAUDE.md template to dynamically count agents (including subagents) and skills
- Move CLAUDE.md creation after parallel phases for accurate counts
- Remove 'Production-Ready' claim from README and CHANGELOG
- Clean up backup files and move docs to proper directory

Initialization now correctly reports:
- 31 QE Agents (20 main + 11 subagents)
- 53 QE Skills
- 8 Slash Commands

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-02 11:31:30 +01:00

6.9 KiB

SwarmOptimizer Quick Reference

Import

import { SwarmOptimizer, Task, Agent } from './core/optimization';
import type {
  OptimizationConfig,
  WorkloadProfile,
  TopologyRecommendation,
  AgentAllocation,
  PerformanceMetrics,
  Bottleneck,
  OptimizationResult
} from './core/optimization';

Initialization

const optimizer = new SwarmOptimizer(memoryStore, eventBus);
await optimizer.initialize();

Core Methods

1. Recommend Topology

const workload: WorkloadProfile = {
  taskCount: 50,
  taskTypes: new Map([['test-generation', 30]]),
  averageComplexity: 0.6,      // 0-1
  parallelizability: 0.8,      // 0-1
  resourceIntensity: 0.5,      // 0-1
  interdependencies: 0.3       // 0-1
};

const recommendation = await optimizer.recommendTopology(workload);
console.log(recommendation.topology);        // 'mesh' | 'hierarchical' | 'ring' | 'star'
console.log(recommendation.expectedSpeedup); // e.g., 3.2
console.log(recommendation.confidence);      // 0-1

2. Allocate Agents

const tasks: Task[] = [{
  id: 'task-1',
  type: 'test-generation',
  complexity: 0.7,
  estimatedDuration: 120000,
  dependencies: [],
  priority: 'critical',
  requiredCapabilities: ['jest']
}];

const agents: Agent[] = [{
  id: 'agent-1',
  type: 'qe-test-generator',
  capabilities: ['jest', 'typescript'],
  currentLoad: 0.2,
  performanceScore: 0.85,
  isAvailable: true
}];

const allocation = await optimizer.allocateAgents(tasks, agents);
console.log(allocation.loadBalance);        // 0-1 (1 = perfect)
console.log(allocation.expectedDuration);   // milliseconds

3. Detect Bottlenecks

const metrics: PerformanceMetrics[] = [{
  taskThroughput: 3.2,         // tasks/second
  averageLatency: 2500,        // milliseconds
  resourceUtilization: 0.88,   // 0-1
  bottlenecks: [],
  timestamp: new Date()
}];

const bottlenecks = await optimizer.detectBottlenecks(metrics);
for (const b of bottlenecks) {
  console.log(b.type);          // 'agent' | 'memory' | 'coordination' | 'io'
  console.log(b.severity);      // 0-1
  console.log(b.recommendation);
}

4. Optimize

const config: OptimizationConfig = {
  targetSpeedup: 3.0,
  maxAgents: 10,
  enableAutoTuning: true,
  enableBottleneckDetection: true,
  enableAdaptiveScaling: true
};

const result = await optimizer.optimize(config);
if (result.success) {
  console.log(result.improvements.get('throughput'));  // % improvement
  console.log(result.improvements.get('latency'));
  console.log(result.improvements.get('overall'));
}

Helper Methods

// Register components
optimizer.registerPerformanceTracker(agentId, tracker);
optimizer.registerLearningEngine(agentId, engine);

// Query state
const history = optimizer.getOptimizationHistory();
const topology = optimizer.getCurrentTopology();

// Cleanup
await optimizer.shutdown();

Topology Decision Matrix

Workload Recommended Why
High parallelizability (>0.7) mesh Best parallel execution
High interdependencies (>0.6) hierarchical Better coordination
Small swarm (<10 agents) star Simple coordination
Medium complexity ring Balanced approach

Bottleneck Thresholds

Type Trigger Severity Calculation
Agent Utilization > 85% (util - 0.85) / 0.15
Memory Util > 75% AND Latency > 1s latency / 5000
Coordination Latency variance > 50% avg variance / (avgLatency * 2)
IO Throughput < 5 AND Util < 50% (0.5 - util) * 2

Performance Scoring

Composite Score =
  normalizedThroughput * 0.4 +
  normalizedLatency * 0.3 +
  normalizedUtilization * 0.3

Where:
  normalizedThroughput = min(1, throughput / 10)
  normalizedLatency = max(0, 1 - (latency / 5000))
  normalizedUtilization = utilization

Memory Keys

optimization/topology/latest         - Latest recommendation
optimization/allocation/latest       - Latest allocation
optimization/bottlenecks/latest      - Latest bottlenecks
optimization/results/{timestamp}     - Results (30d TTL)
optimization/metrics/current         - Current metrics
optimization/workload/profile        - Workload analysis
optimization/tasks/pending           - Pending tasks
optimization/agents/active           - Active agents

Event Integration

// Subscribe to events
eventBus.subscribe('agent:completed', async (event) => {
  // Optimizer handles automatically if registered
});

// Manual trigger
await eventBus.emitAsync('optimization:needed', {
  reason: 'bottleneck-detected'
});

Common Patterns

Auto-Optimization Loop

setInterval(async () => {
  const metrics = await collectMetrics();
  const bottlenecks = await optimizer.detectBottlenecks(metrics);

  if (bottlenecks.some(b => b.severity > 0.5)) {
    await optimizer.optimize(config);
  }
}, 60000); // every minute

Workload-Based Initialization

async function initializeSwarm(taskQueue: Task[]) {
  const workload = analyzeTaskQueue(taskQueue);
  const topology = await optimizer.recommendTopology(workload);

  // Initialize swarm with recommended topology
  await swarm.init(topology.topology);

  const agents = await swarm.getAgents();
  const allocation = await optimizer.allocateAgents(taskQueue, agents);

  // Assign tasks based on allocation
  for (const [agentId, taskIds] of allocation.allocations) {
    await swarm.assignTasks(agentId, taskIds);
  }
}

Real-time Bottleneck Monitoring

async function monitorBottlenecks() {
  const metrics: PerformanceMetrics[] = [];

  eventBus.subscribe('test:completed', (event) => {
    metrics.push({
      taskThroughput: event.passed / event.duration,
      averageLatency: event.duration,
      resourceUtilization: getCurrentUtilization(),
      bottlenecks: [],
      timestamp: new Date()
    });
  });

  setInterval(async () => {
    if (metrics.length > 10) {
      const bottlenecks = await optimizer.detectBottlenecks(metrics);
      if (bottlenecks.length > 0) {
        console.warn('Bottlenecks detected:', bottlenecks);
      }
      metrics.length = 0; // reset
    }
  }, 30000);
}

Best Practices

  1. Run topology recommendation before swarm initialization
  2. Update allocations when task queue changes significantly
  3. Monitor bottlenecks continuously during execution
  4. Store optimization results for later analysis
  5. Register performance trackers for accurate metrics
  6. Use adaptive scaling for dynamic workloads
  7. Enable auto-tuning for production deployments

Error Handling

try {
  const result = await optimizer.optimize(config);
  if (!result.success) {
    console.error('Optimization failed');
    // Fallback to default configuration
  }
} catch (error) {
  console.error('Optimizer error:', error);
  // Use previous optimization or defaults
}