Skip to content

fix(recfilter): coverage drop reason, EC2 platform engine filter, money scaling on dedupe - #379

Merged
cristim merged 4 commits into
mainfrom
fix/368-370-filters
Oct 13, 2026
Merged

cristim merged 4 commits into
mainfrom
fix/368-370-filters

Conversation

@cristim

@cristim cristim commented Oct 13, 2026

Copy link
Copy Markdown
Member

Refs #368, #369, #370 (pkg-first step; CLI consumes via go.mod bump). Three atomic commits, one per issue. Independent of #376.

#368 coverage label

ApplyCoverage (pkg/recfilter/sizing.go ~68-78) reported floor-to-zero drops as target-sized-to-zero. New common.DropCoverageSizedToZero (--coverage-sized-to-zero); coverage<=0 now also records its drops. Floor kept: the flag is documented as rec.Count * coverage/100, an upper bound, and the discrete ratio keeps Count and money in step. Docs should say counts round down and rows rounding to 0 are dropped.

#369 engine filter

IncludesEngine read only DB/cache engines. New common.EngineFilterKey: EC2 uses its normalized Platform (lowercase, optional (Amazon VPC) suffix, linux/unix alias for linux/unix). EngineFromDetails is unchanged because it feeds the dedupe key and Matches, where existing EC2 commitments have no engine. Note windows does not match Windows with SQL Server; use the displayed value.

#370 money scaling

dedupe.go ~262 set Count only. New shared helper common.ResizeCount(rec, n) (Recommendation, error) scales via ScaleRecommendationCosts by n/Count, errors on source Count<=0 or n outside [1, Count]. The CLI cut (cmd/multi_service_engine_versions.go ~497) should call it after the bump.

Evidence

Fail before (new tests, old sources):

--- FAIL: TestAdjustRecommendationsForExisting_PartialCoverageScalesMoney
  Max difference between 400 and 1000 allowed is 1e-09, but difference was -600
--- FAIL: TestApplyCoverage_RISizedToZero_DropsAndRecords/with_drops_summary
  "Dropped 1 recs: target-sized-to-zero=1" does not contain "--coverage-sized-to-zero"
--- FAIL: TestIncludesEngine_EC2PlatformIsTheEngine/exclude_windows (expected false, got true)

After: go test ./... in pkg ok; providers aws/azure/gcp build with workspace and GOWORK=off; go vet clean.

🤖 Generated with Claude Code

cristim and others added 3 commits October 13, 2026 20:53
ApplyCoverage labelled floor-to-zero drops target-sized-to-zero even when
--target-coverage was unset. Add DropCoverageSizedToZero and record the
coverage<=0 drop-all too. Rounding stays floor: coverage is an upper bound.

Refs #368

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The CSV labels EC2 Platform as Engine but IncludesEngine only read
database and cache engines. Add EngineFilterKey, leaving EngineFromDetails
(dedupe key, Matches) untouched.

Refs #369

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add common.ResizeCount (count change plus proportional money scaling via
ScaleRecommendationCosts, erroring on a source count with no per-unit
cost) and use it in the duplicate checker.

Refs #370

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cristim cristim added the bug Something isn't working label Oct 13, 2026
@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

  • Run on-demand review

This review includes 10 billable files and costs up to $2.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 38 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 61 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-go/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 7af21369-79d2-4079-b58b-6bd0edc0d6e5
📥 Commits

Reviewing files that changed from the base of the PR and between f097b88 and 3e4d4a1.

📒 Files selected for processing: 10
  • pkg/common/drop_summary.go
  • pkg/common/engine.go
  • pkg/common/resize.go
  • pkg/common/resize_test.go
  • pkg/recfilter/dedupe.go
  • pkg/recfilter/dedupe_test.go
  • pkg/recfilter/filters.go
  • pkg/recfilter/filters_test.go
  • pkg/recfilter/sizing.go
  • pkg/recfilter/sizing_test.go
  • 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 cc2144d: APPROVE

No blocking findings in pkg. One downstream test must change when the CLI bumps (see below).

A10 ResizeCount

ScaleRecommendationCosts (types.go:329) scales CommitmentCost, OnDemandCost, EstimatedSavings, RecurringMonthlyCost (as a new pointer, so the caller's value is unchanged, which the test checks) and SavingsPlanDetails.HourlyCommitment. No other money field exists on Recommendation or its Details. The ratio fields (SavingsPercentage, BreakEvenMonths) correctly stay unscaled. Nothing is rounded: money is float64 and the ratio is n/Count.

In dedupe the error path cannot actually be reached, because remaining is always in [1, Count] after the <= 0 guard. Failing loud there is still fine. The exported AdjustRecommendationsForExisting signature is unchanged, it already returned an error. Both CLI callers already handle that error (cmd/multi_service_helpers.go:274, :809).

Pre-existing gap, not caused by this PR: dedupe does not recompute ProjectedCoverage/Utilization or DataWarehouseDetails.NumberOfNodes (#1845).

A9 EngineFilterKey

How the real CE platform strings normalize:

  • "Linux/UNIX" and "Linux/UNIX (Amazon VPC)" become linux/unix and match linux, unix and linux/unix.
  • "Windows" matches windows.
  • "Windows with SQL Server Standard", "Red Hat Enterprise Linux", "SUSE Linux" and "Linux with SQL Server Standard" only match their full lowercased name.

So --exclude-engines windows keeps Windows+SQL rows, and sqlserver does not match EC2. That is documented in the PR and tested. For DB-only filters, EC2 include/exclude outcomes are the same as before.

A7 label

Non-blocking but required at the bump: the CLI test cmd/helpers_test.go:385-397 (TestApplySizing_LegacyCoverageRecordsCountsFlooredToZero) asserts DropTargetSizedToZero for the ApplyCoverage floor. With pkg replaced by this head, CLI go test ./... fails only that test: "Dropped 1 recs: --coverage-sized-to-zero=1" does not contain "target-sized-to-zero". Update it in the bump PR. No other consumer keys on the old reason. The architecture plan's G4b/G4c fail-before text still quotes target-sized-to-zero.

PR is BEHIND main. The merge with main and #376 is clean and green.

Evidence

  • pkg vet and tests: ok.
  • All provider modules and the sanity module build with GOWORK=off and in the workspace.
  • Fail-before (old sources, new tests): money 1000 vs 400; label; exclude_windows; coverage 0 records 0.
  • Mutations, all killed:
    • skip OnDemand scaling
    • write RecurringMonthlyCost through the original pointer
    • allow ResizeCount growth
    • stop stripping the VPC suffix
    • drop the linux alias
    • stop recording coverage<=0 drops
    • dedupe without ResizeCount
  • CI: 14/14 green on this SHA.

@cristim

cristim commented Oct 13, 2026

Copy link
Copy Markdown
Member Author

Independent review (claude-opus-5-5) of 3e4d4a1: APPROVE
Update-branch of the approved cc2144d: only main's commits came in, as clean merges with no conflict resolution; the PR's own diff content is unchanged; GOWORK=off vet and tests pass in: pkg.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant