Repository navigation
feat: T130 — The command that waits for a box copies its declared exports back to the project - #3448
Conversation
An absolute path, a path with a .. component, or a path that names the project root fails the expansion with exit 3 (BOX-189), so no box is created. Adds file_export_paths for the client copy.
An attached run, an attach and min box wait copy each declared [[file_exports]] path from /workbench in the ended box to the project. A folder export creates its tree and deletes nothing. Each file is written under a temporary name and renamed into place (BOX-185 to 188).
Covers the wait and attach copy, a detach and a stop that copy nothing, a folder export that deletes nothing, and the atomic write of each file (BOX-185 to BOX-188).
The command that waits for a box now copies [[file_exports]] on the client (BOX-185), so the daemon no longer lists it as unenforced.
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
…d-that-waits-for-a-box-copies-its-decl # Conflicts: # crates/minimal/src/tests.rs
|
A merge of main before round 1, not counted against the cap (1 of 3), pushed as Resolved conflicts in:
Verify Outside the task's
Converted to a draft: something above needs a person before review. A task box whose entry declares a file and a directory export ends, and the waiting command leaves both in the project. A detached run copies nothing. An export path outside the project fails before any box is created. The branch now merges cleanly with main. Notes from the agent: Revise round: resolved the one conflict in crates/minimal/src/tests.rs. Both sides only added tests at the end of the file: this branch's file export tests and main's expander_skew_reports_and_continues. The resolution keeps both, unchanged. The merge commit is fcc1411. cargo clippy -p minimal --all-targets is clean after the merge, and main's expander_skew_reports_and_continues also passes. |
|
Reviewed: no findings; approval withheld, 15 threads unresolved at APPROVE withheld: 15 unresolved threads — minimal-foundry[bot] crates/minimal/src/cmd/boxes/exports.rs:643, minimal-arch[bot] crates/minimal/src/cmd/boxes/exports.rs:473, minimal-arch[bot] crates/minimal/src/cmd/boxes/exports.rs, minimal-arch[bot] crates/minimal/src/cmd/boxes/attach.rs:1525, minimal-arch[bot] crates/minimal/src/cmd/boxes/wait.rs:244, …. Resolving the last thread releases the approval on this head. Resolve the open threads. Resolving the last one releases the approval on this head; no new review is required. Verdict APPROVE, posted as a comment: the App cannot review its own pull request; the check and the label carry it. Clobber: none seen. |
| ExportKind::File | ||
| } else if file_type.is_symlink() { | ||
| // The file service refuses a link that leaves the box's | ||
| // folders, so a link it follows stays inside them. | ||
| match self.kind(&format!("{path}/{name}")).await { | ||
| Ok(kind) => kind, | ||
| Err(e) => return Err(e), | ||
| } | ||
| } else { | ||
| tracing::debug!( | ||
| path, |
There was a problem hiding this comment.
MEDIUM · correctness · confidence 0.60 · in BoxFiles::list
One dangling symlink inside a folder export aborts the whole export. list calls self.kind on each link, metadata returns NoSuchFile, and that error propagates out of read_tree through ?. copy_one then reports 'a folder inside ... is no longer in the box', and nothing is copied. Skip the link, or treat it as a failed entry, so the other files still come back.
What the reviewer checked
exports.rs list():
file_type.is_symlink() => match self.kind(...).await { Ok(kind) => kind, Err(e) => return Err(e) }; read_tree:let mut names = source.list(&dir).await?;
Hand this to an agent
Act on a code-review finding.
File: crates/minimal/src/cmd/boxes/exports.rs
Lines: 455-465
Category: correctness
Severity: medium (reviewer confidence 0.60)
Finding:
One dangling symlink inside a folder export aborts the whole export. `list` calls `self.kind` on each link, `metadata` returns NoSuchFile, and that error propagates out of `read_tree` through `?`. `copy_one` then reports 'a folder inside ... is no longer in the box', and nothing is copied. Skip the link, or treat it as a failed entry, so the other files still come back.
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.
There was a problem hiding this comment.
Addressed in bc14088cc58a: BoxFiles::list now skips a link whose target is not found (debug log), so one dangling link no longer aborts the folder export. Other read failures still propagate.
…d-that-waits-for-a-box-copies-its-decl
There was a problem hiding this comment.
arch-review: CONDITIONS · 4 conditions · the full ruling
The copy is in the right place, and BOX-186 and BOX-189 conform. This change makes exports live, but the copy does not check symlinks at copy time. Section File exports line 516 requires that check on both sides. A symlink committed in a cloned project can send the write outside the project root (C1). A box link into the box's home passes the file service (C2). attach and wait write into the record's project root from any project, and line 514 forbids that (C3). Name each rule that later tasks own (125, once per end, file_exported) with its issue in the PR body (C4).
Ruled at fcc1411 against gominimal/arch@327e1b57d16b by claude-opus-5-5.
| }; | ||
| let rel = parts.join("/"); | ||
| let src = format!("{BOX_PROJECT_DIR}/{rel}"); | ||
| let dest = parts |
There was a problem hiding this comment.
C1 · This destination is not resolved before the write. create_dir_all and tempfile_in follow a symlink in the project, so a committed link sends the write outside the project root. Section File exports line 516 forbids this. Canonicalize each destination of the export first, and write nothing for the export if one escapes.
There was a problem hiding this comment.
Addressed in 6184244d35ae: copy_one now resolves every destination (the export's dest, and each folder and file of a folder export) with canonicalize before any write, and writes nothing for an export that leads outside the project root. New test: export_through_escaping_symlink_writes_nothing.
| } else if file_type.is_file() { | ||
| ExportKind::File | ||
| } else if file_type.is_symlink() { | ||
| // The file service refuses a link that leaves the box's |
There was a problem hiding this comment.
C2 · The file service serves /workbench and the box's home. A link into the home passes its check. Line 516 limits the source to the box's copy of the project. Canonicalize each source through sftp.canonicalize, and refuse the export unless the path is under /workbench. Remove this comment.
There was a problem hiding this comment.
Addressed in 6184244d35ae: Each source and every folder and file of its tree is resolved through SftpSession::canonicalize and must be /workbench or under it, else the export writes nothing. The comment in BoxFiles::list is removed. New test: export_source_symlink_out_of_workbench_writes_nothing.
| if let BoxAfterAttach::Listed(entry) = &ended | ||
| && matches!(entry.state.as_str(), "stopped" | "exited") | ||
| { | ||
| let root = entry.project_root.as_ref(); |
There was a problem hiding this comment.
C3 · This root comes from the box record, not from the command. Line 514 says a command copies only when its own project root is the one the record names. Discover the command's root, compare the two, and copy nothing on a mismatch. Print one stderr line that names the box and its project folder.
There was a problem hiding this comment.
Addressed in 6184244d35ae: The attach now finds its own project root from the cwd and passes it to attach_on_hosts. copy_box_exports copies only when it equals the record's project_root, else it prints one line naming the box and that folder.
| if let Some(ended) = wait_exit(&shown.record, target) { | ||
| // BOX-185: the wait copies the box's declared exports, on | ||
| // every end, before it gives back the box's code. | ||
| let root = shown.record.project_root.as_ref(); |
There was a problem hiding this comment.
C3 · The same issue as in attach.rs: the wait writes into the record's root from any cwd. Pass the command's own project root into box_wait_on_hosts, and copy only when it equals shown.record.project_root.
There was a problem hiding this comment.
Addressed in 6184244d35ae: cmd_box_wait passes the command's own project root into box_wait_on_hosts, and the copy happens only when it equals shown.record.project_root. New test: exports_not_copied_from_another_project.
| root.map(|root| std::path::Path::new(root.as_str())), | ||
| &mut std::io::stderr(), | ||
| ) | ||
| .await; |
There was a problem hiding this comment.
C4 · The outcomes are discarded, so a skipped export does not give exit 125 (line 517). Nothing claims the end, so a later wait copies again (line 512). Nothing reports the outcome as file_exported (line 518). These rules can stay for later tasks, but the PR body must name each one with its issue.
There was a problem hiding this comment.
|
/revise Arch ruling 1313 on fcc1411 set four conditions. Karl ruled on 2026-11-15 that C1, C2 and C3 are done in this PR: BOX-192 and BOX-196 move here from T131 (#3445), and BOX-199 moves here from T133 (#3447). Do all four. The arch conditions C1 to C3, in full:
Keep the tests this task names passing, and add the tests C1, C2 and C3 ask for. Do not rewrite history and do not force-push. |
|
That Nothing to type again: the command gets a rocket when its round starts, or a refusal that names the reason. No round was counted for it yet. |
|
/revise Addendum to the previous /revise note: use the exact text and test names that the plan fixes for C1, C2 and C3. Each message is one stderr line. The test named next to it pins the text.
|
|
That Nothing to type again: the command gets a rocket when its round starts, or a refusal that names the reason. No round was counted for it yet. |
A link to nothing inside a folder export no longer aborts the whole copy. An attach that ends with another code now waits for the box to leave running only when the box declares an export.
|
/revise Addendum to the two held notes: the runtime caps a task at 6 IDs, so BOX-192, BOX-196 and BOX-199 now belong to a new task, T134 (#3453), and not to T130. The work in the held notes does not change, and this PR still does all of it. In the PR body, add one line that says this PR also delivers T134 (#3453) and covers BOX-192, BOX-196 and BOX-199. Do not use a closing keyword for #3453. |
|
That Nothing to type again: the command gets a rocket when its round starts, or a refusal that names the reason. No round was counted for it yet. |
|
Round 1 of 10 on the runtime's review findings, 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 whose entry declares a file and a directory export ends, and the waiting command leaves both in the project. A link to nothing inside the directory no longer stops the other files from coming back. A detached run copies nothing. An export path outside the project fails before any box is created. Notes from the agent: Revise round 1. Both review threads are fixed in exports.rs and attach.rs. No new test covers the dangling-link skip, because it is in the SFTP-backed BoxFiles source, and the unit tests use a fake source. The settle change adds one GetBoxSpec read when an attach ends with a code other than 0 or 254 and the box still reads running. |
An export now writes nothing when a destination resolves through a link outside the project root (BOX-192), or when a source in the box resolves outside /workbench (BOX-196). A waiting command copies only when its own project root is the one in the box's record (BOX-199).
|
Round 1 of 10 on the runtime's review findings, 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 whose entry declares a file and a directory export ends, and the waiting command leaves both in the project, with the permission bits of the box's files. A detached run copies nothing. An export path outside the project fails before any box is created. Notes from the agent: Revise round 1. The one open thread is valid. ExportSource has a new mode() read. BoxFiles reads it from the box's file service metadata. The temporary file gets those bits (masked to 0o777, then the umask), and falls back to 0666 when the box does not say. export_writes_each_file_atomically now also checks that an executable in the box stays executable when it replaces a 0644 file. cargo clippy -p minimal --all-targets is clean. I did not run just ci or just clippy-strict. |
|
The runtime will not revise this pull request again on its own: the diff is +1883/-9 (1892 lines), past 3x the plan's estimate of 580 lines (est: 280 code, 300 tests, as #3444 reads now), at round 1 (the last trigger was the runtime's review findings). A person decides now. Remove |
There was a problem hiding this comment.
arch-review: PASS · the full ruling
The change still conforms to the File exports section of architecture.md, lines 508-518. The new commit gives an exported file the permission bits of the box's file. It masks them to 0o777, so no setuid bit reaches the project. The mode is set on the temporary file before the rename, so the copy stays whole-file as line 515 requires. The other parts keep the PASS on a7410f4.
Ruled at f8b5329 against gominimal/arch@327e1b57d16b by claude-opus-5-5.
| match kind { | ||
| ExportKind::File => tree.files.push(child), | ||
| ExportKind::Dir => { | ||
| let full = format!("{root}/{child}"); | ||
| let id = source.identity(&full).await.unwrap_or(full); | ||
| if seen.insert(id) { | ||
| tree.dirs.push(child.clone()); | ||
| pending.push_back(child); | ||
| } | ||
| } |
There was a problem hiding this comment.
MEDIUM · correctness · confidence 0.60 · in read_tree
read_tree visits a folder once per canonical path, and it sorts names first. If a folder export holds a link to a sibling folder, such as latest -> run-5, the first name in sort order takes the folder. The other name is skipped. Here latest sorts before run-5, so the real folder run-5 is not copied at all. Its files appear only under latest. The outcome still says copied: true and no line is printed. The loop guard must stop only a folder that is an ancestor of the current folder. It must not drop a second path to a folder that is not on the current path.
What the reviewer checked
exports.rs read_tree: names.sort_by(...);
let id = source.identity(&full).await.unwrap_or(full); if seen.insert(id) { tree.dirs.push(..); pending.push_back(..) }
Hand this to an agent
Act on a code-review finding.
File: crates/minimal/src/cmd/boxes/exports.rs
Lines: 281-290
Category: correctness
Severity: medium (reviewer confidence 0.60)
Finding:
`read_tree` visits a folder once per canonical path, and it sorts names first. If a folder export holds a link to a sibling folder, such as `latest -> run-5`, the first name in sort order takes the folder. The other name is skipped. Here `latest` sorts before `run-5`, so the real folder `run-5` is not copied at all. Its files appear only under `latest`. The outcome still says `copied: true` and no line is printed. The loop guard must stop only a folder that is an ancestor of the current folder. It must not drop a second path to a folder that is not on the current path.
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.
There was a problem hiding this comment.
Addressed in 321a7d99fa63: read_tree now stops only a link to an ancestor of the current folder, so latest -> run-5 copies both trees. A new test pins both paths and the loop case.
|
/revise Fix the MEDIUM correctness finding on f8b5329 in " BOX-187 says a folder export copies its whole tree. Make the loop guard stop only a folder that is already on the current path, its ancestors, so a second path to a folder elsewhere in the tree is copied too. Add a test: a folder export with Keep the tests this task and T134 (#3453) name passing. Do not rewrite history and do not force-push. |
The loop guard in read_tree dropped a second path to any folder, so a link such as latest -> run-5 left run-5 out of the copy. The guard now stops only a link to an ancestor of the current folder.
|
Round 1 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 whose entry declares a file and a directory export ends, and the waiting command leaves both in the project. A folder export that holds a link to a sibling folder, such as latest -> run-5, now copies run-5 and latest both, and a link back to an ancestor folder ends without a loop. A detached run copies nothing. An export path outside the project fails before any box is created. Notes from the agent: Revise round 1: read_tree kept one global set of folder identities, so a second path to a folder was dropped. Each pending folder now carries the identities of its ancestors, and the walk skips a link only when it leads to one of them. The new test directory_export_copies_its_tree_and_deletes_nothing_through_sibling_links uses a new fake LinkedBox in tests.rs that follows folder links. Its name matches the existing directory_export test line, so that line runs it. One run with the filter |
|
The runtime will not revise this pull request again on its own: the diff is +2039/-9 (2048 lines), past 3x the plan's estimate of 580 lines (est: 280 code, 300 tests, as #3444 reads now), at round 1 (the last trigger was a /revise note). A person decides now. Remove |
There was a problem hiding this comment.
minimal-review — approval withheld
Verdict COMMENT — APPROVE withheld: 15 unresolved threads — minimal-foundry[bot] crates/minimal/src/cmd/boxes/exports.rs:643, minimal-arch[bot] crates/minimal/src/cmd/boxes/exports.rs:473, minimal-arch[bot] crates/minimal/src/cmd/boxes/exports.rs, minimal-arch[bot] crates/minimal/src/cmd/boxes/attach.rs:1525, minimal-arch[bot] crates/minimal/src/cmd/boxes/wait.rs:244, …. No findings.
Panel: 3 of 3 personas ran (correctness, security, supply-chain).
|
Round 1 of 10 on a failed check suite: the coder changed nothing. Noop on purpose. The directive lists only the failed test-kvm check (and its aggregator ci-linux-kvm-success). The job log excerpt shows only the step scripts and the post-job cleanup, and it names no failing test or error output. test-kvm runs |
|
/arch-review |
There was a problem hiding this comment.
arch-review: PASS · the full ruling
The compare changes only the walk of a folder export. A link to a sibling folder now copies under both names, and a link to an ancestor is not followed. This conforms to line 515 of the File exports rules. The resolved-path checks of line 516 still run on every path before the first write. The baseline PASS on f8b5329b stands for the rest.
Ruled at 321a7d9 against gominimal/arch@327e1b57d16b by claude-opus-5-5.
T130 — The command that waits for a box copies its declared exports back to the project
slice: S2
kind: task
covers: BOX-185, BOX-186, BOX-187, BOX-188, BOX-189
size: L
est: 280 code, 300 tests
executor: agent
difficulty: needs care
model: strongest
diagnostics: each skipped or refused export is named on stderr with its path
observability: the box's record carries a file_exported event for each export
layers:
- expansion:
- crates/mfile/src/expand.rs: refuse an absolute,
..or project-root export path (BOX-189)- crates/mfile/src/error.rs: the BOX-189 refusal
test: cargo nextest run -p mfile export_path_outside_project_refused_exit3
- client:
- crates/minimal/src/cmd/boxes/exports.rs (new): the copy: each export's file or tree, through
min box cp's file reads, each file written under a temporary name and renamed into place (BOX-187, BOX-188)- crates/minimal/src/task.rs: an attached run copies after the box ends;
--detachcopies nothing- crates/minimal/src/cmd/boxes/attach.rs: an attach, and a start that attaches, copy after the box ends
- crates/minimal/src/cmd/boxes/wait.rs:
min box waitcopies for a box that ended- crates/minimal/src/tests.rs: tests
test: cargo nextest run -p minimal waiting_command_copies_file_exports_after_box_ends
test: cargo nextest run -p minimal detached_start_or_stop_copies_no_exports
test: cargo nextest run -p minimal directory_export_copies_its_tree_and_deletes_nothing
test: cargo nextest run -p minimal export_writes_each_file_atomically
- daemon:
- crates/minimald/src/box_manager.rs: drop
file_exportsfromUNENFORCED_SECTIONS, since the client now copies it- crates/minimald/src/box_manager/tests.rs:
unenforced_sections_warn_once_each_naming_sectionno longer expectsfile_exportsproduces:
- crates/minimal/src/cmd/boxes/exports.rs
consumes: none
proof: a task box whose entry declares a file and a directory export ends, and the waiting command leaves both in the project; a detached run copies nothing; an export path outside the project fails before any box is created.
depends on:
- blocked by #2401
Also delivers
This PR also delivers T134 (#3453) and covers BOX-192, BOX-196 and BOX-199: an export that leads out of the project or out of
/workbench, or a copy into another project, is refused and named on stderr.Residuals
Each is owned by a later task:
architecture.mdline 517): BOX-193 and BOX-194 in T131 (T131 — Skip and name each export that cannot be copied, and end a successful command with exit 125 #3445), and BOX-197 in T132 (T132 — Claim each export from the daemon before copying, and record a file_exported event for each #3446).file_exportedreport (line 518), and this task's ownobservability:line: BOX-195 and BOX-200 in T132 (T132 — Claim each export from the daemon before copying, and record a file_exported event for each #3446).Proof
A box whose spec declares a file export and a folder export is stopped. Then
min box wait, or an attach that sees the box end, leaves both in the project folder: the folder export has its whole tree, empty folders included, and no project file is deleted. Each file is written under a temporary name and renamed into place. A detach andmin box stopcopy nothing, and a--detachrun returns before the copy. An export path that is absolute, has a..component, or names the project folder fails the expansion with exit 3, before any box is created.Notes from the agent: Files outside the layers: crates/minimal/src/cmd/boxes.rs declares the new exports module (one
modline and oneuseline). crates/minimal/Cargo.toml addsrussh-sftp.workspace = true, and Cargo.lock changes to match.minneeds it to list the folders of a folder export through the box's file service.min box cpreads one file only, and its reader in events.rs is private, so exports.rs opens the samesftpsubsystem itself.The spec excerpt does not fix the key of a
[[file_exports]]item. The code readspath, or the item itself when it is a string. An item with nopathis not refused, so the existing mfile test that setssrc/dststill passes. A later spec change can pin the key.Observability is not delivered. The
file_exportedevent on the box's record (BOX-195) needs a report RPC in minimald-rpc and minimald, and neither is in this task's layers. The client logs one tracing line per export only, with its path, whether it was copied, and its file count. ExportOutcome already carries each file's path, size and sha256 for that report.Diagnostics: each skipped or failed export prints one stderr line that names its path and the box. These are the lines: "min did not copy
<path>from box , because it was not found in the box.", "... because the path points outside the folder that holds minimal.toml.", "min did not copy all of<path>from box : …[truncated]Tests
cargo nextest run -p mfile export_path_outside_project_refused_exit3cargo nextest run -p minimal waiting_command_copies_file_exports_after_box_endscargo nextest run -p minimal detached_start_or_stop_copies_no_exportscargo nextest run -p minimal directory_export_copies_its_tree_and_deletes_nothingcargo nextest run -p minimal export_writes_each_file_atomicallyVerify
min task run agent-verifyexited 101, so this PR is a draft.Out of scope
These files are outside the task's
layers:, so this PR is a draft:crates/minimal/Cargo.tomlcrates/minimal/src/cmd/boxes.rsCloses #3444