Skip to content

fix(sweep-orchestrator): make detached sweep rows reapable (#725) - #726

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/725-sweep-rows-reapable
Oct 8, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/725-sweep-rows-reapable

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

The minimum viable mitigation for #725. Restores the backstop, not in-instance enforcement — that distinction is the whole point and I want it visible before this merges.

What was wrong

Detached is the default (launchParameterSweep auto-enables it), so the common sweep launches through this Lambda. Its rows carried only spawn:sweep-id, spawn:sweep-index and Name.

  • No UserData → no spored → no TTL, idle or cost enforcement in-instance
  • No spawn:managed → the reaper couldn't act either; its ec2:TerminateInstances is conditioned on exactly that tag, deliberately, as the rail keeping it away from resources spawn doesn't own

Neither layer of the lifecycle invariant (#70/#72) applied: nothing inside enforced anything, nothing outside was permitted to. --ttl, --cost-limit and --on-complete were all accepted and none could function. spawn orphans couldn't show these rows either, for the same missing tag.

The fix, and its limit

Rows now carry spawn:managed=true, plus spawn:ttl-deadline when the sweep has a ttl. Nothing needed plumbing — applyCLISpendControlsToSweep already writes ttl into paramFormat.Defaults, and that map goes to S3 and is read here.

A row is now reclaimed on a reaper cycle rather than at its TTL to the minute. That's a real reduction in guarantee versus a normal launch, and worth stating plainly rather than claiming the bug is fixed. But "reaped within the hour" and "runs until a human notices" are different kinds of problem, and this closes the second. The UserData half needs the full launch config to reach this Lambda; it stays open on #725.

Two deliberate choices

An absent ttl yields no deadline, not a guessed one. The reaper's own max-age ceiling still bounds the instance, whereas a fabricated deadline would terminate work the user never put a clock on. Same reasoning as the Nitro table returning unknown rather than a plausible version.

Both launch paths are stamped. The orchestrator has two RunInstances call sites — single-region and multi-region — and a gate counts tag specifications against calls to the helper. Fixing one and not the other would make a row's reapability depend on which sweep shape the caller used, which is the kind of half-fix that hides. I only noticed there were two because the patch reported patched 2 RunInstances tag spec(s).

Verified

  • Reverting one call site → the gate names the asymmetry: "2 instance tag specification(s) but only 1 call sweepRowLifecycleTags"
  • Removing the tag → the reapability gate fires with why it matters
  • Four tests covering the tag, the deadline, the four no-ttl shapes, and the two-path parity

How this was found

Hardware-testing #697. The sweep smoke kept reporting "found 0 rows" and I fixed two real bugs in my own test leg before realising neither was the cause: the CLI had returned before any instance existed, because the work had gone to a Lambda I hadn't looked at. Reading the launch it actually performs is what surfaced this.

Detached is the DEFAULT — launchParameterSweep auto-enables it — so the common
sweep launches through this Lambda, and its rows carried only spawn:sweep-id,
spawn:sweep-index and Name.

Two consequences that compounded into something worse than either:

  - No UserData, so no spored: no TTL, idle or cost enforcement in-instance.
  - No spawn:managed tag, so the reaper could not act either. Its
    ec2:TerminateInstances grant is conditioned on exactly that tag —
    deliberately, as the rail that keeps it away from resources spawn does not
    own.

So neither layer of the lifecycle invariant (#70/#72) applied: nothing inside the
instance enforced anything and nothing outside it was permitted to. --ttl,
--cost-limit and --on-complete were all accepted on the command line and none
could function. A detached sweep ran until a human noticed, and `spawn orphans`
could not even show it, for the same missing tag.

Rows now carry spawn:managed=true, plus spawn:ttl-deadline when the sweep has a
ttl. Nothing needed plumbing: applyCLISpendControlsToSweep already writes ttl
into paramFormat.Defaults, and that map is uploaded to S3 and read here.

WHAT THIS DOES AND DOES NOT FIX, because the distinction matters: it restores the
BACKSTOP, not in-instance enforcement. A row is now reclaimed on a reaper cycle
rather than at its TTL to the minute. "Reaped within the hour" and "runs until
someone notices" are different kinds of problem, and this closes the second. The
UserData half needs the full launch config to reach this Lambda and stays open on

An absent ttl deliberately yields NO deadline rather than a guessed one. The
reaper's own max-age ceiling still bounds the instance, whereas a fabricated
deadline would terminate work the user never put a clock on — the same reasoning
as the Nitro table returning unknown rather than a plausible version.

The orchestrator has TWO RunInstances call sites, single-region and multi-region.
Both are stamped, and a gate counts tag specifications against calls to the
helper — fixing one and not the other would make a row's reapability depend on
which sweep shape the caller used, which is the kind of half-fix that hides.
Verified by reverting one site and watching the gate name the asymmetry, and by
removing the tag entirely and watching the reapability gate fire.
@scttfrdmn
scttfrdmn force-pushed the fix/725-sweep-rows-reapable branch from c876f2e to a7f5b1a Compare October 8, 2026 01:47
@codecov

codecov Bot commented Oct 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 21e5390 into main Oct 8, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the fix/725-sweep-rows-reapable branch October 8, 2026 01:56
scttfrdmn added a commit that referenced this pull request Oct 9, 2026
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.
scttfrdmn added a commit that referenced this pull request Oct 9, 2026
)

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.
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.

1 participant