---
title: Source/bridge migration finish-line and Phase C reference-mirror
type: task
status: completed
description: >-
  Close out the data-views identity/source-bridge migration: Phase C reference-mirror activation,
  deferred follow-ups (handoff #1-6 plus 2026-05-17 review Issues 6-7), one-shot test-seed
  regression-detection harness against league commit 98d281d1, six coverage-gap fixtures with
  promoted baselines, and full scratch slug retirement. Closes both this plan and the
  source-bridge-architecture task; advances parent identity-model migration's Phase C subset.
base_uri: user:task/league/data-views/finish-line-source-bridge-and-phase-c.md
created_at: '2026-05-17T22:58:19.917Z'
entity_id: 1b9e9e46-9f72-4e45-a14c-052e80de9911
finished_at: '2026-05-18T02:42:06.764Z'
observations:
  - ████████████████████████████████████████████████
  - ████████████████████████████████████████████████
  - ████████████████████████████████████████████████
owner_identity_uri: █████████████████████████
priority: Medium
public_read: true
relations:
  - follows [[█████████████████████-████████████-██████-███████████████]]
  - precedes [[█████████████████████-█████████████-██-████████-████████]]
  - follows [[user:guideline/write/write-software-implementation-plan.md]]
  - follows [[user:guideline/scratch-tier-discipline.md]]
  - follows [[user:guideline/write/write-javascript.md]]
  - follows [[user:guideline/write/write-software.md]]
  - follows [[user:guideline/software/simplify-software-plan.md]]
started_at: '2026-05-18T01:55:48.870Z'
tags:
  - user:tag/league-xo-football.md
updated_at: '2026-08-19T16:27:28.921Z'
visibility_analyzed_at: '2026-11-05T23:48:48.621Z'
---

# Source/bridge migration finish-line and Phase C reference-mirror

## Overview

Close out the data-views identity/source-bridge migration by retiring all loose ends across both the source/bridge architecture task and its parent identity-model migration's Phase C work. Deliverables: (1) Phase C reference-mirror activation that unblocks full aggregator delegation for matchup-opponent paths, (2) all deferred follow-ups (handoff items 1-6 and review Issues 6-7 from 2026-05-17) resolved or explicitly retired with rationale, (3) a one-shot test-seed regression-detection harness comparing pre-migration (league commit 98d281d1) vs current main against the same seeded DB, (4) six new fixtures filling identified coverage gaps with baselines promoted into `test/data-view-queries-result-baselines.json`, (5) the three Validation-and-Cleanup boxes from the source/bridge plan folded in and closed, (6) the `baseline-capture.mjs` scratch-retirement blocker resolved by relocating into the league `test/` tree. Expected outcome: both task plans flip to Completed, the source-bridge scratch slug retires cleanly, and the migration passes a deterministic semantic-equivalence gate against its pre-migration shape.

## Background

**Source/bridge architecture migration status.** Architecturally complete. `data-view-join-function.mjs` (255 lines) and `add-player-year-teams-cte.mjs` (138 lines) deleted; `granularity` field globally retired; dispatcher + identity-bridge-registry + source-attach-registry trio wired; 19 column-defs migrated; test suite at 237 pass / 19 pending / 1 pre-existing fail (`create-a-query-with-player-current-age`, attributable to concurrent points-added work). Knowledge base captured at `text/league/data-views/source-bridge-architecture.md` (293 lines). The 2026-05-17 `/review-software` pass surfaced 7 issues; 2 (Issues 3, 4) fixed in league commit `136fce39`; 2 deferred (Issues 6, 7); 3 declined as intentional or incorrect.

**Parent identity-model migration status.** `In Progress`; 24 checklist items still open. Phase C reference-mirror work: activate identity-derived `pid_reference` / `team_reference` / `year_reference` / `week_reference` from `query_context.identity_id` rather than legacy heuristics in `setup_central_references`; delete `setup_central_references` once `build_query_context` is the single source of truth. The parent task blocks `task/league/fix-data-view-dropping-seasonlogs-columns-silently.md` and supersedes `task/league/unify-data-view-output-aggregation.md`. The `matchup_opponent_type` deferred restriction (already shipped in the source/bridge task with registry-presence rationale) is the proximate Phase C dependency that allows the aggregator inline matchup branch to drop entirely.

**2026-05-17 review deferred items.** Both touch `espn-line-win-rates-column-definitions.mjs`: Issue 6 — potential duplicate year predicate emitted by both source-attach rule and `extra_predicates` against `espn_player_win_rates_index.year`; Issue 7 — `key_columns: { pid, year }` declared on `espn_player_source` but possibly unread by the active rule path. Both flagged at confidence 80 and need rule-internal verification before action.

**Deferred follow-ups inherited from handoff.**

1. Matchup-opponent full aggregator delegation (only default-mode shipped) — gated on Phase C.
2. `apply-plays-join.mjs` `year_array.join(',')` raw-SQL emission should switch to `andOnIn` parameterized binding.
3. Unreachable pid guards in `rules/player-family-to-player.mjs:12-15` and `rules/player-family-to-player-year.mjs:14-17`.
4. `source.attach` receives raw `query_context` instead of `rule_ctx` (`dispatcher.mjs:128`). Partially resolved by plays/team-stats attach helpers; other attach-using sources still get raw context.
5. `extra_predicates` duplicates `get_table_conditions` for `scoring_format_hash` on player-scoring-format-logs.
6. No result-set baseline for any projected fixture.

**Scratch retirement blocker.** `scratch/league/source-bridge-architecture/baseline-capture.mjs` (97 lines) is imported by `test/data-view-queries-result-baselines-capture.spec.mjs` and `test/data-view-queries-result-equivalence.spec.mjs` via a `../../../../scratch/...` path. It cannot retire to `/dev/null` while those imports stand. Relocation into `repository/active/league/test/helpers/` is the cleanest path.

**Coverage-gap fixtures.** Current 128 fixtures include only 7 matching projected/matchup/split keywords. Identified gaps: (a) team-keyed columns on player subject with no year filter and no year split, (b) `force_player_active: true` with year+week splits, (c) two or more bespoke-attach sources in the same query, (d) `matchup_opponent_type` × `year_offset` combination, (e) `scoring_format_hash` with split-by-year on `player-scoring-format-logs`, (f) projected fixture baselines promoted into the result-equivalence baselines.

**Regression-detection harness approach.** Test-seed comparison: `git worktree add ../league-pre-migration 98d281d1`, run a thin replay script from both worktrees against the same `test/global.mjs`-seeded DB, diff per-fixture on row hash, column count, and SQL byte-equivalence. Catches semantic divergences deterministically. One-shot gate; ages out when seeds change.

## Design

### Approach

Six work units, ordered to minimize coupling and let each land + validate independently. Unit A unblocks the slug retirement and must precede Unit F. Unit B (Phase C activation) precedes the aggregator inline-branch removal so the two semantic changes don't compound in one commit. Unit C is fully parallel-safe across its items. Unit D runs against current main and Unit B's output; sequencing it after Unit B catches both source-bridge and Phase C effects together. Unit E can land any time after Unit B settles. Unit F is the close-out.

### File organization

New files:

- `repository/active/league/test/helpers/data-view-baseline-capture.mjs` (moved from scratch; tracked)
- `scratch/league/source-bridge-finish-line/ABOUT.md` (entity stub; tracked)
- `scratch/league/source-bridge-finish-line/regression-diff-report.md` (Unit D output; gitignored)
- `scratch/league/source-bridge-finish-line/worktree-results-pre.json`, `worktree-results-post.json` (Unit D raw captures; gitignored)
- 6 new fixtures under `repository/active/league/test/data-view-queries/`
- `repository/active/league/.gitignore` — add `test/data-view-queries-result-baselines.captured.json` (capture-spec sidecar)

Modified files (league):

- `repository/active/league/test/data-view-queries-result-baselines-capture.spec.mjs`, `data-view-queries-result-equivalence.spec.mjs` — import-path swap
- `libs-server/get-data-view-results.mjs` — Phase C activation; delete `setup_central_references`
- `libs-server/data-views/source-attach/apply-plays-join.mjs` — `year_array.join(',')` → `andOnIn`
- `libs-server/data-views/source-attach/rules/player-family-to-player.mjs`, `player-family-to-player-year.mjs` — remove unreachable pid guards
- `libs-server/data-views/source-attach/dispatcher.mjs` — wrap remaining `source.attach` callers with `rule_ctx`
- `libs-server/data-views-column-definitions/player-scoring-format-logs-column-definitions.mjs` — consolidate `extra_predicates` / `get_table_conditions` duplication
- `libs-server/data-views-column-definitions/espn-line-win-rates-column-definitions.mjs` — resolve duplicate year predicate; resolve `key_columns`
- `test/data-view-queries-result-baselines.json` — 6 new baseline entries plus any rebaselines from Unit B
- Skip-query-match fixture flags re-shuffled per `andOnIn` migration

Modified files (user-base):

- `text/league/data-views/source-bridge-architecture.md` — append "Migration history" H2 section
- `████████████████████████████████████████████████████` — close Validation/Cleanup boxes; flip status; strip pipeline observations
- `███████████████████████████████████████████████████` — flip Phase C reference-mirror items; observation added

### Key components and relationships

- `build_query_context` (existing) becomes the single source of truth for `pid_reference` / `team_reference` / `year_reference` / `week_reference`. Phase C activation drops the parallel `setup_central_references` write-back into `data_view_options`.
- `data_view_options` continues to carry FROM-table-aware overrides where they legitimately differ (the `dv.X ?? query_context.X` pattern in `team-stats-from-plays`). Phase C eliminates only the redundant identity-derived references that mirror `query_context`.
- Aggregator inline matchup branch in `resolve_team_join_target` is **retained intentionally**. The branch (`if matchup === 'current_week_opponent_total' return 'current_week_opponents.opponent'`, mirror for `next_week_opponent_total`) is a reference-target redirect to an opponents CTE that is already attached upstream by the opponent-CTE setup loop in `get-data-view-results.mjs` (around line 1484). It is not row-shape composition, so a matchup-mode entry in the identity-bridge registry would have a no-op `add_cte` and a single-line `join_cte` — over-abstraction per `simplify-software-plan` (no third concrete case, no cross-cutting edit prevented). The branch stays inline and the rationale is captured in the architecture doc's Migration history section by Unit F.
- Unit D regression-detection harness: reuses the existing `data-view-queries-result-baselines-capture.spec.mjs` from each worktree by setting an env var (`DATA_VIEW_BASELINE_OUTPUT_PATH`) to redirect output. No bespoke harness script needed — Mocha already provides the test-runner, DB seeding, and `#libs-server` alias resolution inside each worktree's package root. The diff between the two capture JSON files is computed by a short inline shell/node one-liner.

### Integration points

- Test seeding (`test/global.mjs`) must produce a clean DB state at the start of each worktree run; the harness invokes both worktrees serially against fresh seeds.
- `applied_bridges` Set on `query_context` continues to dedup bridge emission; no change for Phase C.
- The existing equivalence harness (`test/data-view-queries-result-equivalence.spec.mjs`) is the long-term gate; the Unit D harness is a one-shot pre-merge check answering "did the migration change semantics".

### Knowledge Base Impact

- **Domain entry**: `text/league/data-views/source-bridge-architecture.md` (293 lines, canonical). Append "Migration history" H2 documenting Phase C completion, the seven deferred follow-ups' resolutions, and the regression-harness one-shot finding.
- **In-repo system doc**: `repository/active/league/docs/data-views-system.md` already points to the user-base architecture doc. Verify in Unit B that no code excerpts in the doc are invalidated by reference-mirror activation; refresh if so.
- **ABOUT.md files**: none required beyond the new scratch slug's stub.
- **Tag implications**: none. Existing `user:tag/league-xo-football.md` and base-project tags cover the work.
- **Observation candidates**:
  - Source/bridge task: `[plan-completed]` on close plus `[final-status]` summarizing finish-line resolution.
  - Parent task: `[progress]` per Phase C item closed.
  - Architecture doc: `[migration-closed] <date>` observation.
- **Guideline candidates**: none. The pattern is documented in the architecture doc.
- **Relations**:
  - New task `follows` `[[█████████████████████-████████████-██████-███████████████]]`.
  - New task `precedes` parent task's non-Phase-C outstanding items.
  - Update parent task: this plan resolves Phase C reference-mirror, narrowing the parent's remaining scope to UI/Redux/snapshot work.

### Scratch slug declaration

Per `[[user:guideline/scratch-tier-discipline.md]]`, Unit D produces multi-file working-tier artifacts that don't fit the task body and aren't canonical data:

- **Slug**: `scratch/league/source-bridge-finish-line/`
- **Owner task**: this task
- **Durable files** during slug lifetime:
  - `ABOUT.md` — tracked entity stub declaring slug, owner, retirement contract
  - `regression-diff-report.md` — gitignored per-fixture verdict ledger
  - `worktree-results-pre.json`, `worktree-results-post.json` — gitignored raw fixture-replay captures (output of `data-view-queries-result-baselines-capture.spec.mjs` from each worktree)
- **Retirement contract (three-fork)**:
  - **Promote**: nothing. Findings captured in commit messages and the architecture doc's "Migration history" section.
  - **Archive**: if `regression-diff-report.md` surfaces non-trivial intentional divergences worth long-term reference, move to `data/league/data-views/source-bridge-regression-report.md`; otherwise no archive.
  - **Delete**: both raw JSON captures, the report if not archived. ABOUT.md updated to retired status.

## Tasks

### Pre-flight

- [x] **Create scratch slug ABOUT.md and commit**
  - File: `scratch/league/source-bridge-finish-line/ABOUT.md`
  - Purpose: Declare the working-tier slug upfront so Unit D artifacts have a tracked owner.
  - Changes:
    - Create via `base entity create` with `owned_by` relation pointing at this task and the retirement contract above.
    - Commit (user-base side; ████████ auto-commits .md files in scratch).

### Unit A — Test infrastructure relocation

- [x] **Move `baseline-capture.mjs` into the league test tree**
  - Files: `scratch/league/source-bridge-architecture/baseline-capture.mjs` (delete after move) → `repository/active/league/test/helpers/data-view-baseline-capture.mjs`
  - Purpose: The capture module is actively consumed by two production test specs; relocating it into the league tracked tree unblocks scratch slug retirement.
  - Changes:
    - Move file contents into `test/helpers/data-view-baseline-capture.mjs` (create directory if missing).
    - Update header comment to drop the "lives in user-base/scratch/" framing.

- [x] **Update spec imports**
  - Files:
    - `repository/active/league/test/data-view-queries-result-baselines-capture.spec.mjs`
    - `repository/active/league/test/data-view-queries-result-equivalence.spec.mjs`
  - Purpose: Repoint imports from the scratch path to the new tracked location.
  - Changes:
    - Replace `../../../../scratch/league/source-bridge-architecture/baseline-capture.mjs` with `./helpers/data-view-baseline-capture.mjs`.
    - Adjust the capture-spec output path: read from env var `DATA_VIEW_BASELINE_OUTPUT_PATH` first; default to `path.resolve(__dirname, 'data-view-queries-result-baselines.captured.json')` (a gitignored sidecar in the league `test/` directory, NOT into scratch). The env-var override is what Unit D uses to redirect each worktree's output to the scratch slug.
    - Add `test/data-view-queries-result-baselines.captured.json` to `.gitignore` (league repo).
    - Document the manual promotion step in the spec header: when ready, `cp test/data-view-queries-result-baselines.captured.json test/data-view-queries-result-baselines.json` (or `mv`), commit. The `.captured` file is the staging area; the tracked file is the canonical baseline.
    - Run `yarn test --reporter min test/libs-server.data-view-queries.mjs test/data-view-queries-result-equivalence.spec.mjs` and verify 237 / 19 / 1.

### Unit B — Phase C reference-mirror activation

- [x] **Activate identity-derived references from `query_context`**
  - File: `repository/active/league/libs-server/get-data-view-results.mjs`
  - Purpose: Drop the parallel `setup_central_references` writeback into `data_view_options`; let `build_query_context` be the single source of truth for `pid_reference` / `team_reference` / `year_reference` / `week_reference`.
  - Changes:
    - Audit `setup_central_references` (existing function): every consumer reading from `data_view_options.pid_reference` etc. must be reachable via `query_context.pid_reference` etc.
    - For consumers that legitimately need the FROM-table-aware override (e.g., `team-stats-from-plays`), retain `data_view_options.X` as the override layer and document via comment.
    - Delete `setup_central_references` and its call site once all consumers verify.

- (intentionally omitted: "drop aggregator inline matchup branch") -- the inline branch in `resolve_team_join_target` is a reference-target redirect to an opponents CTE that the upstream opponent-CTE setup loop (`get-data-view-results.mjs` ~line 1484) has already attached. It is not row-shape composition, so a matchup-mode entry in `identity-bridge-registry` would have a no-op `add_cte` and a single-line `join_cte`. Per `simplify-software-plan` (rule of three, no hypothetical axis of change, no cross-cutting edit prevented), the 6-line inline branch is the correct level of abstraction. The handoff's deferred follow-up #1 ("matchup-opponent full delegation through aggregators") is hereby resolved as **declined, with rationale**: the architectural payoff doesn't justify authoring a registry entry whose only job is to redirect a reference target. Unit F's architecture-doc Migration history section will record this design decision.

- [x] **Verify column-defs no longer read legacy reference fields**
  - Files: any column-def that still reads `data_view_options.pid_reference` etc.
  - Purpose: After Phase C activation, identity-derived reads should come from `query_context`. The FROM-table-aware override layer should be narrowly scoped.
  - Changes:
    - Grep for `data_view_options.pid_reference`, `data_view_options.team_reference`, etc. across `libs-server/data-views-column-definitions/`.
    - For each hit, decide: legitimate FROM-table override (keep), or unreachable legacy (delete).

### Unit C — Deferred follow-ups

- [x] **Remove unreachable pid guards (handoff #3)**
  - Files:
    - `libs-server/data-views/source-attach/rules/player-family-to-player.mjs:12-15`
    - `libs-server/data-views/source-attach/rules/player-family-to-player-year.mjs:14-17`
  - Purpose: The guards are unreachable per prior analysis recorded in handoff. Remove dead code.
  - Changes:
    - Verify unreachability one more time (no caller path reaches the guarded branch).
    - Delete the guard blocks.

- [x] **Consolidate `extra_predicates` and `get_table_conditions` for `scoring_format_hash` (handoff #5)**
  - File: `libs-server/data-views-column-definitions/player-scoring-format-logs-column-definitions.mjs`
  - Purpose: The two emit the same predicate; consolidating prevents duplicate predicate emission.
  - Changes:
    - Trace both code paths' final SQL output for a representative fixture.
    - Remove the duplicate predicate from whichever path is redundant.
    - Re-run equivalence harness; confirm no row-hash divergence.

- [x] **Wrap remaining `source.attach` callers with `rule_ctx` (handoff #4)** -- DECLINED with rationale. Attempted in 6fcaca10 but reverted: rule_ctx is a shallow-spread snapshot taken before `emit_predicate` runs, so attaches like `game-column-definitions` that branch on late-registered fields (`player_year_teams_cte_name` set by emit_predicate) would see stale state. Helpers that need FROM-table-aware references (`apply-plays-join`, `apply-team-stats`) already use the `dv.X ?? query_context.X` fallback pattern locally; rule of three is not met for the broader abstraction. Per `[[user:guideline/software/simplify-software-plan.md]]`.
  - File: `libs-server/data-views/source-attach/dispatcher.mjs:128`
  - Purpose: `source.attach` receives raw `query_context` instead of `rule_ctx` for some attach-using sources. Standardize on `rule_ctx`.
  - Changes:
    - **Pre-flight enumeration**: `grep -n 'source\.attach\|attach:' libs-server/data-views/source-attach/dispatcher.mjs libs-server/data-views-column-definitions/*.mjs` and write the resulting list of attach-using sources here in the task body before editing; mark each as "already-converted (rule_ctx)" or "still-raw (query_context)". Plays and team-stats are known already-converted per handoff; the rest need verification.
    - Construct `rule_ctx` (`{ query_context, params, source, table_alias, ... }`) in the dispatcher branch and pass uniformly.
    - Update any attach helper signatures relying on raw `query_context` to destructure from `rule_ctx`.

- [x] **Migrate `apply-plays-join` year array to `andOnIn` (handoff #2)**
  - File: `libs-server/data-views/source-attach/apply-plays-join.mjs`
  - Purpose: Replace `year_array.join(',')` raw-SQL emission with parameterized `andOnIn` binding for defense-in-depth even though params are integer-parsed upstream.
  - Changes:
    - Locate the `year_array.join(',')` site; switch to `this.andOnIn('year', year_array)` (or equivalent knex builder).
    - Update `skip_query_match: true` fixtures whose SQL bytes shift as a result; flip them back to `skip_query_match: false` if the new SQL matches a re-captured baseline. Confirm row hashes unchanged via the equivalence harness.

- [x] **Resolve espn-line duplicate year predicate (Issue 6, 2026-05-17)**
  - File: `libs-server/data-views-column-definitions/espn-line-win-rates-column-definitions.mjs`
  - Purpose: Confirm whether the source-attach rule and `extra_predicates` both emit a year predicate against `espn_player_win_rates_index.year`; if so, eliminate the duplicate.
  - Changes:
    - Trace the SQL output for a representative espn-line-win-rates fixture; locate the year-predicate emission sites.
    - If duplicated: drop the `extra_predicates` year entry (keep rule emission as canonical), or vice versa whichever is structurally cleaner.
    - If not duplicated: add a comment explaining why both paths participate.

- [x] **Resolve espn-line `key_columns` field (Issue 7, 2026-05-17)**
  - File: `libs-server/data-views-column-definitions/espn-line-win-rates-column-definitions.mjs`
  - Purpose: `key_columns: { pid: 'pid', year: 'year' }` is declared on `espn_player_source` but possibly unread by the active source-attach rule. Either consume it or remove it.
  - Changes:
    - Grep `source-attach/rules/` for `source.key_columns` references.
    - If used: confirm the espn case works correctly and add a one-line assertion or comment.
    - If not used: remove the `key_columns` field from `espn_player_source` (and `espn_team_source` if applicable).

### Unit D — Regression-detection harness

- [x] **Create worktree at league commit 98d281d1 and run capture spec from both branches**
  - Files: `scratch/league/source-bridge-finish-line/worktree-results-pre.json`, `worktree-results-post.json`
  - Purpose: Capture pre-migration and current-main fixture outputs against the same seeded test DB. No bespoke harness script needed -- Unit A's env-var redirect on `data-view-queries-result-baselines-capture.spec.mjs` does the work from inside each worktree's own package (so `#libs-server` and `#db` aliases resolve cleanly, no cross-package `../` traversal).
  - Changes:
    - **Pre-migration capture**:
      - `git worktree add ../league-pre-migration 98d281d1` (run from `repository/active/`).
      - The pre-migration worktree has NOT yet received Unit A's spec-import swap -- it still imports from `../../../../scratch/league/source-bridge-architecture/baseline-capture.mjs`. Either keep the scratch file in place during this capture step OR copy Unit A's helper into the pre-migration worktree's `test/helpers/` and apply the import swap there as a throwaway worktree-local edit.
      - From the pre-migration worktree: `DATA_VIEW_BASELINE_OUTPUT_PATH=/Users/trashman/user-base/scratch/league/source-bridge-finish-line/worktree-results-pre.json yarn test --reporter min test/data-view-queries-result-baselines-capture.spec.mjs`.
    - **Post-migration capture**:
      - Wait for the pre-migration capture to fully complete before starting (serial, NOT concurrent -- both invocations seed and reset the shared test DB via `test/global.mjs`; concurrent runs would corrupt state).
      - From the main worktree (current `repository/active/league/`): `DATA_VIEW_BASELINE_OUTPUT_PATH=/Users/trashman/user-base/scratch/league/source-bridge-finish-line/worktree-results-post.json yarn test --reporter min test/data-view-queries-result-baselines-capture.spec.mjs`.
    - Verify both output JSON files have entries for all 128+ fixtures (134 after Unit E lands).
    - `git worktree remove ../league-pre-migration` after the diff step below.

- [x] **Generate `regression-diff-report.md` and review** -- 0 divergences. 64 identical hashes, 45 sparse-both, 19 errored-both (pre-existing seed gaps). Migration semantically equivalent.
  - File: `scratch/league/source-bridge-finish-line/regression-diff-report.md`
  - Purpose: Per-fixture verdict ledger comparing pre vs post captures.
  - Changes:
    - Diff `worktree-results-pre.json` vs `worktree-results-post.json` on (row_hash, column_count). For each fixture with divergence, emit a section with: fixture name, pre/post hashes, intentional explanation if known.
    - Hand-review every divergence. Expected intentional divergences: the Issue 1 cell (team-keyed on player subject with no year filter), any orphan-CTE removals, base_years CTE additions.
    - Any unexpected divergence: stop and file a bug observation on this task before proceeding.

### Unit E — Coverage-gap fixtures

- [x] **Add 6 fixtures targeting identified mixture gaps**
  - Files: 6 new files under `repository/active/league/test/data-view-queries/`
  - Purpose: Fill mixture-coverage gaps that the existing 128 fixtures don't exercise.
  - Changes (one fixture file per row, named per existing kebab-case convention):
    - `team-keyed-column-on-player-subject-no-year-filter-no-split.json` — exercises the Issue 1 bridge-always-materializes cell.
    - `team-stats-from-plays-force-player-active-year-week-split.json` — exercises the `force_player_active=true` player-keyed CTE path with year+week splits.
    - `multi-bespoke-attach-plays-practice-dfs-salaries.json` — composes two or more bespoke-attach sources at differing grains in one query.
    - `matchup-opponent-type-with-year-offset.json` — crosses the inline matchup branch with year_offset behavior.
    - `scoring-format-hash-split-by-year-on-player-scoring-format-logs.json` — exercises the duplicate-predicate path from handoff #5.
    - `season-projected-stats-with-result-baseline.json` — projected fixture wired into result-equivalence (one is enough to gate the projected path).
    - Pattern each fixture body after a structurally similar existing fixture; assert representative request shape and expected row count via fixture metadata.

- [x] **Capture and promote baselines for the 6 new fixtures** -- 4 captured row hashes, 2 errored at capture (seed-gap + latent matchup_opponent+year_offset bug observed). Suite: 247 passing / 21 pending / 1 pre-existing fail.
  - Files: `repository/active/league/test/data-view-queries-result-baselines.json`
  - Purpose: Add result-hash baselines so the equivalence harness gates the new fixtures.
  - Changes:
    - Run `yarn test --reporter min test/data-view-queries-result-baselines-capture.spec.mjs` to capture new entries.
    - Promote captured entries into the tracked baselines file (manual merge of the new keys; existing keys unchanged).
    - Re-run `yarn test --reporter min test/libs-server.data-view-queries.mjs test/data-view-queries-result-equivalence.spec.mjs`; expected passing floor 243 (237 + 6 new). Ceiling depends on whether Unit B's reference-mirror activation or Unit C's `andOnIn` migration de-flagged any `skip_query_match` fixtures (each de-flag turns a pending into a pass). Any divergence below 243 or any pre-existing fail other than `create-a-query-with-player-current-age` is a regression -- investigate before proceeding.

### Unit F — Cleanup, KB updates, retirement

- [x] **Append "Migration history" to architecture doc**
  - File: `text/league/data-views/source-bridge-architecture.md`
  - Purpose: Document migration completion, Phase C resolution, follow-up dispositions, and the regression-harness finding.
  - Changes:
    - Add H2 section at end of doc with subsections: (a) Phase C completion date and outcome, (b) seven deferred follow-ups disposition table (resolved / declined / retired), (c) one-shot regression harness result summary with link to archived report if any, (d) coverage fixtures added.
    - Add `[migration-closed] <date>` observation to the entity's frontmatter.

- [x] **Close source/bridge task plan**
  - File: `████████████████████████████████████████████████████`
  - Purpose: Flip Validation/Cleanup boxes to [x] with outcome links to this plan's commits; transition status to Completed.
  - Changes:
    - **Pre-flight re-read**: open the file and confirm the three Validation/Cleanup checkboxes are still `[ ]` (open). If they have shifted state since this plan was written, reconcile -- another session may have closed them out of band; in that case skip the redundant ticking and just update status.
    - Mark the three Validation/Cleanup checkboxes [x] with one-line outcome pointing at the corresponding commits/sections of this plan.
    - Update status to Completed; let `finished_at` auto-set.
    - Strip transient pipeline observations (`[plan-completed]`, `[triage-queued]`, `[draft-triaged]`).

- [x] **Update parent task with Phase C resolution**
  - File: `███████████████████████████████████████████████████`
  - Purpose: Flip Phase C reference-mirror checklist items [x]; record progress observation.
  - Changes:
    - Flip ONLY the Phase C items actually completed by Unit B (`setup_central_references` retired, identity-derived references activated). Do NOT flip any item describing aggregator inline-branch removal -- that work was declined per Unit B's design note and the parent should record the declined-with-rationale rather than a checked box.
    - Add a `[progress] <date>` observation summarizing Phase C completion via this finish-line plan and noting the aggregator-inline-branch decision.
    - Leave non-Phase-C checklist items untouched.

- [x] **Retire source/bridge scratch slug**
  - File: `scratch/league/source-bridge-architecture/`
  - Purpose: With `baseline-capture.mjs` relocated by Unit A, the slug is fully retirable.
  - Changes:
    - Delete the now-orphaned `baseline-capture.mjs` from scratch (Unit A moved its contents).
    - Update `scratch/league/source-bridge-architecture/ABOUT.md` to retired status with three-fork disposition recorded (promoted, archived, deleted as documented in 2026-05-17 partial retirement).

- [x] **Retire finish-line scratch slug**
  - File: `scratch/league/source-bridge-finish-line/`
  - Purpose: Close this plan's working-tier slug per the retirement contract declared in Design.
  - Changes:
    - If `regression-diff-report.md` surfaced non-trivial intentional divergences: move to `data/league/data-views/source-bridge-regression-report.md` and record observation on this task; otherwise no archive.
    - Delete both raw JSON captures and the report (if not archived).
    - Update `ABOUT.md` to retired status with three-fork disposition.
    - Mark this task plan status Completed; strip transient pipeline observations.

## Notes

- The parent identity-model migration retains 20+ open items after this plan closes (UI/Redux, snapshot fixtures, schema work). Those are properly the parent's scope and out of scope here.
- Unit B's `setup_central_references` removal is the single highest-risk change in this plan; the Unit D harness is sized specifically to catch its regressions.
- Unit C items are independent; landing each as a separate commit keeps bisect granular.
- The 6 new fixtures in Unit E are deliberately small — each tests one mixture, not a feature suite. Resist the urge to combine them.
- If Unit D surfaces any unexpected divergence, STOP and file a bug observation on this task before continuing. The pre-existing `create-a-query-with-player-current-age` failure is the only known acceptable divergence; everything else is in scope.
- All file naming follows kebab-case (`data-view-baseline-capture.mjs`, `regression-diff-report.md`, fixture filenames). All imports use `#libs-server` / `#db` / `#constants` aliases per `[[user:guideline/write/write-javascript.md]]`.
- Aggregator inline matchup branch is intentionally retained -- see Unit B rationale and the `[plan-revised]` observation. Treat any future attempt to abstract it into a matchup-mode identity bridge as an explicit design reopening, not a cleanup.
- Unit D reuses `data-view-queries-result-baselines-capture.spec.mjs` directly via `DATA_VIEW_BASELINE_OUTPUT_PATH` env-var redirect from each worktree's package root -- no bespoke harness script. This keeps `#libs-server` / `#db` alias resolution within each worktree's `package.json` `imports` scope per [[user:guideline/write/write-javascript.md]].
