Repository navigation
fix(mfile,mctx,minimald): read a box's minimal.toml beneath its workspace - #3430
bryan-minimal wants to merge 2 commits into
Conversation
…pace The daemon read a box's minimal.toml by plain path, in its own view of the host, while the edit of the same file already stayed inside the workspace. A link at minimal.toml or .minimal could point the read at a file outside the workspace. Add `File::from_dir_within(root)`, the confined counterpart of `from_dir`. It resolves each name beneath the workspace through the same resolver the confined edit uses, now shared by both: on Linux openat2(2) with RESOLVE_BENEATH, and a check that no component under the root is a link elsewhere and on kernels without openat2. A link that stays inside the workspace is still followed. A link that leads out, or dangles, is refused before anything is read, and the refusal names only the file in the workspace, never content of the file the link points at. `mctx::MFileSearchStrategy::Within` and `ProjectSetup::for_init_within` read this way, and a context confined to a workspace re-reads beneath it in `cloned_reinit`. The daemon uses them for a box's context, for the compose-time project read, for the default-file scaffold check and for init. Host CLI reads of a project the user chose are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d editor The default minimal.toml the daemon writes into a box's workspace went through the path-based editor, which follows links. Its only-if-missing check kept it from writing through a link to an existing file, but the guarantee belonged to the caller, not the editor. Write it with `File::edit_exclusively_within(workspace, path, ...)`, as a box's context already edits its minimal.toml, so the editor itself keeps the write inside the workspace. A link there that leads out is refused, and the file it points at is left as it was. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
|
Approved: no findings at Nothing to do. Clobber: none seen. |
norrietaylor
left a comment
There was a problem hiding this comment.
Scope matches the title and the body. The PR factors the openat2 resolver out of the confined edit into resolve_beneath. It adds a confined read (File::from_dir_within, MFileSearchStrategy::Within, ProjectSetup::for_init_within). It also moves the daemon's box reads onto that read. Every hunk traces to inbox#1254 or inbox#1255. Clobber none. git log on mfile/src/lib.rs and box_actor/setup.rs shows only the #3404 stack under this branch, and the edit path keeps its behaviour after the refactor. The NoDir arm returns the same Error::IO("opening", ...) as before. Correctness The Linux read opens through beneath::open_at, and that function adds O_NOFOLLOW | O_NONBLOCK. So a link swapped in after resolution gives ELOOP and a refusal, and a FIFO at minimal.toml does not hang the read. cloned_reinit now prefers the confinement root over repo_path(), and it carries mfile_edit_root forward. The scaffold's early .exists() check follows links, but a link out is then refused at context build. No other non-test from_dir, Override or Context::new read of a box workspace remains in minimald. The graph's own read is out of scope and tracked in inbox#1258. The one finding is about the refusal text. The read path now prints it to a person at activation, and it gives no next step. Not checked: the tests. They need a build, and the Linux openat2 path needs a Linux kernel.
crates/mfile/src/lib.rs:459medium · The read path now prints this refusal to a person. It reaches them when a box with a linkedminimal.tomlstarts (composables.rs wraps it asloading project mfile at ...), and onmin addin the box. The text says what was refused and why, but it gives no next step. It also joins two facts with a semicolon. The siblingdangling_withinat line 1722 already shows the expected shape: "create it or replace the link with a file". Give this refusal a next step, for example "Replace the link with a regular file in the workspace." The same shape is in two more strings:"not a regular file; the read is refused"(line ~1446) and"not a file under the workspace {}; the {} is refused"(line ~1695). Fix all three together.
Closes gominimal/inbox#1254 and gominimal/inbox#1255. Builds on #3404 and is opened against its branch; it retargets to
mainwhen #3404 merges.The daemon now reads a box's
minimal.tomlthe way #3404 made it edit one: every name is resolved beneaththe box's workspace (
openat2withRESOLVE_BENEATHon Linux; a check that no component is a linkelsewhere and on kernels without
openat2). A link that stays inside the workspace is followed. One thatleads out, or dangles, is refused before anything is read, and the refusal carries no content of the file
it points at.
mfile:File::from_dir_within(root). The resolver is factored out of the confined edit and shared bythe read; a host-side read behaves as before.
mctx:MFileSearchStrategy::Within,ProjectSetup::for_init_within, and a confined context re-readsthrough them on reload.
minimald: the box's context, the compose-time project read, init and the default-file scaffold readthrough the confined path. The scaffold also writes through the confined editor, so that invariant is
the editor's and not the scaffold's.
.minimaland dangling links refused with none of the outside file's textin the error; plain and in-workspace-link reads still work; the no-
openat2fallback checked; aconfined context's reload refuses a link out; a scaffold over a link out is refused and leaves the
target unchanged.
Out of scope: host CLI reads (the user chose the project), and the package graph's own read of the
workspace layer, which needs the confinement passed through graph loading and is tracked in
gominimal/inbox#1258.
🤖 Generated with Claude Code