Skip to content

fix(xvm): move a whole surviving release, or none, after removal - #392

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

Sunrisepeak merged 1 commit into
release/0.4.70from
fix/xvm-removal-fallback

Conversation

@Sunrisepeak

Copy link
Copy Markdown
Member

P0.3 of the 0.4.70 release train — 补上 #384 设计文档承诺但未实现的一致性回退。

Problem

#384 的设计文档 §7.1 承诺:

switches an active group to a complete surviving group… otherwise clears all removed members coherently

实现(removal.cppm:312-325)是:

for (auto versionIt = installedIt->second.rbegin(); ...)   // 逐 target,按 installed[] 插入序取最后一个

逐 target 独立搜索,无 group 校验。 两个 target、两次独立搜索、没有共同答案。

红阶段实测的三种故障(这些正是本 PR 的测试对旧实现的失败输出):

Which is: "musl:15.1.0"
g++ fell back to a different provider than gcc          ← 混合工具链,原样重现

a lone member was activated without the rest of its group

Which is: { ("g++", "15.1.0"), ("gcc", "15.1.0") }      ← installed[] 升序
Which is: { ("g++", "15.1.0"), ("gcc", "14.1.0") }      ← installed[] 降序,结果不同

第三条意味着同一份数据库在两台机器上可以解析出不同结果 —— installed[] 只是用户碰巧的安装顺序。

Change

整组迁移,或者不迁移。 候选合格的条件:其 group 能解析,且每个成员都已注册、已加入本 subos 的 installed[]、且不与已激活的版本冲突。候选按版本降序(不再按 installed[] 顺序)。

无完整组存活时,成员保持未激活,由用户显式重选。

未激活的工具链是看得见的问题;不一致的工具链不是 —— gcc --version 报的是对的,要到链接期才炸。

顺带修了一层更深的不确定性:pick_highest_version 里的内联比较器不是严格弱序 —— 仅 namespace 不同的键(15.1.0 vs musl:15.1.0)双向比较都返回 false,谁排在前面取决于输入顺序。提取为 xvm::version_key_greater 并补了全序 tiebreak。

Tests

5 条,其中 3 条经验证对旧实现为红(失败输出即上文的 bug 原文):

测试 旧实现
IncoherentSurvivorDeactivatesTheWholeGroup ❌ g++ 回退到 musl
NoCompleteSurvivorLeavesEveryMemberInactive ❌ 激活了孤立成员
ResultDoesNotDependOnInstalledOrder ❌ 结果随插入序变化
CoherentSurvivingGroupIsActivatedWholesale ✅ 双方都过(护栏)
UngroupedLegacyTargetStillFallsBack ✅ 双方都过(护栏,确认 legacy 单例不受影响)

一处既有测试改的是 fixture 而非期望

RemoveAllDeletesOnlyExecutingProviderAcrossReleases 构造的回退候选 cc@repo-b:9.0.0,其 binding-group root(root-b-9)从未注册 —— 一个悬空组。该测试依赖这个悬空条目被激活,而这正是新回退拒绝的状态,也正是评审里"use 沿着残缺边继续遍历,最后把不存在的版本写入 active workspace"那条根因。

把该条目改成自根(self-rooted)并带 manifest。测试的主题 —— provider 范围内的 remove_all —— 未改动,断言原样保留。

如果保留原 fixture 而放宽实现去迁就它,等于把要修的 bug 重新引入。

Verification

mcpp build   →  Finished release [optimized] in 44.98s
mcpp test    →  test result ok. 11 passed; 0 failed
XvmRemovalFallbackTest  →  5 passed

