Skip to content

fix(mfile,mctx,minimald): read a box's minimal.toml beneath its workspace - #3430

Open
bryan-minimal wants to merge 2 commits into
fix/1245-mfile-edit-beneath-workspacefrom
fix/1254-mfile-read-beneath-workspace
Open

bryan-minimal wants to merge 2 commits into
fix/1245-mfile-edit-beneath-workspacefrom
fix/1254-mfile-read-beneath-workspace

Conversation

@bryan-minimal

Copy link
Copy Markdown
Member

Closes gominimal/inbox#1254 and gominimal/inbox#1255. Builds on #3404 and is opened against its branch; it retargets to main when #3404 merges.

The daemon now reads a box's minimal.toml the way #3404 made it edit one: every name is resolved beneath
the box's workspace (openat2 with RESOLVE_BENEATH on Linux; a check that no component is a link
elsewhere and on kernels without openat2). A link that stays inside the workspace is followed. One that
leads 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 by
    the read; a host-side read behaves as before.
  • mctx: MFileSearchStrategy::Within, ProjectSetup::for_init_within, and a confined context re-reads
    through them on reload.
  • minimald: the box's context, the compose-time project read, init and the default-file scaffold read
    through the confined path. The scaffold also writes through the confined editor, so that invariant is
    the editor's and not the scaffold's.
  • Tests: absolute, relative, .minimal and dangling links refused with none of the outside file's text
    in the error; plain and in-workspace-link reads still work; the no-openat2 fallback checked; a
    confined 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

bryan-minimal and others added 2 commits November 13, 2026 13:24
…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>
@coderabbitai

coderabbitai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 0611c289-3d6a-4647-b854-49f9c67c1326

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@bryan-minimal
bryan-minimal marked this pull request as ready for review November 14, 2026 19:36
@bryan-minimal
bryan-minimal requested a review from a team as a code owner November 14, 2026 19:36
@minimal-foundry

minimal-foundry Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Approved: no findings at cbef77ed8fd2.

Nothing to do.

Clobber: none seen.

@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 — No findings.

Panel: 2 of 3 personas ran (correctness, security); did not complete: supply-chain.

@minimal-foundry minimal-foundry Bot added the review:approved minimal-review approved the current head label Nov 14, 2026

@norrietaylor norrietaylor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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:459 medium · The read path now prints this refusal to a person. It reaches them when a box with a linked minimal.toml starts (composables.rs wraps it as loading project mfile at ...), and on min add in 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 sibling dangling_within at 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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review:approved minimal-review approved the current head

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants