Files
vyndr/tests/unit/takeableTagging.test.js
builtbykev 2bfaeff572 Ledger takeable tagging (deferred C2); efficiency challenger BLOCKED
Champion grade UNCHANGED. Push scoring untouched. Additive tags only — nothing
deleted, nothing re-settled.

PART A — THE EFFICIENCY CHALLENGER: BLOCKED, NOT BUILT.
Review Zero came back ABSENT on all three inputs:
  0.1 efficiency scores DO NOT EXIST (zero occurrences of market_efficiency /
      marketEfficiency / efficiency_score in src/ or web/src/).
  0.2 base thresholds DO NOT EXIST (engine1.js has zero `edge` references — the
      grade is not an edge-vs-threshold comparison; grade_thresholds.json holds
      PROBABILITY bands).
  0.3 the +/-0.05 additive efficiency nudge DOES NOT EXIST. The only 0.05s on
      the grade path are featureCache.teammate_absence_bump, a bvp_advantage
      cutoff, and p*0.9+0.05 inside probabilityEstimator (the 0.5*0.1 term of
      the shrink-toward-0.5). There is no additive scaling to replace.

So a challenger differing from the champion in EXACTLY ONE thing cannot be
constructed: there is no additive scaling to swap, no base threshold to
multiply, and engine1.js has zero `sport` references so market cannot reach the
grade. A threshold must exist first — that is R1 of
specs/full-output-grade-mapping.md, an explicitly held separate order. Shipping
R1+R4 together would make the Phase-3 delta report misleading: the re-letter
would be driven mostly by switching to probability grading while being
presented as the efficiency fix.

0.4 coverage: the spec names 5 scores; the live ledger has 11 markets and only
MLB total_bases maps to one. 9 of 11 have no score, so "all scored markets"
cannot be satisfied without inventing 9 numbers.

PART B — LEDGER TAKEABLE TAGGING: BUILT (the deferred C2).
New src/config/takeableStandard.js: floor on the minus side, UNCAPPED plus.
Deliberately NOT valueEngine.isTakeable (the -160..+200 PROMOTION band) — a
+400 prop is not promotable but IS takeable; a test asserts the two diverge on
the plus side and agree at the floor so they can never quietly merge. Absent
price returns null, never false (Number(null) === 0 would tag a missing price
takeable). The floor is POLICY not derived (C1 could not derive one) and is
labelled so; each row records takeable_floor so a re-derivation can re-tag.

Migration 034 (applied + tracked): ledger_entries.takeable boolean +
takeable_floor numeric, nullable, partial index. Forward tagging in
ledgerService at row build; backfill in one statement.
Result: 1254 rows, 1246 tagged (781 takeable / 465 below floor), 8 NULL with
null_despite_price = 0 (the NULLs are genuinely priceless rows). Settled 1163
and graded 1254 unchanged.

PART C — the model-version boundary tag is DELIBERATELY NOT APPLIED: no scaling
change shipped, so no boundary exists, and stamping one would mark a model
transition that never happened. modelEras.js is its home when a real one lands.

Floor: 312 suites / 3890 tests green (8 new), web build exit 0.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QJs13VsyiSKYQP6rj3NNmc
2026-07-31 00:19:13 -04:00

76 lines
3.1 KiB
JavaScript

/**
* Ledger takeable tagging (specs/takeable-tagging.md).
*
* The load-bearing property: this standard is a FLOOR with an UNCAPPED plus side,
* and it is DELIBERATELY NOT valueEngine's -160..+200 promotion band. A test that
* lets the two converge would erase the distinction the ledger depends on.
*/
const { LEDGER_TAKEABLE_FLOOR, isLedgerTakeable } = require('../../src/config/takeableStandard');
const { isTakeable: isPromotable } = require('../../src/config/valueEngine');
describe('ledger takeable standard — floor on minus, UNCAPPED plus', () => {
test('the floor is inclusive and a worse price is not takeable', () => {
expect(isLedgerTakeable(LEDGER_TAKEABLE_FLOOR)).toBe(true);
expect(isLedgerTakeable(LEDGER_TAKEABLE_FLOOR - 1)).toBe(false);
expect(isLedgerTakeable(-110)).toBe(true);
expect(isLedgerTakeable(-300)).toBe(false);
});
test('the PLUS side is UNCAPPED — this is the whole ratified shape', () => {
for (const p of [100, 200, 201, 400, 600, 5000]) {
expect(isLedgerTakeable(p)).toBe(true);
}
});
test('an ABSENT price is NULL, never false (Number(null) === 0 guard)', () => {
// Without the strict guard, Number(null) === 0 would be >= -160 and a MISSING
// price would be tagged takeable — fabricated data in the record.
expect(isLedgerTakeable(null)).toBeNull();
expect(isLedgerTakeable(undefined)).toBeNull();
expect(isLedgerTakeable('')).toBeNull();
expect(isLedgerTakeable('not-a-price')).toBeNull();
});
test('accepts the string prices the ledger actually stores', () => {
expect(isLedgerTakeable('-110')).toBe(true);
expect(isLedgerTakeable('+150')).toBe(true);
expect(isLedgerTakeable('-275')).toBe(false);
});
});
describe('it must NOT collapse into the promotion band', () => {
test('a long plus price is TAKEABLE but NOT promotable — both true at once', () => {
const longshot = 400;
expect(isLedgerTakeable(longshot)).toBe(true); // a bettor could take it
expect(isPromotable(longshot)).toBe(false); // we would not hero it
});
test('the two disagree on the plus side and AGREE on the minus floor', () => {
expect(isLedgerTakeable(-160)).toBe(true);
expect(isPromotable(-160)).toBe(true);
expect(isLedgerTakeable(-161)).toBe(false);
expect(isPromotable(-161)).toBe(false);
// divergence is confined to the plus side
expect(isLedgerTakeable(250)).toBe(true);
expect(isPromotable(250)).toBe(false);
});
});
describe('the pipeline row carries the tag and the floor it was judged under', () => {
const svc = require('../../src/services/ledgerService');
test('ledgerService requires the ledger standard, not the promotion band', () => {
const src = require('fs').readFileSync(
require('path').join(__dirname, '../../src/services/ledgerService.js'), 'utf8',
);
expect(src).toMatch(/require\('\.\.\/config\/takeableStandard'\)/);
expect(src).toMatch(/takeable: takeableFor\(/);
expect(src).toMatch(/takeable_floor: LEDGER_TAKEABLE_FLOOR/);
});
test('the service module loads and exposes its record builder', () => {
expect(typeof svc.recordPipelineGrades).toBe('function');
});
});