Skip to content

msbuild: follow MSBuild's batch of Updates by its keys and operations (#993, PR B) - #1157

Draft
Smaug123 wants to merge 19 commits into
mainfrom
issue-993-batch-model
Draft

Smaug123 wants to merge 19 commits into
mainfrom
issue-993-batch-model

Conversation

@Smaug123

@Smaug123 Smaug123 commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Claim. The batch of Updates the walk follows is MSBuild's, by its keys and by its operations, in build evaluation and design-time evaluation alike.

Keys

  • A key is NormalizePathForComparisonNoThrow, compared OrdinalIgnoreCase. That is a full path, or the spelling as written where the function refuses to normalise it (PathIsInvalid: a :, |, quote, and the like in the file name).
  • Remove and Exclude share the key function (comparison_key).
  • An Update that leaves the batch removes its earlier fragments by their text. A fragment spelled as its own key leaves with it; any other stays stranded.
  • Under a non-ASCII project directory, a relative fragment is keyed behind the directory as written (batch_key).

Operations

  • An operation the walk certainly runs moves the batch as modelled. "Certainly runs" means its gate is decided true from certain inputs, and so is the gate of each construct around it: group, <Choose> arm, import.
  • Any other operation is followed through both of its outcomes. That includes a condition-false one: design-time evaluation (-getItem with no target) batches a false Update's fragments, and a build skips them.

Committed domain. Compile and PackageReference lists where the walk follows the batch through every Update, in at most four outcomes, plus PR A's shapes (an Update that cannot leave past its first fragment), which need no batch.

Declines. The batch becomes unknown at any of:

  • a fragment the walk cannot key: outside the ASCII domain; under a non-ASCII directory, absolute or climbing out of it; verbatim with a \ or a run of separators;
  • an inexact spec;
  • more than four outcomes;
  • a second outcome that would copy more than 64 keys or 4,096 bytes.

Past that point, each Update is judged as PR A judges it, and an Update that may strand declines its list.

Part of #993 (PR B). It stacks on #1137 (PR A), now merged.

Why both evaluation modes

Probed with SDK 10.0.401. Each row prints each Compile item with its CompileOrder; the SDK's order target puts CompileFirst first.

false_update (a condition-false Update="Z.fs", then A.fs;A.fs Link, B.fs;A.fs CompileFirst, Include A.fs;B.fs)
  design-time (-getItem):   A.fs, B.fs (no CompileOrder)
  build (-t:):              A.fs order=, B.fs order=CompileFirst
group_gate (the same, Z.fs in a group MSBuild skips)
  design-time:              A.fs, B.fs (no CompileOrder)
  build:                    B.fs order=CompileFirst
condition-false PackageReference Update="Alpha;Alpha", then Update="Beta;Alpha" VersionOverride, Include Alpha;Beta
  design-time:              Beta VersionOverride=1.0
  build:                    Beta override=

The two modes disagree wherever a condition-false Update joins the batch. Following both outcomes, the walk commits only where they agree.

an_update_leaving_batched_entries_marks_the_set_uncertain (main's test) therefore keeps its assertion for the false case. The case declines, and the design-time probe agrees with it. My earlier PR 5 draft had corrected it to the build's answer alone; that correction does not appear here.

The corpus differential (fsproj_msbuild_corpus_diff) grades design-time evaluation, and compile order is served from build evaluation. Because PR B's claim covers both modes, that differential grades the claim; this answers round-2 #6 of PR 5.

What changes

  • item_spec:
    • comparison_key keys a spelling MSBuild refuses to normalise as written, but gives no key to one with a \ or a run of separators (MaybeAdjustFilePath changes those with the working directory).
    • batch_key adds the non-ASCII-directory keys.
  • item_pass:
    • BatchState: the outcomes the batch may be in, as UpdateBatchRuns, or unknown.
    • feed_update_batch and feed_world move the batch from operation to operation. They copy only into a second outcome, capped, and they compare outcomes by a digest first.
    • Groups the walk does not walk feed their operations as maybe-run (feed_unwalked_group).
    • reach_doubted covers doubted <ItemGroup> gates and replayed groups that were not reached for certain.
  • New diagnostics:
    • PackageReferenceUncertaintyCauseKind::StrandedUpdate.
    • StrandedUpdatePrefix now names the fragment the Update leaves the batch at.
  • tools/msbuild-condition-oracle: itemsMeta takes designTime.

Tests

Restored certainty. The cases PR A declined now commit again:

  • the two compile_update_compile_order_scales_* tests are certain again;
  • compile_update_compile_order_declines_a_stranded_prefix asserts again that the walk declines exactly where something is stranded;
  • duplicate_identity_package_update_marks_the_set_uncertain's Delta;Gamma is certain;
  • the rooted-repeat corner and the undecided-group-of-skipped-Updates corner are certain and graded against MSBuild;
  • most_generated_cases_are_certain is back to its 55% floor: 119 of 200 commit.

The sweep. update_batches_match_msbuild generates runs of Updates with these dimensions:

  • gates, on the Update and on its group: a gate MSBuild skips, one the walk cannot decide, one the walk takes on an untrusted or inexact read;
  • spellings, including three :-bearing ones and one the walk cannot key;
  • an ASCII or a non-ASCII project directory;
  • a spec read from a value the walk does not hold.

Every commit is held to MSBuild's build order and to the order of its design-time items. At 3,000 cases, 323 reach the oracle, with no divergence. batch_cases_often_commit pins its fixed sample: 18 of 227 commit under an ASCII directory and 10 of 173 under the other.

Unit tests. About 30, ported from the old keys and reach branches and probed against dotnet msbuild where they assert an order.

Cost tests. Counts, not timings:

  • updates_the_walk_runs_copy_no_batch;
  • updates_the_walk_may_not_run_cost_the_batch_linearly, covering keys present, moving and rolled back, and pending batches left at any fragment;
  • a_long_stranded_key_costs_the_batch_linearly.

Mutation checks. Each guard was reverted, and the mutation confirmed applied.

  • Caught:
    • removal by text, the non-ASCII key, the verbatim key and its \ rule;
    • the walked-group doubt, the skipped-group feed, both outcomes, the opaque lone fragment and the never-run strand;
    • the unmoved fast path, the pending-flush fast path, the later-collision fast path, and the key and byte copy bounds;
    • the stranding fragment and the single diagnostic.
  • Masked by another decline, and each filed:
  • Deleted: a guard no test could see, on cwd-dependent removal by text. A fragment that stays is already counted as a strand.

Costs and gates

All run locally, because the build box is down:

Codex

Base 2085e71a1, five rounds:

Round Findings
1 R2: quadratic copying of an unconditional batch.
R4: empty stranding fragment.
R4: package strand reported as a duplicate id.
R3: design-time escaped identity.
R3: ASCII test root.
2 R2: copying a pending batch that flushes at its first fragment.
R3: coverage guard with no case of a class.
3 R2: copying a pending batch that flushes at a later fragment.
R3: fallback test directory not created exclusively.
4 R2: copying a rolled-back non-pending batch.
R3: fallback parent may be non-ASCII.
5 R2: copying a batch with one long key (bytes, not keys).

There was no R1 in any round. Every finding is fixed, each with a test that fails without its fix; the test-harness R3s are the exception.

Rounds 1–5 found one stream: the cost of copying the batch into a second outcome. Round 4's fix closed it by structure, a cap on the keys and bytes any copy holds, past which the walk follows no batch. Round 5 extended the cap from keys to bytes.

Out of the domain, filed

🤖 Generated with Claude Code

Smaug123 and others added 11 commits November 26, 2026 00:52
…#993, PR B)

The walk follows MSBuild's batch of `Update`s (`LazyItemList.ComputeItems`)
again, where PR A declined every `Update` that could leave it past its
first fragment.

Keys: `NormalizePathForComparisonNoThrow`, a spelling it refuses kept as
written (`comparison_key`, which `Remove` and `Exclude` share), and under a
non-ASCII project directory relative fragments keyed behind it
(`batch_key`). Leaving removes earlier fragments by their text.

Operations: one the walk certainly runs moves the batch as modelled; any
other, a condition-false one included, is followed through both outcomes,
since design-time evaluation batches a false `Update` that a build skips
(probed, SDK 10.0.401). A bounded set of outcomes, past which, and past a
fragment the walk cannot key or an inexact spec, every later `Update` is
judged as in PR A.

`update_batches_match_msbuild` holds commits to both MSBuild's build order
and its design-time items, under ASCII and non-ASCII directories; the
oracle's `itemsMeta` op gains `designTime`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A batch the walk follows moves from operation to operation; only a
  second outcome of an operation it may not run copies it, and every copy
  and key comparison is counted.
- A strand across Updates names the fragment the Update leaves at, and a
  package strand is its own cause, StrandedUpdate, not a duplicate id.
- The oracle's design-time items carry their escaped spelling.
- The batch sweep lays its cases under an ASCII root wherever the checkout
  lies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- An Update the walk may not run that, run, flushes a pending batch at its
  first fragment leaves the batch and an empty one, copying neither.
- The batch sweep's coverage guard requires a case under each kind of
  directory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- An Update the walk may not run that, run, leaves a pending batch at any
  fragment flushes it: its outcomes are the batch and an empty one, found
  by a lookup per fragment and no copy.
- The batch sweep's fallback case root is a fresh temporary directory of
  its own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Following an operation the walk may not run copies at most
  MAX_COPIED_KEYS keys; past that the walk follows no batch, so no input
  makes following one quadratic.
- The batch sweep's fallback case root lies under an ASCII parent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Following an operation the walk may not run copies, and compares, at most
MAX_COPIED_BYTES bytes of keys as well as MAX_COPIED_KEYS keys; the cost
counters count bytes too, and a long stranded key is pinned.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…R B)

