Skip to content

fix(azure): flag historical purchase amounts recorded in lookback-window units #669

Open

Description

@cristim

Split out of #612 (item 4 of its checklist). Cap bypass and pending-execution refusal were closed by #655.

Problem

Azure purchases executed before the corrected provider pin (#475) and migration 000106 recorded lookback-window amounts, not term totals:

  • purchase_history.upfront_cost (from result.Cost, internal/purchase/execution.go:945-960)
  • purchase_executions.total_upfront_cost
  • savings in history and dashboard totals (internal/api/handler_history.go ~1121, internal/api/handler_dashboard.go ~713 YTD)

Monthly-variant purchases also stored a non-zero upfront. The term price was never stored, so these rows cannot be backfilled numerically.

Proposed design (additive flag, no backfill)

  1. Migration (next free number, 108 or later; 107 is taken by feat(ladder): planned-purchase timeline with filters and graph editing #665): nullable amount_basis (or boolean legacy_azure_window_amounts) on purchase_history, set for provider = 'azure' rows with timestamp before the cutover.
  2. History API: expose the flag on history rows (handler_history.go ~1121).
  3. Dashboard: exclude flagged rows from YTD savings totals, or include them with an annotation (handler_dashboard.go ~713).
  4. Frontend: a "pre-fix estimate" badge on flagged rows.

Backend (1-3) and frontend (4) as separate PRs to stay under the 400-line limit.

Open owner questions (blocking)

  1. Cutover timestamp: when migration 106 was applied in prod. Rows before it are flagged. Also needs rollout evidence that 106 was applied in dev and prod and a recollection ran.
  2. Exclude vs annotate: should flagged rows be left out of YTD savings totals, or counted and annotated?

Not building until both are answered.

Activity

  1. cristim commented on Oct 8, 2026

    @cristim
    MemberAuthor

    Scope additions from PR #671 review: (1) existing GCP purchase_history rows keep the term total as upfront_cost (the pin before a32fd1a recorded CommitmentCost; GCP CUDs have no upfront), so analytics and coverage double-count them; same stale-row class, same flag could cover provider=gcp rows before the pin bump. (2) The execution-level history row uses exec.TotalUpfrontCost (handler_history.go:515, term total from the recommendation) while new per-purchase GCP rows record 0, so the two disagree. Related: #683

  2. IAmJSD commented on Oct 20, 2026

    @IAmJSD
    Collaborator

    Claiming: working on this

  3. self-assigned this
    on Oct 20, 2026
  4. IAmJSD commented on Oct 20, 2026

    @IAmJSD
    Collaborator

    Released: the issue lists blocking owner questions (the prod cutover timestamp for migration 106 and rollout evidence, among others), which I can't answer from here. Happy to do the backend half (flag migration, history API field, dashboard exclusion) once the cutover is known. @cristim

  5. removed their assignment
    on Oct 20, 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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions