Repository navigation
refactor(gcp): remove unread stored ctx fields - #575
Merged
Merged
Conversation
Contributor
|
Warning Review limit reached
This review includes 13 billable files and costs up to $3.25.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Or wait 6 minutes for your next included review. View limit details
Comment |
Member
Author
Merge gate verdict (claude-cc-libs)Every gate holds at head ece5c58:
CodeRabbit is waived as a merge gate under the 2026-10-19 decision. Squash-merging. |
cristim
added a commit
to LeanerCloud/cloud-commitments-mcp
that referenced
this pull request
Oct 20, 2026
* chore(deps): bump cloud-commitments-go to 1ce87bd Bump pkg, providers/aws, providers/azure and providers/gcp. The only breakage is computeengine.NewClient losing its ctx parameter (LeanerCloud/cloud-commitments-go#575); fix the four test call sites and drop the ctx that became unused in search_dedupe_test.go. The bump also brings (*ec2.Client).GetOfferingDetailsForClass (go#574), used by the next commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(purchase): price standard EC2 RIs at the standard offering committedUSD priced every purchase through GetOfferingDetails, which always resolves the convertible offering. An EC2 purchase with offering_class=standard was therefore capped by CUDLY_MCP_MAX_COMMITMENT_USD and counted against CUDLY_MCP_BUDGET_USD at the convertible price, not the price actually committed. For EC2 with offering_class=standard, price through GetOfferingDetailsForClass (LeanerCloud/cloud-commitments-go#574). A client that lacks the method is refused before any purchase (fail closed); there is no fallback to convertible pricing. Convertible, empty and non-EC2 paths are unchanged. Existing EC2 handler tests that buy a standard RI now use a fake that implements the method. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(purchase): refuse Redshift until the first-attempt time is tracked The bump brings cloud-commitments-go#515: a tokenized Redshift purchase is refused unless PurchaseOptions.RequestedAt (the first-dispatch time of the idempotency key) is set, because reserved nodes are found by start time. The MCP always sets a token, never RequestedAt, and keeps no durable per-key state to supply it; the call time would let a later retry miss the first purchase and double-buy. Refuse Redshift up front, before the budget is reserved, rather than failing in the library after. The audit of PurchaseOptions fields in 9dae64b..1ce87bd found no other newly required option. Also pin classPricer to *ec2.Client at compile time and name the pulled-in behavior changes in the CHANGELOG. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(purchase): track the first-attempt time of each idempotency key Replace the Redshift refusal with the real fix for cloud-commitments-go#515. The library finds an earlier Redshift purchase by start time relative to PurchaseOptions.RequestedAt, so a retry must reuse the first attempt time, not its own call time. Record the first-dispatch time of the token before the provider call and pass it as RequestedAt for every provider. With CUDLY_MCP_BUDGET_STATE set the time is kept in <state>.attempts, using the budget file lock and atomic write (extracted as writeStateAtomically), with 30-day retention (the MCP has no idempotency horizon constant). A corrupt or unwritable store refuses the purchase and releases the budget reservation. Without a state file the time is per process; Redshift, whose dedupe must survive a restart, is refused in that mode. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #6 (M-6).
Removes stored
context.Contextfields that no code reads, so contexts flow per call:providers/gcp/recommendations.go:RecommendationsClientAdapter.ctx(also dropped from the literal inprovider.go).providers/gcp/services/computeengine/client.go:Client.ctxand thectxparameter ofcomputeengine.NewClient, which only fed it. Callers and tests updated.Kept:
computeengine.realBillingService.ctx(read atclient.goListSKUs) andProvider.ctx(separate struct, out of scope).Skipped: cloudsql, cloudstorage, memorystore. Open PR #471 by @IAmJSD edits their
client.gofiles, so they are left for a follow-up after it merges.Deletion probe: after the change, the only remaining
.ctx/ctx:hits in providers/gcp outside those three services are:Verification (providers/gcp, with and without GOWORK=off): build, vet,
go test -timeout 300s -count=1 ./...all pass; golangci-lint 0 issues; scripts/test-git-secrets-allowlist.sh 44 PASS, 0 FAIL.🤖 Generated with Claude Code
Update (review round):
realBillingService.ctxremoved,BillingService.ListSKUsnow takesctxfirst (breaking for custom implementations; no sibling repo references it).Provider.ctxremoved (was only written, never read).computeengine.NewClientcallers outside this repo: mcptools/gcp_computeengine_cud_safeguards_test.go:76,125,tools/search_dedupe_test.go:344,cmd/cudly-mcp/gcp_purchase_protocol_test.go:102; platforminternal/purchase/gcp_history_cost_test.go:48. CHANGELOG entry added. Re-verified at 2958440 with and without GOWORK=off: build, vet, test, test -race, golangci-lint 0 issues.