feat(spot): default spotInterruption on; wire template to UseSpot#141
Merged
Conversation
lionello
marked this pull request as draft
July 22, 2026 11:15
…ent config dir The EC2 Spot interruption handler (issue #20) shipped behind an mkEnableOption, so it defaulted off. A box could then run on Spot with the feature present in the module but no monitor unit instantiated — exactly what bit a live box today: an interruption stopped it on ~2 min notice with no agent prompted to persist context, losing an in-progress session. - modules/agent-box.nix: make spotInterruption.enable a bool option defaulting to true (was mkEnableOption, forced-off). The monitor self-gates on instance-life-cycle and exits at once on non-Spot/dev boxes, so on-by-default is safe. Already-deployed boxes whose configuration.nix doesn't set the flag inherit the new default on the next agent-box-update.service run — no config edit needed. - aws/template.yaml: set spotInterruption.enable = ${UseSpot} so new installs tie it to the CFN Spot parameter; on-demand boxes omit the monitor unit outright. - Notify shell sessions too, instead of skipping them: a shell executes typed text as a command, so the notice is prefixed with '#' to land as a harmless comment the operator still sees in scrollback (no Escape — nothing to interrupt, and Escape+'#' hits readline meta bindings). - Document the config location in the embedded AGENTS.md: name ~/.config/agent-box/ as the config dir and note that its `env` file ignores blank/`#`-comment lines, so it can be annotated. Magic filenames aren't discoverable; a commented, documented config is. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JkQjyhaueHL7GbnA6obZNQ
defangdevs
force-pushed
the
feat/spot-interruption-default-on
branch
from
July 22, 2026 11:33
8dda5fc to
9188d53
Compare
lionello
marked this pull request as ready for review
July 22, 2026 11:35
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The EC2 Spot interruption handler (issue #20) shipped behind
mkEnableOption, so it defaulted off. A box can therefore run on Spot with the feature present in the deployed module but no monitor unit instantiated.That's exactly what bit a live box today: a Spot interruption stopped it on the ~2-minute notice, no agent was prompted to persist context, and an in-progress session was lost. Investigation confirmed the deployed rev contained the feature, but
services.agent-boxnever setspotInterruption.enable, and the default wasfalse→ noagent-box-spot-monitor.service.What
modules/agent-box.nix—spotInterruption.enablebecomes aboolmkOptiondefaulting totrue(wasmkEnableOption, forced-off). Safe as an on-by-default: the monitor readsinstance-life-cycleat startup and exits immediately on a non-Spot/dev box (or when IMDS is unreachable). This is the "fix for all users" — every module consumer (hosts/vm.nix,hosts/bare-metal.nix,flake.nix, hand-written configs) now gets it by default.aws/template.yaml— new installs get the flag from the CFN Spot parameter:spotInterruption.enable = ${UseSpot};.UseSpotisAllowedValues: ['true','false'], so it splices verbatim as a Nix boolean (resolves as a direct parameter Ref inside theFn::Sub, same as the existing${Agent}/${UserName}). On-demand boxes omit the monitor unit outright.Impact on already-deployed boxes
Boxes whose
configuration.nixdoesn't setspotInterruption(i.e. those deployed before the feature existed) inherit the new default on the nextagent-box-update.servicerun — the pin fast-forwards, the module is re-fetched,nixos-rebuild switchapplies the new default, and the monitor unit gets created. No manual root edit required.Validation
nix-instantiate --parse modules/agent-box.nixpasses.UseSpotis not shadowed by theFn::Subvariable map, so${UseSpot}resolves as a template-parameter Ref.🤖 Generated with Claude Code