Skip to content

fix(exchange): make PurchaseHistoryRecord.MonthlyCost a *float64 to distinguish absent from zero #1081

Description

@cristim

Problem

PurchaseHistoryRecord.MonthlyCost is float64 (not *float64), so a nil/unknown monthly cost is stored as 0. Per feedback_nullable_not_zero, an absent monthly cost coerced to 0 is indistinguishable from a real $0/mo commitment in any downstream sum or average.

File: internal/purchase/execution.go:601, 904-913

The derefFloat64 helper is honest about the coercion in its comment, but the table column type forces the information loss.

Compare: RecommendationRecord.MonthlyCost is already *float64 — this field should mirror that.

Fix

  1. Change PurchaseHistoryRecord.MonthlyCost to *float64.
  2. Add a nullable column migration for the history schema.
  3. Update all readers/writers that currently dereference the field unconditionally.

Notes

  • This is migration-bearing — batch with the next history-schema change.
  • Out of scope for the immediate fix/exchange-fail-loud PR (L4 finding from docs/code-review/19-hardcoded-fallbacks-core.md).

Activity

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