refactor(usage): remove USD_PROXY/CREDITS card helpers from usage-sql (ST-074) #82

Merged
janpeter merged 2 commits from claude/st074-drop-usd-proxy-helpers into main 2026-10-12 14:11:59 +02:00
Owner

Part of ST-074 (ISS-4 part 2): the 11 CLAUDE/USD_PROXY rows in model_prices can only be deleted once nothing reads them.

What

Removes from lib/usage-sql.ts the helpers that read the subscription cards (USD_PROXY / CREDITS):
usageRateCardJoinSqlText, usageLineUsdSqlText, usageLineCreditsSqlText, fullyPricedTaskSqlText.
The list-price helpers (listPriceJoinSqlText, listPriceUsdSqlText, fullyListPricedTaskSqlText) and measurableTaskSqlText stay.

Tests are converted to list-price cards. The measurable-v1 fixture now carries the real prices on the API/USD cards and keeps the subscription cards as decoys (999), so a reader that wrongly reads a subscription card fails.

Consumers (origin/main, checked)

  • workers: only listPrice* — unaffected.
  • web: lib/usage-sql.ts is an export * shim; only __tests__/lib/usage-sql.test.ts imports usageRateCardJoinSqlText (migrated in the web PR).
  • mcp: src/tools/get-estimate-history.ts still uses three of the removed helpers (migrated in the mcp PR). The mcp integration test also reads fixtures/usage-ledger/measurable-v1.json through its submodule, so the mcp PR must bump to this commit.

Merge order

Safe to merge first: every consumer is pinned to a1e8333 until it bumps. After merge: bump in mcp and web (together with their migration PRs) and workers.

Verified

npm run verify: typecheck + 790 tests pass (usage-sql: 27, PGlite).

🤖 Generated with Claude Code

Part of ST-074 (ISS-4 part 2): the 11 CLAUDE/USD_PROXY rows in `model_prices` can only be deleted once nothing reads them. ## What Removes from `lib/usage-sql.ts` the helpers that read the subscription cards (USD_PROXY / CREDITS): `usageRateCardJoinSqlText`, `usageLineUsdSqlText`, `usageLineCreditsSqlText`, `fullyPricedTaskSqlText`. The list-price helpers (`listPriceJoinSqlText`, `listPriceUsdSqlText`, `fullyListPricedTaskSqlText`) and `measurableTaskSqlText` stay. Tests are converted to list-price cards. The `measurable-v1` fixture now carries the real prices on the API/USD cards and keeps the subscription cards as decoys (999), so a reader that wrongly reads a subscription card fails. ## Consumers (origin/main, checked) - workers: only `listPrice*` — unaffected. - web: `lib/usage-sql.ts` is an `export *` shim; only `__tests__/lib/usage-sql.test.ts` imports `usageRateCardJoinSqlText` (migrated in the web PR). - mcp: `src/tools/get-estimate-history.ts` still uses three of the removed helpers (migrated in the mcp PR). The mcp integration test also reads `fixtures/usage-ledger/measurable-v1.json` through its submodule, so the mcp PR must bump to this commit. ## Merge order Safe to merge first: every consumer is pinned to `a1e8333` until it bumps. After merge: bump in mcp and web (together with their migration PRs) and workers. ## Verified `npm run verify`: typecheck + 790 tests pass (usage-sql: 27, PGlite). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The measurable-v1 fixture priced the Claude lines through USD_PROXY subscription
cards, with an API/USD decoy. Swap them so the API/USD standard cards carry the
real rates and the subscription cards are the decoys. The usage-sql tests now
exercise only listPriceJoinSqlText, listPriceUsdSqlText, fullyListPricedTaskSqlText,
measurableTaskSqlText and usageSegmentRuntimeSqlText; the tests that covered
only the subscription helpers are dropped.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
refactor(usage): remove subscription-card helpers from usage-sql
All checks were successful
CI / Verify (pull_request) Successful in 43s
5db6ca9088
usageRateCardJoinSqlText, usageLineUsdSqlText, usageLineCreditsSqlText and
fullyPricedTaskSqlText read the Claude USD_PROXY and Codex CREDITS subscription
cards. Production code now prices through listPriceJoinSqlText,
listPriceUsdSqlText and fullyListPricedTaskSqlText, so drop them and update the
comments that referred to them. usageLineAmountSqlText stays as the shared
arithmetic behind listPriceUsdSqlText.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
s4m-codex-reviewer left a comment

