Repository navigation
docs(ladder): document provider commitment precision at PurchaseLayer - #438
Conversation
The AWS purchase boundary already floors Savings Plan commitments to five decimals and refuses amounts outside [0.001, 1000000] (LeanerCloud#403). Record that contract on LadderCapability.PurchaseLayer, require future providers to floor (never round up) and refuse out-of-range amounts, and note that Azure and GCP have no ladder implementation yet. Refs LeanerCloud#354 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cristim
left a comment
There was a problem hiding this comment.
Independent review verdict: CLEAN at afc6f3e
Reviewer: fresh Claude agent (Sonnet, high effort), not the author, cold brief. The PR body was treated as a claim. Coordinator: claude-cc-reviewer.
Blocking findings: none. The diff is comment-only, and every factual statement in it matches the code.
Non-blocking nits:
- The AWS bounds are checked on the raw amount before truncation (
providers/aws/internal/spcommitment/commitment.go:30-34), so a sub-0.001 amount is refused rather than floored. "Including one that floors to zero" is still true, but the comment could say the range check comes first. - The contract sits on the shared
PurchaseLayerdoc, which also covers the convertible-RI layer. The AWS bullet is scoped to Savings Plans, which is correct, but the RI layer isn't mentioned.
Verified, with file:line evidence:
- Rounding:
spcommitment.Normalize(commitment.go:19) truncates to 5 decimals (:39-42, constant:15). For positive amounts truncation equals floor, so "never round up" holds. - Bounds: min
0.001and max1000000.0(:13-14). The check isamount < min || amount > max(:34), so both ends are inclusive, matching[0.001, 1000000]. - Invalid input: NaN, Inf and amounts <= 0 are refused (
:30-32). - Call sites:
PurchaseLayergoes throughpurchaseSPand thenvalidateSPPurchaseRec(providers/aws/ladder/purchase.go:82, which callsNormalizeat:139), beforePurchaseCommitment(:86).- It is called directly in
PurchaseCommitment(providers/aws/services/savingsplans/client.go:222) and inGetOfferingDetails(:652).
- Implementations:
providers/aws/ladderis the onlyLadderCapabilityimplementation (factory.go:45). - No contradiction in
pkg/ladder:- There is no round-up code.
inFlightToOD(allocate_units.go:64-95) uses exactbig.Rat.allocate_units.go:17-19already says provider rounding "MUST round down".- The callers'
r.Float64()calls (allocate.go:225,allocate_units.go:123) are for formatting only.
- Tooling:
gofmt -l pkg/ladderis clean, andgo vet ./ladder/...passes withGOTOOLCHAIN=go1.26.9.
Gate:
- Labels: the PR says
Refs #354, notCloses, so there are no closing-issue labels to mirror. - CodeRabbit: it skipped this PR because it is a draft. A docs-only change plus this review covers the SHA.
- Remaining: CI must be green at this SHA, and the draft must be marked ready (author).
…rtible RIs Addresses review nits on LeanerCloud#438. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Both nits are addressed at 47d8440, a comment-only commit on top of afc6f3e.
🤖 Generated with Claude Code |
cristim
left a comment
There was a problem hiding this comment.
Delta review: CLEAN at 47d8440
Same independent reviewer, delta afc6f3ee..47d84402 only (comment-only, +5/-2). gofmt -l pkg/ladder is clean.
- SP ordering: in
spcommitment/commitment.go, NaN, Inf and <= 0 are refused at:30-32and the inclusive [0.001, 1000000] range check is at:33-35, before truncation to 5 dp at:37-43. The new wording is accurate. - Convertible RIs:
PurchaseLayercallspurchaseRI, which callsvalidateRIPurchaseRec(providers/aws/ladder/purchase.go:101-106). That rejectsrec.Count <= 0, andCountis anint(pkg/common/types.go:213). The EC2 purchase input carries only the offering ID andInstanceCount(providers/aws/services/ec2/client.go:165-168). The only dollar figure isresult.Cost, computed after the purchase (:185). So "no dollar amount to floor" is true.
Both nits from the first pass are addressed, and the CLEAN verdict now covers 47d8440.
Remaining:
- CI: fork runs 38896449877 (CI - Build & Test) and 38896450023 (pre-commit) are
action_requiredand need maintainer approval. - Draft: the author needs to mark it ready. (claude-cc-reviewer)
|
The red Lint Code (providers/gcp) job was the golangci-lint schema download timing out ( 🤖 Generated with Claude Code |
|
Head moved to 6fb60f9: a merge of origin/main (89772cf) into the reviewed 47d8440. |
|
@IAmJSD this is BEHIND main again after go#422 merged (the go ruleset requires up-to-date branches). Please update the branch ( |
|
Done: I merged 🤖 Generated with Claude Code |
Summary
Refs #354. This covers only the in-repo documentation that is still open. It is not
Closes.The code fix for #354 that belongs in this repo already landed in #403 (
29adce1).spcommitment.Normalizefloors Savings Plan commitments to 5 decimals and refuses NaN/Inf/non-positive amounts and anything outside [0.001, 1000000] USD/hr before any SDK call. It runs inPurchaseLayer,PurchaseCommitmentandGetOfferingDetails. So the "%.2f rounds tiny tranches to 0.00" case from the issue no longer reproduces on main. The maintainer's comment on the issue says it stays open for three things:r.Float64()): platform repo, not hereTranche.CommitmentRatealready documents "must not be netted or executed" for empty rates, andinFlightToODalready rejects tranches without a valid rateChange
pkg/ladder/capability.go: the comment onLadderCapability.PurchaseLayernow states the precision contract:*big.Ratto float64 must not round up eitherLadderCapabilityimplementation exists yet (onlyproviders/aws/ladderimplements it)No code or behavior changes, so there is no fail-before/pass-after test. The AWS values in the comment match the constants in
providers/aws/internal/spcommitment/commitment.go, and the existing #403 tests pin them (see below).Verification
Local only, unit/mock evidence. No cloud APIs were called and no purchases were made. Tests ran with
AWS_CONFIG_FILE=/dev/null AWS_SHARED_CREDENTIALS_FILE=/dev/null.Real-cloud gap: the 5-dp / [0.001, 1e6] AWS limits are taken from #403 and its fake-SDK tests. This PR does not re-check them against live AWS.
Out of scope / notes
*big.Ratto float64 seam inPurchaseLayeris still there (see the existing "Precision note").big.Rat.Float64rounds to nearest, so a platform caller that converts an exact tranche amount without flooring first could round up by up to one ulp beforeNormalizetruncates. That conversion lives in the platform executor (platform PR-D), so it's out of scope here. The new comment says callers must not round up.Maintainer: please mirror the issue's triage labels onto this PR:
severity/medium,triaged,urgency/this-sprint,priority/p1,impact/few,effort/s,type/bug. Since this is docs-only, you may prefer a docs type label.🤖 Generated with Claude Code
Summary by CodeRabbit