Repository navigation
T62 — Relay a task's exit code and inputs through the in-box min helper - #2971
Conversation
A task box's entrypoint is the in-box `min task run <task>`. It exited 0 or 1, whatever the task returned. The helper now sends its argv, its $PWD and its exported variables, and the channel answers with `exit:<code>`, which the helper exits with. The channel fills the task's `inherit` variables from the caller's environment, and starts an `inherit_cwd` task in the caller's directory under /workbench. A helper that sends the older `<task> <args>` line still gets the earlier replies. The daemon log names the task and the code it relays.
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
|
Approved: every review thread resolved at @agent-137 resolved the last thread, which releases the approval this review had withheld. Nothing to do. |
There was a problem hiding this comment.
arch-review: CONDITIONS · 8 conditions · the full ruling
The relay of the task's exit code is in the correct owner and conforms to the Exit codes table, line 377. The helper fails open: a run that loses the channel exits 0 (C2). Refusals exit 1, not 4, 2 or 125 (C3). The new notice goes to stdout, the payload stream (C4). An unset inherit variable drops silently, but the laptop path refuses (C6). The daemon trace now logs the caller's whole environment, secrets included (C7, as in #2960). start_dir_in_box follows box symlinks onto the host (C8). C1 fixes the requirement id, and C5 files the open stdio gaps as a residual.
Outside the diff
crates/minimald/src/env.rs:1578: C7 · This trace now records the caller's whole environment, secrets included. Log onlychannel_method(request)(line 384, D9 line 795).
Ruled at 49d9e43 against gominimal/arch@7a86ec7bb3c0 by claude-opus-5-5.
A run stream that ends with no exit: or error: line lost its connection. The helper now exits 1 with an error instead of 0.
There was a problem hiding this comment.
arch-review: CONDITIONS · 5 conditions · the full ruling
The task's own exit code now reaches the caller, and a lost stream fails. Those parts conform. Every other path still exits 1. The design gives 4 for an unknown task, 2 for a usage error, and 125 for a min-side failure (Exit codes lines 363 to 371). C1 and C2 fix this. The task's stderr and the new inherit_cwd notice go to stdout. Line 400 and line 493 forbid this, and C3 fixes it. C4 asks for a residual for stdin, and C5 corrects covers: from BOX-015 to BCLI-010.
Ruled at 0030917 against gominimal/arch@7a86ec7bb3c0 by claude-opus-5-5.
|
Round 1 of 10 on the runtime's review findings, pushed as
Verify Review threads the coder judged:
A task box's entrypoint ( Notes from the agent: Revise round 1: the helper's |
|
/revise Arch's conditions on
|
…sk-s-exit-code-and-inputs-through-the
A relaying min task run now ends each refusal with an exit line: 4 for an unknown task, 2 for bad arguments, an interactive task or a missing inherit variable, and 125 for a failure of min itself. A stream with no exit line exits 125. The task's stderr and min's notes go as err: lines, which the helper prints on stderr. An inherit_cwd directory must resolve under the box's tree.
…sk-s-exit-code-and-inputs-through-the
There was a problem hiding this comment.
arch-review: CONDITIONS · 1 condition · the full ruling
The compare fixes the refusal exit codes and moves stderr and notes off stdout. It now conforms to Exit codes lines 365, 371 and 377, and to line 493. One gap is new. A broken minimal.toml in the box makes min task run exit 125. Exit codes line 364 gives invalid configuration exit 3, and the laptop min already exits 3 for it. Make the change in C1. Then the change conforms. The plan's covers: BOX-015 names the idle-stop rule, so I escalate that correction.
Ruled at f9f8841 against gominimal/arch@7a86ec7bb3c0 by claude-opus-5-5.
|
Round 2 of 10 on a /revise note, pushed as
Verify Review threads the coder judged:
In a task box, Notes from the agent: Directive items 4 and 5 are PR-body edits. The runner writes the body, so I did not make them. The body must say: this change implements BCLI-010 (docs/specs/28-spec-box-cli, 'exit with the exit code of the entrypoint'). It also needs a '## Residuals' section: the in-box |
|
/revise Arch's condition on
|
A refused in-box min task run with a project configuration error (Config, Format or MFile) now exits 3, not 125. refresh_tagged returns the Error it reports so run_task can map it. The channel trace log also cuts a run request's environment group, so exported secrets do not reach the host log.
There was a problem hiding this comment.
arch-review: CONDITIONS · 1 condition · the full ruling
The compare gives a configuration refusal exit 3 and keeps the run environment out of the trace log. Both conform to lines 364 and 972 of architecture.md. One gap is open. A package layer that does not evaluate reaches refusal_exit_code as Error::Graph and exits 125. The doc comment for EXIT_CONFIG and line 364 say that this error is exit 3. A missing package exits 125, but line 365 gives it 4. Make the change in C1.
Ruled at 30d5a59 against gominimal/arch@7a86ec7bb3c0 by claude-opus-5-5.
|
Round 3 of 10 on a /revise note, pushed as
Verify Review threads the coder judged:
A task box's entrypoint (the in-box Notes from the agent: Revise round 3. I added EXIT_CONFIG = 3 and refusal_exit_code(). refresh_tagged now returns the Error it reports, and refresh() maps it to (). run_task uses refusal_exit_code at the refresh_tagged failure, the ctx.task Err arm and the final Err arm. 'session is gone' keeps 125. Deviation: the directive asks the refusal_exit_code unit test (refusal_exit_code_gives_a_config_error_exit_3) to use Error::Format. minimald has no toml dependency, so it cannot build a toml::de::Error. The test uses Error::Config(ConfigError::InvalidRemoteCacheUrl) for the code-3 case and Error::Other for 125. A Format case needs |
|
/revise Arch's condition on
Today a Nickel package layer that does not evaluate reaches |
A package layer that does not evaluate reaches refresh_tagged as Error::Graph(Decode). It now exits 3, as a config error does. A missing package, profile or stack exits 4. A fetch failure stays 125.
There was a problem hiding this comment.
arch-review: PASS · the full ruling
The compare closes the refusal exit codes. A graph error now exits 3 for a bad layer and 4 for a missing package, profile or stack (Exit codes lines 364, 365). A fetch failure exits 125 (line 371). The match covers every graph::Error variant. The rest of the change relays the task's own code and keeps stdout for the task's output, as lines 39, 377 and 493 require. No condition is open. Correct the plan's covers: BOX-015 to BCLI-010 when you next edit the plan.
Ruled at 27636d9 against gominimal/arch@7a86ec7bb3c0 by claude-opus-5-5.
There was a problem hiding this comment.
minimal-review — approval withheld
Verdict COMMENT — APPROVE withheld: 21 unresolved threads — minimal-arch[bot] crates/minimald/src/env.rs, minimal-arch[bot] crates/minimald/src/env_min_helper.sh:217, minimal-arch[bot] crates/minimald/src/env.rs, minimal-arch[bot] crates/minimald/src/env.rs, minimal-arch[bot] crates/minimald/src/env.rs, …. No findings.
Panel: 3 of 3 personas ran (correctness, security, supply-chain).
|
Round 4 of 10 on a /revise note, pushed as
Verify Review threads the coder judged:
A task box's entrypoint exits with the task's own exit code, with its env vars, working directory and args. A refused in-box Notes from the agent: This round adds an Error::Graph arm to refusal_exit_code() and extends its test with one case each for 3, 4 and 125. The match on graph::Error has no wildcard, so a new graph variant must get an exit code at compile time. cargo clippy -p minimald --all-targets and cargo fmt --check are clean. The listener finding (PRRT_kwDOPdfcxM6zbUrc) is real, but its fix is in crates/sandbox/src/listener.rs, which is outside this task's layers. A follow-up task must redact or drop the trace line there. |
|
/revise From the maintainer's pre-merge review at
|
…sk-s-exit-code-and-inputs-through-the
The listener traced each request line before the channel redacted it, so a run request's environment reached the trace log. It also read with lines(), which dropped a request that held a non-UTF-8 byte. It now logs only the length and decodes the line lossily. The in-box helper prints relayed lines with printf, not echo.
A task name or a $PWD with a newline in it, echoed in the no-such-task refusal or the inherit_cwd notice, started a protocol line of its own, so a name ending in exit:0 made the helper exit 0. Control characters in them are now escaped. Tests pin the escape and the printf output.
There was a problem hiding this comment.
arch-review: CONDITIONS · 1 condition · the full ruling
The listener and one_line() changes conform. The trace no longer leaks the caller's environment, and an echoed name cannot end the run. One change deviates. serve_connection() now decodes an invalid byte as U+FFFD, and the task runs with an altered inherit value or argument. On a laptop, min task run refuses a non-UTF-8 inherit value. Line 395 of architecture.md says the in-box form behaves exactly as on a laptop. Make the change in C1. Then the change conforms.
Ruled at 15a166e against gominimal/arch@7a86ec7bb3c0 by claude-opus-5-5.
There was a problem hiding this comment.
minimal-review — approval withheld
Verdict COMMENT — APPROVE withheld: 23 unresolved threads — minimal-arch[bot] crates/minimald/src/env.rs, minimal-arch[bot] crates/minimald/src/env_min_helper.sh:217, minimal-arch[bot] crates/minimald/src/env.rs, minimal-arch[bot] crates/minimald/src/env.rs, minimal-arch[bot] crates/minimald/src/env.rs, …. No findings.
Panel: 3 of 3 personas ran (correctness, security, supply-chain).
|
Round 5 of 10 on a /revise note, pushed as
Verify Outside the task's
Converted to a draft: something above needs a person before review. A task box's entrypoint (the in-box min task run) exits with the task's own exit code, and the task gets the caller's env vars, working directory and args. A run request no longer reaches the trace log with its environment, a non-UTF-8 variable or $PWD no longer makes the run exit 125, and a task name or path with a newline cannot fake an exit: line. Notes from the agent: Round 5 note items. (1) crates/sandbox/src/listener.rs, outside the layers, accepted by the maintainer: the listener now traces only the request length ('listener received a request', bytes=N). The channel still logs the redacted form through loggable_request. Test listener_trace_leaves_out_the_run_environment captures the trace output with a recording subscriber and checks that the env name and value are absent. (2) The listener reads the request with read_until(b'\n') and decodes it with String::from_utf8_lossy, so a non-UTF-8 byte becomes U+FFFD and the request is served. Test listener_serves_a_request_with_a_non_utf8_value. The per-connection code moved into serve_connection so a test can drive it on its own thread. (3) env.rs: new one_line() escapes control characters (escape_debug) in the task name of the no-such-task refusal and in the $PWD of the inherit_cwd notice. Tests in both task_entrypoint_ tests. (4) env_min_helper.sh: msg:, err: and error: lines and the request line now print with printf '%s\n', not echo. The relay test pins that a 'msg:-n' line prints '-n' and an 'err:-E' line prints '-E'. (5) The PR body is the runner's to write. For it: the refusal exit codes are 2 (usage, interactive task, unset inherit variable), 3 (invalid configuration), 4 (task or package not found) and 125 (min failed, or the stream ended with no exit: line). An unset inherit variable is refused with exit 2, not dropped. ## Residuals: #2892 (BCLI T7) the in-box stdin relay (arch C5); #2983 one run path for inherit_cwd, plus the trailing-line flush. I did not run just clippy-strict or the whole …[truncated] |
|
/revise Arch's condition on
|
…sk-s-exit-code-and-inputs-through-the
The listener still decodes a request lossily, and now hands the raw bytes of a line that was not valid UTF-8 to the channel through a new Channel::handle_lossy hook. run_task refuses the run with exit 2 when a declared inherit value or an argument held an invalid byte, with the laptop's text for the inherit case. An undeclared variable still neither refuses nor drops the run.
…sk-s-exit-code-and-inputs-through-the
There was a problem hiding this comment.
arch-review: PASS · the full ruling
The compare adds one branch commit. It refuses a declared inherit value or an argument that is not valid UTF-8, with exit 2. Before this commit, the lossy value reached the task. The inherit refusal uses the laptop's text, so the in-box run behaves as the laptop does (architecture.md line 395). The refusal goes to stderr, so stdout carries only the task output (line 493). The maintainer note names only listener.rs. The new hook in crates/sandbox/src/lib.rs is in the trait's owner crate, so the design has no objection.
Ruled at e7bc71e against gominimal/arch@7a86ec7bb3c0 by claude-opus-5-5.
There was a problem hiding this comment.
minimal-review — approval withheld
Verdict COMMENT — APPROVE withheld: 23 unresolved threads — minimal-arch[bot] crates/minimald/src/env.rs, minimal-arch[bot] crates/minimald/src/env_min_helper.sh:217, minimal-arch[bot] crates/minimald/src/env.rs, minimal-arch[bot] crates/minimald/src/env.rs, minimal-arch[bot] crates/minimald/src/env.rs, …. No findings.
Panel: 3 of 3 personas ran (correctness, security, supply-chain).
|
Round 6 of 10 on a /revise note, pushed as
Verify Outside the task's
Converted to a draft: something above needs a person before review. Review threads the coder judged:
A task box's entrypoint exits with the task's own exit code, with its env vars, working directory and args. In-box Notes from the agent: Revise round 6. Arch's note C1 is done. The listener keeps the lossy decode. For a line that is not valid UTF-8 it now calls a new default method |
|
The runtime will not revise this pull request again on its own: the diff is +1358/-67 (1425 lines), past 3x the plan's estimate of 420 lines (est: 220 code, 200 tests, as #2953 reads now), at round 6 (the last trigger was a /revise note). A person decides now. Remove |
mitodrummer
left a comment
There was a problem hiding this comment.
Reviewed at e7bc71ea. A whole-PR review at 27636d9a ran all 59 env::tests, which pass. It also checked the exit codes (0, 3, 42, 137, 4, 2, 125) and back-compat between old and new helpers. Rounds 5 and 6 land the requested fixes:
- the listener traces only the byte count, never the raw request line, which carries the caller's env (
e5fe604a); - request lines are read as bytes and decoded lossily. Non-UTF-8 in a declared
inheritvalue or an argv item is refused with exit 2, and an undeclared variable passes through (a00dea71); - echoed task names and paths stay on one line, so a crafted name can't inject an
exit:line (15a166e4); - the helper prints with
printf '%s\n'.
Residuals: #2892 (in-box stdin) and #2983 (one run path for inherit_cwd). The out-of-layer crates/sandbox/src/{lib,listener}.rs edits are accepted. The test-kvm failure was an unrelated minvmd egress-gate flake, and it passed on rerun.
agent-137
left a comment
There was a problem hiding this comment.
Reviewed at e7bc71e against #2953 (BCLI-010). run_task relays the entrypoint's exit code; refusals carry 2/3/4/125; a run stream with no exit line returns 125; notes, refusals and task stderr go out as err: lines, so stdout stays clean; inherit and inherit_cwd follow the laptop's rules; the listener and channel traces no longer log the request environment. All 23 open threads are fixed on this head. The run_invocations_in duplication of run_with_cancel is deferred to #2983 and stdin to #2892, both named as residuals. Non-blocking: the body's embedded plan says covers: BOX-015 (the issue says BCLI-010), and its Proof says a refused run exits 1 (it exits 2/3/4/125).
There was a problem hiding this comment.
minimal-review — approved
Verdict APPROVE — every review thread is resolved; @agent-137 closed the last one. The review of e7bc71ea6433 withheld this approval on the threads open then. Posted as a comment: the App cannot approve its own pull request; the check and the label carry it.
T62 — Relay a task's exit code and inputs through the in-box min helper
slice: S2
kind: task
covers: BOX-015
size: M
est: 220 code, 200 tests
executor: agent
difficulty: needs care
model: strongest
diagnostics: the daemon log names the task and the exit code it relays
observability: none: the task's run span already carries its exit code; this changes only what reaches it
layers:
- helper:
- crates/minimald/src/env.rs: run_task relays the task exit code; env vars, inherit_cwd and args reach the in-box run
- crates/minimald/src/env_min_helper.sh: min task run exits with the relayed code
test: cargo nextest run -p minimald task_entrypoint_relays_the_task_exit_code
test: cargo nextest run -p minimald task_entrypoint_carries_env_cwd_and_args
produces: none
consumes: none
proof: A task box's entrypoint exits with the task's own exit code, with its env vars, working directory and args.
depends on:
- blocked by #2398
Proof
In a box,
min task run <task> [args...](the entrypoint of a task box) now exits with the task's own exit code: 0 when the task passes, the failing command's code (for example 3, or 137 for SIGKILL) when it fails, and 1 when the run is refused before it starts. The task gets the caller's args with their spaces intact. Itsinheritvariables take the caller's exported values. Aninherit_cwdtask starts in the caller's directory under /workbench.Notes from the agent: Wire change: the helper now sends
is not a directory under /workbench, so the task runs in /workbench.' Before this changerun%<PWD> 0x1e <task> 0x1f <arg>... 0x1e <NAME=value> 0x1f ..., with backslash escapes for newline, CR and the two separators. The channel answers a run withexit:<code>. The channel still accepts the olderrun%<task> <args>line from a helper installed before this change, and it gives that helper the earliererror:replies. On a failed task the channel now sends onlyexit:<code>. It no longer sends the long 'Invocation N failed with exit code' report and 'error: sandbox command failed.', because the task's output already streamed. Aninheritvariable that the caller does not set is now dropped, not read from the daemon's environment (#585). The[vars] ignorepolicy of the host client is not applied on this path. The helper sends every exported variable, but the daemon uses only the names that the task declares asinherit. The helper lists exported names withcompgen -e. A bash built without it sends no variables. Aninherit_cwdtask outside /workbench, or in a directory the session tree does not have, runs in /workbench, and the helper prints one new line: 'inherit_cwdhad no effect in a box, because the session layout ignores the working directory thatmake_env_with_networktakes. So a run with a start directory spawns each invocation inrun_invocations_in(env.rs) withcurrent_dir. A run without one still goes throughEnv::run.…[truncated]Tests
cargo nextest run -p minimald task_entrypoint_relays_the_task_exit_codecargo nextest run -p minimald task_entrypoint_carries_env_cwd_and_argsVerify
min task run agent-verifypassed ([tasks.verify]).Closes #2953
Out-of-layer edit accepted by the maintainer (2026-11-04):
crates/sandbox/src/listener.rs. The request-line trace redaction and the non-UTF-8 handling need it.Out-of-layer edit accepted by the maintainer (2026-11-04):
crates/sandbox/src/lib.rs.Channel::handlecarries the listener's lossy-decode flag, which arch's non-UTF-8 condition needs.Residuals
min task rundoes not wire the caller's stdin to the task, because__min_rpcfeedssocatonly the request line (arch C4/C5).inherit_cwd(run_invocations_induplicatesSandbox::run_with_cancel, untested), plus the trailing-line flush and the empty-task-name exit code.