Skip to content

docs(cli): correct break-even and region filter notes - #2200

Merged
cristim merged 1 commit into
mainfrom
docs/filtering-corrections
Oct 13, 2026
Merged

cristim merged 1 commit into
mainfrom
docs/filtering-corrections

Conversation

@cristim

@cristim cristim commented Oct 13, 2026

Copy link
Copy Markdown
Member

Follow-ups from the review of #2197.

  • docs/cli/filtering.md: break-even is infinite only when net savings are at or below -upfront/term; net 0 gives break-even equal to the term. --include/exclude-regions narrow only EC2 Instance Savings Plans; Compute, SageMaker and Database plans skip the region filter (shouldIncludeRecommendationRegion).
  • resizeAfterExclusion: the error branch after common.ResizeCount was unreachable (newCount is max(0, Count-excluded) with excluded > 0, so it is always in [1, Count] here) and logged and dropped. It is now an explicit invariant panic, so a broken invariant cannot produce a count with unscaled money.

Tests: the existing extended-support adjustment tests and ScalesMoneyWithCount pass.

🤖 Generated with Claude Code

…e guard an invariant

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

  • Run on-demand review

This review includes 2 billable files and costs up to $0.50.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 20 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 62 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: LeanerCloud/cloud-commitments-cli/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 0593c993-0995-4250-87ea-533fdac694ba
📥 Commits

Reviewing files that changed from the base of the PR and between 9806c9d and cd9c8ca.

📒 Files selected for processing: 2
  • cmd/multi_service_engine_versions.go
  • docs/cli/filtering.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@cristim

cristim commented Oct 13, 2026

Copy link
Copy Markdown
Member Author

Independent review (claude-opus-5-5) of cd9c8ca: APPROVE

No blocking findings.

Docs: both corrections match the code.

  • Break-even: common.BreakEven returns +Inf only when EstimatedSavings + upfront/termMonths <= 0, and net 0 gives upfront / (upfront/term) = term.
  • Region filter: cmd/multi_service_filters.go:128 returns true for region-agnostic plans before the include/exclude check.

Panic in resizeAfterExclusion: acceptable, non-blocking. I re-derived the invariant. The only caller is adjustRecommendationForExcludedVersions. It calls the function only when newCount = max(0, Count - excluded) with excluded > 0 and newCount != Count. So newCount >= 1 implies Count >= 2 and newCount <= Count - 1, and ResizeCount cannot refuse. The branch is unreachable.

Returning an error would need new plumbing through processRecommendation, which has no error return. The panic runs on the filtering goroutine before any purchase. It is not inside the recovered inventory workers (multi_service_engine_versions.go:127), so if it ever fired the run would stop before buying anything rather than continue with unscaled money.

Optional simplification: call common.ScaleRecommendationCosts(rec, float64(newCount)/float64(rec.Count)) and set Count. That removes the error, and with it the unreachable branch, entirely.

Evidence:

  • go vet ./cmd is clean.
  • Extended-support, exclusion and resize tests: 45 pass locally.
  • All CI checks pass on this SHA, and CodeRabbit is clean.
  • No runtime path changes except the unreachable branch, so I did not run anything live.

@cristim
cristim merged commit 1e4d80a into main Oct 13, 2026
18 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant