Repository navigation
msbuild: take MSBuildStartupDirectory as an input to the restore cone's evaluation (#674) - #971
Merged
Merged
Conversation
…'s evaluation (#674) `MSBuildStartupDirectory` is the working directory of the MSBuild process. An evaluation the LSP serves models a build nobody launched, so it has no such directory and the name stays undefined. The restore cone (A₁) models the `dotnet` child that `restore.rs` starts in a directory it chooses, so for that evaluation the directory is a fact borzoi controls. `parse_fsproj_probed` and `test_support::parse_fsproj_reads` take a `startup_directory`. The public entry points do not, so a served evaluation never carries a guessed one. Where it is given, `State::new` canonicalises it through the observer (MSBuild reports the physical directory, and retargeting a link must invalidate the evaluation) and seeds it raw, as the `MSBuildThisFile*` names are, before the reserved set is taken: so it is reserved and protected, and the environment cannot displace it. Unix only. `extra_properties` now rejects the name, as `-p:MSBuildStartupDirectory=` is MSB4177; it was accepted as a global before. `restore.rs` names the child's start directory in one function, `child_start_directory`, with no change in behaviour. Graded by: - `tests/startup_directory_diff.rs`: MSBuild started in the project's directory, a link to it, directories named with a space, `;`, `%20`, `$` and `$(Body)`, and a link to a directory; the name read in a body, an import, an `Include`, conditions, a `<Choose>` arm, an import path and a gated `Compile`. Given the directory, every read commits and agrees; without it, nothing that moves with the directory is committed. - `with_imports_tests::startup_directory`: the read-set soundness sweep over a startup directory reached through a link (it fails if the canonicalisation bypasses the observer), the environment, and directories that cannot be resolved. - The restore-cone census starts our evaluation where the oracle starts. The nine `MSBuildStartupDirectory` reads move from "unset, inexact (the toolset); set in MSBuild" to "value agrees", and nothing else moves. Part of #674. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #674: the second half,
MSBuildStartupDirectory. The first half,MSBuildAssemblyVersion, landed in #954.What
MSBuildStartupDirectoryis the working directory of the MSBuild process. An evaluation the LSP serves models a build nobody launched, so it has no such directory and the name stays undefined. The restore cone (A₁) models thedotnetchild thatrestore.rsstarts in a directory it picks, so for that evaluation the directory is a fact borzoi controls.parse_fsproj_probedandtest_support::parse_fsproj_readstakestartup_directory: Option<&Path>.parse_fsproj,parse_fsproj_with_importsand the_reusing/_asking_every_timevariants do not, so the type system guarantees that a served evaluation never carries a guessed startup directory.State::newcanonicalises it throughobserved::canonicalize, which puts it in the read set, so retargeting a link invalidates the evaluation. It then seeds it raw, as theMSBuildThisFile*names are. The seed goes in before the reserved set is built, so the name is reserved and protected, and the environment cannot displace it. The seed is Unix only. A path that isn't rooted, doesn't resolve, or isn't UTF-8 gets no seed.extra_propertiesnow rejectsMSBuildStartupDirectory. The design comment saysvalidate_inputs"already rejects it". It didn't: a caller global of that name was accepted and committed (the newstartup_directory_in_extras_is_rejectedtest failed before the fix).dotnet msbuild -p:MSBuildStartupDirectory=/xis MSB4177, which I re-probed.restore.rsmoves the directory its child starts in into one function,child_start_directory. No behaviour change.docs/msbuild-reserved-seeding-plan.md(c), thewell_knowndoc, and theis_env_ignored_toolset_namenote. That note was attached toenum EnvExtensionsPathinstead of the function, so it has moved onto the function. Alsodocs/nuget-dgspec-boundary-plan.md: item 3 of A₁.3b is now landed, and its census table is restated from today's manifests.Probed facts, checked against the oracle
Every fact in the design held: the value is the physical directory, it is spliced raw (
%20decodes and;splits anInclude), it has no trailing separator,-p:is MSB4177, and an environment variable of the name is ignored. One addition: MSBuild rejects a project that passes a;-bearing startup directory to a scalar function (Exists,HasTrailingSlash). The walk commits nothing there, and the differential checks that.Grading
tests/startup_directory_diff.rs(new): one oracle per working directory, covering the project's directory, a link to it, directories namedplain,with space,semi;colon,pct%20enc,dollar$signand$(Body), and a link to an unrelated directory. The name is read in a body, an imported file, anInclude, an equality withMSBuildProjectDirectory,HasTrailingSlash,Exists, a<Choose>arm, an<Import>path and a gatedCompile. With the directory, every read must commit and agree with MSBuild, and where MSBuild rejects the project, the walk must commit nothing. Without it, nothing the walk commits may differ from MSBuild's value from any of the nine directories. Non-vacuity checks confirm that each channel does move with the directory.with_imports_tests::startup_directory(new): the read-set soundness sweep over a startup directory reached through a symlink. I mutated the seed to callhost_fs::canonicalizeand the sweep panicked on the relink, so the sweep catches a query that bypasses the observer. The module also checks that the environment doesn't displace the seed and that a directory the walk can't resolve gets no seed.start_directoryhelper. The probe-invariance check now runs both with a startup directory and without one. Exactly the nineMSBuildStartupDirectorylines move, fromunset, inexact (the toolset); set in MSBuildtovalue agrees. Nothing else in either manifest moves.sdk_chain_decline_attributiondoesn't move: that walk is a served one, so the name stays innot_yet_seeded. Only its comment changed.Not in this PR
The
fsproj_global_perturbation_diff.rsaxis: varying the startup directory within that harness's global-set sweep and generator, with per-case MSBuild pins. The new differential covers the four corner routes (gate,<Choose>arm, property-selected import, Compile item) in both modes across nine working directories, but under no globals. Crossing that axis with the global sweep is still open.🤖 Generated with Claude Code