From 8d052131c5bb4b2f6ce4ca05b3d93271ea5d3ac5 Mon Sep 17 00:00:00 2001 From: Kev Date: Sat, 1 Aug 2026 02:12:07 -0400 Subject: [PATCH] Add a bisect hook (?limit=) to the internal snapshot trigger The cap raise 25 -> 500 made an induced snapshot 502 at 13.4s and the run did not complete in background either, while a 25-prop run had completed in 16.3s. That rules out a simple duration timeout and means the cause has to be measured, not guessed. ?limit= bounds one run so the regression can be bisected without a prod env change; omitted, the real DEFAULT_LIMIT applies. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01QJs13VsyiSKYQP6rj3NNmc --- src/routes/internal.js | 8 ++++++-- src/services/snapshotService.js | 5 +++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/routes/internal.js b/src/routes/internal.js index 6ad2f73..d960e91 100644 --- a/src/routes/internal.js +++ b/src/routes/internal.js @@ -177,8 +177,12 @@ router.get('/snapshot/status', async (req, res) => { router.post('/snapshot/:sport', async (req, res) => { const snapshot = require('../services/snapshotService'); try { - const summary = await snapshot.runSnapshot(req.params.sport); - return res.json({ ok: true, summary }); + // ?limit= is a BISECT HOOK, not a production knob: it bounds the graded + // slate for one run so a cap regression can be isolated by measurement + // rather than guessed at. Omitted => gradeSlateService's real DEFAULT_LIMIT. + const limit = Number(req.query.limit) > 0 ? Number(req.query.limit) : undefined; + const summary = await snapshot.runSnapshot(req.params.sport, limit ? { limit } : {}); + return res.json({ ok: true, ...(limit ? { limit_override: limit } : {}), summary }); } catch (err) { const message = err && err.message ? err.message : String(err); console.error('[internal/snapshot] failed:', message); diff --git a/src/services/snapshotService.js b/src/services/snapshotService.js index a6cb1c0..0832ea2 100644 --- a/src/services/snapshotService.js +++ b/src/services/snapshotService.js @@ -400,6 +400,11 @@ async function runSnapshot(sport, opts = {}) { // letting it write (we re-write an ENRICHED version below). let envelope = null; await deps.gradeAndCacheSlate(sp, props, { + // Bisect hook (2026-08-01): lets the internal trigger run a bounded slate + // without a prod env change, so a cap regression can be isolated by + // measurement instead of guessed at. Omitted => gradeSlateService's own + // DEFAULT_LIMIT (the real production value). + ...(Number(opts.limit) > 0 ? { limit: Number(opts.limit) } : {}), source: (odds && odds.provider) || 'odds-api', now: deps.now, cacheSet: async (_k, v) => { envelope = v; },