Repository navigation
Print the --cost-limit cap in the launch preview (#811) - #861
Merged
Merged
Conversation
The preview printed `Max cost: ~$X (rate × ttl)` — compute only — and said nothing about --cost-limit, so the authoritative-looking cost line sat exactly where a reader would expect the cap. `-o json` omitted it too. costLimitScopeNote existed for this, with a doc comment saying it was "used in the launch preview", and its only callers were its own tests. So the note never printed while a green test was counted as coverage for it. The cap and its scope now print beside that number, `Max cost:` says "compute only" out loud, the plan carries cost_limit_usd, and --estimate-only states it too. The note now takes the limit rather than reading the flag global, so renderLaunchPlanTable stays a pure function of the plan it is handed. Refs #811
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
First of #811's staged items — the one it flags as "not cleanup":
costLimitScopeNoteis a gate that cannot fail.Refs #811, notCloses— this is one item of several.The defect is worse than #811 described
#811 says the scope note "never prints". Checking the preview, the surrounding context makes it sharper:
renderLaunchPlanTableprints…and never mentions
--cost-limitat all, in text or in-o json.Max costisrate × ttl, compute only. So a user who launches with--cost-limit 50and previews it sees an authoritative-looking cost line sitting exactly where the cap would go, and no sign the cap exists. A wrapper reading-o jsoncouldn't see the ceiling governing the launch it was about to make either.The cause, which is the interesting part
costLimitScopeNote's doc comment: "used in the launch preview so the scope is stated where the number is shown rather than only in flag help."TestCostLimitScopeNoteStatesTheSplitopens: "the number is shown in the launch preview."Neither was true. Its only callers were
cmd/launch_cost_limit_test.go:119,127. So the note never printed, and a green test was counted as coverage for behaviour that did not happen.This is CLAUDE.md rule 5 at its sharpest. The test was written from the comment — which is the rule — but nobody checked that the comment was true of the code. Rule 5 says to resolve which of the two is wrong before writing the test down; here neither was resolved, and the test certified a doc rather than a behaviour.
The fix
Max cost:;Max cost:now says "compute only" out loud, because the two lines sit together and mean different things;launchPlancarriescost_limit_usd(withomitempty, so an unset cap doesn't serialize as a$0ceiling);--estimate-onlystates it too — the other "what would this cost me" surface, where compute and storage are quoted separately with nothing saying what bounds them;costLimitScopeNotenow takes the limit instead of reading thecostLimitflag global, sorenderLaunchPlanTablestays a pure function of the plan it is handed. Every other line in that table comes from the plan; one line reaching past it to a package global would be the only thing between that renderer and a table-driven test.Gates
Four, each watched failing against a revert that compiles:
TestLaunchPreviewStatesTheCostLimitTestDescribeLaunchPlanCarriesTheCostLimitTestLaunchPlanJSONCarriesTheCostLimitomitemptyremovedThe second exists because the populate-the-field revert initially passed the render gate. With the call present but
CostLimitUSDalways zero, the preview is silent about a cap that is in force — identical symptom, independent failure. One gate covering both would have reported the clean bill of health that let this bug exist in the first place.One thing deliberately not gated: the
--estimate-onlycall site. That path needs a real AWS client, and the only offline gate available would match the call site as a string — rule 3's trap exactly, and a weak gate counted as coverage is worse than none. The render-table gate covers the main preview; the estimate-only line is a two-line addition on an untestable path and is called out here rather than papered over.Not in this PR
#811's remaining items: the
pkg/compliancesplit (keep the validator, drop the report generator), the unambiguous deletions (cmd/orchestrator+pkg/orchestrator,handler.py,pkg/observability/alerting+ itsdeployment/config half, the deadpkg/regionshalf), and thepkg/securityquestion — whether something should be callingSanitizeForLog/ValidateCommandrather than deleting them. One subsystem per PR, as #811 asks.Its step 4 — a deploy script for
cost-history-collector— already landed.🤖 Generated with Claude Code