Skip to content

fix(xvm): materialize the group's declared headers, not one member's includedir - #406

Merged
Sunrisepeak merged 1 commit into
release/0.4.70from
fix/xvm-binding-headers
Jul 26, 2026
Merged

Sunrisepeak merged 1 commit into
release/0.4.70from
fix/xvm-binding-headers

Conversation

@Sunrisepeak

Copy link
Copy Markdown
Member

Closes the second of the two gaps recorded during the PR #402 architecture review. Stacked on #405 conceptually but touches disjoint files.

The problem

bindingHeaders records every header directory a release declares, on the group root. #384 serialized it, parsed it, validated it, and round-tripped it through the version database.

Nothing ever read it.

Materialization went through VData::includedir instead — a single string the installer writes on the root with last-op-wins semantics:

install xlings use
release declares 1 header dir materialized switched
release declares 2 header dirs both materialized only the last switched

So switching away left the other directories' headers in the sysroot, and switching in never brought the incoming release's copies. The sysroot ended up holding a mix of two releases — the exact state the binding-group work exists to make unrepresentable, reached through the header path rather than the member path.

The fix

xvm::group_header_assets(db, target, version) resolves any member of a release to the group's declared list, falling back to includedir when there is none (0.4.69 state has no bindingHeaders; neither does a registration outside a provider group). The switch planner, the removal teardown and the removal fallback all go through it.

Headers move from MemberSwitch to UseSwitchPlan

They belong to the release, not to any member of it. Per-member lists would be wrong twice:

  1. Every member of a group resolves to the same declaration → the same directory linked once per member.
  2. Worse — the loop applied them one member at a time. Member B's removal of the outgoing release could delete links member A had just installed for the incoming one, for every header name the two versions share. For two versions of one toolchain, that is all of them.

The plan now carries removeHeaders and installHeaders deduplicated and disjoint, and cmd_use applies all removals before any install. An asset both releases need is never removed at all — which matters because use re-materializes the active release on every call to repair a drifted sysroot, and remove-then-relink would open a missing-header window on every one of those calls.

destinationPrefix is honored

<sysroot>/include/<prefix> rather than flattening into the include root, and an emptied prefix directory is cleaned up (via remove, so it cannot take a directory it does not own).

includedir is still written

Now for exactly one reason: 0.4.69 switches headers by reading it and knows nothing about bindingHeaders. Dropping it would make a downgrade silently stop moving headers, and the release notes promise the rollback is safe. It records only the last declared directory — which is the limitation 0.4.69 already had, so a downgrade gets the old behavior back, not a worse one.

Reachability, stated plainly

