feat(runtime): host GuestExec layer + portable exit-signal error type (RIG-2493) - #702
Open
rigel-mintaka wants to merge 1 commit into
Conversation
This was referenced Aug 28, 2026
|
Compass engineering docs preview: https://compass-runner-rig-2493-u3-h.compass-eng-docs.pages.dev Deployed from |
rigel-mintaka
force-pushed
the
compass-runner/rig-2493-u2-guestd-supervisor
branch
from
August 28, 2026 04:12
a66b253 to
23e0315
Compare
rigel-mintaka
force-pushed
the
compass-runner/rig-2493-u3-host-exec
branch
from
August 28, 2026 04:15
facc61c to
8a00c7e
Compare
rigel-mintaka
force-pushed
the
compass-runner/rig-2493-u2-guestd-supervisor
branch
from
August 28, 2026 04:35
23e0315 to
7e0a64e
Compare
rigel-mintaka
force-pushed
the
compass-runner/rig-2493-u3-host-exec
branch
from
August 28, 2026 04:37
8a00c7e to
869399a
Compare
rigel-mintaka
force-pushed
the
compass-runner/rig-2493-u2-guestd-supervisor
branch
from
August 28, 2026 10:08
7e0a64e to
efbf696
Compare
rigel-mintaka
force-pushed
the
compass-runner/rig-2493-u3-host-exec
branch
from
August 28, 2026 10:09
869399a to
81856f8
Compare
… (RIG-2493)
U3 + U3b of the frozen microVM Runner V2b plan (`docs/designs/infra/runtime/compass-elastic-session-runtime/microvm-v2b-guest-supervisor-exec.md`, §Plan U3/U3b, §(c)/§(e)). The host-side client half of the exec control plane: a `GuestExec` layer over U1's generated `GuestControl` client, plus the backend-portable error type the runner's kill-classifier keys on.
### U3b — portable exit-signal error (`internal/runtime/exit_status_error.go`, new)
`ExitStatusError{Code int; Signal syscall.Signal}` with `Error()`, in package `runtime`. A remote guest exec cannot forge an `*exec.ExitError`, so the microVM `waitFunc` constructs this instead for a signalled guest exit. `internal/runner/agent_exec.go`'s `isDeliberateKill` is widened to `errors.As` on `*runtime.ExitStatusError` **first** (a non-zero signal ⇒ deliberate kill), then the existing `*exec.ExitError` SIGKILL branch **unchanged** — so the podman byte-path is byte-identical and only the microVM backend gets the new classification.
### U3 — GuestExec layer (`internal/runtime/microvm/exec.go`, new)
Plain structs (`ExecCall`/`ExecResult`/`StreamCall`/`ExitStatus`) mirror the proto so `runtime` types don't leak into `microvm` (`microvm` must not import `runtime`; U4 makes `runtime` import `microvm`).
- **`Exec`** (one-shot RPC): a non-zero exit is a successful `ExecResult`; a refusal/transport failure is an error; a host-side timeout → `*microvm.TimeoutError`.
- **`ExecStream`** (bidi): opens the stream, sends `StartExec`, **awaits `ExecStarted`** before returning; per-exec goroutines pump the `Stdin` pipe → stdin frames (`Close` → `stdin_close` + `CloseRequest`) and demux `stdout`/`stderr` response frames onto `io.Pipe` read ends, closing them on `ExecExit`.
- **`GuestStream.Kill`** issues a `Signal` RPC bounded by `killSignalTimeout` (never blocks teardown past it); **`Wait`** blocks on the demux goroutine and returns `ExitStatus{Code,Signal}`. A ctx-cancel stream break reports SIGKILL — guestd reaps the child bound to the broken stream.
### `podman.go` — funcs-backed ChildHandle
Adds unexported `newChildHandleFuncs(kill, wait func() error) *ChildHandle` plus `killFunc`/`waitFunc` fields. `Kill`/`Wait`/`Terminate` branch to the funcs path when `killFunc != nil`, else drive the original `cmd`/`cancel` path **untouched** (podman byte-unchanged). `Terminate` = kill then wait, returning the wait error (the exit status) when non-nil else the kill error — so a crash-vs-teardown consumer gets the exit signal.
### Verification
`go build ./internal/runtime/... ./internal/runner/...` clean; `go vet` clean over `runtime`, `runtime/microvm`, `runner`. Tests (all hardware-independent, no `microvm` build tag, no KVM):
- `exec_test.go` — fake `GuestControl` server on a unix listener over h2c Connect, dialed by a real client: one-shot non-zero exit is success + spec mapping; refusal is an error; one-shot timeout → `*TimeoutError`; stream demux ordering (interleaved frames land on the correct pipes, drained concurrently); stdin framing + `Close` → `stdin_close`; `Kill` issues the `Signal` RPC and `Wait` unblocks on the signalled exit; ctx-cancel breaks the stream and `Wait` reports SIGKILL.
- `child_handle_test.go` — `newChildHandleFuncs`: `Kill` invokes/propagates; `Wait` surfaces `*ExitStatusError` unchanged; `Terminate` return-value precedence.
- `deliberate_kill_test.go` — `isDeliberateKill` accepts a real `*exec.ExitError` from a SIGKILLed local child (podman-path regression guard) and `*runtime.ExitStatusError{Signal: SIGKILL}`, rejects a non-signal `ExitStatusError`, an unrelated error, and nil.
Ledger-impact: none
Spec-impact: none. Refs RIG-2493
Co-authored-by: Matt Wilkinson <matt@rigel.build>
rigel-mintaka
force-pushed
the
compass-runner/rig-2493-u2-guestd-supervisor
branch
from
August 28, 2026 11:08
efbf696 to
8a86859
Compare
rigel-mintaka
force-pushed
the
compass-runner/rig-2493-u3-host-exec
branch
from
August 28, 2026 11:09
81856f8 to
417292b
Compare
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.
This PR is part of a stack containing 5 PRs:
mainU3 + U3b of the frozen microVM Runner V2b plan (
docs/designs/infra/runtime/compass-elastic-session-runtime/microvm-v2b-guest-supervisor-exec.md, §Plan U3/U3b, §(c)/§(e)). The host-side client half of the exec control plane: aGuestExeclayer over U1's generatedGuestControlclient, plus the backend-portable error type the runner's kill-classifier keys on.U3b — portable exit-signal error (
internal/runtime/exit_status_error.go, new)ExitStatusError{Code int; Signal syscall.Signal}withError(), in packageruntime. A remote guest exec cannot forge an*exec.ExitError, so the microVMwaitFuncconstructs this instead for a signalled guest exit.internal/runner/agent_exec.go'sisDeliberateKillis widened toerrors.Ason*runtime.ExitStatusErrorfirst (a non-zero signal ⇒ deliberate kill), then the existing*exec.ExitErrorSIGKILL branch unchanged — so the podman byte-path is byte-identical and only the microVM backend gets the new classification.U3 — GuestExec layer (
internal/runtime/microvm/exec.go, new)Plain structs (
ExecCall/ExecResult/StreamCall/ExitStatus) mirror the proto soruntimetypes don't leak intomicrovm(microvmmust not importruntime; U4 makesruntimeimportmicrovm).Exec(one-shot RPC): a non-zero exit is a successfulExecResult; a refusal/transport failure is an error; a host-side timeout →*microvm.TimeoutError.ExecStream(bidi): opens the stream, sendsStartExec, awaitsExecStartedbefore returning; per-exec goroutines pump theStdinpipe → stdin frames (Close→stdin_close+CloseRequest) and demuxstdout/stderrresponse frames ontoio.Piperead ends, closing them onExecExit.GuestStream.Killissues aSignalRPC bounded bykillSignalTimeout(never blocks teardown past it);Waitblocks on the demux goroutine and returnsExitStatus{Code,Signal}. A ctx-cancel stream break reports SIGKILL — guestd reaps the child bound to the broken stream.podman.go— funcs-backed ChildHandleAdds unexported
newChildHandleFuncs(kill, wait func() error) *ChildHandlepluskillFunc/waitFuncfields.Kill/Wait/Terminatebranch to the funcs path whenkillFunc != nil, else drive the originalcmd/cancelpath untouched (podman byte-unchanged).Terminate= kill then wait, returning the wait error (the exit status) when non-nil else the kill error — so a crash-vs-teardown consumer gets the exit signal.Verification
go build ./internal/runtime/... ./internal/runner/...clean;go vetclean overruntime,runtime/microvm,runner. Tests (all hardware-independent, nomicrovmbuild tag, no KVM):exec_test.go— fakeGuestControlserver on a unix listener over h2c Connect, dialed by a real client: one-shot non-zero exit is success + spec mapping; refusal is an error; one-shot timeout →*TimeoutError; stream demux ordering (interleaved frames land on the correct pipes, drained concurrently); stdin framing +Close→stdin_close;Killissues theSignalRPC andWaitunblocks on the signalled exit; ctx-cancel breaks the stream andWaitreports SIGKILL.child_handle_test.go—newChildHandleFuncs:Killinvokes/propagates;Waitsurfaces*ExitStatusErrorunchanged;Terminatereturn-value precedence.deliberate_kill_test.go—isDeliberateKillaccepts a real*exec.ExitErrorfrom a SIGKILLed local child (podman-path regression guard) and*runtime.ExitStatusError{Signal: SIGKILL}, rejects a non-signalExitStatusError, an unrelated error, and nil.Ledger-impact: none
Spec-impact: none. Refs RIG-2493
Co-authored-by: Matt Wilkinson matt@rigel.build