- A fragment whose removal by text turns on how MaybeAdjustFilePath spells
  it from the working directory has no key: the batch is unknown past it.
- A world is copied into a second outcome only while its table is small
  too, and a copy counts the table's capacity.
- The batch model's certainty tests are Unix-only, as its keys are; off
  Unix a multi-fragment Update declines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…R B)

- An element that may read an item list (@(Type)) may restart that type's
  batch: MSBuild computes the list there, once, and resumes past it with an
  empty batch; each batch gains that outcome. The batch sweep generates
  such a read.
- Under MSBuild's case-sensitive item names escape hatch, each spelling of
  an item type has its own batch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…R B)

- An element may read an item list wherever a text of it, after
  expansion, may hold an item reference: a group gate, an item's
  attributes or a metadatum, any spacing, through a property the walk is
  not certain of (when some property text, environment or global value
  may form a reference), or an expression the walk cannot expand. Each
  such element adds the restarted (empty) outcome to every batch where
  MSBuild reaches it: the group gate before its children, each child of
  a walked or fed group before its operation, and the whole of a group
  the pass only judges.
- Case-sensitive item names are out of the claim (#1162); the batch is
  keyed case-insensitively again.
- The batch sweep generates reads through a property only where it
  writes one; the commit floor is the measured 1/25.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…R B)

- An element's texts are read as MSBuild reads them before they are
  searched for an item reference: attributes decoded and, as a
  metadatum's, read again as XML; bodies with their CDATA sections and
  comments. A text the walk cannot read counts as a possible read.
- An expansion the walk is certain of is searched too: `$(At)(Compile)`
  with `At` holding `@` reads `@(Compile)`.
- Property bodies are read the same way, once per file, with no
  recursion through nested `<Choose>` arms.
- The batch sweep generates the new read spellings; its floor is the
  measured 1/30. Its certainty expectations are Unix's, where they
  depend on multi-fragment keys.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…PR B)

- Whether a text may read an item list is held to a positive domain: no
  item reference, and either no `$`, an expansion the walk is certain
  of that holds none, or (no property value may hold one) a text that
  cannot form one around a value: no `@`, no `%`, every `$(` a plain
  property reference. A property body outside that last shape (a
  function, spaced or not) may hold one.
