Skip to content

Give spawn sweep resume --max-concurrent-auto, and gate deprecated commands' flags (#935) - #964

Merged
scttfrdmn merged 2 commits into
mainfrom
fix/935
Oct 16, 2026
Merged

scttfrdmn merged 2 commits into
mainfrom
fix/935

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Fixes #935

What

  • spawn sweep resume now accepts --max-concurrent-auto (spawn resume: --max-concurrent has no quota-derived --max-concurrent-auto equivalent #494). spawn resume and spawn sweep resume declare their flags through one function, registerResumeFlags (cmd/resume.go), so a flag added there reaches both spellings.
  • New gate TestDeprecatedCommandFlagsExistOnReplacement (cmd/deprecated_command_flags_test.go). It walks the cobra tree, finds every command whose Deprecated message names a spawn ... replacement, resolves that replacement with rootCmd.Find, and checks every local flag of the deprecated command with VisitAll:
    • if the replacement's Use names <flag-name> (<sweep-id>), the flag is taken positionally, which counts;
    • if the flag is itself deprecated, the flag its message names must exist on the replacement;
    • otherwise the replacement must have the same name and shorthand, bound to the same variable. A flag of the same name bound to something else (the root -o/--output) parses fine and does the wrong thing, which a name check would miss.
      It fails if discovery finds nothing, and if a deprecation message names a command that doesn't resolve. It discovers 10 pairs today (cancel, collect-results, create-ami, list-amis, list-sweeps, resume, and the 4 notify workspace-* shims).

Found by the gate: collect-results --output

spawn collect-results --output/-o FILE is a local flag that shadows the root format flag. Its replacement, spawn sweep collect, only has --output-file/-f, so spawn sweep collect X --output results.csv set the root output format to results.csv and silently wrote results.json. The spawn sweep help example showed that exact invocation. This is the same shadowing #309 fixed in queue/slurm/pipeline. It missed this command.

Fix, following #309's slurm pattern: collect-results gains --output-file/-f, and --output/-o stays as a deprecated alias bound to the same variable. Both collect commands share registerCollectFlags. The help examples, docs-gen/ and examples/result-collection-example.sh now use --output-file.

Evidence

  • Reverting the fix so it still compiles (sweepResumeCmd registering only --max-concurrent and --detach inline) makes the gate fail with:
    spawn resume --max-concurrent-auto -> spawn sweep resume: flag is missing on the replacement (#935)
  • On unchanged main the gate failed with:
    spawn collect-results --output -> spawn sweep collect: the replacement's --output is bound to a different variable, so the same invocation means something else
  • Built binary, no AWS needed:
    • spawn sweep resume x --max-concurrent-auto --max-concurrent 3 gives --max-concurrent-auto and --max-concurrent are mutually exclusive — pick one
    • ... --max-concurrent-auto --detach gives --max-concurrent-auto is not yet supported with --detach (spawn#494)
  • make check: everything passes except the known Docker-only TestGenerateWrapper_ChownFixesCrossUIDStickyUnlink_Docker. make check-nested: all 9 nested modules clean. make check-tidy: clean. make gen-docs is committed.

Notes

@codecov

codecov Bot commented Oct 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…mmands' flags (#935)

spawn resume is deprecated in favour of spawn sweep resume, which lacked
--max-concurrent-auto (#494), so following the deprecation notice lost the
option. Both commands now declare their flags through registerResumeFlags.

A new gate, TestDeprecatedCommandFlagsExistOnReplacement, discovers every
deprecated command whose message names a spawn replacement (10 pairs today)
and requires each of its flags to exist on the replacement under the same
name and shorthand, bound to the same variable (or taken positionally, or,
for a deprecated flag, its named replacement flag to exist).

The gate also found collect-results --output/-o: sweep collect has only
--output-file/-f, so `spawn sweep collect X --output results.csv` set the
root output format and silently wrote results.json, which the sweep help
example itself showed. collect-results gains --output-file/-f and keeps
--output as a deprecated alias; both collect commands share
registerCollectFlags. Help, docs-gen and the example script are updated.

Fixes #935
@scttfrdmn
scttfrdmn merged commit 92340ba into main Oct 16, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the fix/935 branch October 16, 2026 16:35
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.

spawn sweep resume lacks --max-concurrent-auto, so following resume's deprecation notice loses the #494 feature

1 participant