Repository navigation
feat(common): preserve proven commitment currency on Recommendation #409
Description
Summary
Add commitment-only currency metadata to the shared Recommendation contract so downstream consumers can distinguish proven commitment amounts from unknown historical data.
Current behavior
pkg/common/types.go carries CommitmentCost and RecurringMonthlyCost without a currency field. JSON containing a proven commitment currency loses it when decoded and re-encoded through Recommendation. Existing SavingsPlanDetails.Currency and OfferingDetails.Currency describe independent objects and cannot label all recommendation amounts.
Reproduction
Decode a recommendation JSON object containing commitment_currency EUR, upfront 120 and recurring monthly 10 into Recommendation, then encode it or pass it through the actual ScaleRecommendationCosts helper. Before this change, EUR disappears from the output. Empty and absent historical currency must continue to mean unknown.
Expected behavior
Expose optional CommitmentCurrency metadata for CommitmentCost and RecurringMonthlyCost only. Presence requires source-proven amounts and currency for every required payment leg. Currency must survive JSON round trips and scaling while extensive money values change. Do not infer savings or baseline currency, add a USD default, perform FX, or backfill historical records.
Proposed scope
Add the field and semantic comment to pkg/common/types.go, following existing JSON and CSV metadata conventions. Extend the existing types_test.go with known EUR, explicit unknown, legacy absence and actual shared scaling cases. Publish this standalone shared module before provider modules reference the field. Provider population, platform transport and currency-safe consumers are subsequent leaves.
References
Supports the currency-loss class tracked in #124. GCP monthly amount prerequisite is merged in #408. This contract-only leaf does not claim to close #124 or make currency-blind guardrails safe.
Severity: medium. The absent contract prevents the approved provenance-preserving transport; this leaf adds metadata without changing current provider amounts or purchase behavior.
Activity
cristim commentedon Oct 15, 2026
Implemented by PR #410 at 9eea7a0. Exact-SHA independent review and actual public JSON/scaling consumer evidence are recorded on the PR. Publication and CI use the normal repository gates; provider/platform population is separate.
cristim commentedon Oct 15, 2026
PR #410 merged normally at main
498b74f31f01aca9b2c795d1dce9d85c790eabea, after all required CI and the automatic CodeRabbit review completed green on reviewed head9eea7a039874d3168f8b36ea4790e86ccdb7e8a7. The single targeted CI retry resolved the external schema-fetch timeout without a source/config change. The merged tree exactly matches reviewed tree43719e7adf4dc3d567433fd7333dd0e46f7128b2.Published module:
github.com/LeanerCloud/cloud-commitments-go/pkg@v0.0.0-20261015085730-498b74f31f01, whose download origin matches the merge SHA. The actual downloaded shared module builds standalone. A separate native consumer module requires this exact published version, with no workspace or replace directive, and passes legacy/unknown JSON omission, known EUR, ratios 0 / 0.5 / 2, nil and known-zero recurring charges, and pointer isolation through the public scaler.This completes the shared commitment-currency contract for #409. Provider modules can now pin the published API before populating it. No provider source completeness, platform transport, currency-safe guardrail, live cloud economics, purchase or deployment result is claimed. Broader work remains in #124. Follow-up issues filed: none for this contract leaf, confirmed against the exit checklist; remaining scope is explicitly recorded on #124.
Post-merge main build/test run
38709401903and pre-commit run38709401920have independent background watchers. Owner-safe merged branch/worktree cleanup follows the verified clean state.cristim commentedon Oct 15, 2026
Post-merge main build/test 38709401903 and pre-commit 38709401920 both completed SUCCESS on 498b74f. Published shared-module build and separate exact-pin consumer proof passed as recorded above. Shared contract issue #409 is resolved; broader provider/platform work remains tracked by #124.