feat(estimate-history): price get_estimate_history at the API list price (ST-074) #216

Merged
janpeter merged 3 commits from claude/st074-estimate-history-list-price into main 2026-10-12 14:45:00 +02:00
Owner

Part of ST-074 (ISS-4 part 2): get_estimate_history priced actual USD with the Claude USD_PROXY subscription card. After this PR nothing in the mcp reads USD_PROXY or CREDITS cards, so the 11 production USD_PROXY rows can be deleted.

What

  • get_estimate_history prices at the API list price (model_prices: billing_mode = API, billing_unit = USD, standard tier) of the runtime of each usage segment, with fullyListPricedTaskSqlText, listPriceJoinSqlText and listPriceUsdSqlText from scrum4me-shared (same definitions as Scrum4Me Insights and workers /usage). A Codex segment is priced too. A task with a line without an API/USD card keeps actual.usd: null and usd_status: 'no_price', also when a subscription card exists, so the API/USD cards must be seeded (production has all 12 Claude cards).
  • Removes the unused buildSubscriptionRateCardCriteria / findSubscriptionRateCard (no caller in src) with their test; resolveCodexPricingModel and getCodexPricingModelDefault stay.
  • Bumps vendor/scrum4me-shared to 6109a4a (scrum4me-shared#82). Its fixture measurable-v1 now carries the real rates on API/USD cards, so the fixture test expects the measurable task priced again (0.2320, ratio 0.09). ppe-bundle1-parity pins the new gitlink.
  • Docs: CHANGELOG, README and CLAUDE.md say "API list price".

Verified

  • npm test without database: 271 files / 2683 tests pass (84 skipped); tsc --noEmit clean.
  • With a disposable postgres:17-alpine (TEST_DATABASE_URL): usage-ledger.integration 15/15 and the full suite 2732 pass. New cases: Claude task priced from the API card (proxy card ignored), task with only a subscription card / one unpriced line gives no_price, Codex segment priced from the openai card, same model on a Claude segment gives no_price. Swapping the old implementation back made four of them fail.
  • One full run with the database showed 4 failures in one file; I did not capture which, and three later full runs (and the no-database runs) were green.

Rollout

Takes effect on the workers after the MCP rollout (pin on both hosts, 154 and max2).

🤖 Generated with Claude Code

Part of ST-074 (ISS-4 part 2): `get_estimate_history` priced actual USD with the Claude `USD_PROXY` subscription card. After this PR nothing in the mcp reads `USD_PROXY` or `CREDITS` cards, so the 11 production USD_PROXY rows can be deleted. ## What - `get_estimate_history` prices at the API list price (`model_prices`: `billing_mode = API`, `billing_unit = USD`, standard tier) of the runtime of each usage segment, with `fullyListPricedTaskSqlText`, `listPriceJoinSqlText` and `listPriceUsdSqlText` from scrum4me-shared (same definitions as Scrum4Me Insights and workers `/usage`). A Codex segment is priced too. A task with a line without an API/USD card keeps `actual.usd: null` and `usd_status: 'no_price'`, also when a subscription card exists, so the API/USD cards must be seeded (production has all 12 Claude cards). - Removes the unused `buildSubscriptionRateCardCriteria` / `findSubscriptionRateCard` (no caller in `src`) with their test; `resolveCodexPricingModel` and `getCodexPricingModelDefault` stay. - Bumps `vendor/scrum4me-shared` to `6109a4a` (scrum4me-shared#82). Its fixture `measurable-v1` now carries the real rates on API/USD cards, so the fixture test expects the `measurable` task priced again (0.2320, ratio 0.09). `ppe-bundle1-parity` pins the new gitlink. - Docs: CHANGELOG, README and CLAUDE.md say "API list price". ## Verified - `npm test` without database: 271 files / 2683 tests pass (84 skipped); `tsc --noEmit` clean. - With a disposable `postgres:17-alpine` (`TEST_DATABASE_URL`): `usage-ledger.integration` 15/15 and the full suite 2732 pass. New cases: Claude task priced from the API card (proxy card ignored), task with only a subscription card / one unpriced line gives `no_price`, Codex segment priced from the openai card, same model on a Claude segment gives `no_price`. Swapping the old implementation back made four of them fail. - One full run with the database showed 4 failures in one file; I did not capture which, and three later full runs (and the no-database runs) were green. ## Rollout Takes effect on the workers after the MCP rollout (pin on both hosts, 154 and max2). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
get_estimate_history no longer reads the USD_PROXY subscription card. It
joins model_prices at billing_mode API / billing_unit USD for the runtime
of each usage segment (usageSegmentRuntimeSqlText), so a Codex segment is
priced too. A task with a line that has no API/USD card keeps usd_status
'no_price', actual.usd null and no cost ratio.

The integration test keeps the fixture for the measurable set and time
ratios; its cost expectations now follow list pricing (the fixture has no
haiku API card). Three new cases pin the Claude API card over the proxy
card, the missing-card and partial-line paths, and a Codex segment resolved
from its mod_version.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
buildSubscriptionRateCardCriteria and findSubscriptionRateCard, with their
types and test, had no caller left: they selected the USD_PROXY and CREDITS
subscription cards, which the MCP no longer prices against. pricing.ts keeps
resolveCodexPricingModel and getCodexPricingModelDefault (used by
codex-jsonl.ts). CLAUDE.md no longer points at rate-card helpers there.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
chore(shared): bump scrum4me-shared to 6109a4a, fixture test back to list price (ST-074)
All checks were successful
CI / Final merge attestation and immutable publication (pull_request) Has been skipped
CI / PR candidate (never published) (pull_request) Successful in 5m40s
8f9b8d3206
The shared fixture measurable-v1 now carries the real rates on its API/USD
cards and keeps the subscription cards as decoys, so the fixture test expects
the `measurable` task priced again (0.2320, cost ratio 0.09) instead of
`no_price`. The removed shared helpers are not used by the mcp any more.

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

APPROVED

Findings

  • Geen blokkerende of overige codefindings gevonden.

De prijsjoin en de volledigheidscontrole gebruiken dezelfde gedeelde API/USD-definitie, inclusief runtime per segment. Ontbrekende kaarten leveren geen gedeeltelijk USD-bedrag op. De verwijderde subscription-helpers hebben geen resterende aanroepers; de Codex-modelresolutie blijft behouden. De submodulewijziging en documentatie sluiten aan op deze wijziging en de productstandaarden.

Plan

plan gekoppeld via pr_refs (product scrum4me-workers).
Referentie: ST-074 (scrum4me-workers). Geen omitted onderdelen.

De diff voldoet aan de codeonderdelen van T-235 en T-236 en bevat de bijbehorende shared-pin. Deze PR noemt zichzelf onderdeel van ST-074 en claimt geen volledige story-oplevering. De read-only vergelijkingssnapshot is niet bij de review-invoer gevoegd; de productievergelijking, uitrol op beide hosts en data-opruiming moeten bij de vervolgplantaken worden aangetoond.

Verificatie

Beoordeeld op head 8f9b8d3206; PR en head via Forgejo gecontroleerd.

  • npm test: 271 bestanden geslaagd, 2683 tests geslaagd, 84 overgeslagen.
  • npm run typecheck en de via pretest uitgevoerde typecheck:tests: geslaagd.
  • usage-ledger.integration.test.ts op een geïsoleerde PostgreSQL 17-database: 15/15 geslaagd, inclusief Claude, Codex en ontbrekende API-kaarten.
  • tsx-runtime-import en git diff --check: geslaagd.

De overige optionele database- en dispatch-gates zijn niet uitgevoerd.

# APPROVED ## Findings - Geen blokkerende of overige codefindings gevonden. De prijsjoin en de volledigheidscontrole gebruiken dezelfde gedeelde API/USD-definitie, inclusief runtime per segment. Ontbrekende kaarten leveren geen gedeeltelijk USD-bedrag op. De verwijderde subscription-helpers hebben geen resterende aanroepers; de Codex-modelresolutie blijft behouden. De submodulewijziging en documentatie sluiten aan op deze wijziging en de productstandaarden. ## Plan plan gekoppeld via pr_refs (product scrum4me-workers). Referentie: ST-074 (scrum4me-workers). Geen omitted onderdelen. De diff voldoet aan de codeonderdelen van T-235 en T-236 en bevat de bijbehorende shared-pin. Deze PR noemt zichzelf onderdeel van ST-074 en claimt geen volledige story-oplevering. De read-only vergelijkingssnapshot is niet bij de review-invoer gevoegd; de productievergelijking, uitrol op beide hosts en data-opruiming moeten bij de vervolgplantaken worden aangetoond. ## Verificatie Beoordeeld op head 8f9b8d320666d2e0446b369d24db4dd83327ece2; PR en head via Forgejo gecontroleerd. - npm test: 271 bestanden geslaagd, 2683 tests geslaagd, 84 overgeslagen. - npm run typecheck en de via pretest uitgevoerde typecheck:tests: geslaagd. - usage-ledger.integration.test.ts op een geïsoleerde PostgreSQL 17-database: 15/15 geslaagd, inclusief Claude, Codex en ontbrekende API-kaarten. - tsx-runtime-import en git diff --check: geslaagd. De overige optionele database- en dispatch-gates zijn niet uitgevoerd.
Sign in to join this conversation.
No reviewers
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-mcp!216
No description provided.