8000 fix(minimald,sandbox): every sandbox that the daemon starts in a box's classifier leaf has its by minimal-foundry[bot] · Pull Request #3711 · gominimal/minimal · GitHub
[go: up one dir, main page]

Skip to content

fix(minimald,sandbox): every sandbox that the daemon starts in a box's classifier leaf has its - #3711

Draft
minimal-foundry[bot] wants to merge 2 commits into
mainfrom
agent/3696-every-sandbox-that-the-daemon-starts-in-a-box-s
Draft

minimal-foundry[bot] wants to merge 2 commits into
mainfrom
agent/3696-every-sandbox-that-the-daemon-starts-in-a-box-s

Conversation

@minimal-foundry
Copy link
Copy Markdown
Contributor

Follow-up

Fixes #3696

Task marker
### D3696 — Every sandbox that the daemon starts in a box's classifier leaf has its supervisor in that leaf, or the run fails
  kind: task
  size: M
  est: 80 code, 140 tests
  executor: agent
  origin: residual
  epic: 1437
  layers:
    - sandbox:
      - crates/sandbox/src/lib.rs: classifie
8000
r gains a function that moves a pid into a leaf and reads cgroup.procs back. run_with_cancel calls it for each spawned supervisor when the config has a classifier leaf. On an error it kills and reaps the process and fails the run.
      test: cargo test -p sandbox a_run_in_a_classifier_leaf_places_its_supervisor
    - minimald:
      - crates/minimald/src/exec/process.rs: The task launch moves the supervisor of each invocation into the leaf of its box after the spawn. A failed move kills and reaps the process and fails the task with the cause.
      - crates/minimald/src/exec/tests.rs: Add a test with a stand-in leaf that has no cgroup.procs. The task launch returns an error and the process is reaped.
      - crates/minimald/src/box_runtime/enforcement.rs: place_box_processes calls the sandbox function, so one function moves and confirms a supervisor for a box launch, a build and a task.
      - crates/minimald/tests/classifier_root_integration.rs: package_build_in_a_box_leaf_follows_its_verdict_over_a_loaded_table also asserts that the supervisor of the build is in the leaf while the build runs.
      test: cargo test -p minimald a_task_supervisor_the_leaf_refuses_stops_the_task
      test: just test-root-integration
  proof: While a package build or a task runs for a host-address box, the cgroup.procs of the box's leaf lists the sandbox supervisor, and the daemon's own cgroup holds no process of that run.

Proof

While a package build or a task runs for a host-address box, the cgroup.procs of the box's leaf lists the sandbox supervisor next to the program. The daemon moves the supervisor in after the spawn and reads the leaf back. A supervisor that the leaf does not list stops the run: the daemon kills and reaps the process, and the build or task fails with the cause. package_build_in_a_box_leaf_follows_its_verdict_over_a_loaded_table now asserts that the leaf lists the build's supervisor while the build runs. This box did not run that assertion (see notes).

