---
title: Pin the two data-view goldens whose shape depends on unpinned production data
type: task
status: planned
description: >-
  Two goldens fail permanently because their emitters branch on a live database read the fixture
  does not pin; regenerating would bless whichever production state exists that day.
base_uri: user:task/league/data-views/pin-database-dependent-data-view-goldens.md
created_at: '2026-09-25T02:22:45.329Z'
entity_id: 7de8002d-ae2e-400c-9ccb-af0cde468475
owner_identity_uri: █████████████████████████
public_read: true
tags:
  - user:tag/league-xo-football.md
  - user:tag/software-task.md
updated_at: '2026-09-25T02:22:45.329Z'
visibility_analyzed_at: '2026-11-05T23:48:56.623Z'
---

## Problem

Two data-view goldens fail on every run and have for some time. Neither is a code
defect, and neither is fixable by regenerating: both pin SQL whose shape is chosen
by a LIVE DATABASE READ that the fixture does not pin, so the committed expectation
was only ever true for the production state on the day it was blessed.

`test/data-views.golden-clock-invariance.spec.mjs` cannot see this class. It emits
the corpus under two very different ambient clocks and asserts the output matches --
but both instants read the same live rows, so they agree, and the pin reports green
over a fixture that is already drifting.

Measured 2026-09-25 against production. The golden set stands at 317 passing, 2
failing, and these are the 2.

## The two

### player-league-extended-salary-over-market-pre-aggregated

The emitter picks between two salary expressions on `extensions_processed`, which
`get_extensions_processed` resolves by asking whether the scoped league holds ANY
`EXTENSION` transaction (type 9) for the scoped year:

- false -> the full CASE ladder (practice-squad slots, the franchise-tag salary by
  position read from `seasons`, the `salary_paid + (extensions + 1) * 5` ladder)
- true -> bare `COALESCE(s.salary_paid, 0)`

The fixture scopes `lid = 1, season_year = 2026` and pins the FALSE branch. League 1
now carries 134 type-9 rows for 2026, so the emitter takes the true branch and the
golden fails. This flips once per league per season and will flip again.

### player-projected-points-source-and-scoring-result-equivalence

The request names `scoring_format_id: te_premium`. That id exists in neither
`league_scoring_formats` nor anywhere in `libs-shared` -- the named catalog holds
twelve slugs and `te_premium` is not among them. Resolution falls back to default
scoring, so the fixture's third column emits the same expression as its first and
the position-reception CASE the fixture was written to prove never appears.

Decide whether `te_premium` should exist (the fixture's description reads as though
it once did) or whether the fixture should name a format that does.

## Why regenerating is the wrong move

Blessing the current output pins whichever state production happens to be in today.
That is how both arrived here. The extended-salary one would then fail again the
next time a league's extensions are processed, and the projections one would
permanently enshrine a fixture that proves nothing -- its whole purpose is the
te_premium CASE, and the blessed form would not contain it.

This is also a live hazard for [[████████████████████████-██-███████████████████-████-███████-████-████-██████████]],
whose recipe runs `scripts/update-data-view-snapshots.mjs --all`. That sweep would
capture both of these silently. An observation naming them is on that continuation.

## Scope

Test fixtures and, if the te_premium question resolves that way, the named format
catalog. No emitter change is expected -- both emitters are behaving correctly.

## Plan

- [ ] Decide the pinning mechanism. A fixture whose shape depends on a database read
      has to pin that read the way the clock ones pin the clock -- candidates are
      seeding the deciding rows into the disposable database, scoping the request to
      a synthetic league that holds no extension transactions, or splitting each
      fixture into one golden per branch so both arms stay covered
- [ ] Apply it to the extended-salary fixture and confirm it survives a league whose
      extensions ARE processed
- [ ] Resolve the `te_premium` question: mint the format, or repoint the fixture
- [ ] Extend the invariance coverage so this class cannot recur silently -- the clock
      spec's shape is the model, with a control proving the corpus is genuinely
      data-sensitive without the pin
- [ ] Confirm the golden set reaches 319 passing, 0 failing

## Verification

`NODE_ENV=production node scripts/data-view-test-cli.mjs --all`, ANSI stripped
before grepping or every failure grep returns a confident zero. The summary line is
the oracle; assert its presence rather than the absence of failures.

## Key locations

- Fixtures: `test/data-view-queries/player-league-extended-salary-over-market-pre-aggregated.json`,
  `test/data-view-queries/player-projected-points-source-and-scoring-result-equivalence.json`
- Emitters: `libs-server/data-views-column-definitions/player-extended-salary-column-definitions.mjs`
  (`get_extensions_processed`), `libs-server/data-views-column-definitions/player-projected-column-definitions.mjs`
- The rule this task exists to satisfy: `docs/guides/data.md`, the paragraph beside
  the clock pin added at league `28771e4a7`
- Named format catalog: `libs-shared/named-format-catalog.mjs`

## Origin

`repl` on 2026-09-25, while confirming the golden set was unchanged by the week-only
row-axis emitter repair ([[███████████████████████-████-████-███-████-██████-█████-███████████]]).
Both failures pre-date that chain and were confirmed independent of it.
