Retention: model_snapshots live + base64 SSH key support
RETENTION (Phase 2, priority zero). History starts compounding tonight. migration 025 model_snapshots — APPLIED to prod. Append-only, one row per graded prop PER SIDE PER CYCLE, with a unique index on (snapshot_id, player_key, stat, line, side) so a retried cycle cannot duplicate. RLS on, service-role writes only. What it captures that the ledger never did: - features jsonb — the model's INPUTS. Without these a backtest can only grade our own homework; with them any future model can be replayed against the exact conditions this one faced. - REFUSALS (refused + refusal_reason). The ledger drops them, so a gate refusing props that would have WON is invisible — unmeasurable lost edge. Captured via a new onGraded hook in gradeSlateService that fires with BOTH sides before any filtering. - grade_11, the pre-collapse grade. The 4-letter map throws away the entire live C-/C/C+/B- range. - model_version + code_sha on every row. ledger_entries mixes pre/post-fix grades with no marker and cannot be separated retroactively. - p_win / ev_pct / fair_odds / takeable / value — none of which any permanent store held. Wiring: analyzeViaEngine1 attaches _features/_grade_11 (underscore = internal); gradeSlateService fires onGraded then STRIPS them so they never reach a cache or API payload; snapshotService builds rows and persists best-effort. Retention reuses the LEDGER's dateET/gameIdFor helpers so rows share the ledger's natural key exactly — otherwise the settle pass could never join outcomes onto them. Rows are written BEFORE the empty- slate early return: a slate that refused everything is exactly the case worth recording. CONTRACT HELD: retention is injectable and every path is caught. persist() returns errors, never throws; a missing Supabase client is SKIPPED, not an error. A retention failure can never break a snapshot. BACKUP: backup-db.sh now accepts BACKUP_SSH_KEY as base64 (recommended — survives env-var newline mangling, which is how injected SSH keys usually break silently) OR raw PEM, detected by decoding and looking for the PEM header. Verified both forms detect correctly against a real generated key. Suite 279/3325 green, build exit 0. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SmNjJAwEnqHPtXbvSZR8kA
This commit is contained in:
@@ -471,6 +471,14 @@ async function analyzeViaEngine1(rawProp = {}) {
|
||||
// ledger model_value and rendered under the MODEL label on the card.
|
||||
legacy.projection = projection;
|
||||
|
||||
// Session 64 — RETENTION: expose the feature vector + the pre-collapse
|
||||
// 11-step grade so `model_snapshots` can store the model's INPUTS, not just
|
||||
// its output. Without inputs a backtest can only grade our own homework.
|
||||
// Underscore-prefixed = internal: gradeSlateService strips these before the
|
||||
// grade reaches any cache or API payload.
|
||||
legacy._features = features;
|
||||
legacy._grade_11 = engine1Result && engine1Result.grade ? engine1Result.grade : null;
|
||||
|
||||
// Session 62 (A1-S1) — ALT LINE LADDER + EDGE RANKING. The pricing page
|
||||
// sold it; the adapter/card were already built for it; nothing produced
|
||||
// it. Re-grade the SAME feature vector at shifted lines (zero extra I/O)
|
||||
|
||||
Reference in New Issue
Block a user