Truthful provenance for an operator-invoked snapshot
The internal one-shot route already called the SAME production runSnapshot with
the SAME default dependencies — but it passed no trigger, and runSnapshot
defaults an absent trigger to SCHEDULED. So every operator-invoked run was
recorded as though the cron had fired it. That was a lie about provenance,
present by omission, and it would have contaminated the trace of any forced
diagnostic run.
CONTROLLED_FORCED is now its own trigger. Both internal routes (`/snapshot/:sport`
and `/snapshot/all`) stamp it, along with the process generation. The scheduler
still stamps SCHEDULED, and a test asserts neither internal route can label
itself scheduled.
Trace retention moves from "scheduled only" to a named allow-list of SCHEDULED +
CONTROLLED_FORCED. INTRADAY is still refused — it runs every ~20 minutes and
would displace scheduled evidence, which is the failure the store exists to
prevent. MANUAL_API stays refused too.
THE PIPELINE IS UNTOUCHED. snapshotService, gradeSlateService, retentionService,
snapshotScheduler, oddsService and eventIdentity are all UNCHANGED. A test
asserts the route injects no dependency override — no getOdds, gradeAndCacheSlate,
retention, ledger, cacheSet/cacheGet, gameBinder, eventIdentity, mlbAdapter or
notify — so the only difference from a scheduled invocation is the label and the
absence of a scheduled hour, which a forced run genuinely does not have.
The ?limit bisect-hook invariant is preserved and tightened: the opts passed
carry exactly {trigger, processStartedAt} and never a stray limit.
Teeth, injections verified present, against a green baseline:
:sport route mislabelled SCHEDULED -> 3 fail
/all route mislabelled SCHEDULED -> 2 fail
intraday admitted to the store -> 5 fail
trigger filter removed -> 3 fail
THE FIRST TEETH RUN WAS INVALID AND IS DISCARDED: both routes live in one file,
so a single-occurrence replace hit `/snapshot/all` and left `/snapshot/:sport`
correct — the injection landed on the wrong target and the suite passed. Coverage
for `/all` was added, plus a test that the file contains exactly two
CONTROLLED_FORCED stamps and zero SCHEDULED ones, then both were re-run failing
independently.
Four stale assertions updated with the reason recorded: three pinned the
`not_scheduled` refusal string (now trigger-agnostic) and one pinned an empty
opts object on the route.
389 suites / 5,280 tests pass. web tsc exit 0. Lineage stays OFF.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CQJeAG8vcDoL5zkiaJyVb8
This commit is contained in:
+16
-2
@@ -180,7 +180,11 @@ router.post('/prefetch/tank01', async (req, res) => {
|
||||
router.post('/snapshot/all', async (req, res) => {
|
||||
const snapshot = require('../services/snapshotService');
|
||||
try {
|
||||
const results = await snapshot.runAllSnapshots();
|
||||
const acqT = require('../services/ops/acquisitionTrace');
|
||||
const results = await snapshot.runAllSnapshots({
|
||||
trigger: acqT.TRIGGER.CONTROLLED_FORCED,
|
||||
processStartedAt: PROCESS_STARTED_AT,
|
||||
});
|
||||
return res.json({ ok: true, results });
|
||||
} catch (err) {
|
||||
const message = err && err.message ? err.message : String(err);
|
||||
@@ -283,7 +287,17 @@ router.post('/snapshot/:sport', async (req, res) => {
|
||||
// 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 } : {});
|
||||
// TRUTHFUL PROVENANCE. runSnapshot defaults an absent trigger to SCHEDULED,
|
||||
// so an operator-invoked run was previously recorded as though the cron
|
||||
// fired it. It is now labelled for what it is. This changes ONLY the
|
||||
// diagnostic trace — the pipeline path, the dependencies and every
|
||||
// authoritative write are identical to the scheduled invocation.
|
||||
const acqT = require('../services/ops/acquisitionTrace');
|
||||
const summary = await snapshot.runSnapshot(req.params.sport, {
|
||||
...(limit ? { limit } : {}),
|
||||
trigger: acqT.TRIGGER.CONTROLLED_FORCED,
|
||||
processStartedAt: PROCESS_STARTED_AT,
|
||||
});
|
||||
return res.json({ ok: true, ...(limit ? { limit_override: limit } : {}), summary });
|
||||
} catch (err) {
|
||||
const message = err && err.message ? err.message : String(err);
|
||||
|
||||
Reference in New Issue
Block a user