Skip to content

test(sweep): classify every launch flag for the sweep path - #698

Merged
scttfrdmn merged 1 commit into
mainfrom
chore/697-sweep-flag-manifest
Oct 5, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
chore/697-sweep-flag-manifest

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Part of #697 — the gate, not the fix.

What I found when I went looking for a per-path flag gate

I set out to extend #688's "flag read by nothing" gate to catch "flag read on one path but not another" — the shape of #667 and #539. Tracing why paths drift turned up something larger: the sweep path drops flags by construction.

cmd/launch_single.go, the sweep dispatch:

// Parameter sweep launch path - config will be built inside launchParameterSweep
// Create minimal config for sweep orchestration
config := &aws.LaunchConfig{
    Region:       region,
    InstanceType: instanceType, // May be empty, that's ok for sweeps
}
return launchParameterSweep(ctx, config, plat, auditLog)

The single-instance path calls buildLaunchConfig(), which reads every flag global. The sweep path builds two fields and never calls it; buildLaunchConfigFromParams then "start[s] with an empty config". So a flag reaches sweep rows only if someone hand-wrote a shim — and applyCLISpendControlsToSweep (#525) and applyCLIIAMToSweep (#539) are precisely those shims, two categories reclaimed by hand after each was reported.

That makes #525, #539, #549, #667, #673, #674 and #675 one bug reported seven times.

Measured

count
launchCmd flags 127
honoured on the sweep path 44
dropped 83
dropped with no param-file key either 72

Filtering out what genuinely isn't a sweep concept (--batch-queue, --mpi*, --min-viable, --interactive, --dry-run), the consequential gaps are:

  • Storage: a sweep cannot mount anything. All four --efs-*, all eleven --fsx-*, and --attach-volume. For an HPC sweep that means every row stages through S3 because shared storage is unreachable.
  • --security-group-ids is silently dropped on spawn launch: instances always get the default SG (breaks --efs-id) #667 is only half-fixed. --security-group-ids, --security-group, --subnet-id, --subnet, --vpc are still dropped on sweeps, so every row lands in the VPC default security group.
  • --pre-stop / --pre-stop-timeout — the hook that syncs results before termination. Losing it loses output.
  • --on-idle, --active-ports, --active-processes (idle-detection inputs), both webhook URLs and their correlation/timeout companions, --tag, --team, --plugin, --user-data-file.

What this PR does

Only the gate. sweepFlagCoverage classifies all 127 flags as honoured, not applicable, or a known gap with its issue, and three tests keep it honest:

  1. an unclassified flag fails the build — so adding a flag forces the question "does this work on a sweep?" to be answered once, deliberately, instead of discovered later by someone paying for a boot that ignored it;
  2. a known gap must cite an issue, because a gap without one is just a bug nobody wrote down;
  3. a flag claimed as honoured must actually be referenced on the sweep path.

(3) is the one I care most about. A manifest can drift into wishful thinking, and that is exactly how #539's second half survived — its fix listed the flags that existed when it was written, and --s3-read/--s3-write were added to the single path later.

The gate found seven flags I had not classified on its first run (--completion-file, --session-timeout, --user-data, --wait-for-running, --wait-for-ssh, --webhook-correlation, --webhook-timeout). I classified them from the source rather than from memory.

All three gates verified to fail when violated: removing a classification, flipping a known gap to "honoured", and dropping the issue reference each produce the right failure. I checked this because four tests I wrote earlier today passed vacuously, and a gate that cannot fail is worse than no gate.

Deliberately not fixed here

The structural fix — pass the real config into the sweep and let param rows override it — is in #697 with its risks written down. It touches a path that launches N instances at once, it would make buildLaunchConfig's validation start applying to sweeps, and the sweep code branches on fields being empty (firstConfig.IamInstanceProfile == "" decides whether to set up the shared spored role). That wants its own PR and a hardware smoke, not a drive-by at the end of a long session.

Gates

gofmt -l empty, go vet ./..., go test -short ./..., changelog gate, semgrep → 0 findings.

The sweep path drops flags by construction: the dispatch builds a
two-field LaunchConfig instead of calling buildLaunchConfig, and
buildLaunchConfigFromParams merges rows onto an empty struct. A flag
reaches sweep rows only if someone hand-wrote a shim, which has happened
one category at a time after each report (#525, #539 twice, #549, #667
single-path-only, #673/#674/#675).

Measured: 127 flags, 44 honoured, 83 dropped, 72 of those with no
param-file key either — including all EFS/FSx flags and --pre-stop.

sweepFlagCoverage classifies each flag with its issue, and three gates
keep it honest: unclassified fails the build, a gap must cite an issue,
and a flag claimed as honoured must really be referenced on the sweep
path. Each gate verified to fail when violated. The gate found seven
flags I had not classified on its first run.

Does not fix the gaps — stops new ones appearing silently. #697 carries
the structural fix.
@scttfrdmn
scttfrdmn merged commit 4b62c61 into main Oct 5, 2026
6 checks passed
@scttfrdmn
scttfrdmn deleted the chore/697-sweep-flag-manifest branch October 5, 2026 00:37
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