Repository navigation
Conversation
…ion details Refs #349. Derives r (commitment $ per on-demand $ for used commitment) as (util/100) * EstimatedSPCost / (EstimatedSPCost + EstimatedSavingsAmount), ratio of sums over matching details. Strict parsing; absence is ErrNoSPCommitmentRate, never a 1:1 fallback. No consumers yet. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Warning Review limit reached
This review includes 3 billable files and costs up to $0.75.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Or wait 21 minutes for your next included review. View limit details
Comment |
Independent merge-gate review (Opus 5.5, claude-opus-5-5): APPROVE at c8af0b6Head is up to date with main (merge-base = origin/main a2f6c67). Reviewed from Formula vs SDK (costexplorer v1.61.0 types.go, SavingsPlansPurchaseRecommendationDetail): EstimatedSPCost = "cost of the recommended Savings Plans over the length of the lookback period" (full commitment x hours, used and unused); EstimatedSavingsAmount is the lookback-total saving; EstimatedOnDemandCost is the OD left uncovered. Identity: savings = CurrentAvgHourlyODH - EstimatedOnDemandCost - EstimatedSPCost, so covered_od = SPCost + savings = OD value of usage the plan actually covers. Only utilSPCost is spent on that usage, so r = utilSPCost/covered_od. No double counting of utilization: covered_od already excludes waste, SPCost includes it, and util removes it once. Worked example: OD 100, 60 covered at 0.7, util 100: SPCost 42, savings 18, r = 42/60 = 0.70. Same usage, util 80: commitment 52.5, used 42, savings = 60 - 52.5 = 7.5, r = 0.852.5/60 = 0.70 (the rate is unchanged, as it should be). The "util 80 => 0.56" fixture holds SPCost and savings fixed, so it checks arithmetic only, not a physical scenario. If live CE ever reported EstimatedSPCost as used-only, the error direction is under-buy (r too low), not over-buy. This matches plan U1's fallback (HourlyCommitmentToPurchaseHu / OD). The manual live-CE verification caveat is in the godoc and the PR body. r bounds: r = sum(u_i c_i)/sum(c_i+s_i) with u_i in [0,1], c_i,s_i >= 0 gives r <= 1, so the removed bound is unreachable. Negative fields and util > 100 fail in spRateTerms before any sum. NaN/Inf: rejected at parse; overflow to Inf in the sums gives r = 0 or NaN, and both error. Zero covered gives ErrNoSPCommitmentRate; r <= 0 (util 0) is an error. No input path returns r outside (0,1] without an error. Filtering/params: term, payment, plan type and lookback go into the request (converters fail loud), so the response has only one term/payment and no mixing. AccountScope LINKED with an exact AccountId match. EC2 Instance SP matches on normalized region; Compute SP is the account blend, documented on Params.Region (D6 enforcement belongs to the consumer, PR-C). Pagination follows NextPageToken under the existing 20-page cap and fetchSPPageWithRetry. Local evidence: Mutation run (one run, 16 mutants, non-blocking): 12 killed. 4 survived, all coverage gaps and no defects: (1) dropping the NaN/Inf parse check is still caught downstream by IsNaN(r); (2) dropping |
Refs #349. PR-A of the go#349 plan: additive, nothing consumes it yet.
GetSPCommitmentRatereturns r = (util/100) * EstimatedSPCost / (EstimatedSPCost + EstimatedSavingsAmount), ratio of sums over details matching the account (and region for EC2 Instance SP). EstimatedSavingsPercentage is deliberately not used (measured against all on-demand spend). Strict parsing: absent field or no match is ErrNoSPCommitmentRate, invalid is an error, never r == utilization.Verification: recorded-shape fixtures only (30% discount; cross-check CurrentAverageHourlyOnDemandSpend*H - EstimatedOnDemandCost = SPCost + savings), ratio-of-sums, filters, typed absence, invalid fields, bad params. 7 mutations on formula/parse lines; 2 survivors fixed (unreachable r>1 bound removed, negative-savings test tightened). MANUAL VERIFICATION still required: CE field semantics against a live response.
🤖 Generated with Claude Code