CI 状态为已知上游拉取签名(见 #386),依计划 §3.1.1 合入集成分支。

Removing the active release left every member of it looking for a
replacement on its own: per target, walking installed[] backwards, with
no check that the versions picked belong together.

Two targets, two independent searches, no shared answer. Removing GCC 16
with GCC 15 and a musl build of g++ both installed reactivates gcc as
GCC 15 and g++ as musl 15 -- the mixed toolchain this whole model exists
to prevent, reintroduced at the moment of removal. It also depended on
installed[] insertion order, which is just the order the user happened
to install things in, so the same database could resolve differently on
two machines.

Reactivate a whole surviving release at once or nothing. A candidate
qualifies only when its group resolves and every member is registered,
opted into this subos, and does not contradict an already-active
version. Candidates are ordered by version, highest first, so the answer
no longer depends on installed[] order.

When no complete group survives the members stay inactive and the user
re-selects explicitly. An inactive toolchain is a visible problem; an
incoherent one is not -- it reports the right versions from
gcc (XPKG: xlings install fromsource:gcc) 15.1.0
Copyright (C) 2025 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. and fails much later at link time.

Also adds xvm::version_key_greater and routes pick_highest_version
through it. The comparator it replaces was not a strict weak ordering:
keys differing only by namespace (15.1.0 vs musl:15.1.0) compared
equal both ways, so which one sorted first depended on input order --
the same nondeterminism, one layer down.

Tests: five cases. Three fail against the previous implementation, and
their failures are the bug verbatim -- g++ landing on musl while gcc
lands on GCC, a lone member activated without its group, and gcc
resolving to 14.1.0 or 15.1.0 depending only on installed[] order.

One pre-existing test needed its fixture corrected rather than its
expectation. RemoveAllDeletesOnlyExecutingProviderAcrossReleases built a
fallback candidate whose binding-group root was never registered, and
relied on that dangling entry being activated -- precisely the state
reactivation now refuses. The entry is now self-rooted with a manifest;
the test's subject, provider-scoped remove_all, is untouched.
@Sunrisepeak
Sunrisepeak merged commit 8367c26 into release/0.4.70 Jul 26, 2026
Sunrisepeak added a commit that referenced this pull request Aug 9, 2026
… never committed

.agents/docs/2026-08-10-pr519-review-and-completion-design.md
  A review of #519 with each finding carried through to a measurement. Two of
  my own calls did not survive it: R5 (I read payload_of's return backwards --
  it slices the caller's spelling, exactly like store_root_of, and the existing
  Windows test was already guarding that) and R2(b) (by_identity resets on a
  store-name mismatch, so a stamped row's identity is never rewritten and the
  pre-filter cannot disagree with itself). Both are kept and marked, because
  the gap between what I expected and what the home actually held is the part
  worth reading. R4 went the other way: a finding I rated "needs a number"
  turned out to be 143 false positives.

  Headline measurement, real 71 GB home: `self doctor` 195.16s -> 0.63s.

.agents/plans/2026-08-10-pr519-completion-implementation.md
  Task split and cross-repo DAG for the rest. Names the three places where the
  angles conflict (stability vs consistency, compatibility vs architecture, UX
  vs seamless upgrade) and how each was decided, since those are where this
  round was easiest to get wrong. Also records that mcpp #392 does NOT need the
  published xlings it was scheduled behind.

.agents/docs/2026-08-09-instant-query-and-userspace-os-architecture-design.md
.agents/docs/2026-08-09-open-issues-deep-triage.md
  Existed only in a working tree. The first is the groundwork for #518; the
  second triages all 44 open issues. Committing them so neither depends on a
  directory surviving.
Sunrisepeak added a commit that referenced this pull request Aug 10, 2026
…ctually runs (#528)

Reverts both mcpp#406 workarounds and removes the cause instead.

**The lie, and who tells it.** `subos_info.runtime` is the SubOS's declaration
of which glibc it runs. v2026.8.8.1 -- the pinned bootstrap here -- stamped it
from a CONSTANT when it created the default SubOS: `[email protected]`, on a home that
then resolved and installed glibc 2.44 (index latest since xim-pkgindex#582).
The record was false the moment it was written.

mcpp reads it as authoritative and refuses to fall back, which is CORRECT --
its own #392 guard exists because an INTERP from one glibc and a RUNPATH from
another segfaults before main with no diagnostic. Given a truthful record it
does the right thing. Given ours it failed, two repos away, as

    selected RuntimeBinding [email protected] requires payload .../xim-x-glibc/2.39,
    but it is not installed

2026.8.10.1 is the first release that declares the version actually ACTIVE
instead of a constant, so the record it writes is true by construction.
Verified on an isolated home created by it: declaration `[email protected]`, payload
2.44, farm libc.so.6 -> 2.44, and every install through it succeeded --
including the cold gcc and meson installs this round is about.

**The architectural defect is still open**, and it is ours, not mcpp's.
`check_runtime_activation` has exactly two consumers: `xlings use`, which
REFUSES to activate a runtime the SubOS does not declare, and
`doctor --fix`, which adopts. The install path calls neither -- so an install
can resolve and activate a glibc the SubOS never declared, and nothing
reconciles the declaration afterwards. One rule, two write paths, one
enforcer: the reporter/repairer drift this codebase keeps producing. Filed
separately; a bootstrap that starts out truthful does not make a declaration
that can drift correct.

So: `xlings-ci-aarch64` goes back to taking the LATEST mcpp. It is the canary
for exactly this class of breakage and it caught this one; pinning it would
have muzzled it, and the second pin (release.yml's cross-build mcpp clone) is
reverted with it.
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