- A metadatum body is read whole, mixed content included.
- An attribute is decoded from the attribute in hand
  (`document::attribute_value`), so the scan does no search by name.
- The batch sweep generates mixed-content and spaced-function reads;
  its fallback directory is the system's off Unix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Smaug123
Smaug123 force-pushed the issue-993-batch-model branch from 4eab5ab to 7b4a01a Compare November 26, 2026 00:53
Smaug123 and others added 5 commits November 26, 2026 01:39
…R B)

- A text that reads a name the walk holds no value MSBuild may hold of
  (`MSBuildStartupDirectory` with no startup directory given) may read
  an item list, and so may any text once a property body reads such a
  name.
- Whether a property value may hold an item reference is settled when
  the item pass starts, from the final table too: a value the walk
  seeds itself, or an environment or global value, holding an `@` or a
  `%`. That replaces the scan of environment and global values.
- The property-body scan stops, conservatively, at MSBuild's own
  `<Choose>` nesting limit.
- The generic sweep's floor off Unix is the one the walk held before it
  followed the batch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…R B)

- Environment and global values are scanned for a possible item
  reference again: a write may copy one before a later write replaces
  it, so the final table cannot answer for them. Each environment case
  of the test now has its own binding, so that none masks another.
- A body is skipped only for a group by its place (under `Project` or a
  `<Choose>` arm), not for a metadatum named `ItemDefinitionGroup`. The
  batch sweep generates that metadatum.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…PR B)

Each file the walk enters rebinds `MSBuildThisFile*` to its own path,
and a write there may copy one before the next file's rebinding, which
the final table no longer shows. Entering a file whose path holds an
`@` or a `%` marks property values as possibly holding an item
reference.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…R B)

- The read scan knows each element's role from the hook that hands it
  over, not from tag names: a group's gate, an item, and each metadatum
  of an item (whatever its name, `Project` and `ItemDefinitionGroup`
  included). A metadatum's body is read on its own, never as part of
  its item's serialised XML.
- The batch sweep places a read between two `Update`s of a run, and the
  corners hold each such spelling to design-time MSBuild in the sequence
  where a restart strands a fragment; every corner is now graded in
  design-time evaluation too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…R B)

- A spelling with a character `PathIsInvalid` names (`:`, `|`, a
  quote, ...) has no key, for `Remove`, `Exclude` and the batch alike:
  SDK 10.0.401 compares it as written and SDK 8.0.428 normalises it, so
  `a:b` and `./a:b` are two keys to one and one to the other.
- Two outcomes are compared by walking the table of smaller capacity,
  which is the cost counted, so a table a rollback left sparse is not
  walked again on every comparison.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Smaug123 and others added 3 commits November 26, 2026 10:17
…R B)

- A `CompileOrder` whose escaped, untrimmed text differs from the value
  the walk reads (` CompileFirst `, `Compile%46irst`) declines: the
  SDK's order target buckets the text as written, so such an item is in
  no bucket and is not compiled. The batch model let a multi-file
  `Update` carrying one commit; an `Include` or one-file `Update` had the
  same defect. Corners hold both spellings to MSBuild.
- The oracle's design-time `itemsMeta` returns escaped metadata, as the
  SDK's targets compare it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…R B)

- The design-time order reads `FullPath` unescaped once, as the build's
  own is, while `CompileOrder` stays escaped for bucketing.
- `an_item_list_read_between_updates_restarts_the_batch` forces each
  in-run read (a later item reads `@(Other);@(Project)`) and pins
  design-time MSBuild's order per spelling apart from the walk: six
  restart the batch, the metadatum of an item named `Project` does not.
  The walk declines all seven.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…R B)

- The pinned read test names files with `Path::file_name`, so a host's
  separators do not decide it.
- The cases lie under a directory the walk keys (ASCII letters, digits
  and `/._-`), not merely an ASCII one, so a checkout under `/tmp/p|q`
  cannot change a corner's verdict.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant