Skip to content

refactor(cmd): split launch.go into concern files (#318) - #337

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

scttfrdmn merged 1 commit into
mainfrom
audit/phase3-split-launch

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Closes #318. Part of the audit tracker #328 (Phase 3). Pure internal reorganization — the CLI command/flag tree is byte-identical to main.

What changed

cmd/launch.go was 4333 LOC — the largest file in the repo by ~4×. Functions are regrouped by concern into 9 same-package files (Go resolves package symbols across files, so no imports/exports change):

File LOC Concern
launch_flags.go 394 flag var block, launchCmd, init, applyLaunchDefaults, parseIAMRoleTags
launch_single.go 1075 runLaunch, launchWithProgress (core path)
launch_sweep.go 838 parameter-sweep orchestration, rolling queue, detached Lambda
launch_jobarray.go 495 job-array (legacy + cohort), member config, result rendering
launch_config.go 589 buildLaunchConfig, user-data building, attach-volume/EFS parsing
launch_regions.go 323 region detection + constraint filtering
launch_batchqueue.go 278 launchWithBatchQueue
launch_posthook.go 230 DNS register, SSH/spored waits, output-id, tty/mode helpers
launch_preflight.go 224 SSH key, instance-type/OS/lifecycle guards, strata

launch.go held only the package doc-comment + imports after the move (all unused), so it was removed.

Test fix (bonus)

TestSporedUnit_NoPrivateTmp scanned cmd/launch.go for the #66 PrivateTmp=true guard — but launch.go never contained PrivateTmp (the entry was stale). The spored systemd unit is actually emitted by pkg/launcher/bootstrap.go. Repointed the guard's file list at the real emitter, so it now meaningfully protects the invariant (and doesn't reference a deleted file).

Verification

  • 58 functions conserved (main launch.go had 58 → 58 across the split files). Nothing dropped.
  • go build ./..., go vet ./cmd, gofmt -l clean.
  • Full go test ./cmd green (excl. pre-existing TestCatalogValid / feat(plugin): permissions declaration block (#388) #392, which fails on main too).
  • Rebuilt bin/spawn, diffed the full recursive command+flag tree vs main → byte-identical.

Stacks on #336 (client.go split); both are independent internal reorgs. Expect a CHANGELOG rebase when landing the second.

Pure same-package reorganization of cmd/launch.go (4333 LOC, the biggest
file in the repo), no behavior change. Functions grouped by concern into
9 files; launch.go (which held only the package doc + imports after the
move) removed.

- launch_flags.go   — flag var block, launchCmd, init, applyLaunchDefaults, parseIAMRoleTags
- launch_single.go  — runLaunch, launchWithProgress
- launch_sweep.go   — parameter-sweep orchestration, rolling queue, detached Lambda
- launch_jobarray.go— job-array (legacy + cohort), member config, result rendering
- launch_batchqueue.go — launchWithBatchQueue
- launch_config.go  — buildLaunchConfig, user-data building, attach-volume/EFS parsing
- launch_preflight.go — SSH key, instance-type/OS/lifecycle guards, strata
- launch_regions.go — region detection + constraint filtering
- launch_posthook.go— DNS register, SSH/spored waits, output-id, tty/mode helpers

Also fixed TestSporedUnit_NoPrivateTmp: it scanned cmd/launch.go for the
pkg/launcher/bootstrap.go (launch.go never contained PrivateTmp — the entry
was stale). Repointed the guard at the real emitter, making it meaningful.

Verified: 58 funcs conserved (main launch.go 58 → 58 across the split);
go build ./..., go vet ./cmd, gofmt clean; full cmd test suite green;
rebuilt bin/spawn and diffed the command+flag tree vs main — byte-identical.
Part of the 2026-07-11 audit (#328, Phase 3).
@scttfrdmn
scttfrdmn force-pushed the audit/phase3-split-launch branch from ba9bbf3 to 48f5720 Compare July 11, 2026 20:27
@codecov

codecov Bot commented Jul 11, 2026

Copy link
Copy Markdown

@scttfrdmn
scttfrdmn merged commit 2161e65 into main Jul 11, 2026
6 of 7 checks passed
@scttfrdmn
scttfrdmn deleted the audit/phase3-split-launch branch July 11, 2026 20:28
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: split cmd/launch.go (4324 LOC god-file) along its 5 concerns

1 participant