Repository navigation
Conversation
determineCSVCoverage compared cfg.Coverage against the flag's default
(80) to decide whether the user had asked for a coverage, so an explicit
--coverage 80 was indistinguishable from no flag and the CSV run bought
100% of every row's Count.
runTool now records cobra's Changed("coverage") in a new
Config.CoverageFromDefault field, and determineCSVCoverage returns 100
only when that is set. With no flag a CSV run still buys each row's full
Count; any explicit value, including 80, is applied. A Config built in
code leaves the field false, so its Coverage is honored as given. The
non-CSV path never reads the field.
Closes LeanerCloud#2236
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Comment |
Member
Independent review verdict: CLEAN at 7579572Reviewer: fresh Claude agent (Sonnet, high effort), not the author, cold brief. The PR body was treated as a claim. Coordinator: claude-cc-reviewer. Blocking findings: none.
Detection:
Same sizing as the non-CSV path:
Notes (non-blocking):
What was attacked and how (
Gate:
|
This branch has not been deployed
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.
Root cause
determineCSVCoverage(cmd/multi_service_csv.go) decided whether the user had asked for a coverage by comparingcfg.Coveragewith the flag's default,80.0. An explicit--coverage 80matched that value, so it was treated as unset: the function returned 100,filterAndAdjustRecommendationsskipped sizing (csvModeCoverage < 100was false), and the run bought 100% of every CSV row'sCount.Fix
runTool(cmd/main.go) copiestoolCfgand sets a new field,Config.CoverageFromDefault, to!cmd.Flags().Changed("coverage"). This is the sameChanged()checkvalidateTargetCoverageincmd/validators.goalready uses.determineCSVCoveragereturns 100 only whenCoverageFromDefaultis set. Otherwise it returnscfg.Coverage.Configbuilt in code (all callers outsiderunToolare tests) has itsCoveragehonored as given. If a future entry point forgets to set the field, the run sizes to the given coverage and does not silently buy 100%.docs/cli/README.md: the--coveragerow now documents the CSV default.There is no config file or environment variable for coverage. No viper is used, and the only
os.Getenvcalls are for Archera andDISABLE_PURCHASE_DELAY. So the precedence stays as before: an explicit flag wins, and with no flag a CSV run buys 100% and a non-CSV run uses the flag default of 80.determineCSVCoveragewas the only code that relied on the 80 sentinel (grep 'Coverage == 80'). The non-CSV path never readsCoverageFromDefault.Behavior matrix (
--input-csv, dry run, rows with Count 10 and 20)--coverage--coverage 80/-c 80/--coverage=80--coverage 100--coverage 50--target-coverage Ncfg.Coveragecfg.Coverage, unchangedCloses #2236
Verification
All of this ran locally on macOS against the worktree at
7579572b, withAWS_CONFIG_FILE=/dev/null AWS_SHARED_CREDENTIALS_FILE=/dev/null. No real AWS calls were made and nothing was purchased.TestCSVCoverageFlagThroughRootCommand(cmd/csv_coverage_flag_test.go). Each case runsrootCmd.Execute()in a child test process, covering cobra flag parsing,validateFlags,runTool,runToolMultiServiceand the--input-csvdry run. It usesisolateAWSEnv's local 403 endpoint and asserts the per-rowCountvalues in the written purchase report. Cases: no flag,--coverage 80,-c 80,--coverage=80,100and50. A child process is used so the flag state cobra keeps onrootCmdcannot leak between cases.TestDetermineCSVCoveragenow has two cases: defaulted 80 returns 100, and explicit 80 returns 80.Coverage == 80.0sentinel: the three explicit-80 cases fail, plus the unit case. This is the fail-before.runToolnever sets the field: the no-flag case fails.Changed(): the no-flag, explicit-80 and explicit-50 cases fail.go build ./cmd,go vet ./...andgo test ./cmd/ -count=1all pass.run --allow-parallel-runners ./...reports 0 issues.gocyclo -over 10oncmd/main.goandcmd/multi_service_csv.go: clean.scripts/gofmt-hook.sh,make tidy-checkand the trailing-whitespace/EOF checks on the changed files: clean.git-secrets --scanon a temp copy of the tree with an isolated HOME and--register-aws: clean.go test -short -race ./...(skipped for disk space). CI covers these.Out of scope
--coverage, the dry-run commitment IDs still carry the80pctlabel (effectiveSizingPctreadscfg.Coverage), even though 100% is bought. This label-only issue predates this PR.cmd/multi_service.go,cmd/multi_service_csv.goandcmd/multi_service_csv_test.go. This PR does not changecmd/multi_service.go. The overlap inmulti_service_csv.gois limited todetermineCSVCoverageand oneTestDetermineCSVCoveragecase, so whichever lands second should rebase trivially.Labels
Please mirror the labels from #2236 onto this PR:
triaged,priority/p1,severity/high,urgency/this-sprint,impact/few,effort/s,type/bug. This PR was opened from a fork, so they were not applied here.🤖 Generated with Claude Code