Skip to content

[Phase 1] Add effective-dated claude-sonnet-5 pricing rows + lock them with a regression test #1096

Closed

Description

@github-actions

Story

As a cost-reporting maintainer,
I want add two effective-dated claude-sonnet-5-* rows to model-pricing.tsv and lock them with regression tests,
so that every Sonnet 5 token record is priced at the rate in effect on its run date — capturing the introductory discount now and switching to standard pricing on 2026-09-01 automatically, with no code change.

Acceptance Criteria

  1. scripts/lib/model-pricing.tsv gains exactly two APPENDED claude-sonnet-5-* rows (no existing row edited): effective_from 2026-06-30 = input 2.00, cache_read 0.20, cache_write 2.50, output 10.00; effective_from 2026-09-01 = input 3.00, cache_read 0.30, cache_write 3.75, output 15.00.
  2. Both rows follow the tsv's documented derivation: cache_read = 0.1 x input and cache_write = 1.25 x input (identical to the existing claude-sonnet-4-* row 3.00/0.30/3.75/15.00).
  3. price_for "claude-sonnet-5-<id>" "2026-07-15" returns 2.00 0.20 2.50 10.00; the same lookup at 2026-09-02 returns 3.00 0.30 3.75 15.00 (effective-date selection picks the intro rate before Sep 1 and the standard rate after).
  4. tests/model_pricing.bats gains passing cases asserting both effective-dated lookups, and the full bats suite stays green.
  5. No dollar rate is hardcoded in any script — prices remain data in the tsv per AGENTS.md; shellcheck stays clean on any touched shell.

Tasks / Subtasks

