Commit Graph

5 Commits

Author SHA1 Message Date
Dragan Spiridonov b6fd679254 fix(#569): stop the MCP layer laundering missing provenance into confident numbers
Found by the qe-devils-advocate session review, AFTER #569 was already committed.
The handler was producing honest provenance; `coverageAnalyzeConfig.mapToResult`
was converting it back into fabricated certainty on three paths.

1. Absent provenance was treated as "collected".
   `data.branchDataCollected !== false` — and `undefined !== false` is true. Any
   producer that supplies no provenance (notably the coverage-analysis domain
   plugin, whose handler returns a nested-`summary` CoverageReport) therefore
   surfaced issue #569's EXACT reported symptom: 100% branch coverage alongside
   0% function coverage, labelled `measured: true`, with `confidence: 0.7` on its
   gaps. Now requires an explicit `true`; absence means unknown, so an
   unprovenanced result reports `null`.

2. `measured` was derived as `!estimated`.
   These are not complements — there is a third state where nothing was collected
   at all. An empty project reported `lineCoverage: 0, measured: true`: "we
   measured 0%" when the truth was "we measured nothing". Verified through the
   real MCP server before and after. `measured` now requires an explicit claim.

3. `null` was coerced to `0`, and risk was graded off it.
   `?? 0` turned "no data" into a plottable 0%, and `null < 70` is `false` in JS,
   so an unguarded comparison graded "no data" as 'low' risk — the most dangerous
   possible default. Nulls now survive; risk grading requires a real number.

Also fixes the stale-result mystery that dogged verification all session.
`src/optimization/session-cache.ts` fingerprints on domain+action+input only, and
persists to kv_store with a 1-hour TTL, so entries survive package upgrades: a
project analyzed before a fix keeps replaying the old answer, making the fix look
broken. I twice mis-diagnosed this (first as a cache, then wrongly retracted that;
it WAS the cache). The fingerprint now includes the build identity, so an upgrade
misses cleanly and old entries age out. `AQE_SESSION_CACHE_SALT` forces a cold
cache without deleting anything.

This matters beyond #569: every fix in this release would have appeared not to
work for any user with a warm cache.

`CoverageAnalyzeResult.lineCoverage`/`statementCoverage` are now `number | null`,
joining `branchCoverage`/`functionCoverage`. `0` means a measured zero; `null`
means unknown.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-23 14:46:31 +00:00
Dragan Spiridonov 4e011a81d0 chore(release): bump version to v3.9.27
- AbortSignal threading bounds ReasoningBank.initialize() (#478)
  prevents leaked init from runaway patterns.rvf writes
- CapturedExperienceBridge wires hook activity to domain plugins (#479)
  via kernel-side drain of captured_experiences
- Removes dead v3-qe-bridge.sh, two stale planning docs, five orphan
  workers in qe-workers.ts (subsumed by LearningConsolidationWorker)

Net: +430 / -2,090 lines

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-14 09:10:11 +00:00
Dragan Spiridonov a2f9365ddc feat: implement session reuse with O(1) fingerprint cache for 40-60% token savings (#334)
Imp-15: Session Reuse for Repeated Operations

Adds a SHA-256 fingerprint-based operation cache as layer 0 before HNSW
early exit. Exact-match lookups run in O(1) before O(log n) similarity
search, catching repeated operations instantly.

- SessionOperationCache with TTL, capacity eviction, and kv_store persistence
- Wired into TokenOptimizerService.checkEarlyExit() as first check
- cacheOperationResult() stores results after successful LLM execution
- session_cache_stats MCP tool for monitoring hit rates
- CLI: aqe token-usage --cache-stats for cache performance
- Cross-session persistence via existing kv_store table
- 26 new tests covering fingerprinting, TTL, eviction, stats, degradation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 13:36:35 +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