Skip to content

fix(purchase): preserve nullable cost with updated library pin - #34

Merged
cristim merged 1 commit into
mainfrom
fix/33-nullable-cost-pin
Sep 28, 2026
Merged

cristim merged 1 commit into
mainfrom
fix/33-nullable-cost-pin

Conversation

@cristim

@cristim cristim commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

Summary

Pin all four cloud-commitments-go modules to ce951361290141aa53b528dfce862fbc22a1d01b and preserve the provider's nullable upfront cost in MCP output. Unknown costs remain omitted, known zero is returned as 0, and positive totals pass through unchanged.

Root cause and fix

The library changed PurchaseResult.Cost from float64 to *float64. The old scalar conversion prevented a re-pin from compiling and would discard known zero if retained through dereferencing. The execute response now receives the provider pointer directly. Preview cost handling is unchanged.

Regression proof

A registered MCP tool is exercised through an in-memory client/server connection for nil, zero, and positive costs, using a fake provider boundary. Assertions cover serialized cost presence and numeric value with a count of three. No real cloud purchase was performed.

  • New pin with the old production conversion fails compilation at nonZeroCostPtr(result.Cost).
  • A temporary nil-safe scalar conversion compiles but fails the zero-cost protocol assertion because cost disappears.
  • Restoring pointer passthrough passes the protocol cases and full race-tested suite.

Verification

Go 1.26.6, GOWORK=off; all commands passed:

  • go test -race -short ./...
  • go vet ./..., go build ./..., make build
  • go mod verify, go mod tidy -diff
  • golangci-lint 2.10.1, built with Go 1.26.6: run --timeout=10m --allow-serial-runners (0 issues)
  • All applicable pre-commit hooks, including gosec and Trivy

Independent review and protocol mutation proof use the available GPT-6 Astra, explicitly authorized for this session. This is not an Opus review. The final reviewed commit is 5f3a3f4cf00967da8a007f132c5f74a1f39acab4; required GitHub checks still gate merge. CodeRabbit review was waived by the user for this session.

Issue labels are mirrored. Issue #33 does not carry triaged; this PR does not add that marker.

Closes #33

Summary by CodeRabbit

  • Bug Fixes
    • Purchase results now retain the provider-reported upfront cost, including a known zero amount. When the cost is unknown, it is omitted rather than shown as zero.
    • Purchase results no longer include on-demand cost or estimated savings figures, preventing unpriced recommendation values from appearing as confirmed financial results.

Pin all four library modules to ce9513612901 and pass the provider's
upfront cost pointer through unchanged. Preserve known zero values and
omit unknown amounts in MCP output.

Verify nil, zero, and positive costs through the MCP protocol with a
fake provider. The old zero-dropping conversion fails the zero case.
@cristim cristim added type/chore Maintenance / non-user-visible priority/p1 Next up; this sprint effort/s Hours labels Sep 28, 2026
@coderabbitai

coderabbitai Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: LeanerCloud/cloud-commitments-mcp/.coderabbit.yaml

Review profile: CHILL

Plan: Essentials

Run ID: 33e8bcec-494d-42d2-9060-5378f5e81ce9

📥 Commits

Reviewing files that changed from the base of the PR and between 3c422c0 and 5f3a3f4.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (4)
  • go.mod
  • tools/aws_ec2_ri_test.go
  • tools/purchase.go
  • tools/purchase_test.go

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.


📝 Walkthrough

Walkthrough

The PR updates the cloud-commitments-go module requirements and adapts purchase response handling to the nullable PurchaseResult.Cost field. It also adds MCP test coverage for unknown, zero, and positive costs.

Changes

Purchase cost handling

Layer / File(s) Summary
Dependency pin and nullable cost handling
go.mod, tools/purchase.go, tools/purchase_test.go
The module requirements use a newer pseudo-version. Purchase responses now assign the provider cost pointer directly, and the test fixture supplies a pointer value. The response documentation describes omission of unknown cost and retention of known zero.
MCP purchase cost coverage
tools/aws_ec2_ri_test.go
An end-to-end MCP test checks response fields for unknown, zero, and positive costs, confirms one purchase call, and verifies that savings fields are absent.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 5f3a3

Unknown costs can be omitted while known zero and positive costs remain available. No actionable merge risk is identified.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the two main changes: preserving nullable purchase cost and updating the library pin.
Linked Issues check ✅ Passed Issue #33 requires re-pinning all four cloud-commitments-go modules past the PurchaseResult.Cost type change and migrating the purchase response and fixture. go.mod updates all four modules to pseudo-…
Out of Scope Changes check ✅ Passed The reviewed changes stay within issue #33. The purchase documentation describes the new nullable cost behavior. The MCP test verifies unknown, zero, and positive provider costs. These changes support…
Docstring Coverage ✅ Passed Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 3 files. (1 skipped: 1 u…
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

@cristim

cristim commented Sep 28, 2026

Copy link
Copy Markdown
Member Author

MCP #33 independent final-SHA review

Verdict: MERGE once required CI is green, reviewed SHA 5f3a3f4cf00967da8a007f132c5f74a1f39acab4.

Reviewer: gpt-6-astra, session-authorized substitute. This is not an Opus review. No actionable findings in two independent diff passes or staged review; 0 Major, Minor, or Info. Scope matches the approved five-file plan and live issue #33. Comment updates are adjacent and factual. The direct pointer assignment preserves provider-known zero without changing preview, purchase gates, idempotency, or error behavior.

Independent clone: /Users/cristi/.claude/worktrees/cudly-resume-20260929/review-mcp33, detached at reviewed SHA, clean. Before checkout, compared all tracked working files to the committed SHA: identical. Author trees were not mutated.

Verification Result
Protocol test, go test -race ./tools -run '^TestAWSEC2RIPurchaseCostJSON$' -count=1 Exit 0 before and after final-SHA checkout
Semantic negative control in reviewer clone Nil-safe old nonZeroCostPtr(*result.Cost) conversion made exactly zero case fail at aws_ec2_ri_test.go:266, missing JSON cost key; exit 1
Restore then go test -race -short ./... -count=1 Exit 0 for root, command and tools packages
go vet ./... Exit 0 on identical reviewed snapshot
go build -o <review-binary> ./cmd/cudly-mcp Exit 0 on committed SHA
go mod verify Exit 0, all modules verified
golangci-lint 2.10.1, built with Go 1.26.6, run --timeout=10m --allow-serial-runners Exit 0, zero issues, committed SHA
Staged diff check and identity Exit 0; matched reviewed snapshot exactly
CI Not published when this report was written; parent must check required CI on this SHA

All Go runs used GOWORK=off GOTOOLCHAIN=go1.26.6, relevant per-repo OS locks, and macOS. Disk was above 4 GiB before build.

Attacks checked: unknown vs zero vs positive cost, count multiplication (request count 3), omitted unpriced financial fields, schema/tool registration, test assertion sensitivity, provider-call count, unsafe production expansion and dependency drift. Four modules all resolve to target ce951361290141aa53b528dfce862fbc22a1d01b.

Evidence boundary: real MCP protocol and JSON serialization with a fake cloud provider, not a real AWS purchase or live cloud-price verification. No purchases, deployments, or GitHub mutations performed by reviewer. Any new commit invalidates this SHA-specific verdict.

@cristim
cristim merged commit 49c5d20 into main Sep 28, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/s Hours priority/p1 Next up; this sprint type/chore Maintenance / non-user-visible

Projects

None yet

Development

Successfully merging this pull request may close these issues.

build(deps): re-pin cloud-commitments-go past #151 and migrate PurchaseResult.Cost (*float64)

1 participant