Repository navigation
fix(sweep): a detached sweep launched zero instances and reported success (#749) - #751
Conversation
Hardware verified — and this also closes out #725Ran Three things this establishes:
Note Cost: two Still outstanding: part 3 (the |
…cess
The CLI never seeded `ami` into the params the orchestrator Lambda
reads, so every RunInstances was rejected with `MissingParameter: The
request must contain the parameter ImageId`; the Lambda then logged "All
instances launched and completed" and the CLI printed "Parameter sweep
queued successfully" and exited 0. Detached is the DEFAULT for parameter
sweeps, so the default path created nothing for the whole life of the
feature.
The Lambda never sees a LaunchConfig: it reads six param keys and builds
RunInstances from them. Diffing the two sides:
orchestrator reads: ami iam_role instance_type key_name spot ttl
CLI seeded: cost_limit iam_role idle_timeout instance_type
region ttl volume_size
`ami` missing was fatal; `key_name` and `spot` were silently dropped. It
is #697's class again, on the path #697 explicitly scoped itself out of.
AMI resolution is PER ROW, not one sweep-wide default: GetRecommendedAMI
keys off architecture and GPU, so a heterogeneous sweep (#372) would
otherwise get one row's AMI forced onto all of them, and an arm64 AMI on
an x86 row does not boot. Memoized by (region, arch, gpu) like the
foreground path. A resolve failure is FATAL rather than a warning —
continuing would upload a row with no ami, which is the bug.
Precedence is unchanged: a row's own key > the CLI flag > the file's
defaults. An unset flag leaves the key ABSENT rather than writing an
empty string; RunInstances rejects an empty KeyName outright and the
Lambda has its own iam_role fallback that "" would defeat.
Lambda: completionStatus() now returns FAILED when zero of N launched.
This was the worst of the four problems — a cost-control tool reporting
a launch that did not happen, the same class as #737's declined
terminate exiting 0. state.Failed was already counted; the completion
branch simply never consulted it. A PARTIAL failure stays COMPLETED on
purpose: the sweep did run, per-row ErrorMessages are recorded, and a
third status value would send `cancel`, `resume` and six workflow
adapters down a default branch. FAILED is an existing value.
CLI: "The sweep is now running in Lambda. You can disconnect safely" was
a claim the CLI cannot support — its evidence is that the Lambda was
invoked. Now says so and points at `spawn status --sweep-id`.
The gate is mechanical: TestDetachedSweepSeedsEveryKeyTheLambdaReads
greps the Lambda source for getStringParam/getBoolParam and requires
each key to be declared, because a hand-maintained list is exactly what
failed. It immediately caught `region` in my own list — the Lambda takes
the region from the sweep record, not the params — so the list now
documents that the contract is "what the Lambda reads", not "what
matters".
Gates confirmed to fail on revert: ami undeclared, the seeder not
writing ami, and the status always COMPLETED.
e7d55c4 to
36ce38a
Compare
The changelog gate caught this correctly — I committed the fix with no entry at all. Then the entry collided with the existing `### Fixed` group, which is the mechanical duplicate-group conflict; consolidated with `make changelog-fix` rather than hand-merged.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
The script's header still said THIS TEST FAILS on #749. It no longer does: 8/8 against spawn v0.126.0 and the orchestrator Lambda deployed 2026-10-08, the first run in which #725's assertions were observable at all. Replaces the stale claim with what a future reader actually needs: that two things must be true at once and only one of them is in the repo. The CLI must seed the params (#751, in v0.126.0) AND the deployed orchestrator must carry the tag fix (#726). A Lambda does not upgrade with the CLI (#654), so a regression here is as likely to be a stale deploy as a code bug — the header now says to check the deployed LastModified against 'git log -- lambda/sweep-orchestrator/' first. No behaviour change; comments only. bash -n clean.
) The script's header still said THIS TEST FAILS on #749. It no longer does: 8/8 against spawn v0.126.0 and the orchestrator Lambda deployed 2026-10-08, the first run in which #725's assertions were observable at all. Replaces the stale claim with what a future reader actually needs: that two things must be true at once and only one of them is in the repo. The CLI must seed the params (#751, in v0.126.0) AND the deployed orchestrator must carry the tag fix (#726). A Lambda does not upgrade with the CLI (#654), so a regression here is as likely to be a stale deploy as a code bug — the header now says to check the deployed LastModified against 'git log -- lambda/sweep-orchestrator/' first. No behaviour change; comments only. bash -n clean.
Closes #749.
The defect
The orchestrator Lambda never sees a
LaunchConfig— it reads param keys out ofthe uploaded
params.jsonand buildsRunInstancesfrom them. Diffing the twosides:
amiiam_roleinstance_typekey_namespotttlcost_limitiam_roleidle_timeoutinstance_typeregionttlvolume_sizeamimissing was fatal: everyRunInstanceswas rejected withMissingParameter: The request must contain the parameter ImageId.key_nameand
spotwere silently dropped. Detached is the default for parametersweeps, so the default path created nothing for the entire life of the feature,
while the Lambda logged
All instances launched and completedand the CLIprinted
Parameter sweep queued successfullyand exited 0.It is #697's class again, on exactly the path #697 explicitly scoped itself out
of. The codebase even documents the symptom's cause — "only the foreground path
detects an AMI per config" appears as a reason to prefer
--no-detachforheterogeneous sweeps. What nobody noticed is that it meant the detached path
resolved no AMI at all.
The fix, in four parts
1. Seed the keys, resolving the AMI per row. Not one sweep-wide default:
GetRecommendedAMIkeys off architecture and GPU, so a single default wouldforce one row's AMI onto all of them and an arm64 AMI on an x86 row does not
boot (#372). Memoized by
(region, arch, gpu)like the foreground path, so 50rows over three families make three SSM lookups.
A resolve failure is fatal, not a warning — continuing would upload a row
with no
ami, which is the bug. An unset flag leaves the key absent ratherthan writing
"":RunInstancesrejects an emptyKeyNameoutright, and theLambda has its own
iam_rolefallback that an empty string would defeat.Precedence is unchanged — a row's own key > the CLI flag > the file's defaults.
2. The gate is mechanical.
TestDetachedSweepSeedsEveryKeyTheLambdaReadsgreps the Lambda source for
getStringParam/getBoolParamand requires each keyto be declared, with a guard that fails if the regex matches nothing (a silently
vacuous gate being the obvious failure mode). A hand-maintained list is exactly
what failed here, so the list is checked against reality rather than trusted.
It immediately caught an error in my own list: I had included
region, butthe Lambda takes the region from the sweep record (
state.Region), not fromthe params. The list now documents that the contract is "what the Lambda reads",
not "what matters" — conflating those is how a list stops being trustworthy.
3. Stop reporting success after total failure.
completionStatus()returnsFAILEDwhen zero of N launched. This is the worst of the four: a cost-controltool reporting a launch that did not happen, the same class as #737's declined
terminate exiting 0.
state.Failedwas already being counted — the completionbranch simply never consulted it.
A partial failure deliberately stays
COMPLETED: the sweep did run, theper-row
ErrorMessages are in the record, and a third status value would sendcancel,resumeand six workflow adapters — all of which branch onStatus == "COMPLETED"— down a default path.FAILEDis an existing value, sonothing gets a novel one to mishandle.
4. Stop promising what the CLI cannot verify. "The sweep is now running in
Lambda. You can disconnect safely" was unsupportable — the CLI's only evidence is
that the Lambda was invoked. It now says that plainly and points at
spawn status --sweep-id.Verification
amiundeclared in the key listthe orchestrator reads [ami], which detachedParamKeys does not declareamiDefaults["ami"] = <nil>, want ami-explicitCOMPLETEDcompletionStatus(launched=0, failed=2) = "COMPLETED", want "FAILED" — a sweep that launched nothing is not completedAlso asserted: precedence in both directions, that an unset flag writes no empty
value, that a row with no instance type is an error rather than an unresolved
row, and that
completionStatusonly ever returns values that already exist.gofmt,go vet ./...,go test -short ./..., the nested-module suite,make check-docs, changelog gate,semgrep scan --config=auto --error(0 findings).
Hardware: running
scripts/hardware-test-detached-sweep.sh(added in #750)against this build and the currently-deployed Lambda — the CLI half is what makes
rows launch, so that is provable before any redeploy. Result to follow in a
comment.
Needs a deploy
Part 3 lives in the Lambda, so the honest-status half only takes effect after
scripts/deploy-sweep-orchestrator.shruns. Parts 1, 2 and 4 are CLI-side andship with the binary. The deploy needs approval separately — flagging it rather
than bundling it, since the CLI fix is what unblocks #725's verification and it
stands alone.