economics: fix bMem duplicate and JS mirror gap in doc comment
FIX 1: Replace duplicated billable(meters, usage.MeterMemGBHours, ft.MemGBHours) at line 114 with existing bMem variable to prevent maintenance drift. FIX 2: Correct doc comment — fleet box and mem-overage formulas are NOT yet mirrored in the page JS; dashboard task must transliterate them. Until then, knob recompute disagrees with server render for fleet-metered accounts.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 file changed,
+5
−6
internal/economics/compute.go+5 −6
diff --git a/internal/economics/compute.go b/internal/economics/compute.go| index 5b389b24b..1fece7271 100644 |
| --- a/internal/economics/compute.go |
| +++ b/internal/economics/compute.go |
| @@ -85,8 +85,9 @@ func billable(meters map[string]float64, meter string, allowance float64) float6 |
| // PriceAccount prices one account's meters plus its allocated box cost |
| // under sc. These formulas are mirrored verbatim by the dashboard's inline |
| // knob JS (economics.html) — change both together or the page will disagree |
| -// with the server it loaded from. Fleet box and mem overage formulas are |
| -// also mirrored in the JS (Task 6). |
| +// with the server it loaded from. Fleet box and mem-overage formulas are |
| +// NOT yet mirrored in the page JS; the dashboard task must transliterate them. |
| +// Until then, knob recompute disagrees with server render for fleet-metered accounts. |
| func PriceAccount(sc Scenario, account string, meters map[string]float64, allocatedUSD float64) AccountEconomics { |
| rc := sc.RateCard |
| cost := allocatedUSD + |
| @@ -109,10 +110,8 @@ func PriceAccount(sc Scenario, account string, meters map[string]float64, alloca |
| revenue = bApps*sc.Sheet.AppMonthUSD + |
| bEgress*sc.Sheet.EgressGBUSD + |
| bStorage*sc.Sheet.StorageGBMonthUSD + |
| - meters[usage.MeterInstanceHours]*sc.Sheet.InstanceHourUSD |
| - // Mem overage (rate-sheet mode only) |
| - memOverage := billable(meters, usage.MeterMemGBHours, ft.MemGBHours) |
| - revenue += memOverage * sc.Sheet.MemGBHourUSD |
| + meters[usage.MeterInstanceHours]*sc.Sheet.InstanceHourUSD + |
| + bMem*sc.Sheet.MemGBHourUSD |
| } else { // cost-plus |
| billableCost := allocatedUSD*computeFrac + |
| bEgress*rc.EgressGBUSD + |