Sessions 7e-7g: Grading path unified - adapter, computeFeatures, analyzeViaEngine1, all routes migrated, dead code removed

This commit is contained in:
Kev
2026-06-10 10:23:55 -04:00
parent 4815ceac03
commit 4e18eb1efe
9 changed files with 181 additions and 712 deletions
+8 -11
View File
@@ -1,14 +1,11 @@
const express = require('express');
// ARCH-1 ESCAPE HATCH (Session 7f): /api/analyze stays on the legacy
// analyzeProp path. The unification's adapter + computeFeatures +
// analyzeViaEngine1 helpers are built and tested, but the integration
// test for this route asserts specific grade VALUES that the legacy
// engine produced for specific input mocks. Swapping in engine1
// preserves the SHAPE (verified) but produces different VALUES because
// the engine logic is intentionally different. Per the session rule
// "tests pass unmodified", reverted. See docs/SYSTEM-MANIFEST.md §8
// ARCH-1 for the migration roadmap.
const { analyzeProp } = require('../services/propAnalyzer');
// ARCH-1 FIXED (Session 7g): /api/analyze grades through engine1 via
// the unified analyzeViaEngine1 helper (computeFeatures → engine1 →
// gradeAdapter). Response shape stays legacy-compatible — DemoScan
// reads grade / confidence / kill_conditions_triggered /
// reasoning.{summary,steps} without any change. Rate limit (SEC-1)
// and Redis cache (PERF-1) both preserved.
const { analyzeViaEngine1 } = require('../services/intelligence/analyzeViaEngine1');
const { cacheGet, cacheSet } = require('../utils/redis');
const { createRateLimit } = require('../middleware/rateLimit');
@@ -36,7 +33,7 @@ async function cachedAnalyze(prop) {
const key = analyzeCacheKey(prop);
const cached = await cacheGet(key);
if (cached) return { ...cached, _cache: 'HIT' };
const result = await analyzeProp(prop);
const result = await analyzeViaEngine1(prop);
// cacheSet swallows failures (degraded Redis) — analysis still flows
// even when the cache is down.
await cacheSet(key, result, ANALYZE_TTL_SECONDS);