Repository navigation
fix(minimal): honour inherit_cwd for min task run - #1978
Conversation
min task run now sends the invocation directory, relative to the upload root, on the task-run exec request for a task that declares inherit_cwd. The daemon refuses a cwd that is absolute or holds a '..' component, and starts the task at /workbench/<cwd> when that directory is in the uploaded tree. Otherwise it falls back to /workbench with a one-line notice on stderr. Tasks without inherit_cwd still start at /workbench.
|
Warning Review limit reached
This review includes 8 billable files and costs up to $2.00.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Or wait 19 minutes for your next included review. View limit detailsLimit details: You’ve used all 2 included reviews currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (8)
Comment |
|
Reviewed: 1 finding, none blocking at Address the comments on the diff. Clobber: none: |
| if !inherit_cwd || cwd.is_empty() { | ||
| return Ok(None); | ||
| } | ||
| if working.join(cwd).is_dir() { |
There was a problem hiding this comment.
LOW · correctness · confidence 0.50 · in task_start_dir
task_start_di
8000
r decides the start directory against the host uploaded tree (working.join(cwd).is_dir()), but the container's /workbench is that same tree plus the task's own patch mounts. A inherit_cwd task whose cwd directory exists only via a patch-declared fs_mapping under the working dir (e.g. a gitignored subdir the task's patch table recreates at /workbench/...) fails the host check and falls back to the root, even though /workbench/<cwd> does exist in the sandbox. The task then runs in the wrong directory, and the notice ('not in the uploaded tree') is misleading. Narrow — the dir is usually in the uploaded tree when the client is standing in it — but the host check and the container layout can genuinely disagree here.
What the reviewer checked
exec.rs:141 if working.join(cwd).is_dir() { -> /workbench/ else Err(notice). Patch fs_mappings are mounted into the session layout's /workbench, not written to the host working tree (exec.rs:401).
Hand this to an agent
Act on a code-review finding.
File: crates/minimald/src/exec.rs
Lines: 141-141
Category: correctness
Severity: low (reviewer confidence 0.50)
Finding:
`task_start_dir` decides the start directory against the host uploaded tree (`working.join(cwd).is_dir()`), but the container's `/workbench` is that same tree plus the task's own patch mounts. A `inherit_cwd` task whose cwd directory exists only via a patch-declared fs_mapping under the working dir (e.g. a gitignored subdir the task's `patch` table recreates at `/workbench/...`) fails the host check and falls back to the root, even though `/workbench/<cwd>` does exist in the sandbox. The task then runs in the wrong directory, and the notice ('not in the uploaded tree') is misleading. Narrow — the dir is usually in the uploaded tree when the client is standing in it — but the host check and the container layout can genuinely disagree here.
First verify this against the code yourself. It is model output and
may be wrong. If it is wrong, or the tradeoff was deliberate, say so
and change nothing.
👍 useful · 👎 noise — react to tell the reviewer. Replying works too, and says more.
Problem
inherit_cwd = truehad no effect onmin task run. Run from a subdirectory, the task still started at the project root (/workbench). The client never told the daemon where inside the uploaded tree it was invoked, and the daemon's task path never readtask.inherit_cwd.Fix
crates/minimald-rpc:ExecRequest::TaskRungains acwdfield, the invocation directory relative to the uploaded tree. A non-empty cwd rides as an optional third element of the framed JSON payload ([task, args, cwd]). A request without it, bare or framed, parses as an empty cwd, so the existing spellings are unchanged.parserefuses a cwd that is absolute or has a..component.crates/minimal:cmd_task_runcomputes the invocation directory relative to the upload root (empty at the root) and sends it for a task that declaresinherit_cwd.crates/minimald: when the task declaresinherit_cwd, the task starts at/workbench/<cwd>if that directory exists in the uploaded tree. Otherwise it starts at/workbench, and a one-line notice leads the task's stderr. Tasks withoutinherit_cwdkeep starting at/workbench.docs/reference/tasks.md: documents themin task runbehaviour and the fallback.scripts/session-e2e.sh: themin task runproof runs fromsub/innerand checksPWD=/workbench/sub/innerfor aninherit_cwdtask andPWD=/workbenchfor one without it.Tests
CROSS_CONTAINER_OPTS="--env HOME=/tmp" cross test -p minimald-rpc --target aarch64-unknown-linux-musl --locked: 56 passed, 0 failed (new:a_task_run_round_trips_its_cwd).CROSS_CONTAINER_OPTS="--env HOME=/tmp" cross test -p minimal --target aarch64-unknown-linux-musl --locked: 341 passed, 5 failed. The newtask_run_cwd_is_relative_to_the_upload_rootand alltask::tests pass. The 5 failures are environmental in the musl container and outside the touched code (resolver::tests::advisory_*×3,tests::a_stopped_vm_does_not_hold_a_box_name_resolution,tests::legacy_network_spellings_parse_with_hint).CROSS_CONTAINER_OPTS="--env HOME=/tmp" cross test -p minimald --target aarch64-unknown-linux-musl --locked -- exec::: 31 passed, 0 failed (new:task_start_dir_honours_inherit_cwd).CROSS_CONTAINER_OPTS="--env HOME=/tmp" cross clippy -p minimald-rpc -p minimal -p minimald --target aarch64-unknown-linux-musl --locked --all-targets -- -D warnings: clean.cargo fmt --all --check: clean.just minimal-cli(native macOS): builds.shellcheck scripts/session-e2e.sh: clean.origin/mainin the same container: the 3resolver::tests::advisory_*tests andlegacy_network_spellings_parse_with_hintfail identically (sudo: not foundand a stderr-capture mismatch).a_stopped_vm_does_not_hold_a_box_name_resolutionasserts that resolution takes under 1 s, and under qemu it is flaky on both sides. On main it failed 1 of 7 runs. On this branch it failed 3 of 4 runs alongside the other tests and passed when run alone. This change does not touch the box-name resolution path.session-e2e.shproof was not run locally; the VM lanes run it.Refs gominimal/inbox#890