/** * Edge-side efficiency shading CHALLENGER (specs/edge-shading-challenger.md). * MEASURED, NEVER SERVED — these tests lock the properties that make it un-inflatable. */ const c = require('../../src/services/challengers/efficiencyShading'); describe('f(efficiency) is BOUNDED — this is what makes it un-inflatable', () => { test('soft market is INTACT, never amplified above the raw edge', () => { expect(c.shadingFactor(c.E_SOFTEST)).toBe(1); // even a hypothetical score BELOW the anchor cannot amplify expect(c.shadingFactor(0.10)).toBe(1); expect(c.shadingFactor(0.01)).toBe(1); }); test('sharper markets shade DOWN monotonically, toward but never past zero', () => { const f55 = c.shadingFactor(0.55), f60 = c.shadingFactor(0.60); const f80 = c.shadingFactor(0.80), f85 = c.shadingFactor(0.85); expect(f55).toBeGreaterThan(f60); expect(f60).toBeGreaterThan(f80); expect(f80).toBeGreaterThan(f85); for (const f of [f55, f60, f80, f85]) { expect(f).toBeGreaterThan(0); expect(f).toBeLessThanOrEqual(1); } }); test('an UNSCORED market gets f=1 and is FLAGGED, never silently scaled', () => { expect(c.shadingFactor(null)).toBe(1); const row = c.gradeRow({ sport: 'mlb', stat: 'hits', edge: 40 }); expect(row.unscored).toBe(true); expect(row.f).toBe(1); expect(row.efficiency).toBeNull(); }); }); describe('the FIXED bar never moves', () => { test('bands are identical regardless of sport or market', () => { const soft = c.gradeRow({ sport: 'mlb', stat: 'total_bases', edge: 5 }); const unscored = c.gradeRow({ sport: 'wnba', stat: 'points', edge: 5 }); // same raw edge, both f=1 here -> identical band. The bar is one bar. expect(soft.grade).toBe(unscored.grade); expect(c.bandFor(10)).toBe('A+'); expect(c.bandFor(5)).toBe('A'); expect(c.bandFor(3)).toBe('B'); expect(c.bandFor(1)).toBe('C'); expect(c.bandFor(0)).toBe('D'); expect(c.bandFor(-0.1)).toBe('F'); }); test('shading can only ever LOWER a grade, never raise it', () => { for (const e of [0.55, 0.60, 0.80, 0.85, null]) { for (const edge of [0.5, 2, 4, 6, 12, 60]) { const r = c.gradeRow({ sport: 'x', stat: 'y', edge }); const adj = edge * c.shadingFactor(e); expect(adj).toBeLessThanOrEqual(edge + 1e-9); // never amplified expect(r.baseline_grade).toBeTruthy(); } } }); }); describe('cross-market behaviour (the point of the design)', () => { test('the SAME raw edge grades LOWER in an efficient market than a soft one', () => { const raw = 6; const soft = c.gradeRow({ sport: 'mlb', stat: 'total_bases', edge: raw }); // 0.55 -> f 1.00 const sharp = c.gradeRow({ sport: 'nba', stat: 'points', edge: raw }); // 0.80 -> f 0.688 expect(soft.grade).toBe('A'); expect(sharp.grade).toBe('B'); expect(sharp.adjusted_edge).toBeLessThan(soft.adjusted_edge); }); }); describe('absent input is absent, never zero', () => { test('a missing edge returns null rather than grading F', () => { expect(c.gradeRow({ sport: 'mlb', stat: 'hits', edge: null })).toBeNull(); expect(c.gradeRow({ sport: 'mlb', stat: 'hits', edge: '' })).toBeNull(); expect(c.gradeRow({ sport: 'mlb', stat: 'hits', edge: 'x' })).toBeNull(); expect(c.gradeRow(null)).toBeNull(); }); test('a real negative edge DOES grade F (not confused with absent)', () => { expect(c.gradeRow({ sport: 'mlb', stat: 'hits', edge: -5 }).grade).toBe('F'); }); }); describe('MEASURED-NEVER-SERVED fence', () => { test('no production grade path imports this challenger', () => { const fs = require('fs'), path = require('path'); const files = [ 'src/services/gradeSlateService.js', 'src/services/intelligence/analyzeViaEngine1.js', 'src/services/intelligence/engine1.js', 'src/services/snapshotService.js', 'src/utils/gradeAdapter.js', ]; for (const f of files) { const src = fs.readFileSync(path.join(__dirname, '../../', f), 'utf8'); expect(src).not.toMatch(/efficiencyShading/); } }); });