Skip to content

feat(launcher): export headless Provision + BuildLinuxBootstrap (lagotto#19 enabler) - #113

Merged
scttfrdmn merged 1 commit into
mainfrom
feat/headless-launcher
Jun 12, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
feat/headless-launcher

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Why

SDK consumers of spawn's launch path — lagotto's capacity-poller Lambda today, cohort (#108) later — call the low-level aws.Client.Launch directly. But the spored bootstrap user-data (installs spored, runs the spawn:command tag, enforces on-complete/pre-stop/idle/TTL in-instance) was built by buildUserData, unexported in package cmd and wired to CLI flag globals. So those instances launch naked: no spored, nothing reads the tags.

That's the root cause behind lagotto#19 issues #2 (Command not executed) and #3 (on_complete/pre_stop ignored) — see the root-cause writeup. (TTL still fires: Launch tags spawn:ttl-deadline, so the out-of-band reaper catches these — no cost leak.)

What

New pkg/launcher (exported, headless):

  • BuildLinuxBootstrap(BootstrapConfig) — the spored bootstrap as a pure function of (username, public key, plugins, custom user-data). All runtime behavior is driven by the spawn:* EC2 tags buildTags writes, so it needs no disk, no platform.Detect, no CLI globals. Verified byte-for-byte identical to the old inline script (diffed the extracted heredoc against git HEAD).
  • Provision(ctx, client, LaunchConfig, Options) — the headless launch minimum: auto-detect AMI when empty (lagotto#19 Feature request: --tag / --tags flag for custom EC2 instance tags #1), set up the spored IAM profile when empty, build the bootstrap, then Launch. Empty PublicKey is valid (SSM-only / keyless — the Lambda has no SSH key on disk); the spored role attaches AmazonSSMManagedInstanceCore, so the instance is still reachable, and spawn connect can inject a key over SSM later.

cmd/launch.go: buildUserData now delegates to launcher.BuildLinuxBootstrap, keeping only the CLI-side concerns (on-disk key resolution, --user-data @file reading). No behavior change to spawn launch.

Tests

  • BuildLinuxBootstrap: username validation, base64 key encoding, keyless/empty-key path, plugin injection, custom-user-data ordering, core-content invariants (installs spored, runs command tag, starts daemon).
  • Provision: missing-field + Windows rejection, caller-AMI preservation, and a full end-to-end against substrate (AMI auto-detect → IAM → Launch).
  • make check green.

Next

lagotto's Spawner.Spawn() will call launcher.Provision instead of client.Launch (closes lagotto#19, after a spawn release). Then a follow-up adds SSM key-injection to spawn connect for these keyless spores.

…tto#19)

SDK consumers of spawn's launch path (lagotto's capacity-poller Lambda, cohort)
previously called the low-level aws.Client.Launch directly. But the spored
bootstrap user-data — which installs spored, runs the spawn:command tag, and
enforces on-complete/pre-stop/idle/TTL in-instance — was built by buildUserData,
unexported in package cmd and wired to CLI flag globals. So those instances
launched "naked": no spored, nothing read the tags. (lagotto#19 issues #2/#3.)

New pkg/launcher:
- BuildLinuxBootstrap(BootstrapConfig): the spored bootstrap as a pure, headless
  function of (username, public key, plugins, custom user-data). All behavior is
  tag-driven at boot, so it needs no disk / no platform.Detect / no CLI globals.
  Verified byte-for-byte identical to the old inline script.
- Provision(ctx, client, LaunchConfig, Options): the headless launch minimum —
  auto-detect AMI when empty, set up the spored IAM profile when empty, build the
  bootstrap, then Launch. Empty PublicKey is valid (SSM-only / keyless, for the
  Lambda); the spored role attaches AmazonSSMManagedInstanceCore so the instance
  is still reachable.

cmd/launch.go: buildUserData now delegates to launcher.BuildLinuxBootstrap (it
keeps only the CLI-side concerns — on-disk key resolution and --user-data @file
reading). No behavior change to `spawn launch`.

lagotto will consume launcher.Provision next; this is the spawn-side enabler.
@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 72.72727% with 27 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/launcher/provision.go 71.42% 8 Missing and 4 partials ⚠️
cmd/launch.go 0.00% 9 Missing ⚠️
pkg/launcher/bootstrap.go 87.50% 4 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 72dc068 into main Jun 12, 2026
3 checks passed
@scttfrdmn
scttfrdmn deleted the feat/headless-launcher branch June 12, 2026 03:59
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