8000 fix(minimal): honour inherit_cwd for min task run by norrietaylor · Pull Request #1978 · gominimal/minimal · GitHub
[go: up one dir, main page]

Skip to content

fix(minimal): honour inherit_cwd for min task run - #1978

Merged
norrietaylor merged 1 commit into
mainfrom
fix/task-run-inherit-cwd
Oct 5, 2026
Merged

norrietaylor merged 1 commit into
mainfrom
fix/task-run-inherit-cwd

Conversation

@norrietaylor
@norrietaylor norrietaylor commented Oct 5, 2026 •
Copy link
Copy Markdown
Member

Problem

inherit_cwd = true had no effect on min 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 read task.inherit_cwd.

Fix

  • crates/minimald-rpc: ExecRequest::TaskRun gains a cwd field, 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. parse refuses a cwd that is absolute or has a .. component.
  • crates/minimal: cmd_task_run computes the invocation directory relative to the upload root (empty at the root) and sends it for a task that declares inherit_cwd.
  • crates/minimald: when the task declares inherit_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 without inherit_cwd keep starting at /workbench.
  • docs/reference/tasks.md: documents the min task run behaviour and the fallback.
  • scripts/session-e2e.sh: the min task run proof runs from sub/inner and checks PWD=/workbench/sub/inner for an inherit_cwd task and PWD=/workbench for 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 new task_run_cwd_is_relative_to_the_upload_root and all task:: 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.
  • The same 5 tests, filtered, on origin/main in the same container: the 3 resolver::tests::advisory_* tests and legacy_network_spellings_parse_with_hint fail identically (sudo: not found and a stderr-capture mismatch). a_stopped_vm_does_not_hold_a_box_name_resolution asserts 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.
  • The session-e2e.sh proof was not run locally; the VM lanes run it.

Refs gominimal/inbox#890

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.
@norrietaylor
norrietaylor requested a review from a team as a code owner October 5, 2026 06:12
@coderabbitai
coderabbitai Bot commented Oct 5, 2026
Copy link
Copy Markdown
Contributor

Warning

Review limit reached

  • Run on-demand review

This review includes 8 billable files and costs up to $2.00.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

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.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 155d7e4b-5e78-4ff6-9c71-23b559977895
📥 Commits

Reviewing files that changed from the base of the PR and between 908b5a8 and f95a197.

📒 Files selected for processing (8)
  • crates/minimal/src/cmd/session.rs
  • crates/minimal/src/task.rs
  • crates/minimal/src/tests.rs
  • crates/minimald-rpc/src/exec.rs
  • crates/minimald/src/exec.rs
  • crates/minvmd/tests/minimald_session_integration.rs
  • docs/reference/tasks.md
  • scripts/session-e2e.sh
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@minimal-foundry
minimal-foundry Bot commented Oct 5, 2026 •
Copy link
Copy Markdown
Contributor

Reviewed: 1 finding, none blocking at f95a197173f1.

Address the comments on the diff.

Clobber: none: git log on crates/minimald/src/exec.rs and crates/minimald-rpc/src/exec.rs shows no prior fix reverted by this head commit.

@minimal-foundry minimal-foundry Bot left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minimal-review — advisory review

Verdict COMMENT — 1 finding, 1 inline.

if !inherit_cwd || cwd.is_empty() {
return Ok(None);
}
if working.join(cwd).is_dir() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@norrietaylor
norrietaylor added this pull request to the merge queue Oct 5, 2026
Merged via the queue into main with commit 12c0992 Oct 5, 2026
35 checks passed
@norrietaylor
norrietaylor deleted the fix/task-run-inherit-cwd branch October 5, 2026 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0