Repository navigation
fix(mctx,minimald,sandbox): the in-box min task run uses one sandbox run path for inherit_cwd and - #3389
Conversation
RunOptions carries the cancellation token, the directory every invocation starts in, and a slot that receives the first invocation's stdin pipe. A bare CancellationToken still converts, so callers that pass only a token do not change.
The working directory, stdin slot and cancellation token reach Sandbox::run_with_cancel unchanged. Env::run delegates to it.
BoxChannel::run_task passes start_dir and the forwarded stdin to Env::run_with_options, so an inherit_cwd task and a default task share one path. run_invocations_in is gone. StreamWriter sends a last line without a newline when it shuts down. An end-to-end test drives both tasks through run_task and checks the exit line.
…-min-task-run-uses-one-sandbox-run-pat # Conflicts: # crates/minimald/src/env.rs
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
…-min-task-run-uses-one-sandbox-run-pat
The RunOptions insertion split the linux cfg from the impl block it gated, which broke the macOS build. A test constant also split the make_base_with_synth doc comment from its function.
|
Round 1 of 10 on a failed check suite, pushed as
Verify Converted to a draft: something above needs a person before review. A run of an inherit_cwd task and of a default task through BoxChannel::run_task relays the same exit line (run_task_relays_exit_through_both_paths passes), and run_invocations_in is no longer in the code. The sandbox crate again gates its Linux-only impl block on Linux, so the macOS lanes can compile it. Notes from the agent: Revise round 1. The macOS unit and zoned failures had one cause. The earlier commit put the StdinSlot and RunOptions definitions between |
|
Round 2 of 10 on a failed check suite: the coder changed nothing. Revise round 2. I made no change. commitlint: the failure is on the commit 82ac550, whose subject starts with 'Env::run_with_options' (subject-case). My instructions forbid me to rewrite commits that are already on the branch, so a new commit cannot clear this check. A person can reword that commit, or squash the pull request with a lower-case subject. tests: the log excerpt does not name the failing test. The branch changes only crates/sandbox, crates/mctx and crates/minimald. Under nextest, every test passes in those crates and in the crates that depend on them (mip, op, orchestrator, minimal). So the CI failure is either in a crate this branch does not reach or a flaky test, and I cannot reproduce it. ci-linux-native-success is the aggregator, and it fails because the tests job fails. Environment notes: this box sets MINIMAL_OTEL=off. With it set, task_entrypoint_carries_env_cwd_and_args fails (the request starts with 'otel%off%'), and two stdin tests in minimald env ha…[truncated] |
|
/revise CI
Run |
…-min-task-run-uses-one-sandbox-run-pat
run_with_cancel_starts_in_the_given_dir and run_task_relays_exit_through_both_paths start a real sandbox. A host that denies the unprivileged user namespace, such as a stock Ubuntu 24.04+ CI runner, cannot start one, so the run fails. Both tests now skip on user_namespaces_restriction(), as the other sandbox tests do.
|
Round 3 of 10 on a /revise note, pushed as
Verify Converted to a draft: something above needs a person before review. On a host that can start a sandbox, run_task_relays_exit_through_both_paths runs an inherit_cwd task and a default task through BoxChannel::run_task. Both relay the same exit line, exit:0 on a pass and exit:3 on a failure. run_invocations_in is no longer in the code. Notes from the agent: Revise round 3. I was not able to reproduce either CI panic on this box. Both tests pass here under cargo test and under cargo nextest run -p minimald -p sandbox. This box has no /proc/sys/kernel/apparmor_restrict_unprivileged_userns. The CI runner is Ubuntu 26.04, which sets that sysctl to 1 by default. Both panics are at the first sandbox run. So the likely cause is that the host denies the unprivileged user namespace. Both tests now skip when sandbox::user_namespaces_restriction() returns Some, as a_held_start_runs_the_program_only_once_released and other sandbox tests do. On a CI host with the restriction, these tests will skip and will not run. If CI fails for a different reason, the panics will stay, and the next round needs the panic message from the tests job log. The directive excerpt did not include it. I did not touch the commitlint failure on 82ac550 and did not rewrite history, as the directive asked. The e2e failure (ConfigureLoadout RPC timed out) was not in the directive's note, and I did not address it. cargo test -p mctx exits 101 here only because rustdoc is missing on this box. |
|
/revise CI The earlier panics (job 131752183894) came from the runner, not from the code. The runner refused the user namespace: Keep both skips. Add tests that run on the CI
Each new test must not call |
…-min-task-run-uses-one-sandbox-run-pat
apply_run_options sets the working dir and the stdin slot on the command of one invocation. The new test builds commands and spawns nothing, so it runs on the CI tests lane, which denies the user namespace.
run_task hands its invocations to an InvocationRunner. mctx::Env runs them in the sandbox, and a test runner starts none. The new test checks the exit line of an inherit_cwd task and a default task on a host that denies the user namespace.
|
Round 4 of 10 on a /revise note, pushed as
Verify Converted to a draft: something above needs a person before review. A run of an inherit_cwd task and of a default task through the run_task relay sends the same exit line (exit:0 for a pass, exit:3 for a failure), and run_invocations_in is no longer in the code. Two new tests now check this on a host that denies the user namespace, such as the CI tests lane, and they never skip. Notes from the agent: Revise round 4. Both userns skips stay. New tests, which do not call user_namespaces_restriction() and do not skip: (1) sandbox tests::run_with_cancel_starts_in_the_given_dir_on_each_built_command. run_with_cancel now sets its options through a new apply_run_options(cmd, current_dir, &mut stdin). The test builds hakoniwa commands without a spawn and checks the working dir on each command, and that only the first command takes the caller's stdin slot. (2) minimald env::tests::run_task_relays_exit_through_both_paths_with_a_fake_runner. run_task now calls run_invocations_relayed with an InvocationRunner. mctx::Env implements it with run_with_options, and a FakeRunner implements it in the test. The test checks the start_dir_in_box results, the run options the runner gets, the relayed output, the exit:0 and exit:3 lines for an inherit_cwd and a default task, and a forwarded stdin. Both new test names contain the test: line filters, so the existing test: lines run them. I cannot quote CI nextest PASS lines: CI runs after the push, so the runner must add them to the PR body. Commitlint: the failure is on the earlier commit 82ac550 (subject 'Env::run_with_options ...' starts with an upper-case letter). A fix needs a rewrite of that commit, and the rules for this round do not permit a rewrite or a force-push. So the commitlint check stays red until a person rewords that commit or squashes on merge. |
|
The runtime will not revise this pull request again on its own: the diff is +809/-137 (946 lines), past 3x the plan's estimate of 300 lines (est: 140 code, 160 tests, as #3344 reads now), at round 4 (the last trigger was a /revise note). A person decides now. Remove |
|
Approved: no findings at Nothing to do. Verdict APPROVE, posted as a comment: the App cannot review its own pull request; the check and the label carry it. Clobber: none seen. |
There was a problem hiding this comment.
arch-review: PASS · the full ruling
The change conforms to the design. Every in-box min task run now runs on one sandbox path, and only the run options differ. This follows architecture.md lines 395 and 400: inside a box, a task run behaves exactly as outside. The stdout and stderr tags, the stdin: handshake and the exit line did not change, so principles 4 and 5 (lines 334-335) still hold. The stdin gap for later invocations is a residual, and #3094 tracks it. The full-suite verify did not finish, and that result is for CI to settle.
Ruled at 68836d6 against gominimal/arch@327e1b57d16b by claude-opus-5-5.
There was a problem hiding this comment.
Read at 68836d64 against D2983. run_invocations_in is gone. BoxChannel::run_task always runs through run_invocations_relayed, then Env::run_with_options, then Sandbox::run_with_cancel, and an inherit_cwd task, a stdin-forwarding task and a default task differ only in RunOptions. apply_run_options sets current_dir on every invocation and gives the stdin slot to the first only (the #3094 gap, documented). The slot gets the pipe before any output is read, so stdin: precedes the first msg: line. A failing slot kills the child and tears down its net guard. StreamWriter::finish_line/poll_shutdown flush a last line without a newline. task_ended() now runs once after the whole run, not after the first invocation, which is equivalent because later invocations get no stdin. Tests: the real sandbox path (run_task_relays_exit_through_both_paths, run_with_cancel_starts_in_the_given_dir; these skip where userns is denied), a fake-runner relay test that always runs, and the built-command test for apply_run_options. Required CI green; the agent-verify hang was #3415.
Defect
Fixes #3344
crates/sandbox/src/lib.rscrates/mctx/src/env.rscrates/minimald/src/env.rsTask marker
Proof
BoxChannel::run_task now runs an inherit_cwd task and a default task on one path: Env::run_with_options, then Sandbox::run_with_cancel. run_invocations_in is no longer in the code. run_task_relays_exit_through_both_paths runs real tasks through run_task. The inherit_cwd task starts in /workbench/sub and the default task starts in /workbench. Both relay exit:0 when they pass. Both send their last line without a newline, then the same exit:3 line, when they fail. A forwarded stdin reaches an inherit_cwd task on the same path.
Notes from the agent: run_with_cancel takes
options: impl Into<RunOptions>, and a CancellationToken converts into RunOptions. Because of this, the two op callers (crates/op/src/specs.rs, crates/op/src/standalone_test.rs) compile without change and stay out of the diff. The stdin slot is a boxed FnOnce(File) that the sandbox calls after attach and before it reads any output, so thestdin:line still comes before every output line. In run_task, StreamWriter::finish_line is called directly and not through an awaited shutdown(), because mctx::Error is not Send and must not be held across an await. poll_shutdown calls the same method. forward_lines is now #[cfg(test)] because only tests use it. The end-to-end test needs a temp dir that is not nodev or noexec. It skips with a message when no candidate is suitable. It does not use /run or /state, because the sandbox mounts its own directories over them. The test recreates the session home, because the existing setup_channel_in helper drops that tempdir. I added setup_channel_under (the same helper with a base dir) in the test module.cargo test -p mctxexits 101 only because rustdoc is missing on this box. All of its unit tests pass. I did not run just ci or clippy-strict.Tests
cargo test -p sandbox run_with_cancel_starts_in_the_given_dircargo test -p mctxcargo test -p minimald run_task_relays_exit_through_both_pathscargo test -p minimald stream_writer_flushes_last_line_on_shutdownVerify
min task run agent-verifytimed out after 1800s, so this PR is a draft.Base
The base branch moved while the coder worked and was merged in before the tests ran. These files changed on BOTH sides since the branch point — read them first, because a rewrite from a stale reading can undo a merge without a conflict:
crates/minimald/src/env.rs