fix(tools): sandbox yarnrc parents, mise lock policy, tool process groups, install proof
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 withMISE_DISABLE_BACKENDS=asdf,vfox, throughpatchula_mise::without_plugins, which lookups use too.- Before the sanitized
mise.tomlis written, every tool argument it locks goes through the newpatchula_mise::admit. That is the name and option check plus the instance-metadata guard, built from the entry's options withbracketed, as a lookup builds them. Lookups now go throughadmitas 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-yarnfirst foryarnandvfox:jdx/vfox-poetryfirst forpoetry. 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 andmise lock. - Consequence, checked against real mise: under the restriction,
mise lockrecordsyarnasaqua:yarnpkg/berryandpoetryaspypi: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'sextract,files,configandconfig-filesstates. Bumping those versions changescrates/engine/src/lib.rs, whichcatalogandcatalog-controlshash, so all six are bumped intests/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 testfor patchula-process, patchula-mise, patchula-tools (unit), patchula-datasource and patchula-notes;mise run test:tools(40 real tool tests); the enginestate_paritytest; clippy-D warningson process, mise, tools and engine.
Follow-ups
- Consider pinning the Count's own
yarnandpoetryto 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(withMISE_AUTO_INSTALL=true) ever installs a tool and so runs an option such aspostinstall. If it does, refuse those options formise lock.