ADORSYS-GIS / ADORSYS-GIS/lightbridge-authz
[Task]: NULL cost survives as null (f64 → Option<f64>)
- Langage dominant
- Rust
- Étoiles
- 0
- Forks
- 1
- Merge moyen
- 6 h 42 min
- PR mergées (30 j)
- 246
Description
Parent: #586 (Per-grain query APIs)
### Summary
Fix the NULL money bug: `UsageSeriesPoint.total_cost` must survive serialization as `null`, never `0.0` (governance#188).
### The bug
`crates/lightbridge-authz-usage/src/repo.rs:269`:
```rust
total_cost: row.total_cost.unwrap_or(0.0),
```
This collapses "unknown cost" into "$0.00". "I don't know what it cost" is not the same as "it was free."
### What to change
1. **`UsageSeriesPoint.total_cost`**: `f64` → `Option` in `crates/lightbridge-authz-usage/src/models/mod.rs:291`
2. **`repo.rs:269`**: remove the `unwrap_or(0.0)` — keep the `Option`
3. **Every new grain point struct** (`ExecutionSeriesPoint`, `DayFactSeriesPoint`): cost fields declared as `Option` (or `Option` for micro-USD BIGINT columns)
### Wire impact
`total_cost` changes from `number` to `number | null` in the JSON response. Existing callers that deserialize as `f64` will break on `null`. This is a deliberate, tested breaking change per governance#188.
### Cross-repo coordination
`converse-frontends` must be notified — the `total_cost` field changes from `number` to `number | null`. Feature-flag the frontend change if needed.
### Tests
- Existing `query_usage` test: seed a row with NULL cost → assert response has `null`, not `0.0`
- New grain tests (Tickets B/C/D): same pattern per grain
- `spend_query_it_tests` must pass unchanged (they already use `Option` for spend)
### Source of truth
- governance#188 — NULL cost must survive to the wire
- `docs/plans/0586-per-grain-query-apis-analysis.md` — AC 5
### Verification evidence
To be attached on the implementing PR.
Guide de contribution
Ouvrir le guide de contribution
Évaluation
Cette issue n'a pas encore été évaluée.