Skip to content

feat(runner): microVM boot canary startup preflight (RIG-3148) - #847

Open
rigel-mintaka wants to merge 3 commits into
mainfrom
compass-runner/rig-3148-boot-canary
Open

feat(runner): microVM boot canary startup preflight (RIG-3148)#847
rigel-mintaka wants to merge 3 commits into
mainfrom
compass-runner/rig-3148-boot-canary

Conversation

@rigel-mintaka

Copy link
Copy Markdown
Contributor

Add the dynamic half of the microVM backend's startup preflight: a boot
canary that really boots a throwaway VM through the backend's own verbs
(Create->Start->Exec->Remove), proving the whole chain -- KVM, vsock,
image, guest supervisor, exec gate -- not just binary presence.

  • CanaryReport{BootLatency, GuestRSSBytes} and
    (*MicroVMRuntime).BootCanary(ctx) in microvm_preflight.go. The canary
    owns the VM's whole lifetime inside the call, so it derives a bounded
    ctx (caller deadline as-is when present, else a 90s bound) and severs
    teardown from it so a timed-out boot still tears down. Remove and the
    throwaway-workspace cleanup are joined into the return, never discarded.
    Boot latency is the Start wall time; guest PSS is best-effort telemetry
    (a read error leaves it at 0, logged, never fatal -- the gate is the
    boot chain).
  • Extend the runner startup gate: a canaryBooter probe interface
    (distinct single-method probe, not a widened microVMPreflighter) and a
    runMicroVMPreflight helper that runs VerifyMicroVMSupport, then -- only
    once it passes -- BootCanary, logging the report. A microVM engine that
    cannot canary is a fail-closed startup error naming the type, never a
    silent skip.
  • Hermetic seam-faked suite over the launch/client seams (no KVM), plus a
    KVM-gated TestBootCanary riding the existing microVM CI leg. A one-line
    cross-reference distinguishes the no-boot enablement smoke test from
    this real boot canary.

Refs RIG-3148
Co-authored-by: Matt Wilkinson matt@rigel.build

@linear-code

linear-code Bot commented Sep 3, 2026

Copy link
Copy Markdown

RIG-3148

@trunk-io

trunk-io Bot commented Sep 3, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

Compass engineering docs preview: https://compass-runner-rig-3148-boot.compass-eng-docs.pages.dev

Deployed from compass-runner/rig-3148-boot-canary at ee6a3a6.

rigel-mintaka and others added 3 commits September 3, 2026 01:17
Add the dynamic half of the microVM backend's startup preflight: a boot
canary that really boots a throwaway VM through the backend's own verbs
(Create->Start->Exec->Remove), proving the whole chain -- KVM, vsock,
image, guest supervisor, exec gate -- not just binary presence.

- `CanaryReport{BootLatency, GuestRSSBytes}` and
  `(*MicroVMRuntime).BootCanary(ctx)` in microvm_preflight.go. The canary
  owns the VM's whole lifetime inside the call, so it derives a bounded
  ctx (caller deadline as-is when present, else a 90s bound) and severs
  teardown from it so a timed-out boot still tears down. Remove and the
  throwaway-workspace cleanup are joined into the return, never discarded.
  Boot latency is the Start wall time; guest PSS is best-effort telemetry
  (a read error leaves it at 0, logged, never fatal -- the gate is the
  boot chain).
- Extend the runner startup gate: a `canaryBooter` probe interface
  (distinct single-method probe, not a widened microVMPreflighter) and a
  `runMicroVMPreflight` helper that runs VerifyMicroVMSupport, then -- only
  once it passes -- BootCanary, logging the report. A microVM engine that
  cannot canary is a fail-closed startup error naming the type, never a
  silent skip.
- Hermetic seam-faked suite over the launch/client seams (no KVM), plus a
  KVM-gated TestBootCanary riding the existing microVM CI leg. A one-line
  cross-reference distinguishes the no-boot enablement smoke test from
  this real boot canary.

Refs RIG-3148
Co-authored-by: Matt Wilkinson <matt@rigel.build>
… discipline (RIG-3148)

