Repository navigation
ARCH-10: monthlyCostFromConvertibleRI money formula duplicated verbatim, with bare 730/8760 despite named constants [go part] #109
Description
Split from LeanerCloud/cloud-commitments-cli#1199 (cross-component issue, monorepo split)
Severity: P3. Confidence: high. Informational.
Affected files:
providers/aws/recommendations/parser_sp.go:241-242(definesconst hoursPerMonth = 730.0, the canonical constant)Recommendation:
Move the shared money-display formula next toec2svc.ConvertibleRIor into a shared exchange package with a sharedHoursPerMonthconstant, so callers in other repos (e.g.cloud-commitments-platform'sinternal/api/handler_ri_exchange.goandinternal/server/handler_ri_exchange.go, which currently hardcode a bare730) can reuse it instead of re-deriving it.Findings from the 2026-09-02 codebase audit (A08b-044)
The same bare-constant problem has a wider footprint than the
monthlyCostFromConvertibleRIduplication.8760.0appears as an inline literal on money paths in twelve provider files:
- Azure:
providers/azure/services/cache/client.go:548,cosmosdb/client.go:548,database/client.go:567,search/client.go:463,managedredis/client.go:492,synapse/client.go:439,compute/client.go:709,savingsplans/client.go:411- GCP:
providers/gcp/services/cloudsql/client.go:363,cloudstorage/client.go:356,memorystore/client.go:350,computeengine/client.go:822As with 730, a named constant is the fix, in the shared pricing helper both providers already import.
A second, adjacent hygiene item in the same files: the GCP billing service IDs are opaque and uncommented, e.g.
services/9662-B51E-5089atproviders/gcp/services/cloudsql/client.go:350plus the equivalents atcloudstorage/client.go:343(services/95FF-2EF5-5EA1),memorystore/client.go:337(services/D559-82DA-3A56) andcomputeengine/client.go:809(services/6F81-5844-456A). A transposed digit there yields an empty SKU catalog that surfaces as "no pricing found" rather than an error, so naming each as a documented package constant is worth doing in the same pass.
Re-verified live on 2026-09-27: hoursPerMonth still at parser_sp.go:241-242; all twelve 8760.0 sites and all four GCP ListSKUs("services/...") literals confirmed present at the line numbers above (drifted slightly from the original audit's numbers due to unrelated commits, but all still exist as bare literals).
Acceptance criteria
hoursPerMonth/HoursPerMonth(or equivalent) is exported from a location importable by both AWS, Azure and GCP provider packages (and, ideally, bycloud-commitments-platform's exchange handlers, which currently duplicate the formula with a bare730).- All twelve
8760.0literals in the Azure and GCP client files listed above are replaced with the shared constant (or a locally-namedhoursPerYear/equivalent that documents its relationship tohoursPerMonth). - The four opaque GCP billing service IDs (
9662-B51E-5089,95FF-2EF5-5EA1,D559-82DA-3A56,6F81-5844-456A) become named, documented package constants instead of inline string literals. - No behavior change; this is a magic-value/duplication cleanup only.
Activity
cristim commentedon Oct 17, 2026
Checked against main: the monthlyCostFromConvertibleRI half is platform-side. The 8760 literals sit in 12 Azure and GCP client files, which open PRs #473, #424, #433, #471, #493 and #307 edit. Blocked on those PRs.