b742230d94
FOUNDATION-FIRST re-order, phase 1 (tooling + safety). BACKUP (highest-severity open item) — INSTALLED, not re-proven. src/backupScheduler.js runs scripts/backup-db.sh nightly from inside the API container, armed at boot in server.js. The container already has SUPABASE_DB_URL, pg_dump and the Supabase route, so deploy == installed: no host crontab, no Coolify click. Arming is deliberately opt-OUT (armed whenever SUPABASE_DB_URL exists; BACKUP_CRON=0 kills it) because the S62 design was opt-in and nobody ever opted in — the DB went unbacked every night for weeks. A failed run pages high-priority ntfy; silence is the danger with backups. Durability is the one part still needing a human: the container FS is ephemeral, so a dump dies on redeploy unless BACKUP_REMOTE (off-box rsync) or BACKUP_DIR (persistent volume) is set. The scheduler detects that and pages a WARNING at boot rather than letting an undurable backup read as "backed up". Runbook rewritten to lead with the code path. MANUAL REGRADE TRIGGER — scripts/run-snapshot.js, runnable via docker exec with no VYNDR_INTERNAL_KEY and no new HTTP surface. Runs the SAME snapshotService.runSnapshot the cron runs (including the team-stats refresh that powers opp_rank_stat), supports `all` and `--settle`, and prints the grade/confidence distribution plus p_win/ev_pct presence — which is the thing you actually want when verifying a grading change. ACCESS BLOCKER, logged honestly in specs/model-train.md: there is no VYNDR_INTERNAL_KEY in the local .env and SSH to the box times out from WSL2, so I can neither curl the internal endpoints (which already exist from S45) nor docker exec. The trigger is built and correct but only Kev can run it until a key or SSH access exists. This is the highest-leverage unblock for phases 2 and 3, which both need on-demand regrade+settle to verify anything. Also logged the standing cautions: CLV ledger stays private until backtest-proven; "self-improving model" is unsupported marketing until the loop closes; the engine is MLB/WNBA-calibrated and NFL/NBA/soccer need their own calibration before the hub grades them (scaling gate). Suite 277/3300 green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SmNjJAwEnqHPtXbvSZR8kA
46 lines
2.3 KiB
JavaScript
46 lines
2.3 KiB
JavaScript
// Session 65 (§A4) — preflight BEFORE anything else prints, so the container's
|
|
// state (content present? critical env present? cron armed?) is the first
|
|
// thing in the logs, not something inferred after a silent rollback.
|
|
require('./preflight').runPreflight();
|
|
|
|
const app = require('./app');
|
|
// Session 20 — surface which providers are actually configured at
|
|
// boot. A silently-missing key (e.g. ODDSPAPI_KEY unset in prod)
|
|
// otherwise only manifests when the gateway tries to fall over and
|
|
// finds no chain.
|
|
const { getConfiguredProviders, listProviderIds } = require('./config/providers');
|
|
// Session 24 — warm the Tank01 cache after boot so streaks / hot lists /
|
|
// game lines have data on the first page load. Non-blocking; see module.
|
|
const { scheduleStartupPrefetch } = require('./startupPrefetch');
|
|
// Session 45 — in-process snapshot cron (gated on SNAPSHOT_CRON=1).
|
|
const { startSnapshotScheduler } = require('./snapshotScheduler');
|
|
const { startBackupScheduler } = require('./backupScheduler');
|
|
|
|
// Default 3001 — Next.js owns 3000 locally and in production. The poller,
|
|
// internal cron, and BASE_URL conventions all assume 3001 for the Express
|
|
// backend. PORT env still overrides for special-case deploys.
|
|
const PORT = process.env.PORT || 3001;
|
|
|
|
app.listen(PORT, () => {
|
|
console.log(`[VYNDR] Server running on port ${PORT}`);
|
|
const configured = getConfiguredProviders();
|
|
const missing = listProviderIds().filter((id) => !configured.find((c) => c.id === id));
|
|
console.log(`[VYNDR] providers configured (${configured.length}): ${configured.map((c) => c.id).join(', ') || 'none'}`);
|
|
if (missing.length) {
|
|
console.warn(`[VYNDR] providers missing keys: ${missing.join(', ')}`);
|
|
}
|
|
|
|
// Session 24 — fire-and-forget cache warm. 5s delay so Redis is ready.
|
|
// Skips itself when RAPID_API_KEY is unset; never blocks or crashes boot.
|
|
scheduleStartupPrefetch();
|
|
|
|
// Session 45 — arm the snapshot cron (no-op unless SNAPSHOT_CRON=1).
|
|
startSnapshotScheduler();
|
|
|
|
// Session 64 — arm the NIGHTLY BACKUP. Opt-OUT (armed whenever
|
|
// SUPABASE_DB_URL exists; BACKUP_CRON=0 kills it). The host cron was written
|
|
// in S62 and never installed, so the database went unbacked every night;
|
|
// shipping it as code means deploy == installed.
|
|
startBackupScheduler();
|
|
});
|