Skip to content

Go parity (spawn v0.149.0): pinned signed bootstrap stub, pre-launch refusals, terminate-on-error - #111

Merged
scttfrdmn merged 6 commits into
mainfrom
chore/go-parity-2026-10
Oct 29, 2026
Merged

scttfrdmn merged 6 commits into
mainfrom
chore/go-parity-2026-10

Conversation

@scttfrdmn

@scttfrdmn scttfrdmn commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #108
Refs #109
Refs #110

Brings spawn-ts's launch path up to date with Go spawn v0.149.0. spawn-ts had not followed Go since v0.97.x, at the 0.7.0 release on 2026-08-01. Every item below cites its Go source. No AWS calls were made.

1. Bootstrap: Go's release-build stub, pinned to spawn v0.149.0 (#1274, #1412)

src/aws/userdata.ts was a hand-written copy of an August Go bootstrap, and it had drifted:

  • It installed the unversioned latest spored.
  • Signature verification was off unless a key was passed.
  • It had no recovery when the install failed: no spawn_fatal_retire.
  • It lacked the SELinux relabel (#1052), the curl retry for EL8 (#1056) and the Spot-replacement check (#1007).
  • It wrote the session timeout inline.
  • It interpolated the username into the shell unquoted.

It now renders exactly what launcher.BuildLinuxBootstrap renders in a Go v0.149.0 release build. That is the stub that:

  1. fetches spawn/versions/0.149.0/bootstrap.sh from the regional bucket, falling back to us-east-1;
  2. runs it only if its sha256 is 250f111b…54b2 and its .sig verifies against the spore.host key;
  3. lets the body install spored from spawn/versions/0.149.0/, never latest.

Any exit before spored is running terminates the instance.

  • Byte-for-byte parity, tested. src/aws/testdata/stub-fixtures.v0.149.0.json is Go's own output for five input sets: bare, key + custom user, command with quotes, custom completion file, and plugins with <>&. The tests require ===. bootstrap-body.v0.149.0.sh is spawn bootstrap-body at the tag, and a test pins the sha to it.
  • Reproducible. scripts/gen-go-fixtures.sh 0.149.0 takes the spawn module from the proxy (checked against the sum DB), renders the fixtures, and checks that the module's own CLI prints the same body. Re-running it changed nothing. The body hash can also be checked independently: go run github.com/spore-host/[email protected] bootstrap-body | sha256sum.
  • Encoding: gzip, then base64, as EncodeLinuxUserData does (CompressionStream). A bare launch is 1.8 KB.
  • plugins.json now matches Go's json.Marshal bytes (sorted keys, HTML escaping) via a new core/gojson.ts. It is tested against Go-generated vectors.

Why spored 0.149.0, and not a newer one (#108)

The pinned spored is not a Go release choice; it is the newest spored that enforces what spawn-ts writes.

  • spored v0.150.0 (spawn#1359, PR Launch-fixed spored settings move to a per-launch config object; freeze the latest spored (#1359, #1419) spawn#1420, unmerged) reads active-ports, active-processes, both webhooks, notify-* and idle-cpu only from the per-launch config object, and ignores those tags. There is no tag fallback, by owner decision.
  • spawn-ts writes them as tags. On a newer spored, activePorts/activeProcesses would stop holding an instance up, and an in-use instance could be stopped as idle.
  • spawn/versions/0.149.0/ is permanent. The release workflow publishes the body, spored, .sha256 and .sig there and reads them back before the CLI is installable (#1415).
  • The unversioned latest is also frozen at 0.149.0 (spawn#1419 decision), but only implicitly. An explicit pin does not depend on that decision holding, and the stub needs a versioned body anyway.

Moving past 0.149.0 means writing the object. That work is #110 and draft PR #112, stacked on this one, which depends on spawn v0.150.0. This PR can merge without it.

Behaviour changes callers can see:

  • EC2ProviderOptions.sporedSigningPublicKey is now a rotation override. When absent, the spore.host key is used, so verification always happens, as in a Go release build.
  • An invalid local username is refused before any AWS call.

2. Refusals before any AWS call (Go Client.Launch)

Go spawn-ts
#1063 CheckUserDataSize: 16384 decoded / 25600 encoded checkUserDataSize in EC2Provider.launch. Go's TestCheckUserDataSizeLimits table is ported verbatim
#1375 CheckNestedSpawnTTL: a spawn-instance-nested-* profile needs a TTL; an idle timeout is not enough checkNestedSpawnTtl (core/bounds.ts). Go's table is ported, plus the ARN form, because spawn-ts accepts profile ARNs and Go is only ever given names
#1336 checkTagLimit: more than 50 tags is refused checkTagLimit. It runs once with Go's preflight stand-in identity (before STS) and again on the real set. Sweep params are still budgeted, never refused. A maximal spawn-ts launch is exactly 50 (tested)
#1308 validateIdleCPU: a threshold outside 0-100 refused in buildLaunchTags, as Go's buildTags refuses it
#922/#1330 a one-time Spot instance cannot be stopped A Spot launch whose lifecycle stops the instance (idle timeout, on-complete stop/hibernate) is refused. Go makes such requests persistent; that needs a cancel on every terminate, so spawn-ts refuses, as Go's detached sweep does. Before this, spored retried a failing stop with backoff while the instance billed until TTL, or indefinitely with an idle-only bound

3. Lifetime

  • #1298: terminate on a failure after RunInstances, unless keepOnError / --keep-on-error. This is in both EC2Provider.launch and SpawnClient.launch. In the client, a throwing launched listener or a failed follow-up list used to reject the launch while the instance kept billing. The error says whether the instance was terminated, kept, or could not be terminated.
  • #990: an unparseable lifetime is refused, not dropped. toSpec did parseDuration(v) ?? 0, so ttl: "1d", "4 h" and "-1h" each became a launch with no TTL. Launch durations now go through a port of pkg/ttl.ParseDuration/ParseTTL: d is accepted, and signed or unit-less values are refused, with Go's reasons. parse_test.go is ported verbatim. --ttl 0 / --ttl=-1h are refused by the CLI. Tags are still read with the stricter time.ParseDuration grammar.
  • TTL "always set": Go applies a 1h idle default when there is neither TTL nor idle timeout. spawn-ts keeps its documented, stricter divergence and refuses (evaluateBounds); this PR does not change that.

4. Tag contract

  • spawn:spot-request-type=one-time on Spot launches (#922), read by Go's stop/status, the dashboard and the reaper.
  • The 50-tag refusal is described above. Reserved prefix: spawn-ts has no user --tag input, so Go's spawn:-prefix refusal (parseKVTags) has nothing to apply to. If one is added it must refuse spawn: (case-insensitive).

Intentionally left out

item why
Launch config object / spawn:config (#1359) depends on unreleased spawn v0.150.0; #110, draft PR #112
spored verification after launch (heartbeat poll, #1296/#1298) portable but an API-shape change (launch would resolve minutes later); filed as #109
SSM-first connect (#1296) already the case: the browser terminal is SSM-only, and spawn-ts has no SSH path or --wait-for-ssh
Multi-card EFA (#1404/#1407/#1410) spawn-ts has no network-interface or EFA surface; MPI is tag-emit only (docs/execution-shapes.md)
Inline-body fallback (InlineBody, Go dev builds) spawn-ts always ships a pinned release, so the stub is always the right form
Persistent Spot requests refused instead (above)
Storage/FSx/EFS, containers, custom user data, staged task files (#1274 task path), Windows bootstrap not part of spawn-ts's surface; a browser can't mount or stage, and spawn-ts launches Linux only
spawn:price-source, Go's %.6f/%.4f price formatting not behavioural: readers parse floats

Gates (each watched FAIL against a revert that type-checks)

gate revert result
stub byte-equality + pin test SPAWN_BOOTSTRAP_VERSION = "0.150.0" 6 FAIL
SPAWN_SPORED_VERSION pin dropped (latest spored) 6 FAIL
FATAL_RETIRE dropped 6 FAIL
body sha pinned to vendored body last hex digit changed 6 FAIL
username validation validateUsername call removed 8 FAIL
plugins.json Go bytes serializeDeclarations back to JSON.stringify FAIL
gojson vs Go vectors HTML escaping off / U+2028 not escaped 4 / 2 FAIL
#1063 checkUserDataSize call voided FAIL
#1375 nested check voided / ARN not parsed FAIL / 2 FAIL
#1336 checkTagLimit never throws 2 FAIL
#922/#1330 Spot refusal voided / idle ignored FAIL / FAIL
#1298 EC2Provider rethrows without terminating / client rethrows without terminating 3 FAIL / 2 FAIL
#990 client back to parseDuration ?? 0 / CLI back to parseDuration / signed check removed 7 / 2 / 1 FAIL
#1308 idle-cpu range validateIdleCpu call removed 3 FAIL
completion file to bootstrap (#1131) completionFile not passed FAIL
spawn:spot-request-type tag removed 2 FAIL

Checks

npm run typecheck, npm test (779 passed), npm run build, npm run build:lib, check:exports, check:imports: all pass. semgrep scan --config=auto --error: clean. release:check fails only on "0.7.0 is already published", which is expected because no version bump is done here.

…9.0, plus launch refusals

- userdata: the #1274 stub (fetch + sha256 + signature-verify the published
  bootstrap body), spored pinned to spawn/versions/0.149.0 (#1412), byte-equal
  to Go's BuildLinuxBootstrap for the same inputs (fixtures from v0.149.0);
  gzip+base64 like EncodeLinuxUserData; Go username validation.
- refuse before any AWS call: user data over 16 KiB (#1063), a nested-spawn
  profile without a TTL (#1375), more than 50 tags (#1336).
- terminate an instance whose launch failed after RunInstances unless
  keepOnError (#1298), in EC2Provider and SpawnClient.
- launch durations use Go's pkg/ttl parser (1d; no signed values) and an
  unparseable one is refused instead of silently dropped (#990).
- spawn:spot-request-type=one-time on Spot launches (#922).
- plugins.json is Go json.Marshal byte-compatible (sorted keys, HTML escaping).
@scttfrdmn
scttfrdmn merged commit 772813a into main Oct 29, 2026
1 check passed
@scttfrdmn
scttfrdmn deleted the chore/go-parity-2026-10 branch October 29, 2026 18:40
@scttfrdmn
scttfrdmn restored the chore/go-parity-2026-10 branch October 29, 2026 18:41
@scttfrdmn
scttfrdmn deleted the chore/go-parity-2026-10 branch October 29, 2026 18:41
@scttfrdmn scttfrdmn mentioned this pull request Oct 30, 2026
scttfrdmn added a commit that referenced this pull request Oct 30, 2026
Promote [Unreleased] to [0.8.0] — 2026-10-29 with the breaking changes called
out (the #111 refusals, terminate-on-error by default, #112's config object),
bump package.json and LIB_VERSION, and ship NOTICE (Apache-2.0 §4(d)), as
truffle-ts#87 and lagotto-ts do.
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.

spored v0.150.0+ ignores the hook tags spawn-ts writes (webhooks, notify, active ports/processes)

1 participant