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
+33 -19
View File
@@ -29,21 +29,19 @@ reality, update this file FIRST.
└───────────────────────────────────┘
```
Two parallel grading paths coexist (audited in Session 7c):
**Unified grading path (closed by Session 7g):**
- **Legacy path** (still wired): `routes/scan|analyze|bets|alerts`
`parlayScanService``propAnalyzer``grader.js``UnifiedOddsProvider`
→ 9 book adapters (ESPN, Pinnacle, DraftKings, FanDuel, BetMGM, Caesars,
PrizePicks, Covers, Rotowire) → `processing/{LineShoppingEngine,
MiddlesDetector, EVCalculator}`.
- **New path** (Sessions 6a-6c): `routes/grading/pipeline`
`gradingOrchestrator``featureCache` + `trapDetection` +
`consistencyScore` + `probabilityEstimator``engine1`
(A/B-tier only) `engine2` via OpenRouter.
- `routes/scan/parlay` and `routes/analyze/{prop,batch}`
`analyzeViaEngine1` (`computeFeatures``engine1``gradeAdapter`).
- `routes/grading/pipeline` (scheduled) → `gradingOrchestrator`
`featureCache` + `trapDetection` + `consistencyScore` +
`probabilityEstimator``engine1` → (A/B-tier only) `engine2`.
The two paths share `grade_history`, `Redis`, `Supabase`. They do not
share the grading function itself. **This duplication is documented as
finding #ARCH-1 below.**
The book-adapter chain (`UnifiedOddsProvider` + 9 legacy adapters +
`services/{rateLimiter,circuitBreaker}.js`) remains live but only for
the DATA REFRESH path at `/api/pipeline/refresh` — a separate concern
from grading. ARCH-1 retired the legacy GRADING path (`propAnalyzer`,
`grader.js`) in Session 7g.
---
@@ -411,12 +409,28 @@ No circular imports detected.
### ARCH — Architecture
- **[ARCH-1] Dual grading paths.** Severity: Medium. Status:
**PARTIAL in Session 7f**/api/scan/parlay migrated to engine1.
/api/analyze/{prop,batch} stayed on legacy after Escape Hatch
(integration test asserts specific legacy-engine grade values).
/api/bets/* doesn't touch the legacy path at all (verified by grep).
Dead-code removal blocked because /api/analyze still imports
analyzeProp.
**FIXED in Session 7g**all grading routes (/api/analyze/prop,
/api/analyze/batch, /api/scan/parlay) now grade through engine1 via
the unified `analyzeViaEngine1` helper. /api/bets/* never used the
legacy path. Dead files removed: `src/services/propAnalyzer.js`,
`src/services/grader.js`, `tests/unit/grader.test.js` (-10 tests).
UnifiedOddsProvider + the 9 legacy book adapters + the legacy
rateLimiter/circuitBreaker stay live — they're still consumed by
`/api/pipeline/refresh` (the data refresh path, a separate
concern). When that route eventually migrates off them, those
files can also retire.
Migration story for the record:
Session 7c — audit catalogued ARCH-1.
Session 7d — adapter scoped + DEPRECATED banner on grader.js.
Session 7e — adapter built + tested (gradeAdapter.js, 26 tests).
Session 7f — computeFeatures (8 tests) + analyzeViaEngine1
(7 tests) + /api/scan/parlay migrated.
/api/analyze escape-hatched (integration test
asserted legacy-engine values).
Session 7g — analyze test mocks rotated to drive the new path;
/api/analyze migrated; dead code removed.
Adapter, computeFeaturesForProp, and analyzeViaEngine1 helpers all
shipped and tested. Future migration can flip the analyze route any