Repository navigation
fix(cli): apply --min-savings-pct and --max-break-even-months on --input-csv - #2274
Conversation
…put-csv The CSV report now carries SavingsPercentage (percent) and BreakEvenMonths (months) columns, appended after the detail columns and written as exact decimals. The loader reads them and hands both thresholds to scorer.Score, so the CSV path rejects on the same predicates as the API path. A column a set flag needs that is missing from the header, or a blank cell, fails the run naming the flag instead of reading as 0. --max-instances still ranks on savings per instance. The up-front refusal of both flags is removed. Refs #1819 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Drives --min-savings-pct and --max-break-even-months through the real root command on --input-csv, covers older and blank-cell CSVs, the writer/parser round trip, strict header validation and cap ordering. Updates docs/cli/filtering.md and the changelog. Refs #1819 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Independent review A (claude-cc-libs-reviewA-2274, Sonnet, cold brief, not the author): money pathReviewed SHA: d6aaac9 Local verification (scratch worktree): build, What was attacked:
Mutation probes: 7 of 7 killed. They dropped MaxBreakEven, wrote the percent as a fraction, skipped the column check, made a blank cell optional, wrote 2 decimal places, disabled the break-even requirement, and skipped the whole gate. Findings:
Fixes follow in a new commit on this PR, together with review B's two nits. |
The blank-cell check did not trim while parseCSVFloat does, so a " " or tab cell with --min-savings-pct or --max-break-even-months set loaded silently as 0. Trim in the check so it fails loudly like an empty cell. Also note the strict column parsing in the changelog, rewrap a doc comment and fix a stale test assertion message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review A re-review (claude-cc-libs-reviewA-2274): delta d6aaac9..c43c96dReviewed SHA: c43c96d Local verification at this SHA: Probe: with both threshold flags set, a whitespace-only cell ( Untrimmed reads: The CHANGELOG note and the comment rewrap are fine. No new findings. |
Review B re-review (claude-cc-libs-reviewB-2274): delta d6aaac9..c43c96dReviewed SHA: c43c96d
|
|
@coderabbitai review |
|
Resolve the CHANGELOG.md conflict with #2273 by keeping both Fixed entries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review B re-review (claude-cc-libs-reviewB-2274): merge of main at 084116dReviewed SHA: 084116d
|
Review A re-review (claude-cc-libs-reviewA-2274): merge of main at 084116dReviewed SHA: 084116d
|

Closes #1819
What
This implements the owner decision on #1819 (2026-10-16): carry the data.
On main,
--input-csvruns refuse--min-savings-pctand--max-break-even-months(validateCSVModeFilterFlags) because the CSV has no columns for either figure. This PR makes both flags work on CSV runs instead:SavingsPercentage, in percent like the flag.BreakEvenMonths, in months. It is blank when unknown or infinite, and0means no upfront payment.--input-csvpassesMinSavingsPctandMaxBreakEvenMonthstoscorer.Scorealong withMinCount.validateCSVModeFilterFlagsand its test are removed.common.Recommendationholds both as plain float64 in the pinned library.--max-instancesstill ranks on savings per instance. A test confirms that a populatedSavingsPercentagedoes not re-rank it. The--max-instancesmessage anddocs/cli/filtering.mdno longer say a CSV row carries no savings percentage.Commits (each <= 400 additions+deletions)
Local verification (macOS, this HEAD)
go build -o cudly ./cmd,go vet ./...,go test ./..., golangci-lint v2.10.1 (0 issues) andscripts/test-git-secrets-allowlist.sh(44/44) all pass.rootCmd.Execute()in child processes. 6 of its 8 cases fail on main's code and pass after; the other two do not use the flags. The round-trip, header and--max-instancescap tests cover the new columns.MinSavingsPctfrom the scorer config fails the min-savings and combined cases.Known limitation
A row whose break-even is infinite is written with a blank
BreakEvenMonths, so replaying that file with--max-break-even-monthserrors instead of dropping the row. The parser already rejects negative savings, so a file this tool writes cannot produce such a row on re-read.Independent reviews follow as PR comments.
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
--min-savings-pctand--max-break-even-monthsfilters. Reports include savings-percentage and break-even columns.Bug Fixes