---
title: Disambiguate Trade Review Market Value Naming
type: task
status: completed
description: >-
  view_trade_asset_flow aliases a KeepTradeCut value to market_value_at_trade and that name reaches
  the trade-review API and the page a league manager reads, reintroducing the misleading spelling
  the 2026-08-02 roster_asset_holding rename removed. Renames through view, server, API and SPA to
  keeptradecut_value_at_trade before composite_trade_value arrives and collides with it.
base_uri: user:task/league/disambiguate-trade-review-market-value-naming.md
created_at: '2026-08-03T22:49:41.131Z'
entity_id: 7c3773be-0918-4e32-a5ee-a1e9dc8bf82a
finished_at: '2026-08-04T22:45:30.889Z'
observations:
  - ████████████████████████████████████████████████
  - ████████████████████████████████████████████████
  - ████████████████████████████████████████████████
  - ████████████████████████████████████████████████
  - ████████████████████████████████████████████████
  - ████████████████████████████████████████████████
  - ████████████████████████████████████████████████
  - ████████████████████████████████████████████████
owner_identity_uri: █████████████████████████
priority: Medium
public_read: true
relations:
  - relates [[████████████████████████-███████-█████-████████████]]
  - relates [[███████████████████████-█████-█████████-████████]]
  - follows [[user:guideline/write/disambiguate-domain-object-names.md]]
started_at: '2026-08-04T20:33:12.408Z'
tags:
  - user:tag/league-xo-football.md
  - ███████████████-██████-███████████
updated_at: '2026-10-26T05:00:23.091Z'
visibility_analyzed_at: '2026-11-06T00:17:50.487Z'
---

# Disambiguate Trade Review Market Value Naming

## Overview

`view_trade_asset_flow` aliases a KeepTradeCut value to `market_value_at_trade`, and that name propagates to the
trade-review API and the page a league manager reads. It is the same misleading spelling the 2026-08-02
`roster_asset_holding` rename removed, reintroduced one layer out.

A single-source vendor index is being presented as if it were a multi-source market value. It will collide directly
with `composite_trade_value`, which [[████████████████████████-███████-█████-████████████]] introduces as a genuine
multi-source composite.

## Background

On 2026-08-02, league `17e469052` renamed `roster_asset_holding.composite_market_value_at_{acquisition,termination}`
to `keeptradecut_value_at_*`, because that is what `compute-snapshots-bulk.mjs` has always populated them from. The
task recorded it as "truth-in-naming on a subsystem this goal does not touch" and split it out deliberately. This is
the other half, missed because the rename swept the base table and not the view over it.

`db/schema.postgres.sql:26805`:

```sql
src.keeptradecut_value_at_termination AS market_value_at_trade
```

The spelling reaches:

| surface | site |
| --- | --- |
| view | `view_trade_asset_flow` — `market_value_at_trade` |
| server | `libs-server/trade-review/grade-trades.mjs:318,321` — `market_value_at_trade`, `current_market_value` |
| API | `api/routes/leagues/trade-review.mjs:153-156` |
| SPA | `app/views/components/trade-review-trade/trade-review-trade.js:148-170` |
| script | `scripts/grade-trades.mjs:45` |

`current_market_value` is the worse of the two: it has no base-table equivalent that could have been renamed, it is
computed in `grade-trades.mjs` from `ktc_at()` / `ktc_pick_at()`, and it is rendered to the user as "now".

Per [[user:guideline/write/disambiguate-domain-object-names.md]], a name that spans two concepts must carry a
distinct verbose spelling from first definition. "Market value" here means one vendor's index; it will shortly also
mean a fitted composite over four sources.

## Design

Rename to say the source: `keeptradecut_value_at_trade` and `current_keeptradecut_value`, matching the base-table
spelling the 2026-08-02 rename settled on.

Rename through every layer in one change. A view alias, a server field and a JSON response key are one name wearing
three hats, and leaving any layer on the old spelling reintroduces a translation seam that exists only because the
rename stopped early — which is the defect being fixed.

**No compatibility alias on the view, and no dual key in the API response.** The SPA is deployed from this repo in
the same cycle, so there is no independent client to break.

### Sequencing

`view_trade_asset_flow` is a `CREATE OR REPLACE VIEW`, not a table rename, so it does not open the schema-export
race window that renames and drops do. It is still DDL: keep the apply-to-commit window short and check for a
concurrent `yarn export:schema` before committing.

The SPA change means this needs `yarn build && yarn deploy:dist && yarn deploy:sourcemaps`, not a backend-only
deploy — prefer `yarn deploy:all`.

### Knowledge Base Impact

- `text/league/player-valuation-system.md` — § "Trade grading" documents these field names
- The view's own `COMMENT ON VIEW` already says "market_value_at_trade is the source holding's KTC value at the
  moment it left", which is a comment explaining away a wrong name. It goes with the rename

### Working tier

None needed.

### Orchestrator shape

Single task entity.

## Plan

- [x] **Coordinate with the trade-review frontend owner before starting**
  - A `█████████████████████████████` session recently shipped this surface. Check `base thread list --running`; if
    live, hand this over or sequence behind it rather than editing the same component
  - Verify: either that session is not live, or its owner has acknowledged

- [x] **`db/adhoc/2026-08-04-rename-trade-asset-flow-market-value.sql`**
  - `CREATE OR REPLACE VIEW view_trade_asset_flow` with `keeptradecut_value_at_trade`; rewrite the view comment to
    describe the column rather than excuse its name
  - `-- STATUS: PENDING` banner; `yarn db:exec`; `yarn export:schema`; commit both together
  - Verify: the exported schema diff is exactly the view; no other session's DDL rode along

- [x] **Sweep the four consumers**
  - `grade-trades.mjs`, `api/routes/leagues/trade-review.mjs`, the SPA component, `scripts/grade-trades.mjs`
  - `current_market_value` becomes `current_keeptradecut_value` at the same time — it is the same concept and
    splitting the two renames doubles the sweep
  - Verify: grep for `market_value_at_trade` and `current_market_value` across the repo returns zero hits outside
    `db/adhoc/` history. Validate the pattern against a known occurrence first
  - Verify: `test/trade-review.spec.mjs` passes; it asserts on both names today

- [x] **Deploy and confirm on the served bundle**
  - Full frontend deploy — the SPA renders these fields
  - Verify: read the new name out of the bundle production actually serves, not the source. Grep the whole deployed
    directory rather than `main.js` — route chunks are code-split and a confident zero in `main.js` means nothing
    (grep the deployed bundle on `league` for `keeptradecut_value_at_trade`)

- [x] **Update `text/league/player-valuation-system.md` § Trade grading**
  - Verify: the document names the new fields and states they are single-source KeepTradeCut, not a composite
