Commit Graph

3 Commits

Author SHA1 Message Date
Dragan Spiridonov 3d7a2f91dd fix(security): resolve 4 CodeQL ReDoS alerts + decompose oversized modules
Security (CodeQL #193-196):
- command-validator: replace greedy .* with [^)]* in $() pattern
- input-sanitizer: replace .* with \S+(?:\.\S+)* in UPDATE SET pattern
- path-traversal-validator: split alternation into two .replace() calls
- regex-safety-validator: use [^\]]* and non-greedy variants in detection patterns

Flaky test indicators (5 files, 58 real setTimeout calls eliminated):
- file-watcher.test.ts: vi.useFakeTimers + advanceTimersByTimeAsync
- qcsd-refinement.test.ts: vi.useFakeTimers + advanceTimersByTimeAsync
- qcsd-ideation-url.test.ts: vi.useFakeTimers + advanceTimersByTimeAsync
- server-client.test.ts: process.nextTick for data callbacks
- stream-controller.test.ts: vi.useFakeTimers + advanceTimersByTimeAsync

File size discipline (issue #374 P2):
- time-crystal.ts (1,714 → 6 files, max 447 lines):
  time-crystal-types, phase-executor, time-crystal-persistence,
  time-crystal-analysis, time-crystal-scheduling, time-crystal (controller)
- qe-reasoning-bank.ts (1,941 → 7 files, max 738 lines):
  qe-reasoning-bank-types, pretrained-patterns, agent-routing,
  embedding-utils, pattern-promotion, qe-reasoning-bank (class)

All re-exports preserved for backward compatibility.
536 directly affected tests pass. Build clean.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 19:58:01 +00:00
Dragan Spiridonov 00e4d2cfa6 fix(tests): add afterEach cleanup to 104 test files missing it (#374 P2)
125 test files had beforeEach/beforeAll but no afterEach/afterAll,
leaking state between tests and causing order-dependent failures.

Added cleanup to 104 files (skipped 4 archived, 16 import-only):
- 2 critical DB handle leaks (witness-chain): added db.close()
- 7 high-risk service files: added vi.restoreAllMocks()
- 7 beforeAll files: added matching afterAll
- 88 medium/low risk: added afterEach with appropriate cleanup

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 12:51:47 +00:00
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