Skip to content

fix(tools): sandbox yarnrc parents, mise lock policy, tool process groups, install proof - #345

Open
sweepies wants to merge 1 commit into
mainfrom
fix/tools-sandbox
Open

sweepies wants to merge 1 commit into
mainfrom
fix/tools-sandbox

Conversation

@sweepies

@sweepies sweepies commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Four fixes from the tools/process scan.

1. Yarn reads parent .yarnrc.yml files

Yarn Berry reads every .yarnrc.yml from its working directory up to the filesystem root, but only <cwd>/.yarnrc.yml was cleaned of plugins/yarnPath. A root .yarnrc.yml with plugins: [{path: evil/yarn.lock}] would load repository JavaScript into a Berry project in app/.

Now every .yarnrc.yml from the project up to the tree root is replaced by its sanitized copy for the run. A new context::Replaced guard restores the committed files on the normal path and on drop, so an early return or a cancelled run restores them too. The .npmrc handling now uses the same guard.

Test: yarn_sees_every_yarnrc_up_to_the_tree_root_sanitised (success and failure) checks that the tool sees only sanitized copies at both levels and that both committed files come back.

2. mise lock ran plugin backends and skipped the lookup checks

  • mise lock (Run::Mise, the one run that reads the repository's tool configuration) now always runs with MISE_DISABLE_BACKENDS=asdf,vfox, through patchula_mise::without_plugins, which lookups use too.
  • Before the sanitized mise.toml is written, every tool argument it locks goes through the new patchula_mise::admit. That is the name and option check plus the instance-metadata guard, built from the entry's options with bracketed, as a lookup builds them. Lookups now go through admit as well, so both paths share one entry point.
  • One deviation from the brief: the restriction is not on every mise invocation from tools. mise's registry lists vfox:jdx/vfox-yarn first for yarn and vfox:jdx/vfox-poetry first for poetry. With plugins disabled for the Count's own tool runs, the real Yarn test failed: the store's install is recorded as a vfox one. Those plugins are chosen by mise's registry for tools the Count names, not by a repository, so the threat model does not require it. The restriction applies to every mise that handles repository-chosen tool names: lookups and mise lock.
  • Consequence, checked against real mise: under the restriction, mise lock records yarn as aqua:yarnpkg/berry and poetry as pypi:poetry, the next backends. This is documented in guide/lockfiles.md.

Tests: mise_lock_refuses_tools_a_lookup_would_refuse covers asdf:/vfox: names and metadata URLs in a string, an inline table, an array of tables and a [tools.x] table. The run fails and mise lock never starts. MiseFixture now checks that every mise lock run has the backends disabled.

3. Process groups only died on timeout

patchula-process now kills the leader's process group every time the leader exits, whatever its exit status. A Group drop guard does the same on cancellation and timeout. Data already in the pipes survives the kill, so the drains still read everything the leader wrote. A grandchild that keeps stdout open can no longer turn a successful run into TimedOut. dotnet runs with MSBUILDDISABLENODEREUSE=1.

Tests (Linux): a_grandchild_does_not_outlive_a_command_that_exits (exit 0 and exit 3; sleep 300 & holds stdout, which used to hang until the limit) and a_cancelled_command_takes_its_grandchildren_with_it.

4. A failed tool run reinstalled its toolchain next time

A first use now runs mise install <specs> on its own: clear and seed under the exclusive lock, then install under the shared lock with the 30-minute allowance. The install is recorded as soon as mise succeeds. The tool run itself always has the 180-second limit. A Rust install gets the same RUSTUP_HOME/CARGO_HOME as the run. A failing run, including the Go public-proxy attempt before its retry, keeps its install.

Tests: first_tool_use_installs_apart_from_the_run (whether the tool passes or fails, the second call neither uninstalls nor reinstalls) and a_rust_install_uses_the_runs_toolchain_homes.

Other

  • crates/mise/src/ is hashed by the engine's extract, files, config and config-files states. Bumping those versions changes crates/engine/src/lib.rs, which catalog and catalog-controls hash, so all six are bumped in tests/state-versions.tsv.
  • Docs: guide/lockfiles.md (mise lock checks and backends, Yarn rc files, process groups, tool store recording and limits), guide/sources.md (mise lock shares the lookup checks), internals/cache.md (install under the shared lock, proof on install).
  • Ran on the VM: cargo test for patchula-process, patchula-mise, patchula-tools (unit), patchula-datasource and patchula-notes; mise run test:tools (40 real tool tests); the engine state_parity test; clippy -D warnings on process, mise, tools and engine.

Follow-ups

  • Consider pinning the Count's own yarn and poetry to non-plugin backends, so no lockfile tool install runs a vfox plugin at all. That would mean new specs in defaults.toml and test:tools, a reinstall of existing stores, and real-tool checks.
  • Check against real mise whether mise lock (with MISE_AUTO_INSTALL=true) ever installs a tool and so runs an option such as postinstall. If it does, refuse those options for mise lock.

View guided diff Turn on auto-fix

…oups, install proof

- Yarn reads every .yarnrc.yml from its project up to the filesystem root;
  each one up to the tree root is now sanitized for the run and restored by
  a drop guard, as every .npmrc already was.
- mise lock runs with the asdf and vfox backends disabled and checks every
  tool argument it locks, options included, with the lookup's name, option
  and instance-metadata checks (patchula_mise::admit) before mise starts.
- The executor kills the process group whenever the leader exits, and from
  a drop guard on cancellation, so grandchildren never outlive the call or
  hold its pipes; dotnet runs with MSBUILDDISABLENODEREUSE=1.
- A first use installs its tools with `mise install` apart from the run and
  records the install when mise succeeds, so a failing tool no longer gets
  its toolchain uninstalled and reinstalled on the next call.
- Bump the extract, files, config, config-files, catalog and
  catalog-controls state versions for the crates/mise/src edits.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
count-patchula c459c67 Commit Preview URL

Branch Preview URL
Nov 15 2026, 11:21 PM

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.

1 participant