Repository navigation
fix(linux): preserve setup failures through executable launch - #248
Conversation
## Problem Linux startup could report success before privilege, filter, environment, and executable preparation finished. Late setup failures could disappear or look like workload exit codes. The native setup-reporting suite exposes ten failures on the previous implementation. Its abrupt-launcher-death case remains a passing control. ## Solution Keep the setup-status writer with the workload through preparation and executable launch. The launcher and namespace supervisor close their copies before waiting for workload exit. Require workload marker 128, Linux supervisor marker 6, and channel closure before reporting completed setup. Retain failure stages 1 through 5, including an executable failure after marker 128. Reject incomplete and incompatible status messages. Update the helper protocol documentation and retain current-main executable lookup. This reports completed preparation, not application readiness. Abrupt death after both preparation markers but before executable launch remains indistinguishable from successful launch. The helper and Box must come from the same build. Root-launch policy, grants, signal forwarding, and process cleanup do not change. ## Tests Native Amazon Linux 2023 on ARM64, Rust 1.98.1. setup_reporting_linux passes all eleven cases after the fix. bounding_failure_reports_apply, capability_failure_reports_apply, privilege_failure_reports_apply, filter_failure_reports_apply, environment_failure_reports_decode, and executable_failure_reports_exec verify late failure stages and absent workload output. abrupt_launcher_death_has_no_setup_completion and abrupt_death_during_filter_installation_has_no_setup_completion cover premature channel closure. an_unclosed_supervisor_writer_reports_failure_without_waiting_for_workload_exit covers a retained writer. buffered_success_keeps_ordinary_workload_exit_codes preserves codes 0, 3, 4, 5, and 42. streaming_setup_finishes_before_workload_exit covers an interactive workload waiting for input. setup_reporting_preserves_late_failures_in_buffered_and_streaming_execution and setup_reporting_preserves_successful_buffered_and_streaming_execution exercise the real Box callers. setup_completion_does_not_hide_a_later_exec_failure fails with premature success restored. setup_completion_rejects_duplicate_or_unknown_markers fails when malformed bytes are ignored. The restored reader passes both tests. Final format, all-feature build, and workspace Clippy passed. Clippy used the documented vendored-shell allowances; the host has no just installation. The full Rust workspace gate passed in 1,384 seconds. Its 142 result summaries, including child reruns, record 4,608 passes, zero failures, and 17 ignored entries. Four runtime coverage limits remain: missing installed alias image, absent cardinality probe, unrun Linux alias-read assertion, and missing credential daemon. These limits are outside the setup-reporting suite. The deterministic integration gate recorded all 133 expected cases: 124 passed, nine macOS-only skips, and no failures or errors. An independent feature-critic review found no remaining source issue. The original reviewed source also passed a no-default-features build. No macOS build or execution ran locally; hosted checks remain required before merge. The example command found no scripted examples; the manual SDK tutorial was not run. Adjacent supervisor-isolation validation remains separate because no candidate was available.
|
Assessment: Comment The protocol change looks correct for each setup failure, success, and version-skew case I traced. I left two non-blocking comments. One: a run cancelled during startup is now reported as a protocol error. Two: the native suite has no host-capability probe, so some tests pass without testing anything. Assumptions and rules checked that held
The documented trade-off (an abrupt death between the marker and exec cannot be told apart from a successful exec) is stated clearly in both READMEs. |
|
Assessment: Approve (re-review of
What I checked in this commit, and what held
|
|
Assessment: Approve (re-review of The merge keeps the setup-status protocol intact. It also brings What I checked in the merge, and what held
|
Human readable section
Problem. Box could report that a Linux command started before its startup work finished. A later setup failure could disappear or appear as the command's own exit code. Callers could mistake a Box startup failure for a command result.
Solution. Keep the setup-error connection open until Box attempts to launch the command. Require completion messages from the command's setup process and the Linux supervisor, which waits for the command to exit. Box waits for these messages and connection closure before it reports startup success. Preserve reported setup failures in both execution APIs: the API that collects output and the API that streams it. Interactive commands can still start while they wait for input.
Trade-off. A successful startup result does not prove that the application is ready. If the process dies after setup but before executable launch, it can close the connection without an error message. Box cannot distinguish that final interval from a successful launch. Box and its helper executable must come from the same build.
Description
The status connection carries setup messages from the new processes to Box. The Linux supervisor waits for the workload process to exit. The workload keeps its writing end of the connection until executable launch or failure. The waiting launcher and Linux supervisor release their copies before they wait for process exit. This lets streaming startup complete while the command still waits for input.
Each setup process sends a distinct completion byte: 128 for workload preparation and 6 for Linux supervisor preparation. The reader requires both on Linux. It rejects duplicate, unknown, and legacy status messages. Incomplete setup fails both buffered execution, which collects output, and streaming execution, which delivers output as it arrives. For an agent launcher killed by a signal, Box preserves its signal exit status. Reported setup failures and malformed messages still take precedence.
The helper and Box must come from the same build. The change preserves root-launch policy, filesystem grants, process cleanup, and signal forwarding. The conflict resolution preserves the supervisor memory protection and read-only process filesystem already merged into
main.Related Issues
None.
Type of Change
Bug fix
Testing
Current conflict resolution (
b05a5b855a7715ed5386f02b115b6d77adf7e9f7). This commit mergesmainatef009143f5ed960d18c145c4fcc7063da1e9ec93. It preserves the supervisor memory guard before the workload fork, descriptor cleanup, and the workload status writer through executable launch. The executed seven-route process-memory probe and root prerequisite remain unchanged from main.supervisor_memory_refusal_reports_apply_before_workload_startverifies that a refused guard reports apply-stage failure before workload output, with a successful launch control.Current local validation. Amazon Linux 2023 on ARM64, Rust 1.98.1,
EXPERIMENTAL_LINUX_SUPPORT=TRUE, four build jobs and four test threads. The tested tree is1de851bd1c5d4eba7b80cc387dfc188e48e89db2.cargo test --workspace --all-features --no-fail-fast -- --nocapturebox_libraryassertion program also completed successfully.kernel.yama.ptrace_scope=0; it did not skip either memory probe.The original workspace output audit rejected one avoidable skip: the alias image was absent beside the unit-test binary. After installing the built helper with the repository's CI recipe, the exact existing unit-test binary passed
run::broker::aliases::tests::the_installed_image_materializes_when_present, with no skip, and its supplemental output audit passed. The original audit error remains recorded; it is not relabeled as a clean audit. The two expected limits remain: the alias-read assertion is omitted on Linux, while its write assertions run, and the live credential-daemon fixture is absent. No local deterministic or macOS run was added for this conflict repair.Main later advanced to
db481935ec27d183e8b3aa4a87a518c0f55ece21through PR #217. A read-only merge check was clean, producing tree28a99494f9b62ecb0603c8ded7ae2254af211eb7. Local tests cover the statedef00914integration base; hosted pull-request checks will cover the current-main combination. Current hosted checks. At2026-11-02T19:38:59.812645+00:00, the continuous integration run is pending. Packaging and change detection passed; substantive Rust, native filesystem, and deterministic jobs remain incomplete. See the CodeQL run for its current results. The automatic review trigger passed its access check, but current-head review remains pending. No environment approval is pending for continuous integration or the review trigger. There is no current-head automated assessment yet. The latest earlier assessment below coversd806fc2only. Hosted validation remains pending.Prior hosted checks. The continuous integration gate passed for
d806fc2ebd3ae07825248edb937a0f6169f74829on November 1, 2026. This status is separate from the local and historical test results below. The optional Verdict job skipped and provides no coverage.Local and historical validation. The full workspace results below cover
4aedf8b. Later focused checks and combined testing appear separately.Validation used non-root Amazon Linux 2023 on ARM64, Linux 6.12, and Rust 1.98.1. Exact kernel revisions are recorded per run.
EXPERIMENTAL_LINUX_SUPPORT=TRUEenabled the Linux paths; tests used four threads.The final source preserves the current-main executable lookup change.
bash scripts/test-all.sh rustat4aedf8bbash test-integ/run.sh --lockedThe review follow-up passed all 119 tests in the Box containment module and all 11 native setup tests. Format, all-feature build, and strict Clippy also passed. Namespace tests now probe host support, and fault checks first run a clean positive control. A syscall filter that refuses namespace creation produced 11 native and two boundary skips, with explicit messages; those runs establish skip behavior only.
The native suite checks six induced setup failures, abrupt launcher death, death during filter installation, refused status closure, buffered exit codes, and interactive streaming startup.
The Box tests exercise the actual buffered and streaming callers.
An independent baseline run failed 10 of the 11 native regressions; its abrupt-launcher-death case passed as a control.
Restoring the fix passed all 11.
Tests also ran with deliberate defects. Each affected regression failed, and the restored code passed.
Restoring premature success fails
setup_completion_does_not_hide_a_later_exec_failure.Ignoring malformed bytes fails
setup_completion_rejects_duplicate_or_unknown_markers; the restored reader passes.Disabling the signal-exit correction fails
cancelling_before_the_launch_gate_preserves_the_signal_exit; restoring it passes. This test kills the real gated helper with four signals and confirms that no workload output appears.The log contains 4,608 reported passes across 142 result summaries. One nested rerun is already counted by its parent suite; the table excludes it.
Ignored entries include six child-only helpers that parent tests run separately, live fixtures, long performance tests, known upstream defects, and one documentation example.
Four runtime messages identify remaining coverage limits.
The installed alias image and cardinality probe were absent. The Linux alias-read assertion did not run, and no credential daemon was available.
The alias-write assertions still ran. None of these messages came from the setup-reporting suite.
The integration runner reports an unknown commit for the copied binaries.
The evidence records their SHA-256 hashes and the final source manifest separately.
The reviewed earlier source also passed a no-default-features build.
The example command found no scripted examples; the manual SDK tutorial was not run.
No macOS build or execution ran locally. All hosted checks passed at
4aedf8b, including Linux and macOS unit and deterministic tests. The prior headd806fc2also passed the hosted continuous integration gate on November 1, 2026.Combined validation with PR #243 at
be5ab399and this PR atd806fc2passed in a separate checkout: 14 Box setup tests, one four-signal cancellation test, 12 native setup tests, and 124 deterministic cases. Nine declared macOS-only cases skipped; all 133 expected cases were recorded. The tested conflict resolution keeps supervisor hardening before the workload fork and preserves the setup writer through executable launch. The current diff keeps the setup-reporting scope and adds a failure-reporting regression for the existing supervisor memory guard.just check, orcargo test --workspace --all-features)cargo fmt --allandcargo clippy --workspace --all-targets --all-features -- -D warningsThe lint command uses the vendored-shell allowances required by
CONTRIBUTING.mdand thejust clippyrecipe.The host does not have
just, so the equivalent commands ran directly.Checklist
AI assistance: Codex implemented, tested, and reviewed this change under the author's direction.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.