Repository navigation
refactor(cmd): extract runLaunchBatch to dedup parallel-launch (#320) - #339
Merged
Merged
Conversation
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 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.
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) andlaunchJobArrayeach hand-rolled the identicalsync.WaitGroup+ buffered-channel fan-out with a privatetype launchResult struct. Extracted a sharedrunLaunchBatch(n, launch func(index))helper + one package-levellaunchResulttype in newcmd/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 booloption, 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
launchJobArrayis preserved verbatim (Terminateon partial failure). Verified both behaviors still present in the diff.Verification
go build ./...,go vet ./cmd,gofmt -lclean.go test ./cmdgreen, including job-array tests (TestBuildJobArrayMemberConfig,TestValidateJobArrayConfig,TestJobArrayStateManagement,TestFormatInstanceName). Pre-existingTestCatalogValid(feat(plugin): permissions declaration block (#388) #392) still fails onmain.bin/spawn, command+flag tree byte-identical vsmain.launchResultstructs 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.