Dev Notes

  • model-pricing.tsv selection is deterministic: for (model M, date T) pick the row whose glob matches M AND effective_from <= T, choosing the MOST SPECIFIC glob (most literal chars), ties -> latest effective_from. The header block in the file documents this — read it before editing.
  • PRICE-CHANGE RULE (critical): never edit an existing row — APPEND a new dated row. You are adding a NEW glob (claude-sonnet-5-*), so there is no conflict with claude-sonnet-4-*; the two globs are equally specific but match different model strings.
  • The cache_read/cache_write columns are DERIVED, not quoted by Anthropic: cache_read = 0.1 x input, cache_write (5-min) = 1.25 x input. Every existing Claude row follows this (e.g. opus-4-* 5.00/0.50/6.25/25.00, sonnet-4-* 3.00/0.30/3.75/15.00). Apply the same to keep the table internally consistent (see epic untracked-prerequisite Go-live improvements for PR review agent #2 — confirm before trusting).
  • Testing standard: tests/model_pricing.bats sources scripts/lib/model-pricing.sh and asserts price_for output as the 4-field string input cache_read cache_write output. Copy the @test "price_for: sonnet 4.6 ..." case (approx lines 20-24) and adapt for each effective window; use a 2026-07 date for the intro row and a 2026-09-02 date for the standard row.
  • AGENTS.md: 'Prices are data, not code: keep per-model rates in scripts/lib/model-pricing.tsv (effective-dated) — never hardcode dollar rates in scripts.' Do NOT add Sonnet 5 rates anywhere else.

Project Structure Notes

Pure data + test change under scripts/lib/ and tests/. No script logic changes; consumers (model-pricing.sh price_for/cost_usd/et_multiplier_for) pick up the new rows automatically via the existing glob+date selection.

References

Likely target surface

  • scripts/lib/model-pricing.tsv
  • tests/model_pricing.bats

Story prepared by the BMAD Scrum Master (Bob) for epic #1095. Status: ready-for-dev.

Activity

  1. don-petry commented on Jul 4, 2026

    @don-petry
    Collaborator

    Dev-Lead Implementation Plan

    Issue: #1096 — [Phase 1] Add effective-dated claude-sonnet-5 pricing rows + lock them with a regression test

    Scope

    Append two effective-dated claude-sonnet-5-* rows to scripts/lib/model-pricing.tsv (intro rate from 2026-06-30, standard rate from 2026-09-01) and lock the date-based selection with new bats regression cases. Pure data + test change; no script logic touched.

    Implementation Checklist

    • Append claude-sonnet-5-* 2026-06-30 2.00 0.20 2.50 10.00 to the Anthropic (authoritative) block of model-pricing.tsv (TAB-separated, existing column order)
    • Append claude-sonnet-5-* 2026-09-01 3.00 0.30 3.75 15.00 (standard rate; derivation cache_read=0.1×input, cache_write=1.25×input)
    • Confirm no script hardcodes a Sonnet 5 dollar rate

    Tests to Write

    • price_for: sonnet 5 intro window (2026-07-15) → 2.00 0.20 2.50 10.00 in tests/model_pricing.bats
    • price_for: sonnet 5 standard window (2026-09-02) → 3.00 0.30 3.75 15.00

    Test Command

    bats tests/model_pricing.bats

  2. don-petry commented on Jul 4, 2026

    @don-petry
    Collaborator

    Dev-Lead: Implementation Complete

    Plan Execution

    • Appended claude-sonnet-5-* 2026-06-30 2.00 0.20 2.50 10.00 (intro rate) to the Anthropic block of model-pricing.tsv
    • Appended claude-sonnet-5-* 2026-09-01 3.00 0.30 3.75 15.00 (standard rate)
    • Confirmed derivation: cache_read = 0.1×input, cache_write = 1.25×input (matches existing sonnet-4 row)
    • Added two price_for bats regression cases (intro + standard windows)
    • Verified no script hardcodes a Sonnet 5 dollar rate; dev-lead-lint.sh (shellcheck + agent frontmatter) clean

    Test Results

    1..15
    ok 1 price_for: opus 4.7 at a 2026 date → $5 / $0.50 / $6.25 / $25
    ok 2 price_for: sonnet 4.6 → $3 / $0.30 / $3.75 / $15
    ok 3 price_for: sonnet 5 intro window → $2 / $0.20 / $2.50 / $10
    ok 4 price_for: sonnet 5 standard window (after 2026-09-01) → $3 / $0.30 / $3.75 / $15
    ok 5 price_for: more-specific glob wins (opus-4-1 legacy = $15, not $5)
    ok 6 price_for: unknown model → empty
    ok 7 price_for: selects the rate in effect on the record's date
    ok 8 price_for: date before the earliest effective_from → empty (no retroactive guess)
    ok 9 cost_usd: opus 21952/0/14665 ≈ $0.476385 (no cache)
    ok 10 cost_usd: includes cache-read and cache-write terms
    ok 11 cost_usd: unknown model → empty (never silently $0)
    ok 12 et_multiplier_for: haiku baseline = 1.0
    ok 13 et_multiplier_for: sonnet = 3.0
    ok 14 et_multiplier_for: opus 4.7 = 5.0 (was hardcoded 15)
    ok 15 et_multiplier_for: unknown model → safe default 1.0
    

    Boundary spot-check (effective-date selection):

    2026-08-31 → 2.00 0.20 2.50 10.00   (intro, before switch)
    2026-07-15 → 2.00 0.20 2.50 10.00   (AC #3 intro)
    2026-09-02 → 3.00 0.30 3.75 15.00   (AC #3 standard)
    

    Files Changed

    • scripts/lib/model-pricing.tsv: appended exactly two TAB-separated claude-sonnet-5-* rows; no existing row edited
    • tests/model_pricing.bats: added two price_for cases asserting the intro (2026-07-15) and standard (2026-09-02) lookups

    Notes

    Full suite: 15/15 passing (13 pre-existing + 2 new). New glob claude-sonnet-5-* is equally specific to claude-sonnet-4-* but matches disjoint model strings, so no selection conflict. Pure data + test change — no consumer logic touched; price_for/cost_usd/et_multiplier_for pick up the rows automatically. No commit/push per workflow contract.

  3. added a commit that references this issue on Jul 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    dev-leadFor dev-lead agent pickupinitiativeEpic / initiative tracking issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions