Files
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

2.4 KiB

SPEC-034-B: Experience Replay Buffer

Field Value
Specification ID SPEC-034-B
Parent ADR ADR-034
Version 1.0
Status Draft
Last Updated 2026-01-20
Author Architecture Team

Overview

This specification defines the Prioritized Experience Replay Buffer that stores and samples training experiences for the neural topology optimizer. Experiences are sampled based on TD error magnitude to prioritize learning from surprising transitions.


Experience Types

export interface Experience {
  state: number[];
  actionIdx: number;
  reward: number;
  nextState: number[];
  done: boolean;
  tdError: number;
}

PrioritizedReplayBuffer Implementation

export class PrioritizedReplayBuffer {
  private buffer: Experience[] = [];
  private capacity: number;

  constructor(capacity: number) {
    this.capacity = capacity;
  }

  push(exp: Experience): void {
    if (this.buffer.length >= this.capacity) {
      this.buffer.shift();
    }
    this.buffer.push(exp);
  }

  /** Sample prioritized by TD error */
  sample(batchSize: number): Experience[] {
    // Sort by absolute TD error (higher error = more learning potential)
    const sorted = [...this.buffer].sort((a, b) =>
      Math.abs(b.tdError) - Math.abs(a.tdError)
    );
    return sorted.slice(0, batchSize);
  }

  get length(): number {
    return this.buffer.length;
  }
}

Validation Rules

Rule ID Description Severity
SPEC-034-B-001 capacity must be > 0 Error
SPEC-034-B-002 batchSize must be <= buffer length Warning
SPEC-034-B-003 Experience state arrays must be same size Error

Spec ID Title Relationship
SPEC-034-A Value Network Generates TD errors
SPEC-034-C Neural Optimizer Uses replay buffer

Changelog

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

References