Files
proffesor-for-testing__agen…/.github/workflows/optimized-ci.yml
Dragan Spiridonov a6202c39a3 chore(release): v3.9.1 (#395)
* feat: implement ADR-062 (StrongDM all 3 tiers) and ADR-087 (RuVector 14/14 capabilities)

ADR-062 StrongDM Software Factory — all 6 actions across 3 tiers:
- Tier 1: Loop detection wired to MCP protocol-server (blocks on strike 3+),
  token dashboard (pre-existing)
- Tier 2: Holdout testing (10% FNV-1a selection, filtered in test-execution),
  gate ratcheting (monotonic 5-pass/2%/95% cap, persisted to MemoryBackend)
- Tier 3: Progressive context (TF-IDF prediction, reduces availableFiles on spawn),
  meta-learning cycle (4 insight types, stored + published as domain events)

ADR-087 RuVector Advanced Capabilities — milestones 1-5:
- EWC++ recordOutcome + backgroundConsolidate wired to 3 domain coordinators
- R1: HDC fingerprinting (10K-bit hypervectors, wired to PatternStore.store())
- R3: Delta event sourcing (sparse encoding, wired to PatternStore.store())
- R13: Cognitive routing (predictive compression, wired to mailbox.send/receive)
- R14: Hyperbolic HNSW (Poincare ball, auto-indexed in PatternStore.store())

Also updates ADR statuses: 059, 060, 061 → Implemented (were already done),
062 → Implemented, 086 → In Progress, 087 → Implemented.

223 new tests across 11 test files, all passing. Zero regressions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat: implement RVF cluster (ADR-065/066/067/071) with native benchmarks

Implements the RVF persistence cluster for persistent HNSW vector storage,
agent memory branching, and HNSW unification foundation.

Key changes:
- RvfPatternStore: IPatternStore backed by @ruvector/rvf-node native HNSW
  (1.2ms cold-start, 0.19ms search p50, verified with real native binary)
- AgentMemoryBranch: per-agent COW isolation via derive(), ingest-log merge,
  wired into Kernel.initialize() + DefaultAgentCoordinator
- HnswLegacyBridge: adapts old IHNSWIndex to unified IHnswIndexProvider,
  wired into PatternStore when useUnifiedHnsw flag enabled
- Factory routing: createPatternStore() returns RvfPatternStore when flag
  enabled + native available + data directory exists
- Dream engine: accepts external RVF adapter (no duplicate file handles),
  RVCOWBranchManager enhanced with recall validation check
- @ruvector/gnn bumped 0.1.19→0.1.25, 3 new feature flags added
- IPatternStore interface extracted for polymorphic pattern store usage
- 50 new tests (16 RvfPatternStore + 17 AgentMemoryBranch + 12 bridge + 5 benchmarks)
- 1188 tests pass, 0 regressions

ADR status: 066 Implemented, 067 Implemented, 065 Implemented,
069/071 In Progress (honest assessment after brutal-honesty review)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(init): resolve skills/agents paths from package root, not relative to bundle depth

esbuild code-splitting puts installer code into dist/cli/chunks/ (3 levels
deep) instead of dist/init/ (2 levels deep), so the old ../../ traversals
landed at dist/ instead of the package root — causing "Source directory not
found" errors for all global installs.

Replace brittle relative-path resolution in all 4 installers with a shared
findPackageRoot() that walks up to the nearest package.json with
name=agentic-qe. Prioritise assets/ paths (canonical npm source) over
.claude/ paths.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat: complete RVF cluster Phases 2-3 (ADR-067/069/071/072) with devil's advocate fixes

Phase 2A (ADR-067): Agent memory branching enabled — useAgentMemoryBranching=true,
BRANCH_DISCARD witness action, recordIngest callback exposed to agents via config.

Phase 2B (ADR-069): Dream RVF COW — useRvfFork driven by isRVFPatternStoreEnabled(),
child adapter stored + temp files cleaned up on merge/discard, 13 tests.

Phase 2C (ADR-071): HNSW unification — useUnifiedHnsw=true, HNSWEmbeddingIndex routes
through HnswAdapter, UnifiedMemory vectorIndex uses UnifiedHnswIndex, HnswLegacyBridge
delegates to adapter string-ID APIs (no duplicate ID maps), addEmbeddingsBatch routed
correctly, saveIndex/loadIndex safe under unified mode.

Phase 3 (ADR-072): RVF primary migration scaffolding — RvfMigrationAdapter (5-stage
routing with write latency tracking), RvfConsistencyValidator (rolling divergence +
compaction), RvfStageGate (go/no-go with witness chain), rvfMigrationStage=1 default,
wired into shared-rvf-dual-writer at stage >= 2, 32 tests.

Cross-cutting fixes from devil's advocate review:
- Shared RVF adapter singleton eliminates dual file handles (kernel + dream engine)
- RvfPatternStore reports honest nativeAvailable=false + rvfInitError on failure
- ESM-safe dynamic import() replaces require() in dream-engine and branch-manager
- quality_assess defaults to src/ instead of cwd to prevent full-project scan hang
- discoverSourceFiles skips .agentic-qe/.claude/.cache dirs, adds maxFiles=5000 cap

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat: complete RVF cluster plan — Phase 2C decommission, Phase 3 integration, fix 7 pre-existing test failures

Phase 2C (ADR-071) — HNSW decommission:
- Remove RuvectorFlatIndex fallback from unified-memory.ts; always use UnifiedHnswIndex
- Hardcode isUnifiedHnswActive()=true in HNSWEmbeddingIndex (hnswlib-node legacy path is dead code)
- Create HnswShadowValidator for brute-force vs HnswAdapter divergence validation
- Benchmark alias (rvf-pattern-store.bench.ts) for plan compliance

Phase 3 (ADR-072) — RVF Primary Migration integration:
- RvfMigrationCoordinator: wires adapter + validator + gate with real SQLite/RVF handles
- MCP tools: migration_status, migration_check, migration_promote (persistence category)
- Kernel boot wiring: coordinator initializes when rvfMigrationStage >= 2
- RvfMigrationAdapter.setStage(): propagate promotions to routing logic
- Promote default rvfMigrationStage from 1 (hybrid) to 2 (dual-write-sqlite-primary)
- Integration test: 13 tests covering full lifecycle (stage 1→2→3→4), write/read routing,
  consistency checks, gate enforcement, fallback, metrics

Test fixes (7 pre-existing failures → 1 remaining):
- code-intelligence-metrics-wiring: spy console.info not console.log (logger routes to console.info)
- mcp-integration: disable ADR-062 loop detection (repeated identical calls are by design)
- dream-cycle-tool (2 tests): RvfPatternStore empty-query branch returns all patterns from SQLite
- coherence-integration (4 tests): RvfPatternStore vector search fallback computes brute-force
  cosine over SQLite embeddings when RVF adapter unavailable; getStats() falls back to SQLite count;
  auto-attach SQLitePatternStore in initialize() when not explicitly wired

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* chore(release): bump version to v3.9.1

- Version bump in package.json and skills-manifest.json
- Fix "Dynamic require of X is not supported" in ESM bundles by adding
  createRequire banner to both CLI and MCP build scripts — every chunk
  now has a working require() for Node.js builtins
- Add CHANGELOG.md entry and release notes for v3.9.1

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(ci): regenerate package-lock.json for npm ci compatibility

The lock file was out of sync with package.json — new transitive
dependencies added on main were missing. All 15 CI checks failed
at `npm ci` with "Missing from lock file" errors.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(ci): pin Node to 24.13.0 and restore working lock file

Node 24.14.1 ships npm 11.11.0 which enforces stricter lock file
validation than 11.6.x (what 24.13.0 ships). The existing lock file
passes under 11.6.x but fails under 11.11.0 with "Missing from lock
file" for transitive dependencies of private-registry packages.

Pin all 5 workflow files to node-version: '24.13.0' and restore the
lock file from commit f9b76968 (last CI-passing state) with only the
version bump to 3.9.1.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(ci): regenerate package-lock.json with npm 10 for stable npm ci

npm 11 (Node 24) produces internally inconsistent lock files that npm ci
rejects — each npm install resolves transitive deps differently. Generated
with npm 10 (Node 22 LTS) which produces stable lock files compatible with
both npm 10 and npm 11.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-05 18:51:49 +02:00

389 lines
14 KiB
YAML

name: Optimized CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
workflow_dispatch:
# On PRs: cancel stale runs when a new push arrives (old run is obsolete).
# On main: never cancel — every push must run to completion for accurate CI signal.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
actions: write
pull-requests: write
checks: write
# ─── Shared exclusions for journey test shards ───
# The original test:journeys:ci command excludes these directories:
# browser, browser-integration, mcp, sync, learning, domains, llm, n8n, *.e2e.test.ts
# By targeting specific subdirectories per shard, most exclusions are implicit.
# Only the "remaining" shard needs explicit excludes.
jobs:
# ─── Journey Tests: 4 parallel shards ───
# Previously a single 25-min job that timed out. Now 4 shards of ~5-8 min each.
journey-governance:
name: Journey — Governance
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: '24.13.0', cache: 'npm' }
- run: npm ci
- run: npm run build
- name: Run governance integration tests
run: timeout 480 npx vitest run tests/integration/governance/ --reporter=verbose
env:
NODE_OPTIONS: '--max-old-space-size=1024'
journey-ruvector-coordination:
name: Journey — RuVector + Coordination
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: '24.13.0', cache: 'npm' }
- run: npm ci
- run: npm run build
- name: Run ruvector + coordination integration tests
run: bash scripts/ci-vitest-run.sh tests/integration/ruvector/ tests/integration/coordination/ --reporter=verbose
env:
NODE_OPTIONS: '--max-old-space-size=1024'
journey-root:
name: Journey — Root-level
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: '24.13.0', cache: 'npm' }
- run: npm ci
- run: npm run build
- name: Run root-level integration tests
run: |
# Run only test files directly in tests/integration/ (not in subdirectories)
FILES=$(find tests/integration -maxdepth 1 -name '*.test.ts' ! -name '*.e2e.test.ts' | sort)
if [ -n "$FILES" ]; then
bash scripts/ci-vitest-run.sh $FILES --reporter=verbose
else
echo "No root-level integration tests found"
fi
env:
NODE_OPTIONS: '--max-old-space-size=1024'
journey-remaining:
name: Journey — Remaining Subdirs
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: '24.13.0', cache: 'npm' }
- run: npm ci
- run: npm run build
- name: Run remaining integration subdirectory tests
run: |
# Everything in tests/integration subdirs EXCEPT the ones covered by
# other shards (governance, ruvector, coordination) and the original
# exclusions (browser, mcp, sync, learning, domains, llm, n8n).
bash scripts/ci-vitest-run.sh \
tests/integration/adapters/ \
tests/integration/cli/ \
tests/integration/code-intelligence/ \
tests/integration/feedback/ \
tests/integration/migration/ \
tests/integration/opencode/ \
tests/integration/parsers/ \
tests/integration/planning/ \
tests/integration/protocols/ \
tests/integration/requirements-validation/ \
tests/integration/rl-suite/ \
tests/integration/rvf/ \
tests/integration/security/ \
tests/integration/templates/ \
tests/integration/test-execution/ \
tests/integration/test-generation/ \
tests/integration/validation/ \
--reporter=verbose
env:
NODE_OPTIONS: '--max-old-space-size=1024'
# ─── Contract + Code Intelligence: separate parallel jobs ───
contract-tests:
name: Contract Tests
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: '24.13.0', cache: 'npm' }
- run: npm ci
- run: npm run build
- name: Run contract tests
run: |
if [ -d "tests/unit/domains/contract-testing" ] && [ "$(ls -A tests/unit/domains/contract-testing/*.test.ts 2>/dev/null)" ]; then
timeout 480 npm run test:contracts
else
echo "No contract tests found"
fi
env:
NODE_OPTIONS: '--max-old-space-size=512'
code-intelligence-tests:
name: Code Intelligence Tests
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: '24.13.0', cache: 'npm' }
- run: npm ci
- run: npm run build
- name: Run code intelligence tests
run: timeout 480 npm run test:code-intelligence
env:
NODE_OPTIONS: '--max-old-space-size=768'
SKIP_INTEGRATION_TESTS: 'true'
# ─── Infrastructure tests (unchanged, already parallel) ───
infrastructure-tests:
name: Infrastructure Tests
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: '24.13.0', cache: 'npm' }
- run: npm ci
- run: npm run build
- name: Run Infrastructure Tests
run: |
if [ -d "tests/infrastructure" ] && [ "$(ls -A tests/infrastructure/*.test.ts 2>/dev/null)" ]; then
timeout 480 npm run test:infrastructure
else
echo "No infrastructure tests found"
fi
env:
NODE_OPTIONS: '--max-old-space-size=768'
- name: Run Regression Tests
run: |
if [ -d "tests/regression" ] && [ "$(find tests/regression -name '*.test.ts' 2>/dev/null | head -1)" ]; then
timeout 480 npm run test:regression
else
echo "No regression tests found"
fi
env:
NODE_OPTIONS: '--max-old-space-size=512'
# ─── Postgres integration tests (unchanged) ───
integration-tests:
name: Postgres Integration Tests
runs-on: ubuntu-latest
timeout-minutes: 10
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_DB: aqe_test
POSTGRES_USER: aqe_test
POSTGRES_PASSWORD: aqe_test
ports:
- 15432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: '24.13.0', cache: 'npm' }
- run: npm ci
- run: npm run build
- name: Run Postgres integration tests
run: timeout 480 npm run test:integration:pg
env:
POSTGRES_URL: postgresql://aqe_test:aqe_test@localhost:15432/aqe_test
NODE_OPTIONS: '--max-old-space-size=1024'
# ─── Performance gates (after journey shards complete) ───
performance-gates:
name: Performance Gates
runs-on: ubuntu-latest
needs: [journey-governance, journey-ruvector-coordination, journey-root, journey-remaining, contract-tests, code-intelligence-tests]
if: success()
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: '24.13.0', cache: 'npm' }
- run: npm ci
- run: npm run build
- name: Run Performance Gates
id: perf-gates
run: |
timeout 480 npm run performance:gate > perf-report.md 2>&1 || PERF_EXIT=$?
echo "PERF_EXIT_CODE=${PERF_EXIT:-0}" >> $GITHUB_OUTPUT
cat perf-report.md
- uses: actions/upload-artifact@v4
if: always()
with:
name: performance-report
path: perf-report.md
retention-days: 30
- name: Check performance gate results
run: |
EXIT_CODE="${{ steps.perf-gates.outputs.PERF_EXIT_CODE }}"
if [ "$EXIT_CODE" -eq 0 ]; then
echo "All performance gates passed"
elif [ "$EXIT_CODE" -eq 2 ]; then
echo "Performance gates passed with warnings"
else
echo "Performance gates failed (exit code: $EXIT_CODE)"
if [ "$EXIT_CODE" -eq 1 ]; then
exit 1
fi
fi
# ─── Coverage analysis (PRs only, after journey shards) ───
coverage:
name: Coverage Analysis
runs-on: ubuntu-latest
needs: [journey-governance, journey-ruvector-coordination, journey-root, journey-remaining]
timeout-minutes: 10
if: success() && github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: '24.13.0', cache: 'npm' }
- run: npm ci
- run: npm run build
- name: Run tests with coverage (excluding browser E2E)
run: bash scripts/ci-vitest-run.sh --coverage --reporter=verbose
env:
NODE_OPTIONS: '--max-old-space-size=1024'
CI: 'true'
- uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-report
path: coverage/
retention-days: 7
- name: Check coverage thresholds
run: |
if [ -f "coverage/coverage-summary.json" ]; then
COVERAGE=$(cat coverage/coverage-summary.json | jq '.total.lines.pct')
echo "Line coverage: ${COVERAGE}%"
if (( $(echo "$COVERAGE < 80" | bc -l) )); then
echo "Coverage below 80% threshold"
else
echo "Coverage meets threshold"
fi
fi
# ─── Test dashboard (summary) ───
dashboard:
name: Test Dashboard
runs-on: ubuntu-latest
needs: [journey-governance, journey-ruvector-coordination, journey-root, journey-remaining, contract-tests, code-intelligence-tests, infrastructure-tests]
if: always()
timeout-minutes: 2
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: '24.13.0' }
- name: Generate Dashboard
run: node scripts/test-dashboard.cjs
- name: Generate Migration Metrics
run: |
echo "# CI Test Metrics" > ci-metrics.md
echo "" >> ci-metrics.md
echo "**Date**: $(date -u +"%Y-%m-%d %H:%M:%S UTC")" >> ci-metrics.md
echo "**Commit**: ${{ github.sha }}" >> ci-metrics.md
echo "" >> ci-metrics.md
total_files=$(find tests -name "*.test.ts" 2>/dev/null | wc -l || echo "0")
total_lines=$(find tests -name "*.test.ts" -exec wc -l {} + 2>/dev/null | tail -1 | awk '{print $1}' || echo "0")
large_files=$(find tests -name "*.test.ts" -exec wc -l {} \; 2>/dev/null | awk '$1 > 600' | wc -l || echo "0")
skipped=$(grep -r "describe.skip\|it.skip\|test.skip" tests --include="*.test.ts" 2>/dev/null | wc -l || echo "0")
echo "## Current State" >> ci-metrics.md
echo "- Total test files: $total_files (target: 50)" >> ci-metrics.md
echo "- Total lines: $total_lines (target: 40,000)" >> ci-metrics.md
echo "- Files > 600 lines: $large_files (target: 0)" >> ci-metrics.md
echo "- Skipped tests: $skipped (target: 0)" >> ci-metrics.md
echo "" >> ci-metrics.md
baseline_files=426
baseline_lines=208253
files_reduced=$((baseline_files - total_files))
lines_reduced=$((baseline_lines - total_lines))
echo "## Progress from Baseline" >> ci-metrics.md
echo "- Files reduced: $files_reduced (-$((files_reduced * 100 / baseline_files))%)" >> ci-metrics.md
echo "- Lines reduced: $lines_reduced (-$((lines_reduced * 100 / baseline_lines))%)" >> ci-metrics.md
cat ci-metrics.md
- uses: actions/upload-artifact@v4
with:
name: ci-metrics
path: ci-metrics.md
retention-days: 30
- name: Comment on PR
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const metrics = fs.readFileSync('ci-metrics.md', 'utf8');
const body = `## Test Suite Metrics
${metrics}
---
*Generated by Optimized CI*`;
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const botComment = comments.find(c =>
c.user?.type === 'Bot' && c.body?.includes('Test Suite Metrics')
);
if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body
});
}