Repository navigation
CONDITIONS
Governs: architecture.md Runtime line 39 (a task's stdin, stdout and stderr are wired through, and min task run propagates its exit code). Exit codes lines 365, 371 and 377 (4 for not found, 125 for a min-side runtime failure, and run-style commands propagate the program's code). min box run/min task run line 493 (min writes nothing else to stdout, and a pty_enabled entry is refused with exit 2). Design principles 4 and 7 (lines 334 and 337: diagnostics go to stderr, subtree-limited file access, secrets redacted from all output). Output conventions line 384. D9 line 795 (content, such as command arguments, stays behind flags that are off by default in exported telemetry). Running min inside a box line 395 (the grammar behaves exactly as it does on a laptop). The checkout 7a86ec7b has no arch-map.md. No since.diff or findings.json was staged, and no prior ruling covers this PR.
Ruling: the placement is correct. BoxChannel::run_task and the in-box helper own this path, and the task's layers name both files. The core relay conforms to line 377: relayed_exit_code maps Error::Execution to its code, and the helper returns that code. Eight conditions remain. C1: the task cites BOX-015, but spec 29's BOX-015 is about idleness, and BCLI-035 is the requirement this change implements. C2 and C3 (fail closed and the exit-code table): a channel that closes mid-run gives exit 0, and every refusal or runtime failure gives 1, not 4, 2 or 125. C4: the new start-directory notice goes to stdout, which is the task's payload stream. C5: the stdio gaps (stderr merged into stdout, and no stdin) are pre-existing, but nobody owns them. File them as a residual with an issue. C6: an unset inherit variable now drops silently. The laptop path (crates/minimal/src/task.rs:257) refuses, and the in-box path refused before this change. C7: the run request now carries the caller's whole environment, and BoxChannel::run traces the raw line (env.rs:1578), so secret values reach the daemon log. This follows #2960, which applied D9 line 795 and line 384 to the same kind of content. C8: start_dir_in_box calls is_dir() on a path that follows a symlink from the box, so a box on a native host can probe host directories.
Not checked: I could not confirm whether hakoniwa reports a signal-killed child as code 128 + n (the 137 case in the test is synthetic). The hakoniwa source is not in this sandbox, and a build is out of bounds. The new path uses the same status.code that sandbox uses, so the two paths agree. I did not check whether the host client's [vars] ignore policy must apply inside a box. The PR body states that this path does not apply it, and line 395 does not decide whether that policy reaches a nested min. The timeout → 124 case is not addressed by this task.
Conditions
- C1: Name the requirement this change implements. In
crates/minimald/src/env.rs, replaceBOX-015 (T62)withBCLI-035 (T62)in the comment inrun_task(head line 2238) and in the doc comments oftask_entrypoint_relays_the_task_exit_code(line 4233) andtask_entrypoint_carries_env_cwd_and_args(line 4293). Spec 29's BOX-015 (docs/specs/29-spec-box-local-first line 140) is "never stop a box for idleness or for the loss of a client", and this change does not touch that. Spec 28's BCLI-035 ("WHEN a run-style command's entrypoint exits THE SYSTEM SHALL propagate its exit code") is the requirement it implements. Amend T62'scovers:line in #2953 toBCLI-035to match. - C2:
crates/minimald/src/env_min_helper.sh: arunrequest fails closed. In__min_rpc, whenmethodisrunand the read loop ends with noexit:and noerror:line, or with anexit:value that is not 0 to 255, return 125, not 0. Today the finalif [[ "$relayed" =~ ... ]](head line 207) falls through, and the function returns 0, so a channel that closes mid-run reports success. Keep the current behaviour for the other methods. Add a case totask_entrypoint_relays_the_task_exit_codewhere the reply ismsg:task output\n, with no terminal line, and assert exit 125. - C3:
crates/minimald/src/env.rsrun_task: whenrequest.relays_exit()is true, end each refusal and each runtime failure with the code from the exit-code table as anexit:<n>line, after themsg:lines that explain it. A missing task (no such task '{task_name}', line 2122) ends withexit:4. The interactive-task refusal (cannot run interactive tasks from within an environment) ends withexit:2. Aresultfor whichrelayed_exit_codereturnsNone(line 2249, thewrite_errorfallthrough) ends withexit:125. Keep theerror:replies for a request from an older helper. Pin 4, 2 and 125 intask_entrypoint_relays_the_task_exit_code. - C4: Send the new start-directory notice to stderr, not to stdout.
crates/minimald/src/env.rsrun_taskwrites<dir> is not a directory under /workbench, so the task runs in /workbench.as amsg:line (line 2161), and__min_rpcechoesmsg:lines to stdout. That puts a diagnostic into the task's payload stream. Add anerr:reply tag. The channel writes the notice aserr:{notice}, and__min_rpcinenv_min_helper.shprintserr:lines withecho "$rest" >&2. Assert in a test that the notice reaches stderr and that stdout stays empty. - C5: File an issue for the stdio gaps that remain in in-box
min task run, and name it as a residual in the PR body. The issue covers three gaps. The task's stderr reaches the caller's stdout asmsg:lines, both throughStreamWriter::pairand through the newrun_invocations_in(forward_msg_lines(p, &err), line 3081). The task gets no stdin, because__min_rpcpipes only the request line intosocat. The task-run notices are not split out. This change leaves these gaps open, and the design requires stdin, stdout and stderr to be wired through. A residual without an issue is not accepted. - C6:
crates/minimald/src/env.rsinherit_from_callerrefuses the run, and does not drop the variable, when the caller does not set a declaredinheritvariable. ReturnErr(name)in place ofNone => false(line 2988). Thenrun_taskwrites the refusal that the laptop path writes (crates/minimal/src/task.rsline 257: "task '' declaresenv_vars.<name> = { inherit = true }, but is not set in this shell; export it before running the task"), followed byexit:1when the request relays an exit code, or byerror:when it does not. The code before this change also refused, through theinheriting environment variableerror incrates/mctx/src/env.rs. Update theNOT_SET_BY_CALLERassertion intask_entrypoint_carries_env_cwd_and_argsto expect the refusal. - C7:
crates/minimald/src/env.rsBoxChannel::run: stop logging the raw request line.tracing::trace!("session channel handling: {line}")(line 1578) now records every exported variable of the caller, with its value, because therunrequest carries the caller's whole environment. That includesclient_envsecrets and tokens. Log onlychannel_methodof the request (for exampletracing::trace!(method = channel_method(request), "session channel handling")), afterchannel_request_spanstrips the traceparent. Add a test that arunrequest withSECRET=vin its environment group puts novinto a captured trace. - C8:
crates/minimald/src/env.rsstart_dir_in_boxchecks the directory inside the session tree only.working.join(rel_path).is_dir()(line 3020) follows a symlink that the box makes, so a box can learn whether any host path is a directory from whether the notice prints. Canonicalizeworking.join(rel_path)withcanonicalize_utf8(orstd::fs::canonicalize). Accept the directory only when the result is a directory that starts with the canonicalworking. Otherwise return the notice. Add a case totask_entrypoint_carries_env_cwd_and_argswith a symlink underworkingthat points outside it, and expect the notice.
Ruled at 49d9e43 against gominimal/arch@7a86ec7bb3c0 by claude-opus-5-5; arch_rulings 817, job 264fda9a-56f7-4548-9675-473c5a803127.