REQUEST_CHANGES

Findings:

  • error — lib/usage-sql.ts:9 — De verwijderde exports hebben nog een productieconsumer: op scrum4me-mcp origin/main importeert en gebruikt src/tools/get-estimate-history.ts:10-13,40-42 nog fullyPricedTaskSqlText, usageLineUsdSqlText en usageRateCardJoinSqlText. T-238 stap 1 eist vooraf geen productiegebruik en schrijft bij bestaand gebruik expliciet stop en meld voor. De PR-beschrijving erkent dit gebruik maar kiest een andere volgorde. De huidige submodulepin voorkomt directe productiebreuk; een bump zonder migratie breekt echter de imports. Rond eerst de consumer-migratie af en herhaal de lezerscheck, of leg de gewijzigde volgorde expliciet vast in het gekoppelde plan.

Plan gekoppeld via pr_refs (product scrum4me-workers). Referentie: ST-074 (scrum4me-workers), specifiek T-238. Geen omitted onderdelen. Deze PR claimt alleen de shared-opruiming; overige storytaken (seeds, bumps, rollout, productie-SQL en ISS-4) zijn geen ontbrekende implementatie in deze PR.

Code en architectuur: de resterende helpers blijven pure SQL-tekst met interne ESM-import; schema en meetbaarheidslogica blijven intact. Tests behouden Postgres/PGlite-dekking voor runtime, provider/tier, ontbrekende prijzen en gebruikersscope. Comments en fixture zijn consequent naar API-lijstprijzen bijgewerkt. Geen aanvullende code- of docsfindings.

Verificatie op head 5db6ca908834175ceb519c05cf90186990e8b88b: npm run verify geslaagd (dependency-gate, typecheck, 44 testbestanden / 790 tests, waaronder 27 usage-sql-tests); git diff --check schoon. Consumergebruik en submodulepin zelfstandig gecontroleerd op MCP origin/main.

# REQUEST_CHANGES Findings: - **error — lib/usage-sql.ts:9** — De verwijderde exports hebben nog een productieconsumer: op `scrum4me-mcp` `origin/main` importeert en gebruikt `src/tools/get-estimate-history.ts:10-13,40-42` nog `fullyPricedTaskSqlText`, `usageLineUsdSqlText` en `usageRateCardJoinSqlText`. T-238 stap 1 eist vooraf geen productiegebruik en schrijft bij bestaand gebruik expliciet **stop en meld** voor. De PR-beschrijving erkent dit gebruik maar kiest een andere volgorde. De huidige submodulepin voorkomt directe productiebreuk; een bump zonder migratie breekt echter de imports. Rond eerst de consumer-migratie af en herhaal de lezerscheck, of leg de gewijzigde volgorde expliciet vast in het gekoppelde plan. Plan gekoppeld via pr_refs (product scrum4me-workers). Referentie: ST-074 (scrum4me-workers), specifiek T-238. Geen omitted onderdelen. Deze PR claimt alleen de shared-opruiming; overige storytaken (seeds, bumps, rollout, productie-SQL en ISS-4) zijn geen ontbrekende implementatie in deze PR. Code en architectuur: de resterende helpers blijven pure SQL-tekst met interne ESM-import; schema en meetbaarheidslogica blijven intact. Tests behouden Postgres/PGlite-dekking voor runtime, provider/tier, ontbrekende prijzen en gebruikersscope. Comments en fixture zijn consequent naar API-lijstprijzen bijgewerkt. Geen aanvullende code- of docsfindings. Verificatie op head `5db6ca908834175ceb519c05cf90186990e8b88b`: `npm run verify` geslaagd (dependency-gate, typecheck, 44 testbestanden / 790 tests, waaronder 27 usage-sql-tests); `git diff --check` schoon. Consumergebruik en submodulepin zelfstandig gecontroleerd op MCP origin/main.
Sign in to join this conversation.
No reviewers
No labels
severity/s4
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
janpeter/scrum4me-shared!82
No description provided.