Repository navigation
Description
Found while hardware-testing #697's fix. This is worse than #697 and it is on the default path, so I am filing it separately rather than folding it in.
Detached is the default, not an opt-in
cmd/launch_sweep.go:132 auto-enables it for every sweep:
if !detach && !noDetach {
detach = true
fmt.Fprintf(os.Stderr, "\n⚠️ Auto-enabling --detach for parameter sweep\n")
fmt.Fprintf(os.Stderr, " This prevents zombie instances if CLI disconnects.\n")
}The stated reason is zombie prevention, which makes the finding below painful: the path chosen to prevent zombies is the one that cannot stop them.
So the CLI uploads params to S3, invokes spawn-sweep-orchestrator, and returns. The instances are launched by that Lambda, not by the code #697 fixes.
The Lambda builds RunInstances from four keys
lambda/sweep-orchestrator/main.go:676:
input := &ec2.RunInstancesInput{
MinCount: aws.Int32(1),
MaxCount: aws.Int32(1),
InstanceType: ec2types.InstanceType(instanceType),
IamInstanceProfile: &ec2types.IamInstanceProfileSpecification{Name: aws.String(iamRole)},
TagSpecifications: []ec2types.TagSpecification{{
ResourceType: ec2types.ResourceTypeInstance,
Tags: []ec2types.Tag{
{Key: aws.String("spawn:sweep-id"), ...},
{Key: aws.String("spawn:sweep-index"), ...},
{Key: aws.String("Name"), ...},
},
}},
}
if ami != "" { input.ImageId = aws.String(ami) }
if keyName != "" { input.KeyName = aws.String(keyName) }
if spot { input.InstanceMarketOptions = ... }It reads exactly four param keys — ami, iam_role, instance_type, key_name — and that is the whole launch.
There is no UserData. The Lambda declares its own 9-field LaunchConfig at line 172 with a UserData field that is never populated and never read, under the comment // Additional fields as needed. Verified: zero SecurityGroupIds, zero SubnetId, zero BlockDeviceMappings anywhere in the file.
Why that is a cost leak rather than a feature gap
Two independent consequences, and together they remove every lifetime guarantee the project claims:
No UserData means no spored. So no TTL enforcement, no idle enforcement, no cost-limit enforcement, no completion signal, no --on-complete. The instance runs until something external stops it.
No spawn:managed tag means the reaper cannot touch it either. The reaper's ec2:TerminateInstances grant is conditioned on ec2:ResourceTag/spawn:managed=true — deliberately, as the rail that "kept the reaper away from three unrelated 1200 GiB research filesystems and a c7g.4xlarge belonging to someone else". A detached sweep's rows do not carry that tag, so the terminate is an implicitDeny.
That is the lifecycle invariant inverted. The project's position is that "lifetime is enforced in-instance by spored, so it needs an out-of-band reaper backstop" (#70/#72). On this path neither layer applies: nothing inside the instance enforces anything, and nothing outside it is permitted to.
A detached sweep of N rows therefore runs until a human notices. --ttl, --cost-limit and --on-complete are all accepted on the command line and none of them can function.
Why it has not been noticed
The CLI prints a confident success and a status command:
✅ Parameter sweep queued successfully!
Orchestration: Lambda (infra account)
The sweep is now running in Lambda. You can disconnect safely.
Nothing says the rows will be unmanaged. And spawn orphans cannot show them either, for the same missing tag — discovery filters on spawn:managed=true.
Relationship to #697
#697 measured "83 of 127 flags dropped" by analysing cmd/launch_sweep.go and buildLaunchConfigFromParams. That is the foreground path, reachable only with --no-detach. My fix there is real and verified, but it covers the path almost nobody takes by default.
On the default path the count is closer to 123 of 127, and the four that survive are not the ones that matter.
Suggested direction, not a patch
I do not think this should be fixed by growing the Lambda's four keys into a second implementation of buildLaunchConfig — that is how the two paths diverged. Two shapes seem plausible:
- Have the CLI build the full configs and hand them to the Lambda, so there is one config builder and the Lambda only orchestrates concurrency and retries. The sweep record already goes through S3, so there is a natural place to put them.
- Make the Lambda call the same
pkg/code the CLI does, rather than its ownRunInstances.
(1) looks smaller and removes the duplicate rather than widening it.
Minimum viable mitigation, if a full fix is not immediate: have the Lambda stamp spawn:managed=true and spawn:ttl-deadline. That alone restores the reaper backstop, which is the difference between "a sweep row has no in-instance enforcement" and "a sweep row cannot be stopped by anything".
Reproduce
spawn launch s --instance-type t4g.small --param-file two-rows.json \
--efs-id fs-… --ttl 20m --cost-limit 0.50
# CLI returns 0 immediately: "Parameter sweep queued successfully"
aws ec2 describe-instances --filters Name=tag:spawn:sweep-id,Values=<id> \
--query 'Reservations[].Instances[].Tags'
# → spawn:sweep-id, spawn:sweep-index, Name. No spawn:managed. No TTL.
# And no UserData, so no spored.Found on spawn v0.124.0 + the #697 branch, us-east-1, via the sweep leg added to make smoke.
Activity
fix(smoke): add a sweep leg, and scope #697's claim to the foreground…
fix(sweep): honour CLI flags instead of dropping 83 of 127 (#697) (#724)
fix(sweep-orchestrator): make detached sweep rows reapable (#725)
fix(sweep-orchestrator): make detached sweep rows reapable (#725) (#726)
feat(reaper): report when spored has stopped checking in (#682)
feat(reaper): report when spored has stopped checking in (#682) (#729)
fix(scripts): make the hand-written Lambda deploys safe and verifiable
fix(scripts): make the hand-written Lambda deploys safe and verifiable (
scttfrdmn commentedon Oct 8, 2026
Reopening context rather than the issue: the tag fix (#726) is merged and deployed, but it is unobservable on the default path. Running the real-hardware test for this issue found that a detached sweep launches zero instances —
MissingParameter: The request must contain the parameter ImageIdon every row, because the CLI never seedsamiinto the params the Lambda reads — and then logsAll instances launched and completedwhile the CLI reports success. Filed as #749.So the tagging is correct code behind a door that does not open. #749 has to land before this can be verified end to end.
test(sweep): add the detached-sweep hardware test, and list the Lambd…
scttfrdmn commentedon Oct 9, 2026
Verified end to end on real hardware. 8/8. Closing.
This is the first run in which the assertions were observable at all — every
previous attempt died on #749 before an instance existed.
The third assertion per row is the one that matters most:
spawn:managed=trueis only worth having if it actually unlocks the terminate, so the test runs
iam simulate-principal-policyforec2:TerminateInstancesagainst eachinstance's real ARN with
ec2:ResourceTag/spawn:managedsupplied as context.Both returned
allowed. The tag and the grant are confirmed together, notseparately.
Why it works now
Two things had to be true at once, and only one of them lives in the repo:
amiinto the params the Lambda readsseedDetachedLaunchKeysLastModified15:20:55Z, newer than every commit touchinglambda/sweep-orchestrator/I checked the second one by hand before running, because a Lambda does not
upgrade with the CLI — that is #654, and it is the reason a green run here is
not self-evidently a green codebase. The script's header now says so, with the
command to re-check.
Cost safety
Baseline before: 0 instances, 0 placement groups, 0 pre-existing sweep rows in
435415984226/us-east-1. After the script's own teardown, verified
independently: 0 live instances, and both row IDs queried directly report
terminated— not merely absent from a filtered list, which is the #736 trap.Cost ≈ $0.01.
scripts/hardware-test-detached-sweep.sh's header, which still claimed the testfails, is corrected in the same change.
test(sweep): the detached-sweep harness passes; correct its header
test(sweep): the detached-sweep harness passes; correct its header (#766