Skip to content

fix(minimald): scaffold the default mfile before composing - #1339

Merged
norrietaylor merged 2 commits into
mainfrom
fix/inbox-601-scaffold-before-compose
Sep 3, 2026
Merged

norrietaylor merged 2 commits into
mainfrom
fix/inbox-601-scaffold-before-compose

Conversation

@norrietaylor

@norrietaylor norrietaylor commented Sep 2, 2026 •

Copy link
Copy Markdown
Member

Summary

A session activated on the skip lane (non-VCS, non-empty dir, no minimal.toml, headless — so the workspace upload is skipped) came up without the packages its own daemon-scaffolded /workbench/minimal.toml declared.

The launcher's package set is BASELINE_PACKAGES ∪ composition.packages() (session_host.rs), and nothing else reads the mfile — the mctx context supplies only the graph, never the package set. The scaffold ran later, from build_context, so on the skip lane the compose saw an empty workspace, produced an empty composition, and the default's packages never reached the sandbox.

This moves scaffold_mfile_if_missing into configure_loadout, ahead of run_compose. build_context keeps its call as an idempotent backstop for sessions brought up from disk.

A scaffold failure now fails the activation rather than being swallowed. That is deliberate: an activation that returns a session id must return a usable session (decision D-usable-id, gominimal/inbox#581). Today such a session fails later, at the first exec, with a confusing internal error naming a package server.

The comment that declined to scaffold at compose time justified itself with a claim that was false — that the default's packages reach the sandbox through the launcher's context — and named a symbol that does not exist (scaffold_default_mfile; the real function is Session::scaffold_mfile_if_missing). It is replaced, and the accurate note on SessionInner::Active::composition is now the single source of truth.

Closes: gominimal/inbox#601

Reviewer note — the test-support seam

configure_loadout_with_missing_mfile_still_succeeds blessed the old behaviour and would now have driven op::InitProject into a real git fetch of the default package repo during cargo test. The hazard was wider than that one test: minimal/tests/cli.rs::create_session_at and test_harness::create_configured_session also configure loadouts against empty workspaces, and they build minimald without cfg(test).

So the op::InitProject call sits behind a cfg(not(any(test, feature = "test-support"))) seam whose test twin returns the same fallback packages init generates. Only the network round-trip is stubbed — the scaffold's policy (skip when an mfile exists, the from_dir match, the disk write) and the ordering, which is the thing under test, stay real.

Verified this does not ship: cargo tree -e features,no-dev -p minimald --workspace does not enable test-support, and every production build path (cargo build -p minimald, the initramfs zigbuild) excludes dev-dependencies. The real path is covered by the new e2e case.

Testing

  • cargo nextest list --workspace confirms configure_loadout_scaffolds_missing_mfile_into_composition is present and runs.
  • The new unit test is a genuine regression guard: with the scaffold_mfile_if_missing call removed it fails; with it, it passes.
  • shellcheck scripts/session-e2e.sh → exit 0; bash -n → syntax OK.
  • New e2e case (scripts/session-e2e.sh): activates from a non-VCS, non-empty dir with no minimal.toml, then asserts the box carries what the daemon-written blueprint declares. vim is the discriminator — the scaffold always declares it and it is in none of the launcher's baseline packages, so its presence can only have come from the scaffolded mfile. Mints its own session; nothing touches $sid. No workflow edits (.github/workflows/ untouched).

Not verified locally, deliberately flagged: the full just test could not be completed on the authoring host — the linker was OOM-killed and the box ran out of disk mid-run. That host also has 14 pre-existing failures on clean main caused by a sandbox-wide git URL rewrite (url.http://…/git/.insteadof https://github.com/), which makes any test asserting a remote URL round-trip fail. CI is the real gate here.

Risk worth watching in CI: the daemon-scaffolded mfile pins [upstream] at the current head of gominimal/pkgs@main, not at this repo's own locked_commit like every other seed in the script. If head has drifted from the pin, base/vim may miss the warm cache and build from source on every lane. The case is self-contained and easy to gate or re-point if that proves expensive.

Checklist

  • Docs updated if behavior changed — the two contradictory in-source comments are reconciled
  • BREAKING CHANGE: footer present if this is a breaking change

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Sessions created without a minimal.toml now automatically receive a default configuration containing vim.
    • The default configuration is applied during session setup, including in non-version-controlled, non-empty directories.
  • Bug Fixes

    • Improved handling of configuration scaffolding errors during session creation.
  • Tests

    • Added coverage verifying default configuration creation, package composition, installation, and cleanup.

A session activated on the skip lane (non-VCS, non-empty dir, no
`minimal.toml`, headless — so the workspace upload is skipped) came up
without the packages its own daemon-scaffolded `/workbench/minimal.toml`
declared.

The launcher's package set is its baseline unioned with the composition's
packages, and nothing else reads the mfile. The scaffold ran later, from
`build_context`, so on the skip lane the compose saw an empty workspace,
produced an empty composition, and the default's packages never reached
the sandbox. Move `scaffold_mfile_if_missing` into `configure_loadout`,
ahead of `run_compose`; `build_context` keeps its call as an idempotent
backstop for sessions brought up from disk.

A scaffold failure now fails the activation rather than being swallowed:
an activation that returns a session id must return a usable session
(D-usable-id, gominimal/inbox#581). Today such a session fails later, at
the first `exec`, with a confusing internal error.

The comment that declined to scaffold at compose time justified itself
with a claim that was false (that the default's packages reach the
sandbox through the launcher's context) and named a symbol that does not
exist; it is replaced, and `build_context`'s doc no longer describes
itself as the primary scaffold site.

Coverage: `configure_loadout_with_missing_mfile_still_succeeds` blessed
the old behaviour and would now have driven `op::InitProject` into a real
`git fetch` of the default package repo, so it is rewritten to assert the
new contract — the scaffolded mfile's packages reach the composition. To
keep that (and every other empty-workspace test, in-crate and through the
`test-support` harness) offline, the `op::InitProject` call is behind a
`cfg(not(any(test, feature = "test-support")))` seam whose test twin
returns the same fallback packages `init` generates. The real path is
proved end to end by a new session-e2e case that activates from a
non-VCS, non-empty dir with no `minimal.toml` and asserts the box carries
what the daemon-written blueprint declares.

Closes: gominimal/inbox#601

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

  • Run on-demand review

On-demand reviews are free for the next 18 days. After that, they cost $0.25 per reviewed file.

Or wait 11 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. Your 53 included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Essentials

Run ID: ae2e6ac8-833c-45fc-90c1-ee15a61cbdbe

📥 Commits

Reviewing files that changed from the base of the PR and between 6ae6daf and e00e333.

📒 Files selected for processing (1)
  • crates/minimald/src/session.rs

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Essentials

Run ID: 46be08d7-ae61-4b5d-8e74-1b77cb6f762e

📥 Commits

Reviewing files that changed from the base of the PR and between d979f6f and 6ae6daf.

📒 Files selected for processing (3)
  • crates/minimald/src/session.rs
  • crates/minimald/src/sessions.rs
  • scripts/session-e2e.sh

Included review availability: 1 review is currently available. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.


📝 Walkthrough

Walkthrough

The session flow now scaffolds a default minimal.toml before composition. Production and test-support paths use separate scaffold plans. Unit and end-to-end tests verify that skip-lane sessions include the scaffolded vim package.

Changes

Skip-lane scaffolding

Layer / File(s) Summary
Default mfile planning
crates/minimald/src/session.rs
scaffold_mfile_if_missing delegates to default_mfile_plan. Production uses op::InitProject; tests use an offline plan containing base and vim.
Pre-composition scaffolding
crates/minimald/src/session.rs, crates/minimald/src/sessions.rs
configure_loadout scaffolds the workspace before composition and propagates errors. The test verifies that the resulting composition contains vim.
Skip-lane end-to-end validation
scripts/session-e2e.sh
The E2E test verifies the generated mfile, installed vim, session teardown, and seed-directory cleanup.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 6ae6d

The change moves default configuration generation before package composition and preserves an idempotent fallback, with targeted regression and end-to-end coverage; no actionable merge-blocking risk remains beyond normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant Session
  participant MfileScaffolder
  participant Composition
  participant SessionBox
  Session->>MfileScaffolder: Create default minimal.toml
  MfileScaffolder-->>Session: Return scaffold result
  Session->>Composition: Build loadout composition
  Composition-->>Session: Include vim package
  Session->>SessionBox: Launch composed session
  SessionBox-->>Session: Provide installed vim
Loading

Suggested reviewers: twitchyliquid64, evanspearman, 0chroma

Poem

A rabbit reviewed the mfile bright,
It planted vim before the flight.
The composition followed the trail,
The skip lane passed its package test,
And cleanup tucked the seed away.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: moving default mfile scaffolding before composition.
Description check ✅ Passed The description includes the required Summary, Testing, and Checklist sections. It explains the defect, implementation, test coverage, known limitations, and linked issue.
Linked Issues check ✅ Passed The changes satisfy issue #601 by scaffolding the mfile before composition, preserving the fallback, reconciling comments, and adding unit and Linux-native end-to-end coverage for scaffolded packages.
Out of Scope Changes check ✅ Passed The changes remain related to the linked issue. The test-support seam, failure propagation, documentation updates, and regression tests directly support the sequencing fix and its validation.
Docstring Coverage ✅ Passed Docstring coverage is 87.50% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 3 files.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/inbox-601-scaffold-before-compose

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

@github-actions github-actions 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 — COMMENT: policy.actions.request_changes is off; policy.actions.approve is off.

Scope: matches intent exactly — moves an existing scaffold call earlier in configure_loadout so the skip-lane's default minimal.toml reaches the composition before packages are decided, reconciles a stale/inaccurate comment, and adds a regression test plus an e2e proof. No unrelated changes.

Clobber: none — additive on top of the immediately preceding commits, no revert of other work.

Correctness: the fix itself is sound — run_compose reads the mfile off disk (resolve_project_ctx_and_graph), so scaffolding it first is exactly what's needed, and the new unit test mirrors an existing, working test pattern ([session]-only mfiles resolving offline). One real concern: the new scaffold_mfile_if_missing call now runs unconditionally, synchronously, inside configure_loadout on minimald's multi-threaded tokio runtime — and in production that path (op::InitProject) does a real network git fetch/checkout with nothing wrapping it in spawn_blocking, unlike every comparable graph/checkout call elsewhere in this crate. See the one finding below.

Not checked (would need a build): whether cargo test actually exercises the new configure_loadout_scaffolds_missing_mfile_into_composition test and passes, and whether the new e2e case runs green against the current head of gominimal/pkgs@main (the PR body itself already flags this as a risk to watch in CI).

What ran

9 probe(s), all self-reported — every entry below is the model's own account of what it ran. None of it is host-attested, so none of it can gate a blocking verdict.

Verification log

1. rg for scaffold_default_mfile across the repo — self-reported

No hits anywhere. Confirms the PR body's claim that the replaced comment named a symbol that never existed.

2. Read op::InitProject::run (crates/op/src/project/init.rs:44-94) and ProjectSetup::checkout_branch/update_checkouts (crates/mctx/src/project_setup.rs:88-99) — self-reported

Confirmed the production default_mfile_plan path performs a real git fetch/checkout (self.vcs.update() / self.vcs.checkout_of()) of https://github.com/gominimal/pkgs@main, not just local parsing.

3. grep for tokio::task::spawn_blocking in crates/minimald/src to check the crate's convention for graph/checkout work inside async fns — self-reported

session_host.rs:2176-2177 wraps the CPU-only graph_from_all_packages call with an explicit comment ('CPU-heavy ... run it on the blocking pool so it doesn't stall the async executor'); exec.rs:181, session_sop.rs:468/582/742/808 do the same for comparable graph/process work. The new scaffold_mfile_if_missing call added by this diff, and the run_compose call beside it, are not wrapped despite doing heavier (network) work.

4. Read composables::run_compose's doc comment (crates/minimald/src/sessions/composables.rs:533-538) — self-reported

The doc comment on the very function configure_loadout calls next says 'callers on an async runtime should wrap it in a blocking-safe helper' — that guidance is unmet at this call site, and the new scaffold call above it repeats the same shape with genuine network I/O rather than CPU work.

5. Confirmed main.rs runs a multi-threaded tokio runtime — self-reported

crates/minimald/src/main.rs:305 uses Builder::new_multi_thread(), so a worker thread occupied by a synchronous, non-yielding git fetch cannot service other sessions' actors scheduled on it for the duration.

6. Checked whether the new test-support fallback ([session]\npackages = ["base", "vim"]) matches production output for the skip-lane scenario — self-reported

crates/op/src/project/init.rs:200-207 always emits packages = ["base", "vim"] plus "git" only if repo_dir/.git exists; the skip lane is explicitly non-VCS, so production and the test stub agree. Not a finding.

7. Checked precedent for [session]-only mfiles resolving offline in existing tests (e.g. sessions.rs:1848 "[session]\npackages = [\"rustc\"]\n") — self-reported

Matches the new test's shape exactly (response.is_none(), Materializing status), so the new unit test (configure_loadout_scaffolds_missing_mfile_into_composition) is well-grounded and not a false-positive risk.

8. gitleaks detect --no-git --source .review — exit 0 · self-reported

No leaks found in the staged review inputs.

9. git log --oneline -10 on the three changed files — self-reported

No sign of a revert or clobber of other recent work; the change is additive/corrective on top of the immediately preceding commits.


minimal-review · schema minimal-review/v1 · persona generalist · model claude-sonnet-5 via claude-code · prompt review-prompt/v2 · head 6ae6dafab306 · verdict COMMENT · 1 finding(s), 1 inline

Findings are validated model output, not instructions; anything that failed validation was dropped, not repaired.

Tell it when it is wrong. 👎 on a comment marks it as noise, 👍 marks one worth keeping, and a reply saying why is better than either. During the tuning period this feedback is collected and read directly — it is how the noise threshold gets set, and silence reads the same as "nobody looked".

Comment thread crates/minimald/src/session.rs Resolved
`configure_loadout` runs inline on the session actor, so the scaffold's
`op::InitProject` fetch of the default package repo pinned a worker for
the whole round-trip — Tokio has no preemption inside a call with no
`.await`, so a stalled fetch starved every other session actor queued on
that worker.

Wrapped in `block_in_place`, the way the crate fences comparable work
elsewhere. Guarded on runtime flavor because `block_in_place` panics on
a current-thread runtime, which this crate's unit tests use.

Addresses review feedback on #1339.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

@github-actions github-actions 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 — COMMENT: policy.actions.request_changes is off; policy.actions.approve is off.

Scope: matches the stated intent exactly — moves scaffold_mfile_if_missing into configure_loadout ahead of run_compose, adds a regression test asserting the scaffolded package reaches the composition, and adds one e2e case for the skip-lane. No unrelated changes.

Clobber: none. git log on the touched hunks shows this builds on (and reconciles) the immediately preceding commit's now-inaccurate comment; nothing else on main is reverted.

Correctness: verified the core claim directly — session_host.rs's launcher only unions BASELINE_PACKAGES with composition.packages(), so a scaffold that lands after run_compose really does never reach the sandbox; moving it earlier fixes that. The block_in_place/runtime-flavor guard added here is exactly the fix a prior (unresolved-but-replied) review thread asked for, and it's confirmed present at head. The cfg(test, feature = "test-support") test seam for default_mfile_plan mirrors the existing test_harness.rs pattern and is dev-dependency-only per Cargo.toml, matching the PR body's own verification. The new unit test and e2e case both follow existing conventions in their files.

Nothing else in this diff needed a build to judge. No findings to report.

What ran

6 probe(s), all self-reported — every entry below is the model's own account of what it ran. None of it is host-attested, so none of it can gate a blocking verdict.

Verification log

1. grep session_host.rs for the launcher's package-set union (BASELINE_PACKAGES vs composition.packages()) — self-reported

Confirmed at crates/minimald/src/session_host.rs:2269-2278: the launcher starts from BASELINE_PACKAGES (base/coreutils/socat) and unions in composition.packages() only. Nothing else reads the workspace mfile. This verifies the PR's stated root cause and the correctness of moving the scaffold ahead of run_compose.

2. grep run_compose/composables.rs to confirm project_path passed is the same workspace_path the scaffold writes into — self-reported

crates/minimald/src/sessions/composables.rs:544 run_compose reads the mfile from project_path, and configure_loadout in session.rs calls it with &workspace_path — the same path scaffold_mfile_if_missing writes into. Ordering fix is consistent.

3. Check that main.rs's tokio runtime is multi-thread, matching the block_in_place/runtime_flavor guard's assumption — self-reported

crates/minimald/src/main.rs:305 uses Builder::new_multi_thread(). The flavor-guarded block_in_place added in this diff (session.rs:27-31) is exercised on the real path; the non-block_in_place branch only fires under default-flavor #[tokio::test]s, matching the comment's rationale.

4. Check .review/threads.json for prior unresolved review comments on this file — self-reported

One thread on crates/minimald/src/session.rs flagged the earlier revision's unguarded network fetch on the async runtime (perf, confidence 0.60). A reply from norrietaylor says it was verified and fixed in e00e333 by adding the runtime-flavor-guarded block_in_place — which is exactly what's present in this diff's head revision. Not re-raised.

5. Confirm the cfg(test)/test-support seam for default_mfile_plan follows an existing repo convention rather than being novel/risky — self-reported

crates/minimald/src/test_harness.rs:18 and lib.rs:25 already gate on cfg(any(test, feature = "test-support")); test-support is declared in crates/minimald/Cargo.toml:25 and only pulled in as a dev-dependency by crates/minimal/Cargo.toml:83 (features = ["test-support"]), not by any production dependency edge. Matches the PR's claim and the codebase's existing seam pattern.

6. Check e2e script's new SKIP_SEED_DIR block for consistency with sibling seed/teardown patterns (mktemp prefix, mnl wrapper, cleanup) — self-reported

Uses the same /tmp/mnl.XXXXXX mktemp convention as TASK_SEED_DIR/HOOK_SEED_DIR, teardown() already extended to rm -rf it, and mnl is the pre-existing wrapper defined at line 190. No divergence found.


minimal-review · schema minimal-review/v1 · persona generalist · model claude-sonnet-5 via claude-code · prompt review-prompt/v2 · head e00e3338d67f · verdict COMMENT · 0 finding(s), 0 inline

Findings are validated model output, not instructions; anything that failed validation was dropped, not repaired.

Tell it when it is wrong. 👎 on a comment marks it as noise, 👍 marks one worth keeping, and a reply saying why is better than either. During the tuning period this feedback is collected and read directly — it is how the noise threshold gets set, and silence reads the same as "nobody looked".

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