Additive review-fix commit on the W3 boot-canary PR, closing the one gating
finding plus three lows from the review round:

- medium (test-adequacy): the PSS-read-error fail-open branch — the one
  fail-open seam on an otherwise fail-closed startup gate (record §(e)/OQ-10) —
  had no hermetic coverage, so a regression flipping it to fatal (spurious
  Runner-startup refusal on a host with an unreadable smaps_rollup) would pass
  every test. Added a `pssErr` knob to canaryFakeVM (threaded through the launch
  recorder) and TestBootCanaryPSSErrorNonFatal, which pins that a PSS read error
  leaves BootCanary succeeding with GuestRSSBytes == 0 and the session torn
  down. Mutation-verified RED on flip-to-fatal.
- low (lock discipline): BootCanary read `session.vm` outside `m.mu`, the one
  production reader deviating from the microvmSession invariant. Now reads the
  handle under the lock, matching Stop (microvm_lifecycle.go).
- low (doc): tightened the canaryTeardownGrace comment to state it bounds Remove
  only if/when Remove honors its ctx deadline — today Remove is deadline-agnostic
  — so the constant no longer implies an enforced ceiling it lacks.
- low (test symmetry): TestBootCanaryNonZeroExitFails now carries the temp-leak
  and wasShutdown assertions its sibling failure-path tests carry.

No behavior change on the happy path; the under-lock read is a visibility/
invariant tightening with no functional effect (single-owner canary session).

Refs RIG-3148

Co-authored-by: Matt Wilkinson <matt@rigel.build>
…RIG-3148)

Round-r1 review fold for the V5 W3 boot canary. All four findings are test-only; `microvm_preflight.go` is unchanged.

### Nonce round-trip (was the gating medium)

The nonce-mismatch branch — exec returns exit 0 but stdout does not carry the minted nonce — was uncovered: `canaryFakeClient.Exec` always echoes the command back, so the fake structurally could not produce exit-0-with-wrong-stdout. That branch is the "exec gate" leg of the whole-chain claim (record §(e)): exit 0 alone only proves a call returned; the nonce is the sole assertion the guest ran our command and returned our data. Added a `stdout *string` override knob (mirroring the r0 `pssErr` knob) and `TestBootCanaryNonceMismatchFails`. Mutation-verified: disabling the nonce check goes RED, restored GREEN.

### Deadline guard (was low, tautological test)

`TestBootCanaryHonorsCallerDeadline` could not fail on the bug it named — a 5s caller bound is clamped by `context.WithTimeout` regardless of the `if _, ok := ctx.Deadline(); !ok` guard, so a re-deriving implementation passes it. Added `TestBootCanaryHonorsLongerCallerDeadline` with a 10-minute caller deadline (the only case the guard actually protects: a longer caller deadline must pass through, not be clamped to the 90s canary bound). Mutation-verified: removing the guard goes RED for the new test while the old 5s test stays GREEN.

### Partial PSS (was low, half-covered contract)

The real `VM.PSS()` returns a partial map alongside a joined error as its normal shape; `TestBootCanaryPSSErrorNonFatal` drove `pss=nil` so the partial-data-plus-error combination was undefended. Added `TestBootCanaryPartialPSSStillReported`. Mutation-verified: discarding the partial map inside the error branch goes RED.

### Path convention (was low)

`boot_canary_microvm_test.go` built `<RunRoot>/microvm` by string concatenation beside the production `filepath.Join`; switched to `filepath.Join`.

Gates green: gofmt, linux + `-tags microvm` builds, hermetic suite (11 tests), golangci-lint `--build-tags microvm` (0 issues), nilaway (exit 0).

The remaining r1 low (threading a signal-cancellable ctx into the startup preflight callsite) is a control-flow-ordering judgment call and is filed separately for Matt.

Spec-impact: none. Refs RIG-3148

Co-authored-by: Matt Wilkinson <matt@rigel.build>
@rigel-mintaka
rigel-mintaka force-pushed the compass-runner/rig-3148-boot-canary branch from 5be9b07 to ee6a3a6 Compare September 3, 2026 05:19
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