Skip to content

refactor(cmd): extract runLaunchBatch to dedup parallel-launch (#320) - #339

Merged
scttfrdmn merged 1 commit into
mainfrom
audit/phase3-runlaunchbatch
Jul 11, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
audit/phase3-runlaunchbatch

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Closes #320. Part of the audit tracker #328 (Phase 3). Behavior preserved exactly — no command/flag change, tree byte-identical.

What changed

launchAllAtOnce (parameter sweep) and launchJobArray each hand-rolled the identical sync.WaitGroup + buffered-channel fan-out with a private type launchResult struct. Extracted a shared runLaunchBatch(n, launch func(index)) helper + one package-level launchResult type in new cmd/launch_batch.go. Both callers now call the helper and keep their own result post-processing.

Important: the cleanup divergence is intentional, and preserved

The plan floated a cleanupOnFailure bool option, but the two paths should differ and the divergence is correct:

So this PR unifies only the shared fan-out, not the cleanup policy. The #220 cleanup block in launchJobArray is preserved verbatim (Terminate on partial failure). Verified both behaviors still present in the diff.

Verification

  • go build ./..., go vet ./cmd, gofmt -l clean.
  • Full go test ./cmd green, including job-array tests (TestBuildJobArrayMemberConfig, TestValidateJobArrayConfig, TestJobArrayStateManagement, TestFormatInstanceName). Pre-existing TestCatalogValid (feat(plugin): permissions declaration block (#388) #392) still fails on main.
  • Rebuilt bin/spawn, command+flag tree byte-identical vs main.
  • Net −3 LOC; both duplicate launchResult structs removed.

These functions need real AWS to run end-to-end (no direct unit tests), so correctness rests on the mechanical diff + the preserved control flow — reviewed line-by-line; the only change is where the fan-out lives.

launchAllAtOnce (sweep) and launchJobArray each hand-rolled the same
sync.WaitGroup + channel fan-out with a private launchResult struct.
Extracted a shared runLaunchBatch(n, launch func(i)) helper + one
package-level launchResult type (new cmd/launch_batch.go). Each caller
keeps its own result post-processing.

Behavior preserved EXACTLY, including the intentionally-divergent
partial-failure handling: sweeps keep successful instances (parameter
sets are independent); a job array terminates its successes on any
failure (it's a unit — the #220 orphan-instance cleanup, unchanged). This
is a de-dup of the shared fan-out, NOT a unification of cleanup policy —
the divergence is correct, so a cleanupOnFailure flag would have been
wrong. Net -3 LOC; both local structs gone.

Verified: go build ./..., go vet, gofmt clean; cmd tests green incl.
job-array tests; command tree byte-identical vs main.
Part of the 2026-07-11 audit (#328, Phase 3).
@codecov

codecov Bot commented Jul 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 29 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/launch_batch.go 0.00% 18 Missing ⚠️
cmd/launch_jobarray.go 0.00% 7 Missing ⚠️
cmd/launch_sweep.go 0.00% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 740cd20 into main Jul 11, 2026
6 of 7 checks passed
@scttfrdmn
scttfrdmn deleted the audit/phase3-runlaunchbatch branch July 11, 2026 20: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.

[audit] Refactor: extract runLaunchBatch for launchAllAtOnce + launchJobArray (also closes #220-class cleanup divergence)

1 participant