Skip to content

Print the --cost-limit cap in the launch preview (#811) - #861

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/811-cost-limit-scope-note
Oct 12, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/811-cost-limit-scope-note

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

First of #811's staged items — the one it flags as "not cleanup": costLimitScopeNote is a gate that cannot fail.

Refs #811, not Closes — 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: renderLaunchPlanTable prints

Rate:         $0.0725/hr on-demand (truffle)
Max cost:     ~$0.58 (rate × ttl)

…and never mentions --cost-limit at all, in text or in -o json. Max cost is rate × ttl, compute only. So a user who launches with --cost-limit 50 and 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 json couldn'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."
TestCostLimitScopeNoteStatesTheSplit opens: "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

  • the cap and its scope print beside Max cost:;
  • Max cost: now says "compute only" out loud, because the two lines sit together and mean different things;
  • launchPlan carries cost_limit_usd (with omitempty, so an unset cap doesn't serialize as a $0 ceiling);
  • --estimate-only states it too — the other "what would this cost me" surface, where compute and storage are quoted separately with nothing saying what bounds them;
  • costLimitScopeNote now takes the limit instead of reading the costLimit flag global, so renderLaunchPlanTable stays 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:

revert gate
render call removed (the original bug) TestLaunchPreviewStatesTheCostLimit
field never populated from the config TestDescribeLaunchPlanCarriesTheCostLimit
JSON tag dropped TestLaunchPlanJSONCarriesTheCostLimit
omitempty removed same

The second exists because the populate-the-field revert initially passed the render gate. With the call present but CostLimitUSD always 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-only call 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/compliance split (keep the validator, drop the report generator), the unambiguous deletions (cmd/orchestrator + pkg/orchestrator, handler.py, pkg/observability/alerting + its deployment/ config half, the dead pkg/regions half), and the pkg/security question — whether something should be calling SanitizeForLog/ValidateCommand rather 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

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

codecov Bot commented Oct 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.77778% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/launch_single.go 0.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 8dd88a7 into main Oct 12, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the fix/811-cost-limit-scope-note branch October 12, 2026 00:40
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