Repository navigation
fix(mctx,minimald,sandbox): the in-box min task run uses one sandbox run path for every task, and - #3271
fix(mctx,minimald,sandbox): the in-box min task run uses one sandbox run path for every task, and#3271minimal-foundry[bot] wants to merge 5 commits into
Conversation
…first invocation Sandbox::run_with_cancel applies a run directory to each command it spawns and hands the first invocation's stdin pipe to a hook. Env exposes both, so an in-box task run can keep the one run path.
An inherit_cwd task or a run with forwarded stdin went through run_invocations_in, which skipped the task's saved stdout and stderr files. run_task now sets the start dir and the stdin hook on the env and runs through env.run with StreamWriter. run_invocations_in and forward_lines are gone. StreamWriter::poll_shutdown sends the last line that has no newline.
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
bryan-minimal
left a comment
There was a problem hiding this comment.
Read at da82580, with a lab run.
What it does holds up. BoxChannel::run_task goes through env.run for an inherit_cwd task and for forwarded stdin alike; the sandbox applies the run dir to each command and gives only the first invocation the stdin pipe; StreamWriter::poll_shutdown flushes what it holds. The two unit tests cover the relayed exit: on both paths and a real sandbox run that starts in the given directory, feeds stdin to the first invocation only and saves the output file.
Lab, Linux, against the current release: the full CI mirror (workspace nextest, the native daemon e2e, clippy, doctests) passes at this tree, and five scenarios that drive an in-box task run pass on Ubuntu 24.04 and Fedora on both sides: the baseline, a task fed stdin through a pipe (zero exit and non-zero), a task after its worker's retirement, and a build whose grandchild keeps the pipe open (the task returns on its own). Nothing regressed.
Two notes, neither against the change:
- The body's pre-existing failure,
env::tests::task_entrypoint_carries_env_cwd_and_args, passes in the full workspace run on Linux here, so it is the agent host's, not the tree's. - The one failure the first run here hit was
net::classifier::tests::host_ip_lookup_outside_a_steered_box_resolves_real_fence_admits_only_the_box_leafonBroken pipe, a race inrun_nft_script(a refusing stand-in exits before the daemon finishes writing its script, and the write's EPIPE wins over nft's own words). It is unrelated to this PR and fixed separately; the rerun here passed.
One behaviour change the body names is worth a line in the PR description's summary rather than the agent's notes: task_ended now runs after the whole run rather than after the first invocation, so a forwarded-stdin read failure during a later invocation of a multi-invocation task fails the run. That reads as the right order, and it is the kind of change a reader of the history should find at the top.
Approving.
|
/revise minenv_run_forwards_stdin_to_the_task hangs (verify timed out at 1800s) — the forwarded-stdin path through forwarding_hook/settle_forwarded never completes; fix it so the test finishes. Also check task_entrypoint_carries_env_cwd_and_args ("not a run request") against main without this change; if it passes there, this change broke it. |
…-min-task-run-uses-one-sandbox-run-pat
A host with MINIMAL_OTEL=off made the helper prefix its request with otel%off%. The test channel then panicked, and the forwarding helper waited for a reply that never came.
…-min-task-run-uses-one-sandbox-run-pat
|
Round 1 of 10 on a /revise note, pushed as
Verify An in-box min task run of an inherit_cwd task, or of a task with forwarded stdin, goes through env.run. The task starts in the caller directory and saves its stdout and stderr files like any other task. run_task_relays_exit_on_both_paths sees the relayed exit: line on both paths. minenv_run_forwards_stdin_to_the_task now finishes in under a second. Notes from the agent: Revise round 1. The hang was not in forwarding_hook or settle_forwarded. This box exports MINIMAL_OTEL=off, so the min helper prefixed its request with otel%off%. run_request_data then panicked with 'not a run request' in the server thread. After that, the helper waited forever on socat -t 2000000000, which kept the socket half open, so the test hung. task_entrypoint_carries_env_cwd_and_args failed for the same reason. The branch changes neither of these tests, their runners, nor env_min_helper.sh, so main fails the same way on a host with MINIMAL_OTEL=off. I did not run main to confirm this. The fix removes minimald_rpc::trace::OTEL_ENV from the environment in run_min_against and run_min_against_channel, the same way the opt-out test does. That is a test-only change in crates/minimald/src/env.rs (commit 34a556e). One other risk remains: a server-side panic in run_min_against_channel still makes the helper wait forever, and does not fail the test. I did not change that, because it is outside what the note asks. The 17 full-suite failures are in network and namespace tests outside this task's layers. I did not check whether they also fail on main. |
Defect
Fixes #3270
crates/sandbox/src/lib.rscrates/mctx/src/env.rscrates/minimald/src/env.rsTask marker
Proof
An in-box min task run of an inherit_cwd task, or a run with forwarded stdin, now goes through env.run like every other task. The task starts in the caller directory (Sandbox::set_run_dir applies the directory to each command), and the sandbox saves its stdout and stderr files. The minimald test sees the relayed exit: line on the path with no stdin and on the forwarded-stdin path. The sandbox test shows a real sandbox run that starts in the given directory, feeds stdin to the first invocation only, and saves the output to the stdout file.
Notes from the agent: Design: sandbox::Sandbox has two new setters, set_run_dir and set_first_stdin(FirstStdin). run_with_cancel applies the run dir to every command and gives only invocation 0 a stdin pipe, which goes to the hook after attach. A hook error kills the child, tears down the network and fails the run. mctx::Env has set_start_dir and set_first_stdin, so Env::run keeps one signature. In minimald, forwarding_hook starts ForwardedStdin and sends
stdin:. settle_forwarded then moves the copy out, calls task_ended and maps a hook failure to the old 'min task run could not pass its stdin to the task' error. One behaviour change: task_ended now runs after the whole run, not after the first invocation. A forwarded-stdin read failure during a later invocation of a multi-invocation task can now fail the run. mctx::Error is not Send, so run_task cannot await shutdown after env.run. end_writers calls the same emit_rest that poll_shutdown calls, synchronously. The test serve_task helper now uses forwarding_hook, StreamWriter and settle_forwarded in place of forward_lines. The forward_lines assertion in the old refusal test is removed. Pre-existing failure, not from this change: env::tests::task_entrypoint_carries_env_cwd_and_args fails on this box with my minimald changes stashed too ('not a run request' at the request parse). No scope widening.Tests
cargo test -p sandbox run_with_cancel_starts_in_the_given_dircargo test -p minimald run_task_relays_exit_on_both_pathscargo test -p minimald stream_writer_shutdown_flushes_last_lineVerify
min task run agent-verifytimed out after 1800s, so this PR is a draft.