Skip to content

Verify spored by the instance's OS, not the workstation's (#882) - #886

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/882-verify-by-target-os
Oct 13, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/882-verify-by-target-os

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Closes #882

The defect

Step 10b of spawn launch gated spored verification on:

if waitForSSH && plat.OS != "windows" {

plat is platform.Detect() and Platform.OS is runtime.GOOS — the machine running spawn. So the instance's verification depended on the user's laptop:

workstation → instance before consequence
macOS/Linux → Windows Linux check (AWS-RunShellScript) sent to Windows SSM refuses with UnsupportedPlatformType; launch reports "spored never came up" about a healthy spore and exits 1 — observed on i-061da267b7a9442de during #879's validation. With --terminate-on-error, it terminates a healthy instance.
Windows → Linux no check at all a failed spored install is reported as a successful launch
macOS/Linux → Linux correct —

The fix

sporedVerificationFor(waitForSSH, targetOS) decides from config.TargetOS only. The workstation's OS is deliberately not a parameter, so it can't drift back in. The only other plat.OS use in the launch path — enabling ANSI colours in a Windows terminal — really is about the local machine and stays.

A Windows target is verified, not skipped. verifySporedReadyOn asks the Service Control Manager over AWS-RunPowerShellScript whether the spored service is Running, with a 10-minute budget (first boot also installs the AWS CLI). It queries the service rather than running spored.exe because a verified-install refusal (#879) leaves no binary to run, and "no binary" has to read as not ready, not as an execution error. This matters now: #879 made the Windows install fail closed, so there's a real failure to report — and skipping would leave exactly the silent Windows case #878 described.

verifySporedReady keeps its signature and Linux behaviour for its other callers (plugin.go, the Substrate tests), which pass unchanged.

Gates

TestLaunchDecidesSporedVerificationByTargetOS reads the call site's AST: it fails if sporedVerificationFor is passed anything of plat, if it isn't passed config.TargetOS, or if the launch calls the Linux-only verifySporedReady. Structural on purpose — the defect was one wrong value in one condition, and a behavioural test of the decision function can't see what its caller passes. Matched as call expressions, so the comment that names plat.OS to explain this can't trip it.

Plus the decision table, the probe mapping (Windows → PowerShell document, Linux → shell), and a parse check of the Windows probe under PowerShell's parser.

revert (each compiles) result
decide by plat.OS — the original bug fails
launch calls Linux-only verifySporedReady fails
Windows probe sent as a shell document fails
decision ignores the target OS fails
skip verification for Windows fails

The last is the tempting non-fix: it also makes the false error disappear, while leaving Windows spores unverified.

make check, check-docs, semgrep, gitleaks (8.21.2) clean.

Not yet: one real Windows launch

The PowerShell probe parses, and RunPowerShell is proven against real Windows from #879's validation — but this exact probe string hasn't run against a real instance, and the end-to-end claim (a Windows launch from macOS now passes Step 10b) hasn't been observed. Same ~$0.04, ~15-minute launch as before, then terminate and leak-check. Waiting on an OK.

🤖 Generated with Claude Code

The launch gated spored verification on plat.OS, which is runtime.GOOS — the
machine running spawn. From macOS, a Windows instance got the Linux check, SSM
refused it (UnsupportedPlatformType), and the launch falsely reported that spored
never came up; with --terminate-on-error that terminates a healthy instance. From
a Windows workstation, a Linux instance got no check at all.

sporedVerificationFor now decides from config.TargetOS only, and a Windows target
is verified via AWS-RunPowerShellScript (is the spored service Running) instead of
being skipped. An AST gate on the call site fails if anything of plat reaches the
decision.

Closes #882
@codecov

codecov Bot commented Oct 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 64.51613% with 11 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/launch_single.go 0.00% 7 Missing ⚠️
cmd/launch_posthook.go 83.33% 3 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn

Copy link
Copy Markdown
Contributor Author

Validated on a real Windows instance — from macOS, with --terminate-on-error

Deliberately the combination #882 was about: before this fix it would have terminated a healthy instance.

workstation: darwin
spawn launch win882-verify --ami ami-00d8aa800578d8b12 --os windows --instance-type m7i.large \
  --region us-east-1 --ttl 45m --terminate-on-error --yes

✅ Waiting for Windows (password available, up to 12 min) (46.6s)
✅ Verifying spored agent (up to 10 min) (113.2s)
launch exit: 0

The PowerShell probe ran against the real instance and passed; the instance was not terminated. Confirmed independently over SSM afterwards: service: Running, spored version 0.128.0.

Terminated and leak-checked: root volume NotFound, launch-created SG deleted then NotFound, 0 non-terminated instances, 0 ENIs, 0 EIPs, 0 DNS records. ~3 min of runtime.

@scttfrdmn
scttfrdmn merged commit ec075ec into main Oct 13, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the fix/882-verify-by-target-os branch October 13, 2026 16:49
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.

spawn launch picks spored verification by the LOCAL OS, not the instance's

1 participant