No recipe in the official index declares header directories at all, and xvm.setup can only declare one per call — calling it twice is refused as a duplicate registration (correctly, by #384's registration layer). So the multiplicity this fixes is currently unreachable through the public recipe API.

It is still worth fixing: the field is persisted, validated and round-tripped today. Leaving it unconsumed is the next "written but never read" value, and the first recipe that needs two header directories would hit a silent half-switch instead of an error.

The E2E fixture pushes the second headers op onto _XVM_OPS directly to exercise the path.

Verification

  • 6 new unit cases (XvmGroupHeaders) + 2 for the destination prefix
  • E2E-32 extended: the fixture now ships include/ and include-fixed/, both version-stamped, and every scenario asserts both moved
  • Red-phase confirmed:
    • reverting the resolver fails 3 unit cases
    • and fails E2E-32 scenario 2 with sysroot header is '1.0.0', expected '2.0.0' — the workspace and include-fixed/ on 2.0.0 while include/ stayed on 1.0.0, i.e. the split this PR removes
  • Regression: E2E xvm_group_switch / remove_multi_version / xpkg_snapshot_remove / subos_xpkg_install / install_idempotent all pass locally; 11 unit binaries green

Also in this PR

Release-notes update covering both review findings (this one and #405's lock coverage), including the honest note about reachability above.

…includedir

`bindingHeaders` records every header directory a release declares, on the
group root, and #384 serialized it, parsed it, validated it and round-tripped
it through the version database. Nothing ever read it.

Materialization went through `VData::includedir` instead -- a single string
the installer writes on the root with last-op-wins semantics. For a release
declaring one header directory the two agree. For one declaring two they do
not: install materializes both, because it walks the effect list, while
`xlings use` only ever remembers the last. Switching away left the other
directories' headers in the sysroot and switching in never brought the new
release's copies. The sysroot held a mix of two releases -- the exact state
the binding-group work exists to make unrepresentable, reached through the
header path instead of the member path.

`xvm::group_header_assets(db, target, version)` resolves any member of a
release to the group's declared list, falling back to `includedir` when there
is none -- 0.4.69 state has no `bindingHeaders`, and neither does a
registration outside a provider group. The switch planner, the removal
teardown and the removal fallback all go through it.

Header assets also move from MemberSwitch to UseSwitchPlan, because they
belong to the release rather than to any member of it. Per-member lists would
link the same directory once per member, and -- worse -- the loop applied them
one member at a time, so member B's removal of the outgoing release could
delete links member A had just installed for the incoming one, for every
header name the two versions share. Which, for two versions of one toolchain,
is all of them. The plan now carries the two lists deduplicated and disjoint,
and `cmd_use` applies all removals before any install.

`destinationPrefix` is honored too. No recipe can set it today -- libxpkg's
`xvm.setup` takes a bare `includedir` -- but it is part of the persisted model
and round-trips, and a serialized field materialization ignores is what this
change is removing, not adding.

`attach_legacy_header_dir` still writes `includedir`, now for one reason only:
0.4.69 switches headers by reading it and knows nothing about
`bindingHeaders`, so dropping it would make a downgrade silently stop moving
headers. The release notes promise the rollback is safe.

Reachability, stated plainly: no recipe in the official index declares header
directories at all, and `xvm.setup` can only declare one per call (a second
call is refused as a duplicate registration). So the multiplicity this fixes
is currently unreachable through the public recipe API. The E2E fixture pushes
the second op onto `_XVM_OPS` directly to exercise it.

Verified: 6 new unit cases (XvmGroupHeaders) + 2 for the destination prefix;
E2E-32 extended with a second header directory. Reverting the resolver fails
3 of the unit cases and E2E-32 scenario 2, which reports the sysroot holding
1.0.0's `include/` while the workspace and `include-fixed/` are on 2.0.0.
@Sunrisepeak
Sunrisepeak merged commit 63105f5 into release/0.4.70 Jul 26, 2026
7 checks passed
Sunrisepeak added a commit that referenced this pull request Aug 10, 2026
… costs

The cross-build lane went red on main, not just here. mcpp 2026.8.10.1's host
toolchain post-install fixup binds `[email protected]` while the resolver installs
2.44 -- latest since xim-pkgindex#582 -- and refuses to fall back.

Established by re-running ONE unchanged run id across the index bump that made
mcpp 2026.8.10.1 latest (xim-pkgindex#588, 01:55Z): the same commit passed with
mcpp 2026.8.8.4 at 19:09 and failed with 2026.8.10.1 at 03:41. Same workflow,
same runner image. Also reproduces locally against UNMODIFIED libxpkg 0.0.55,
which is what rules out this branch as the cause.

Filed as mcpp-community/mcpp#406.

The pin is temporary and it is not free: this job takes the latest mcpp on
purpose, to be the canary for exactly this. Pinning it muzzles the canary, so
the comment names the removal condition rather than sitting there as an
unexplained version. Until #406 lands, breakage against the newest mcpp is
invisible on this lane.

Also adds the 2026.8.10.2 release notes.
Sunrisepeak added a commit that referenced this pull request Aug 10, 2026
…it cannot (2026.8.10.2) (#526)

* fix(deps): a cold home can install gcc again, and CI can see it when it cannot (2026.8.10.2)

2026.8.10.1 began filling `dependency_store_roots` on every install, and
shipped libxpkg 0.0.55 in the same release. Either alone is inert; together
they executed a path where `dep_install_dir` gated on how specific the QUERY
was rather than on whether the ANSWER was unique. Six of the seven call sites
in xim-pkgindex returned nil: gcc and meson could not install on any cold home
-- new machines, cold CI caches, `fresh-install`, and every downstream mcpp
build -- while godot silently fell back to the host's GL and the graphics
banner reported `unknown`.

The fix is libxpkg 0.0.56 (`resolved_dep` judges ambiguity, which its own
uniqueness guard already decided, and matches the version half as the RANGE a
recipe actually writes). This commit takes that dependency and adds the thing
that was missing on this side: a way to notice.

**E2E-79, and why it has to be cold.** A warm home skips the install, so the
config hook never runs -- which is exactly why every lane here stayed green
while the released binary could not install a toolchain. The first detector
was a downstream repo's cache miss. This test is that detector, in-tree: a
consumer declares a namespaced ranged coordinate, the resolver places the
dependency, and the hook must find it. Verified against both builds -- it
fails on libxpkg 0.0.55 with "this is #524" and passes on 0.0.56.

It also pins the other half of the contract, with a second consumer that asks
for something it never declared: that must fail, name the coordinate, and say
it is not a declared dependency. "Cannot answer" and "is not installed" made
the same nil for a whole release, and that is what sent the bug report looking
for a missing glibc that was sitting on disk.

**`.agents/tools/repro-dep-install-dir.sh`** replays all seven real call
shapes against any libxpkg revision offline -- no network, no install, no home
touched. It reads the file out of git, and takes `worktree` for an
uncommitted one, because otherwise a fix that is not yet committed tests as if
it did not exist.

Root cause, blast radius and the #525 analysis:
`.agents/docs/2026-08-10-issue-524-525-root-cause-and-fix-design.md`
Task graph and cross-repo order:
`.agents/plans/2026-08-10-issue-524-525-implementation.md`

Refs #524, #525

* ci(aarch64): pin mcpp to 2026.8.8.4 until mcpp#406, and say what that costs

The cross-build lane went red on main, not just here. mcpp 2026.8.10.1's host
toolchain post-install fixup binds `[email protected]` while the resolver installs
2.44 -- latest since xim-pkgindex#582 -- and refuses to fall back.

Established by re-running ONE unchanged run id across the index bump that made
mcpp 2026.8.10.1 latest (xim-pkgindex#588, 01:55Z): the same commit passed with
mcpp 2026.8.8.4 at 19:09 and failed with 2026.8.10.1 at 03:41. Same workflow,
same runner image. Also reproduces locally against UNMODIFIED libxpkg 0.0.55,
which is what rules out this branch as the cause.

Filed as mcpp-community/mcpp#406.

The pin is temporary and it is not free: this job takes the latest mcpp on
purpose, to be the canary for exactly this. Pinning it muzzles the canary, so
the comment names the removal condition rather than sitting there as an
unexplained version. Until #406 lands, breakage against the newest mcpp is
invisible on this lane.

Also adds the 2026.8.10.2 release notes.
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