Skip to content

feat(array): add 'spawn array retry --failed' + local launch record (Closes #389) - #402

Merged
scttfrdmn merged 1 commit into
mainfrom
feat/389-array-retry
Jul 19, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
feat/389-array-retry

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Summary

Second of two stacked PRs finishing the spawn array command group (#389). Stacked on #401 (array logs) — review/merge that first; this PR's diff is against that branch.

Adds spawn array retry <name> --failed, plus the local launch-record persistence it needs.

Why a launch record

A job array has no server-side record — members are discovered by grouping EC2 on the spawn:job-array-* tags. But a surviving member's tags don't carry the full launch config: spawn:command only rides when ≤256 chars, and AMI/subnet/security-group/user-data are never tagged. A faithful relaunch needs the original config.

Decision: persist a lightweight local record at launch (~/.config/spore/arrays/<array-id>.json + a name→latest-id pointer). SDK-free, local-only — no infra-account dependency, matching the array group's "no server-side record" ethos. Documented tradeoff: retry works only from the machine that launched the array.

retry --failed

  • Loads the record by array name (clear error if none — "retry must run from the machine that launched it").
  • Computes indexes with no running/pending member — missing --min-viable gaps plus terminated/stopped members.
  • Relaunches only those, under the original job-array id so they regroup (spawn array status sees them).
  • Prompts before launching billable instances (--yes to skip); relaunched members inherit the original TTL from the record.

Refactor

  • launchCohort split into a thin wrapper (builds memberParams, writes the record) + reconcileArrayMembers over an explicit index set — the launch path passes 0..count-1, retry passes the failed subset.
  • Job-array knobs threaded through a memberParams struct instead of package globals, so retry rebuilds members from the record without mutating launch state.

Testing

  • pkg/arrayrec: save/load round-trip, name-pointer-latest, missing-record error, 0600 perms, path-traversal safety (t.TempDir(), no AWS).
  • cmd: TestRetryIndexes (missing/terminated/stopped/duplicate-index cases), updated TestBuildCohort/TestBuildJobArrayMemberConfig for the new signatures.
  • TestFlagConventions / TestTier0_CommandCoverageGate pass; docs-gen/array.md regenerated (drift gate clean).
  • No billable EC2 launched. A real retry run requires an explicit TTL + approval and is out of scope here (retry reuses the record's original TTL by design).

Closes #389

@scttfrdmn
scttfrdmn changed the base branch from feat/389-array-logs to main July 19, 2026 18:51
…loses #389)

A job array has no server-side record — members are discovered by tags. But a
surviving member's tags don't carry the full launch config (spawn:command only
rides ≤256 chars; AMI/subnet/SG/user-data are never tagged), so a faithful
relaunch needs the original config from somewhere.

Add pkg/arrayrec: a lightweight local launch record written at launch time to
~/.config/spore/arrays/<array-id>.json (+ a name pointer to the latest id).
SDK-free and local-only — no infra dependency, matching the array group's ethos.
Tradeoff: retry works only from the machine that launched the array.

'spawn array retry <name> --failed' loads the record, computes the indexes with
no running/pending member (missing --min-viable gaps + terminated/stopped), and
relaunches only those under the ORIGINAL job-array id so they regroup. Prompts
before launching billable instances (--yes to skip); relaunched members inherit
the original TTL.

Refactor launchCohort into reconcileArrayMembers over an explicit index set, and
thread the job-array knobs through a memberParams struct instead of package
globals, so retry rebuilds members from the record without mutating launch state.

Closes #389
@scttfrdmn
scttfrdmn force-pushed the feat/389-array-retry branch from f700644 to 04dc17a Compare July 19, 2026 18:52
@codecov

codecov Bot commented Jul 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 25.21739% with 172 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/launch_jobarray.go 8.18% 101 Missing ⚠️
cmd/arraygroup.go 33.92% 37 Missing ⚠️
pkg/arrayrec/record.go 46.87% 25 Missing and 9 partials ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 6937117 into main Jul 19, 2026
5 of 7 checks passed
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.

First-class job-array reporting: spawn array status/logs/retry/collect/cancel

1 participant