Notes from the agent: One function now moves and confirms a supervisor: sandbox::classifier::place_supervisor, with leaf_lists_pid moved beside it. place_box_processes calls it, and enforcement.rs re-exports leaf_lists_pid for the existing box_runtime tests. run_with_cancel holds the program at a start gate (Sandbox::hold_start) when the config has a leaf, places the supervisor, then releases the gate. The task launch in exec/process.rs cannot hold a start gate, because mctx::Env exposes no hold_start and crates/mctx is outside the layers. So place_supervisor treats a failure for a supervisor in state Z or X as Ok: a fast task can exit before the move, and an exited supervisor is not a process left outside the leaf. A follow-up can add a start gate to the mctx Env so the task path holds its program too. The root integration probe now sleeps 500 ms at start so the watch thread can read the leaf while the build is alive. New printed text (task refusal, pinned in a_task_supervisor_the_leaf_refuses_stops_the_task): "the task did not start: Minimal could not move the task's supervisor process into the cgroup that decides the box's network access. The cgroup no longer exists. If it keeps failing, run min bug to collect a diagnostic bundle." It follows the existing box-launch refusal text. Not run here: just test-root-integration (its gvproxy prerequisite needs network, and the lane needs root and a classifier tr…[truncated]

Tests

line exit tail
cargo test -p sandbox a_run_in_a_classifier_leaf_places_its_supervisor 0 running 2 tests test tests::a_run_in_a_classifier_leaf_places_its_supervisor_over_a_stand_in ... ok test tests::a_run_in_a_classifier_leaf_places_its_supervisor_in_the_real_tree ... ok test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 106 filtered out; finished in 0.00s running 0 tests
cargo test -p minimald a_task_supervisor_the_leaf_refuses_stops_the_task 0 running 1 test test exec::tests::a_task_supervisor_the_leaf_refuses_stops_the_task ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 1546 filtered out; finished in 0.00s running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 13 filtered out; finished in 0.0
just test-root-integration 1 fetch-gvproxy: building gvproxy-linux-amd64 v0.9.0 from the pinned source build-gvproxy: downloading https://go.dev/dl/go1.26.10.linux-amd64.tar.gz warning: unknown fields in task runtime-implement-test-0: network warning: unknown fields in task runtime-implement-test-1: network warning: unknown fie

Verify

min task run agent-verify exited 100, so this PR is a draft.

0) sandbox config::tests::only_the_bound_dir_layout_takes_a_home_override
        PASS [   0.006s] (1586/1680) sandbox config::tests::the_devpts_remount_keeps_the_box_ptmx_open_and_caps_at_box_pty_max
        PASS [   0.006s] (1587/1680) sandbox config::tests::the_synth_passwd_entry_names_the_box_uid_and_gid
        PASS [   2.435s] (1588/1680) minimald::netns_root_integration a_group_member_that_ignores_sigterm_is_sigkilled_after_the_grace
        PASS [   0.208s] (1589/1680) sandbox forker::tests::a_fork_on_a_short_lived_thread_dies_with_it
        PASS [   0.007s] (1590/1680) sandbox forker::tests::a_panic_is_reraised_and_the_fork_thread_survives
        PASS [   0.006s] (1591/1680) sandbox listener::tests::listener_serves_a_request_with_a_non_utf8_value
        PASS [   0.007s] (1592/1680) sandbox listener::tests::listener_tells_the_channel_which_bytes_were_not_utf8
        PASS [   0.006s] (1593/1680) sandbox listener::tests::listener_trace_leaves_out_the_run_environment
        PASS [   0.007s] (1594/1680) sandbox session_bind::tests::a_dangling_link_in_the_home_gets_its_target_made_in_the_home
        PASS [   0.006s] (1595/1680) sandbox session_bind::tests::a_kernel_error_at_a_bind_is_explained_with_its_next_step
        PASS [   0.006s] (1596/1680) sandbox session_bind::tests::a_link_out_of_the_home_is_refused_and_one_inside_it_followed
        PASS [   0.007s] (1597/1680) sandbox session_bind::tests::a_path_out_of_the_home_is_refused
        PASS [   0.006s] (1598/1680) sandbox session_bind::tests::a_plain_patch_path_resolves_to_its_own_object
        PASS [   0.007s] (1599/1680) sandbox session_bind::tests::a_refusal_says_what_was_refused_why_and_what_to_do
        PASS [   0.009s] (1600/1680) sandbox session_bind::tests::a_refused_create_leaves_nothing_behind
        PASS [   0.009s] (1601/1680) sandbox session_bind::tests::a_stow_link_that_climbs_within_the_home_is_followed
        PASS [   0.006s] (1602/1680) sandbox session_bind::tests::a_swap_after_the_resolve_does_not_change_the_handle
  stdout ───

    running 1 test
    test session_bind::tests::a_swap_between_the_resolve_and_the_bind_cannot_change_what_is_mounted ... FAILED

    failures:

    failures:
        session_bind::tests::a_swap_between_the_resolve_and_the_bind_cannot_change_what_is_mounted

    test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 107 filtered out; finished in 0.00s

  stderr ───

  Cancelling due to test failure: 3 tests still running
        PASS [   0.209s] (1604/1680) sandbox forker::tests::a_fork_on_the_fork_thread_outlives_the_caller
        PASS [   3.114s] (1605/1680) minimald::otel_shutdown_integration a_silent_collector_does_not_hold_the_daemons_exit
        PASS [   5.138s] (1606/1680) minimald::otel_shutdown_integration a_connection_open_at_shutdown_still_exports_its_span
────────────
warning: 74/1680 tests were not run due to test failure (run with --no-fail-fast to run all tests, or run with --max-fail)
error: test run failed

run_with_cancel holds the program at a start gate, moves the supervisor
into the leaf with classifier::place_supervisor, and reads the leaf back.
A supervisor that is not in the leaf fails the run, which kills and reaps
the process.
The task launch moves each invocation's supervisor into the leaf of its
box after the spawn. A failed move kills and reaps the process and fails
the task with the cause. place_box_processes now calls the sandbox
function, so a box launch, a build and a task share one placement.
@coderabbitai
coderabbitai Bot commented Nov 20, 2026
Copy link 8000
Copy Markdown
Contributor

Important

Review skipped

Bot user detected.

Ask an organization administrator to verify that this bot has an active assigned CodeRabbit review seat. See the seat-assignment guide. After the seat is confirmed, request a review again.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4e35e81a-77c8-4f5a-8853-61290cc1cb66

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

This branch has not been deployed

No deployments
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.

A sandbox that the daemon starts in a box's classifier leaf leaves its supervisor outside the leaf

0 participants

0