The monitoring contract gets a callsite
Traced 2026-09-03: `calibrationRegistry.reverify` had ZERO production callers, and the only reference to the artifact machinery outside its own directory was the shadow builder, behind a flag that is off. The previous tranche declared that future settled outcomes are forward evaluation evidence and shipped no evaluator — the contract lived in a comment. That is the same shape as statModel.js and correlateValidator.js, cited for months and never present. `forwardMonitor` scores the FROZEN artifact on outcomes settled strictly after its training_cutoff, and `snapshotScheduler.calibrationMonitorTick` runs it on the existing per-minute cadence, throttled 6h, every failure swallowed. A test asserts the tick is defined, invoked AND exported, and drives it with a fake to prove it passes the promoted artifact and a forward-only window. It cannot change what it watches: the module imports no fitter and no registry, and a test greps the stripped source for fitIsotonic, fitPlatt, writeFileSync, upsert, update, promote( , artifactRegistry and PROMOTED. LOW N IS ITS OWN ANSWER. Below the floor it reports INSUFFICIENT_SAMPLE with `healthy: null` — never false, never true. The floor is DERIVED, not chosen: resolving an error of the certified tolerance at two standard errors needs n >= 0.25/(0.05/2)^2 = 400, and a test recomputes it from TOLERANCE so the two cannot drift apart. TOLERANCE is 0.05, the same number certifyBands used, so the monitor can be neither stricter nor laxer than the thing it watches. Wrong-era forward rows are INVALID, not scored — scoring them would measure a different forecaster, which is the defect this line of work removed. An unreadable read is AUDIT_UNAVAILABLE, which is not a health verdict. A drift alert says in its own text that the artifact is frozen and unchanged, because the alert is not a demotion. `currentEraSource.loadRows` gains an optional `after` bound, strictly greater so the cutoff date itself can never be scored as forward evidence. SHADOW REMAINS BLOCKED: the production variable is still absent (configuration_source "default") after a restart at 05:09:02Z, so no shadow cohort was obtained and no replay was substituted for one. Artifact unchanged: mlb-hits-isotonic@2026-09-03, knots 5ae940ea163b7da2. Live OFF. Suite 405/405, 5,654 passed. Teeth 31/31 + 10/10 + 23/23. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CQJeAG8vcDoL5zkiaJyVb8
This commit is contained in:
@@ -209,6 +209,46 @@ logic(26, 'PerformanceDistribution becomes servable', () => {
|
||||
return { caught: !/chain\.chainAcross\(/.test(snap), detail: 'no chainAcross call' };
|
||||
});
|
||||
|
||||
// ── FORWARD MONITOR (this tranche) ───────────────────────────────────────
|
||||
logic(27, 'forward monitor claimed active with no production caller', () => {
|
||||
const sched = codeOf(fs.readFileSync(path.join(ROOT, 'src/snapshotScheduler.js'), 'utf8'));
|
||||
const defined = sched.includes('const calibrationMonitorTick = async () =>');
|
||||
const invoked = sched.includes('await calibrationMonitorTick();');
|
||||
const exported = sched.includes('calibrationMonitorTick };');
|
||||
// the previous tranche had the CONTRACT and none of these three
|
||||
return { caught: defined && invoked && exported,
|
||||
detail: `defined=${defined} invoked_on_tick=${invoked} exported=${exported}` };
|
||||
});
|
||||
|
||||
inject(28, 'forward monitor refits the active artifact',
|
||||
'src/services/model/forwardMonitor.js',
|
||||
`const { knownNumber } = require('../../utils/known');`,
|
||||
`const { knownNumber } = require('../../utils/known');
|
||||
const _cal = require('./calibration');
|
||||
const _refit = () => _cal.fitIsotonic([], {});`,
|
||||
'tests/unit/forwardMonitor.test.js');
|
||||
|
||||
inject(29, 'low forward N reported HEALTHY',
|
||||
'src/services/model/forwardMonitor.js',
|
||||
` if (n < MIN_FORWARD_ROWS) {`,
|
||||
` if (false) {`,
|
||||
'tests/unit/forwardMonitor.test.js');
|
||||
|
||||
inject(30, 'the monitor scores evidence the fit already saw',
|
||||
'src/services/model/forwardMonitor.js',
|
||||
` if (artifact.training_cutoff && String(r.date) <= String(artifact.training_cutoff)) continue;`,
|
||||
` if (false) continue;`,
|
||||
'tests/unit/forwardMonitor.test.js');
|
||||
|
||||
logic(31, 'live serving turns on before all gates pass', () => {
|
||||
const snap = codeOf(fs.readFileSync(path.join(ROOT, 'src/services/snapshotService.js'), 'utf8'));
|
||||
const deployedEmpty = /CALIBRATION_DEPLOYED\s*=\s*Object\.freeze\(\[\s*\]\)/.test(snap);
|
||||
const stage = registry.PROMOTED['mlb:hits'].stage === registry.STAGE.APPROVED_FOR_SHADOW;
|
||||
const notLive = A.approved_for_live === false;
|
||||
return { caught: deployedEmpty && stage && notLive,
|
||||
detail: `CALIBRATION_DEPLOYED empty=${deployedEmpty}; stage=${registry.PROMOTED['mlb:hits'].stage}; approved_for_live=${A.approved_for_live}` };
|
||||
});
|
||||
|
||||
const landed = results.filter((r) => r.landed).length;
|
||||
console.log(JSON.stringify({ teeth_landed: `${landed}/${results.length}`, results }, null, 2));
|
||||
process.exit(landed === results.length ? 0 : 1);
|
||||
|
||||
Reference in New Issue
Block a user