Files
vyndr/tests/unit/clvLegacyRemoval.test.js
builtbykev ca9ca34cbb Remove legacy C4 CLV from FIVE surfaces; install directional badge on ledger
TRUTH FIX FIRST. row.clv/clv_result derive from the overwritable
closing_line — 637/699 rows had closing == locked — so of the 578 rendered
chips, 522 "flat"s encoded a CAPTURE FAILURE as a held line. That number
was live on FIVE surfaces, not the one the order assumed:

  1. ledger card            ClvChip@319            (authed)
  2. public profile /u/     duplicate chip@260     (PUBLIC, shareable)
  3. dashboard              "· CLV BEAT"@508       (authed)
  4. board / Slate          "CLV BEAT/FADED"@422   (FREE surface)
  5. board / Slate          "✓ HIT · CLV BEAT"@517 (FREE surface)

Removing it from the ledger alone would have left the lie live on three
surfaces including two public ones, defeating the stated PRIMARY GOAL, so
the removal covers all five. That is a deliberate extension beyond the
"scoped to ledger card" guardrail and is flagged as such — the guardrail
protected against feature creep, and this is the same defect at four more
addresses.

DIRECTIONAL BADGE installed in the old ledger slot. Three time states now
read distinctly on the row: entry (locked_odds, at-grade) · close (badge,
at-close) · outcome (hit/miss, final). The RESULT stays the row hero.
The PUBLIC profile deliberately gets NO badge — it never receives dclv
data (Analyst+Desk, server-gated), so that surface now shows the settled
result alone.

HONEST ABSENCE, tested: the 578 formerly-chipped rows now render NOTHING —
not a "flat", which is the old chip's lie in subtler form. Rows settled
before capture existed will never get dclv, and permanent silence is the
correct output. All six states verified in place; a 40-row dense ledger
stays legible (27 badges, max 40 chars, one line, consistent slot after
OutcomeChip); no CLV sort or filter exists.

FIELD REMOVAL DEFERRED as a separate scoped cleanup: /api/ledger/mine and
/api/profiles still SEND clv/clv_result, and dashboard/Slate still type
them. Display removal is local and safe; stripping the fields mid-swap
could break a response consumer.

Suite 289/3485 green, build exit 0.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SmNjJAwEnqHPtXbvSZR8kA
2026-07-20 13:58:47 -04:00

91 lines
3.6 KiB
JavaScript

/**
* Session 64 — the legacy C4 CLV display is GONE from every surface.
*
* TRUTH FIX, not a placement. row.clv/clv_result derive from the overwritable
* closing_line: 637/699 rows had closing == locked, so 522 of the 578 rendered
* "flat"s encoded a CAPTURE FAILURE as a held line. That number was live on
* FIVE surfaces, two of them public.
*
* These lock the removal so it cannot quietly return, and lock the distinction
* between the two CLV lineages.
*/
const fs = require('fs');
const path = require('path');
const read = (f) => fs.readFileSync(path.join(__dirname, '..', '..', f), 'utf8');
const SURFACES = {
'ledger card (authed)': 'web/src/app/ledger/page.tsx',
'public profile (share link)': 'web/src/app/u/[handle]/PublicProfile.tsx',
'dashboard': 'web/src/app/dashboard/page.tsx',
'board / Slate': 'web/src/components/Slate.tsx',
};
// Comments explaining the removal legitimately mention the old names.
const stripComments = (src) => src
.replace(/\/\*[\s\S]*?\*\//g, '')
.split('\n').filter((l) => !l.trim().startsWith('//')).join('\n');
describe('LEGACY C4 CLV — removed from every surface', () => {
for (const [name, file] of Object.entries(SURFACES)) {
test(`${name} renders no legacy CLV`, () => {
const code = stripComments(read(file));
expect(code).not.toMatch(/clv_result\.toUpperCase/);
expect(code).not.toMatch(/CLV \{row\.clv/);
expect(code).not.toMatch(/CLV BEAT/);
});
}
test('the ClvChip component itself no longer exists', () => {
expect(stripComments(read(SURFACES['ledger card (authed)']))).not.toMatch(/function ClvChip/);
expect(stripComments(read(SURFACES['public profile (share link)']))).not.toMatch(/ClvChip/);
});
});
describe('THE TWO LINEAGES MUST NEVER CROSS', () => {
test('the new badge reads ONLY dclv_state, never row.clv/clv_result', () => {
const badge = read('web/src/lib/clvBadge.js');
expect(badge).toMatch(/dclv_state/);
expect(badge).not.toMatch(/clv_result/);
expect(badge).not.toMatch(/read\.clv\b/);
});
test('the ledger row renders the directional badge in the old slot', () => {
const src = read(SURFACES['ledger card (authed)']);
expect(src).toMatch(/<ClvBadge read=/);
expect(src).toMatch(/import ClvBadge/);
});
test('the PUBLIC profile gets NO badge — it never receives dclv data', () => {
expect(read(SURFACES['public profile (share link)'])).not.toMatch(/ClvBadge/);
});
});
describe('HONEST ABSENCE — not a subtler "flat"', () => {
const { clvBadge } = require('../../web/src/lib/clvBadge');
test('a formerly-chipped historical row now renders NOTHING', () => {
// Exactly the shape of the 578 rows that used to show "CLV 0 · FLAT".
const legacyRow = { clv: 0, clv_result: 'flat', locked_odds: '-110', closing_line: 1.5, outcome: 'hit' };
expect(clvBadge(legacyRow)).toBeNull();
});
test('rows that will NEVER get dclv (settled pre-capture) stay silent forever', () => {
expect(clvBadge({ outcome: 'miss', locked_odds: '-120', dclv_state: null })).toBeNull();
});
test('absence makes NO claim — there is no "flat"/"no movement" output path', () => {
const states = ['unknown', 'flat', null, undefined];
for (const st of states) {
expect(clvBadge({ dclv_state: st, locked_odds: '-110', closing_odds: '-145' })).toBeNull();
}
});
});
describe('NO CLV SORT/FILTER (a soft aggregate)', () => {
test('the ledger exposes no CLV sort or filter control', () => {
const code = stripComments(read(SURFACES['ledger card (authed)']));
expect(code).not.toMatch(/sort.*dclv|dclv.*sort/i);
expect(code).not.toMatch(/filter.*dclv|dclv.*filter/i);
});
});