Repository navigation
fix(server): report the ladder plan's net existing commitment - #1461
Conversation
The platform pinned pkg to a commit from before go#614, so Allocate's NetExistingUSDPerHour was not available to the ladder handler (LeanerCloud#243). Move pkg and providers/{aws,azure,gcp} to go main, which also brings in go#441, LeanerCloud#471, LeanerCloud#491, LeanerCloud#439, LeanerCloud#627, LeanerCloud#628 and LeanerCloud#629. The bump needs three mechanical follow-ups: - go#575 dropped the ctx argument from computeengine.NewClient; the GCP history-cost test is updated to the new signature. - go#603/LeanerCloud#609 renamed provider.ProviderConfig to provider.Config and left the old name as a deprecated alias. staticcheck SA1019 flags every use, so all references move to provider.Config. mock.AnythingOfType reports the real type name, so the zonal-recs mock now matches "*provider.Config". - The providerfactory bypass guard matched only the ProviderConfig name; it now recognises both names so a Profile literal is still caught. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
assembleLadderPlan summed each layer's gross ExistingUSDPerHour into the plan, ladder_runs.existing_usd_hr and the approval email, while Allocate sized the gap against existing minus expiring. A layer with $8/hr OD of existing of which $4/hr expires showed Existing $8/hr next to a gap of $6/hr against a $10/hr target, which does not reconcile. Report Allocate's NetExistingUSDPerHour instead (go#614), which is set on every result including the hold-only exits, so the plan shows the figure the engine used rather than a recomputed one. Closes LeanerCloud#243 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Independent review (IAmJSD's agent, fresh context, given only the diff, the issue and the PR text): VERDICT: APPROVE Blocking:
Non-blocking:
Attacked:
Body-stale:
Reviewer: rE2. Bar while the maintainers are away (set by IAmJSD as acting owner): one approving independent review on the head, two for money, auth and security paths. |
|
Independent review (IAmJSD's agent, fresh context, given only the diff, the issue and the PR text): VERDICT: APPROVE Blocking:
Non-blocking:
Attacked:
Body-stale:
Reviewer: rE6. Bar while the maintainers are away (set by IAmJSD as acting owner): one approving independent review on the head, two for money, auth and security paths. |
|
Independent review (IAmJSD's agent, fresh context, given only the diff, the issue and the PR text): VERDICT: APPROVE Addendum to my review above. After posting, I skimmed the earlier reviews and found one point I had missed. It comes from an earlier review, and I confirmed it in the code: Blocking:
Non-blocking:
Attacked: read Body-stale: as in my review above. Also, the body doesn't mention the amend-ceiling change. Reviewer: rE6. Bar while the maintainers are away (set by IAmJSD as acting owner): one approving independent review on the head, two for money, auth and security paths. |
# Conflicts: # go.mod # go.sum # internal/providerfactory/bypass_guard_test.go
govulncheck in the Docker image build now fails on these two advisories, both fixed in x/net v0.62.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent review (IAmJSD's agent, fresh context, given only the diff, the issue and the PR text): VERDICT: APPROVE Blocking:
Non-blocking:
Attacked:
Body-stale:
Reviewer: rG1. Bar while the maintainers are away (set by IAmJSD as acting owner): one approving independent review on the head, two for money, auth and security paths. |
|
Independent review (IAmJSD's agent, fresh context, given only the diff, the issue and the PR text): VERDICT: APPROVE Blocking:
Non-blocking:
Attacked:
Body-stale:
Reviewer: rH3. Bar while the maintainers are away (set by IAmJSD as acting owner): one approving independent review on the head, two for money, auth and security paths. |
|
Local verification at |
|
Merged by IAmJSD's agent at IAmJSD's request (IAmJSD is acting owner while the maintainers are away), under the bar IAmJSD set: 2 approving independent review(s) on |
Why
#243's last open item (finding 8, cross-repo):
assembleLadderPlanadded up each layer's grossExistingUSDPerHourand wrote that total into the ladder plan,ladder_runs.existing_usd_hrand the approval email'sExplain()output.Allocate, though, sizes the gap against net existing commitment (existing minus expiring). Take a layer with $8/hr OD existing, of which $4/hr expires, and a $10/hr target. The plan showed Existing $8/hr next to a $6/hr gap, so an approver could not get from target minus existing to the gap.The go side landed in LeanerCloud/cloud-commitments-go#614:
AllocateResult.NetExistingUSDPerHour.mainalready pinscloud-commitments-goat88b95b6(#1490), which contains go#614, so this PR no longer changes the pin. It is now only the handler change and its test.The other #243 findings were fixed earlier: #1265 has the per-finding table and lists finding 8 as the only deferred item. I re-checked them on current
main. So this PR closes the issue.Closes #243
What
fix(server):assembleLadderPlannow reportsallocResult.NetExistingUSDPerHour(copied, not aliased) and no longer takes thelayerStatesparameter.Allocatesets this figure on every successful result, hold-only exits included. It covers only the configured layers, butAllocatealready rejects a layer state outside them, so the scope is the same as before.Files:
internal/server/handler_ladder.goand the new testinternal/server/ladder_existing_units_test.go.Refresh note. The branch originally carried a
chore(deps)commit bumping the pin to go80e9b846plus the follow-ups that bump needed (provider.ProviderConfigtoprovider.Configrename, thecomputeengine.NewClientsignature change, the bypass-guard update). #1490 has since movedmainto88b95b6, which contains80e9b846(checked withgit merge-base --is-ancestor), and brought the same follow-ups.origin/mainwas merged into this branch withgo.mod,go.sum,internal/providerfactory/bypass_guard_test.goand the leftover comment ininternal/purchase/execution.goall taken frommain, sogit diff origin/main...HEADnow shows only the two files above. The go behaviour changes that came with the bump reachedmainthrough #1490 and are not part of this PR.Verification
Fail before, pass after. The new test is
TestExecuteLadderRun_ReportsNetExistingCoverageininternal/server/ladder_existing_units_test.go. It runs the realexecuteLadderRun→Allocate→ plan pipeline with existing 4 and expiring 2 commitment at rate 0.5 (8 OD gross, 4 OD net). There are two cases: an allocating run and a baseline-unavailable hold.origin/main'shandler_ladder.go, both cases FAIL:Max difference between 4 and 8onexisting_usd_hrand on the plan JSON, andgap reconciles with target - existingfails with 2 vs 6.Checks after the refresh (run with
AWS_CONFIG_FILE=/dev/null AWS_SHARED_CREDENTIALS_FILE=/dev/null AWS_EC2_METADATA_DISABLED=true):go build ./...,go vet ./...andgo vet -tags integration ./...: clean.go test ./internal/server/ ./internal/providerfactory/: pass.golangci-lint run ./internal/server/...: 0 issues.Combined-tree verification. This branch was tested together with the other queued branches on a local, never-pushed tree:
queue/platform@400d256b= origin/main7b86e386plus these heads, merged in this order:Linux, Go 1.26.9,
AWS_CONFIG_FILE=/dev/null AWS_SHARED_CREDENTIALS_FILE=/dev/null AWS_EC2_METADATA_DISABLED=true; Docker Postgres via testcontainers. The full suite ran onf7c48020, which differs from this tree only by test-only commits on fix/issue-30, fix/issue-713 and fix/issue-263 that replace placeholder account-number literals with named constants:go build ./...,go vet ./...,go vet -tags integration ./...and the fullgo test -race -short -count=1 ./....--build-tags integration.gocyclo -over 10is silent on the changed non-test files.-tags integration -count=1):internal/analytics,internal/api,internal/auth,internal/config,internal/database/postgres/migrations,internal/purchase,internal/schedulerandinternal/serverall pass. Migrations 000149, 000150 and 000151 apply in order on this tree.approval-details,settings-accounts,api) pass (221 tests).accountkey); fixed with named constants. Re-run on this tree: git-secrets, using the repo'sscripts/setup-git-secrets.shpatterns in a fresh repo with an isolated HOME, found nothing in the changed files, and a planted fake key was flagged.scripts/test-git-secrets-allowlist.sh: 183 PASS, 0 FAIL..tftest.hclfiles were not run locally (CI runs them). Nothing was applied to any cloud.🤖 Generated with Claude Code
Amendment ceiling
New ladder runs also use the net existing commitment when enforcing tranche-amendment raises. The ceiling therefore increases by the expiring amount relative to the former gross snapshot, matching the planner allocation. Older stored runs keep their gross, stricter ceiling until a new run replaces the snapshot. The implementation comment now describes both cases.