// Package usage holds the platform's metering shapes: what a box or console // pass writes under usage/ in the deployment bucket, and the canonical meter // vocabulary every consumer — statements, scenarios, dashboards, a future // billing engine — speaks. Meter names are FROZEN once merged: renaming one // orphans every statement already written (spec: billing readiness). // // Everything here is decision-grade, not invoice-grade (spec: modelling // instrument): CAS-merge retries can in rare cases double-count one 5-minute // window, and days a writer was down are simply absent. Consumers must treat // missing days as reduced coverage, never as zero usage. package usage import "time" // Meter identifiers — the canonical billing vocabulary. const ( MeterCPUCoreHours = "cpu_core_hours" MeterMemGBHours = "mem_gb_hours" MeterEgressGB = "egress_gb" MeterRequests1k = "requests_1k" MeterStorageGBMonth = "storage_gb_month" MeterAppMonths = "app_months" MeterInstanceHours = "instance_hours" MeterFleetBoxHoursServer = "fleet_box_hours_server" MeterFleetBoxHoursDevice = "fleet_box_hours_device" // MeterBackhaulGB is the hop SUBSET of MeterEgressGB (usage.EdgeRow's // HopBytesOut): bytes that left a home box for a region edge before // reaching the client. It rides in statements and the economics sweep // as data (#288) and is priced in NO account's cost, revenue or bill — // #284's ruling is absorb. A billing engine iterating meters generically // must skip it, as economics.PriceAccount's usage check does; its priced // terms name their meters. The platform's own cost for it is the // inter-region leg, RateCard.InterRegionGBUSD. MeterBackhaulGB = "backhaul_gb" // MeterBackhaulRequests1k is the request-count twin of MeterBackhaulGB: // requests that crossed a region before being served. Informational, // unpriced, same posture. MeterBackhaulRequests1k = "backhaul_requests_1k" // Scan meters stay in the units the scanner observes. Converting bytes to // decimal gigabytes at collection time would discard small scans forever, // and neither meter is priced today. MeterScanObjects = "scan_objects" MeterScanBytes = "scan_bytes" ) // DayOf is the UTC date label used in every usage key. func DayOf(t time.Time) string { return t.UTC().Format("2006-01-02") } // MonthOf is the UTC month label used in statement and bill keys. func MonthOf(t time.Time) string { return t.UTC().Format("2006-01") } // HourLabel is the two-digit UTC hour used inside day objects. func HourLabel(t time.Time) string { return t.UTC().Format("15") }