Skip to content

fix: recover CLI stability and runtime safety - #519

Merged
Sunrisepeak merged 33 commits into
mainfrom
fix/stability-regression-recovery
Aug 9, 2026
Merged

Sunrisepeak merged 33 commits into
mainfrom
fix/stability-regression-recovery

Conversation

@Sunrisepeak

@Sunrisepeak Sunrisepeak commented Aug 9, 2026 •

Copy link
Copy Markdown
Member

范围

本 Draft PR 恢复 xlings 的稳定性与本地命令即时响应,并收口真实正确性问题:

架构取舍单独讨论于 #518。D6 本轮继续使用版本化 JSON,不引入 SQLite。

相关问题:#506、#513、#514、mcpp-community/mcpp#392。

头条:真实 71 GB home 上的实测

命令 2026.8.9.2 本 PR
self doctor(默认) 195.16s 0.63s 310×
info gcc 17.357s 0.143s 121×
list gcc 7.398s 0.132s 56×
list 7.411s 0.204s 36×

切片由 .agents/tools/slice-real-home.sh 构建,跑完 verify-untouched 证明真实 store 未被改动。

第二轮评审(2026-08-10)修掉的 7 个问题

第一轮交付后做了一次带实测的评审,见
.agents/docs/2026-08-10-pr519-review-and-completion-design.md。
其中两条我自己的判断被测量推翻,也留在文档里。

问题 实测
R0 升级过的老 home 被判成 Error 且 use 走不出来 真实 home 普查:35 个 SubOS 只有 2 个有 runtime 声明,33 个 ABSENT,其中 20 个有 active glibc —— 升级时被盖成 [email protected] 而实际在跑 2.39 → doctor Error + use glibc 2.39 被拒,提示的唯一出路「新建 SubOS」是假死局(正向迁移一直是通的)
R1 subos use --sandbox --cmd '…' 缺名字时 exit 0 且不执行 本轮验收命令本身就是这个形状;--shell 更严重,候选表会进入被 eval 的 stdout
R2 list <filter> 可能是 list 的真子集 前置跳过判定只走出边,反向可达的 owner 看不见
R3 remove 的退出码与它自己三行外的注释矛盾 拆成两个问题:裸名 = 「确保没了」exit 0;@版本 = 「删这个版本」exit 1
R4 ELF 规则一次放宽三处,无增量测量 baseline 2 → 147,其中 143 条是误报:PT_INTERP 指向 SubOS 视图被当成宿主 loader。修后 143→0,剩下 2 条是真的(godot:我们的 loader + 宿主 libc)
R6 get_catalog 自愈分支在一条真实路径上永不触发 默认构造的 expected 是成功值
R7 --fix --scope X 只窄化检测不窄化修复 改文案让说的和做的一致
R5 Windows 路径拼写不一致 ❌ 我读反了,payload_of 返回原始拼写,本来就一致。改动已回滚,既有测试是对的

验证证据

  • 完整 Linux unit:36/36
  • 受影响 E2E:18/18(含新增 subos_runtime_declaration_upgrade_test.sh 三态、4 条 subos use 无名修饰符用例、remove 两半契约)
  • test_generated_command_reference / test_cli_spec_parity(240 option spellings、64 parser literals)/ test_docs_examples 全过
  • no_xlings_version_pin_check.sh 过
  • 真实 store verify-untouched 干净
  • push 前 whitespace、本机身份/路径/凭据扫描通过;工作区干净,未改写历史

版本

2026.8.10.1。计划里的预期值 2026.8.9.3 已过期(最新 tag v2026.8.9.2,今天 2026-08-10),
按计划自身「cut 前重新计算」的约束重算;常规修复不使用 .0。

剩余闭环

见 .agents/plans/2026-08-10-pr519-completion-implementation.md。
全平台 CI terminal green → squash merge → release → 本地 gtc 补 GitCode → GET+sha256 →
xim-pkgindex pointer A → xlings subos <name> --sandbox --cmd 真实验证 → mcpp #392 / pointer B。

mcpp #392 不依赖本 PR 发布:它读的是编译器所属 registry home 的 SubOS manifest,
subos_info.runtime 自 2026.8.5.1 起就在公开发布里,可以立即并行开工。

过程约束

  • Draft PR + additive commits;禁止 amend、rebase、force-push
  • E2E 使用隔离临时状态,不触碰真实用户环境
  • 本地通过、远端当前 HEAD 通过、发布后公共链路通过是三类独立证据
  • release 后不把 xlings 版本 pin 进 fresh-install CI

@Sunrisepeak

Copy link
Copy Markdown
Member Author

Checkpoint 2026-08-09: query-stall recovery is recorded in c749a58..1e5c3e9; the clean-runner assertion fix is 898676a; doctor quick/deep separation is d6752e3; macOS module portability follow-ups are 1199f21 and db4cc0b. Runtime-authority work is now in RED/GREEN development. All remaining slices will be added as granular commits to this Draft PR, without amend/rebase/force-push, and each staged diff will be checked for local usernames, machine names, credentials, and private paths before push.

@Sunrisepeak

Copy link
Copy Markdown
Member Author

Runtime checkpoint pushed as 71b996c. The shared guard now rejects host-loader plus payload core runtime, cross-payload and cross-provider loader/libc splits, mixed SubOS core symlinks, and copied host core paths; leaf graphics libraries remain legal. SubOS runtime authority now compares manifest declaration with the exact active workspace version, rejects ordinary mismatching use before legacy self-heal or config writes, preserves multiple global glibc payloads, and cannot be bypassed by unrelated manifest defects. Verification: clean no-cache unit run 36/36 targets; SameSource 16/16; SubosRuntime 5/5; full unfiltered unit run 36/36; three focused runtime E2Es pass. Staged and committed diffs passed private-path, username, machine-name, credential, and whitespace scans.

@Sunrisepeak

Copy link
Copy Markdown
Member Author

Design checkpoint pushed as 36df44a. It adds the stabilization design and the cross-repository dependency/task plan, marks Tasks 1-7 with recorded evidence, links the separate architecture discussion in #518, keeps D6 on versioned JSON rather than SQLite, and removes local worktree/user paths before publication. Tasks 8-16 remain explicitly pending in the plan.

@Sunrisepeak

Copy link
Copy Markdown
Member Author

Task 8 checkpoint — #513/#514 host integration (8a325be)

The PR remains Draft. #506, SubOS candidate UX, native-CI follow-ups, final integrated gates and release are still pending.

@Sunrisepeak

Copy link
Copy Markdown
Member Author

Native-CI follow-up checkpoint (2ad98a0, af7bbd7)

The previous Draft head exposed two independent runtime regressions, now fixed in separate additive commits:

  • macOS canonical path aliases made one payload look like two identities. Added a symlinked-store RED test; focused SameSource gate is now 20/20. Existing paths are compared canonically, while diagnostics retain their original spelling and unmaterialized paths remain lexical.
  • The candidate aarch64 cold-home contract failed because a declared-but-not-yet-materialized default runtime was counted as a broken active payload. It is now a visible non-fatal warning only when both active binding and payload are absent. Active-version mismatch and active-version payload loss remain fatal; the runtime-authority E2E still verifies exact refusal and zero writes.

Both commits passed focused RED-to-GREEN gates, diff checks and privacy/credential scans. A fresh native matrix is running at the new head.

@Sunrisepeak

Copy link
Copy Markdown
Member Author

Task 9 / #506 checkpoint — commit 1436867

  • Removal selection is now scoped to the provider executing the uninstall hook. A same-name version owned by another provider neither blocks the hook nor enters the removal set.
  • A dependency-free payloadless config may reach uninstall only when its exact local/snapshot recipe proves an uninstall hook; an unknown exact coordinate remains NotFound.
  • Preservation E2E confirms the foreign provider DB entry, workspace entry, shim, and payload remain unchanged.

Fresh verification at this commit:

  • full unit suite: 36/36 targets passed
  • remove_foreign_provider_delegator_test.sh: PASS
  • config_install_no_implicit_dir_test.sh: PASS
  • remove_orphan_payload_test.sh: PASS
  • focused XVM removal matrix: 8/8 passed
  • git diff --check: clean
  • committed-file/privacy scan: clean

The PR remains Draft. Next additive commits address the Windows path-separator regression and the namespace E2E setup that still assumed query-side index sync.

@Sunrisepeak

Copy link
Copy Markdown
Member Author

Native-CI follow-up checkpoint:

  • 6f229b1 fixes Windows-native store parsing by recognizing both filesystem separators while preserving the original path spelling for diagnostics. The portable backslash regression case and the complete same-source matrix pass (21/21).
  • 7ada4cc updates the namespace E2E to materialize local indexes through explicit xlings update; query commands remain LocalOnly and do not regain implicit sync behavior.

Focused verification:

  • same-source runtime matrix: 21/21 passed
  • index_same_name_namespace_test.sh: PASS
  • local_query_no_index_sync_test.sh: PASS, including CLI, interface, remove lookup, sandbox lookup and doctor structural checks
  • git diff --check and privacy scan: clean

Both are additive commits on the existing Draft PR. Native checks are rerunning at the new head.

@speak-agent

Copy link
Copy Markdown
Collaborator

交接文档:稳定性回归恢复与运行时闭环

更新时间:2026-08-09

当前主 PR:#519(Draft)

独立架构讨论:#518

一、目标与边界

本轮不是做泛化重构,而是先恢复 xlings 作为通用用户态 OS/包管理基础设施应有的稳定性:

  1. 彻底修复 xlings info/list/self doctor 等本地命令卡顿,恢复“不需要网络时立即返回”的契约;
  2. 修复 install hook: stdout/log.error/stderr swallowed — failing install() surfaces only as an empty E_INTERNAL #513、pkginfo.install_dir() returns nil for a dependency that exists only in the shared registry cache #514、remove fails on a package that delegates its install: "exact removal version is not registered" #506 三个真实正确性问题;
  3. 在允许多份 glibc/runtime payload 共存的前提下,保证一个 SubOS 同一时刻只有一个精确生效的 core runtime;
  4. 改善 xlings subos use:无参数列候选,支持安全的大小写/唯一前缀匹配,歧义时绝不猜;
  5. 之后用已发布的 xlings 完成 mcpp fix(xvm): move a whole surviving release, or none, after removal #392、图形栈、真实 sandbox/GPU、跨平台发布与公共索引闭环。

明确边界:本轮 D6 继续使用版本化 JSON,不引入 SQLite;图形栈以稳定现有能力和真实验证为主,不为了 mcpp 做专用适配。

二、已经完成并进入 PR #519 的工作

1. 设计、依赖关系与跨仓前置

2. 本地命令卡顿与查询正确性

提交范围:c749a58..1e5c3e9,测试状态修正为 898676a。

  • 将查询路径与索引同步解耦:info/list/remove lookup/sandbox lookup/doctor 的本地查询不再隐式拉取或同步索引。
  • info <pkg> 改为 targeted inventory;list <filter> 先过滤再加载,不再无条件遍历完整 catalog、payload 与全局状态。
  • 补齐 provider/namespace/legacy identity 规则:能证明唯一身份才继续,歧义时 fail closed,避免为了“快”而返回错误包。
  • 真实旧 HOME 对照结果:
    • info gcc:约 17.357s -> 0.143s
    • list gcc:约 7.398s -> 0.132s
    • list:约 7.411s -> 0.204s
  • 新旧 stdout 对照保持一致,112 行清单无语义回退;相关 unit 36/36、查询 E2E 3/3 通过。

3. doctor quick/deep 分层

提交:d6752e3、1199f21、db4cc0b、919c3ef,后续冷 runtime 修正为 af7bbd7。

  • 默认 xlings self doctor 为 quick:只做结构/配置/绑定一致性检查,不启动 patchelf、getent 或递归子 xlings。
  • --deep 才做 payload/ELF 审计,并有明确上限;500 ELF / 1000 read 的边界测试没有越界扫描。
  • scope 缺失、未安装或歧义会在扫描前失败。
  • “声明了但尚未 materialize,且没有 active binding/payload”的冷 runtime 只给可见 warning;active version 不一致或 active payload 丢失仍为 fatal。
  • 修复了 macOS module 构建中的 <cstdio> global-fragment 问题和 raw const char* format 参数问题。

4. SubOS runtime 权威与图形叶子库边界

提交:71b996c、2ad98a0、6f229b1。

  • 新增双向 core-runtime guard,拒绝 host loader + payload libc、跨 payload/provider 的 loader/libc 拆分、SubOS core symlink 混用和复制出的 host core path。
  • 同一个 SubOS 必须让 manifest 声明与 active workspace 精确一致;拒绝发生在 legacy self-heal、配置写入或 shell 进入之前,因此失败路径不改状态。
  • 全局可以并存多份 glibc/runtime payload;限制的是“一个 SubOS 当前只能有一个精确 active runtime”,不是全局单例。
  • 图形/音频等 leaf library 仍允许合法组合,不把整套图形栈错误提升为 core runtime。
  • macOS symlink/canonical alias 以实体身份比较但保留原始诊断路径;Windows store path 同时识别 / 与 \,不依赖 POSIX 分隔符。
  • focused SameSource 21/21、SubosRuntime 5/5、runtime E2E 通过。

5. #513 / #514 的 xlings host 集成

提交:8a325be。

6. #506 provider-aware removal

提交:1436867。

  • removal 只按执行 uninstall hook 的 provider 判断 ownership;其他 provider 的同名版本不阻塞、不进入删除集合。
  • dependency-free、payloadless config 只有在 exact local/snapshot recipe 能证明 uninstall hook 时才允许进入卸载;未知坐标仍返回 NotFound。
  • E2E 已验证 foreign provider 的 DB、workspace、shim、payload 均保持不变。
  • full unit 36/36,focused XVM removal 8/8,三条关键 removal E2E 通过。

7. 原生 CI 暴露后的增量修复

  • 2ad98a0:修复 macOS canonical alias 被误判为两个 payload identity。
  • af7bbd7:修复 aarch64 冷 HOME 的 runtime declaration 假阳性。
  • 6f229b1:修复 Windows 原生反斜杠 store path 解析。
  • 7ada4cc:namespace E2E 显式执行 xlings update;没有把隐式 query-side sync 加回来。

评论发布时,PR 远端 HEAD 为 7ada4cc:Linux、Linux E2E、Linux root、macOS、aarch64 cross/QEMU/native 均已通过;Windows build-and-test 仍在运行。此 CI 只覆盖远端 HEAD,不包含下述尚未提交的 Task 10。

三、当前工作区已有、但尚未提交/推送的 Task 10

目标:xlings subos use 候选发现与安全模糊匹配。

当前实现已完成:

  • xlings subos use 无参数不再报 missing argument,而是只读输出排序后的候选和 active 状态;不创建环境、不改 current link、不启动 shell。
  • 候选只有一个权威来源:home registry 的 subos 对象;兼容旧布局时只在 manifest 存在的情况下有界合成一次 default,不扫描任意目录、不写迁移状态。
  • 匹配顺序:大小写敏感 exact → 唯一大小写不敏感 exact → 唯一大小写不敏感 prefix。
  • 大小写碰撞或多 prefix 返回歧义错误且不进入环境;substring/edit-distance 仅给最多 3 个建议,从不自动进入。
  • CLI、interface、agent text renderer、TUI 共用同一个 candidate/resolver;interface 发 subos_candidates DataEvent,并记录 query、reason、候选、是否自动选择和 canonical selected name。
  • subos list 与 subos use 共用候选视图;use 的解析路径不统计 tool 数量,避免把 bin 扫描重新放回热路径。
  • CLI spec 已把 name 改成 optional,生成的 command reference 已同步。

已跑过的验证:

  • RED:无参数在旧实现返回 missing argument;spec 的 validate_manual_argv({"use"}) 失败。
  • GREEN:CommandSpec 7/7;完整 unit 36/36。
  • 新 candidate E2E 通过:无参数只读、exact、大小写 exact、唯一 prefix、歧义、未知建议、interface 自动选择、大小写碰撞、legacy default、空候选提示。
  • 受影响的既有 E2E 全部通过:subos_xpkg_use_cmd、subos_shell_level、subos_events、subos_use_process_model、local_query_no_index_sync。
  • git diff --check、已跟踪与新增文件的本机身份/路径/凭据扫描均干净;新增 E2E 保持 executable。

尚未做的收口:

  1. 复核 D4 event reason 枚举:实现新增了 case_insensitive_exact / unique_prefix,设计文档目前只列 missing_name | ambiguous | not_found,需要同步后再提交。
  2. 重跑 generated command reference 和 CLI spec parity。
  3. 将这一组 10 个已跟踪文件 + 1 个新增 E2E 作为独立 additive commit 提交,建议提交信息:fix(subos): discover and resolve use candidates safely。
  4. 推送后发布 checkpoint,并等待新 HEAD 的完整原生 CI。
  5. 计划文档中 Task 8/9/10 的 checkbox 仍未回填,建议另做一个 docs(plan) 追踪提交,不要混进行为修复提交。

四、过程中遇到的主要问题与结论

  1. 卡顿不是“网络偶尔慢”,而是热路径设计回归。 本地只读命令意外承担了 index sync、完整 catalog/materialization、全量 inventory 与外部探测;修复必须从调用图移除副作用,而不是加超时或缓存掩盖。
  2. 性能修复很容易破坏身份语义。 targeted query 必须同时处理 namespace、provider ownership、legacy chain 和歧义;不能把“找到第一个同名包”当成优化。
  3. doctor 的 quick/deep 不是输出选项,而是执行预算契约。 默认路径不能递归调用 CLI,也不能把全 payload ELF 扫描伪装成健康检查。
  4. runtime 不能按目录顺序选择。 多份 glibc payload 合法,但 active runtime 必须由 SubOS manifest + workspace 的精确坐标共同决定;目录遍历顺序没有权威性。
  5. 路径身份与展示路径必须分离。 macOS symlink/canonical path 和 Windows separator 都证明了字符串比较不可移植;比较用 canonical identity,诊断保留用户看到的原路径。
  6. 冷状态与损坏状态不能混为一谈。 未 materialize 的声明不是 active runtime 损坏;只有已激活不一致或 active payload 缺失才应 hard fail。
  7. 测试夹具曾依赖被移除的隐式行为。 namespace E2E 原先靠查询命令偷偷同步索引;正确修复是显式 materialize fixture,而不是恢复副作用。
  8. optional positional 会与 shell 命令竞争。 subos use --shell probe 中 probe 应属于 shell command;命名环境要写成 subos use probe --shell。spec/E2E 已按该语义覆盖。
  9. 跨仓闭环不能只看源码或单平台 build。 install hook: stdout/log.error/stderr swallowed — failing install() surfaces only as an empty E_INTERNAL #513/pkginfo.install_dir() returns nil for a dependency that exists only in the shared registry cache #514 需要 libxpkg 发布和公共索引消费;runtime/path 问题只有 macOS、Windows、aarch64 原生 CI 才暴露。

五、还没有完成的工作

A. xlings PR #519 与发布

  • Task 10 审核、提交、推送及新 HEAD 原生 CI。
  • 更新 Task 8/9/10 的计划证据。
  • fetch 最新 main/tags/releases,普通版本号使用当天 .1/.2...,禁止把例行修复发成 .0。
  • 跑完整 unit/E2E/no-pin/性能回归门禁和 Linux static release candidate。
  • 所有原生 CI terminal green 后,按授权 squash merge;不得用 amend/rebase/force-push。
  • 发布全平台 assets/sidecar,随后从 CN 机器执行 tools/mirror-latest.sh xlings,用 GET + sha256 验证 GitHub/GitCode。
  • 更新并合入 xim-pkgindex/pkgs/x/xlings.lua 的所有平台版本和 latest pointer;fresh-install 不得 pin xlings 版本。

B. mcpp #392 与 runtime/graphics

C. xim-pkgindex / xlings-res 生态收口

D. 最终真实用户路径

六、建议的接手顺序

  1. 不改动现有 Task 10 工作区,先审 git diff、补 D4 设计枚举、跑 spec/reference parity。
  2. 重跑 full unit 与 focused SubOS E2E;确认 privacy scan 和 git diff --check。
  3. 独立 commit/push Task 10,再用单独 docs commit 回填 Task 8/9/10 证据。
  4. 等待 PR fix: recover CLI stability and runtime safety #519 新 HEAD 的 Linux/macOS/Windows/aarch64/root/E2E 全部 terminal green;失败只做 additive fix commit。
  5. 完成 Task 11 的 xlings version/release/GitCode/index pointer A。
  6. 基于已发布 xlings 执行 Task 12–14(mcpp fix(xvm): move a whole surviving release, or none, after removal #392/pkginfo.install_dir() returns nil for a dependency that exists only in the shared registry cache #514/release)。
  7. 执行 Task 15 生态 pointer B 与 workaround 清理。
  8. 执行 Task 16 公共 cold/legacy/sandbox/GPU 审计和 issue closure。

七、必须继续遵守的过程约束

  • 所有改动继续放在 Draft PR,以小而明确的 additive commit 动态记录;禁止 amend、rebase、force-push。
  • 每次 commit/push 前扫描 staged/commit diff,禁止出现本机用户名、主机名、私有绝对路径、邮箱、token、credential 或 private key。
  • E2E 始终使用隔离的临时 HOME/XLINGS_HOME/SubOS root,不碰真实用户状态。
  • “本地测试通过”“远端当前 HEAD 通过”“发布后公共链路通过”是三种不同证据,不能互相替代。
  • 多份 glibc/runtime payload 可以共存;一个 SubOS 当前只能有一个精确 active runtime。
  • D6 本轮不使用 SQLite;release 普通版本不得使用 .0;fresh-install 不得 pin released xlings。

当前交接点没有需要丢弃或回滚的修改;最重要的是先把 Task 10 作为独立可审提交送入 Draft PR,再继续 release 和跨仓闭环。

@speak-agent

Copy link
Copy Markdown
Collaborator

Task 10 / 交接后续 checkpoint:可提交内容已全部更新到本 Draft PR。

  • 1fee812:xlings subos use 无参数候选发现、安全 fuzzy resolver、统一 CLI/interface/agent/TUI 事件渲染、legacy default 有界兼容和完整 E2E。
  • a6d13e2:同步 D4 的 case_insensitive_exact / unique_prefix reason、可选 selected/hint 字段,并回填 Task 8/9/10 的提交与测试证据。
  • fresh verification:build passed;CommandSpec 7/7;full unit 36/36;generated command reference 与 CLI spec parity 通过(240/64);candidate E2E + 5 条受影响 E2E 均以绝对构建产物、fail-fast 方式通过。
  • push range 的 whitespace、本机身份/路径、凭据扫描通过;工作区干净;没有 amend/rebase/force-push。

先前交接评论中“Task 10 尚未提交/推送”的段落现已由上述两个 additive commits 完成。PR 正文也已更新为当前状态。新 HEAD a6d13e2 的原生 CI 正在运行;PR 保持 Draft,Task 11–16(release、mcpp #392、生态与真实 sandbox/GPU 闭环)仍未完成。

Measured on a real home: of ~25 SubOS, three carried a `subos_info.runtime`
and the rest predated the block entirely. Every one of those was declared
against DEFAULT_RUNTIME the first time anything rebuilt its block -- and once
the declaration became authoritative, that stamp made `self doctor` report an
error and `use` refuse to activate the runtime the SubOS was already on, for
a state nobody chose.

Three separately reasonable changes composed into it:

  1. `preserved_runtime` kept a RECORDED binding and fell straight through to
     the caller's constant otherwise. A subos that predates `subos_info`
     recorded nothing, so it got the constant.
  2. D5 moved from "is the declared runtime installed anywhere" (Warning) to
     "is it this SubOS's active runtime" (Error, counted in the exit code).
  3. `use` gained a guard that refuses a contradicting activation.

Fixes, in the same order:

  1. `observed_runtime` reads the workspace in the SAME file. A subos that
     never recorded a binding is not silent about its runtime -- `use` has
     been maintaining that record all along. Declaring what it runs makes the
     declaration true rather than absent; recording nothing is not an option,
     because validate_block requires a well-formed binding and a block without
     one is reported broken forever.
  2. `--fix` adopts the active runtime for homes already stamped by
     2026.8.9.1/.2, reading it back through the same `observed_runtime` the
     detection used so reporter and repairer cannot drift. Only the Error
     shape is adopted: a declaration with no active runtime is a cold intent
     (`subos new --runtime X` before installing X) and overwriting it would
     undo a decision someone took.
  3. Both messages now name two ways out that exist. "Create a new SubOS" was
     never the only one -- activating the DECLARED version is exactly what the
     guard permits -- so the dead end was in the text, not the code.

tests/e2e/subos_runtime_declaration_upgrade_test.sh covers all three states:
legacy (no block), already-stamped, and cold intent.
`xlings subos use` with no name lists candidates and exits 0. That is right on
its own, but the check ran BEFORE the mode dispatch, so it also swallowed every
form that asked for an effect:

  subos use --cmd 'make'          exit 0, make never ran
  subos use --sandbox --cmd '...' exit 0, the command never ran
  subos use --global              exit 0, nothing persisted
  subos use --shell               exit 0, and a rendered candidate TABLE went
                                  to stdout -- the stream the caller eval's

Never-happened and succeeded produced the same exit code, which is this repo's
recurring shape. It also aimed at the release's own acceptance path: the
evidence for this whole round is `subos use <name> --sandbox --cmd ...`, and a
typo in that name would have printed a list and reported success.

Discovery now requires the rest of the command to have asked for nothing else.
Four E2E cases pin it: each exits 1, none executes its marker, --shell emits no
candidate table, and --global persists nothing.
…ll one

`list <filter>` skips a workspace pair before resolving it, using a cheap
over-approximation of the owner candidates. The approximation walked only a
version's OWN outgoing binding edges, while the real resolver builds an
incoming index and reaches members through it -- and `legacy_root_in_selection`,
which decides which members become candidates at all, is precisely a question
about incoming edges.

So an owner reachable only by walking backwards was invisible to the skip
decision: `list <name>` omitted a row that plain `list` showed, and nothing in
either output said they disagreed.

The walk now follows edges in both directions. Only a filtered query can skip a
pair, so only a filtered query pays for the reverse index.

Stated as an invariant rather than one hand-picked case: for the same fixture,
`list <F>` must equal `list` filtered by F. A second test pins the mechanism,
asserting the blind walk really does miss the owner -- so the invariant test is
a genuine RED turned GREEN, not a tautology.
…g it the host's

Measured against a real home: the new reverse rule produced 145 loader/libc
findings, and 143 of them were the same false positive.

    interpreter -> <repo>/.xlings/subos/default/lib/ld-linux-x86-64.so.2
    core file   -> ~/.xlings/data/xpkgs/xim-x-glibc/2.39/lib/ld-linux-x86-64.so.2

That interpreter IS our loader, reached through a SubOS view. `payload_of` is
documented to return empty for a subos directory, so an empty interpPayload was
read as "the host's loader" and every migrated binary tripped the rule.

The RUNPATH side already resolves through symlinks -- that is what
core_runtime_sources_ exists for. Resolving only one side is what made the two
sides disagree. The interpreter now gets the same treatment when it does not
land in a store directly.

Real home after the fix: 143 -> 0. The two findings that remain are real, and
are ones the previous same-provider filter structurally could not see:

    xim-x-godot/4.6.3/godot
      interpreter -> ~/.xlings/data/xpkgs/xim-x-glibc/2.39/lib64/ld-linux-x86-64.so.2
      RUNPATH     -> /usr/lib/x86_64-linux-gnu

our loader paired with the host's libc, which is the crash-before-main case.

Two tests: a real symlink farm that must pass, and a genuine host interpreter
with a payload core that must still violate.

Also pins the spelling invariant the Windows-separator test was already
guarding: payload_of and store_root_of both slice the caller's own spelling,
and normalization only finds the split point. An earlier attempt to "fix" a
divergence here broke that test, which was right to fail.
…ion"

The unresolvable-coordinate path returned 1, three lines above a comment
promising the opposite -- that removing what is not there is success, "without
breaking scripts that re-run `remove` defensively". A package whose recipe has
left the index, or a local --add-xpkg recipe since deleted, is as gone as it
gets, and reporting a failure to go is wrong.

Turning it into a blanket exit 0 was wrong too, and the existing payloadless
config test said so: `remove [email protected]` must fail.

Both contracts are right because they answer different questions:

  remove pkg          "make sure pkg is gone" -- warn, exit 0
  remove [email protected]    "remove THIS version"   -- exit 1; the coordinate itself
                      is wrong, and success would confirm removing something
                      that cannot exist

The discriminator is whether the user named a version. Both halves are pinned:
the existing explicit-coordinate case, plus a new bare-name defensive re-run.
…s what it narrows

Two small honesty fixes found while reviewing the round.

get_catalog: a default-constructed `expected<void, E>` is a SUCCESS value, so
when a LocalOnly caller had already initialized the singleton, the InstallReady
self-heal held "the result of a rebuild that never happened" and could only
ever fire on the sub-index branch. `optional` makes never-probed its own state.

doctor --scope narrows the payload/runtime audit only; every other check, and
every repair --fix performs, still covers the whole home. The announce line now
says so instead of letting the reader infer a confinement that is not there.
… 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.
Ordinary date version. Latest tag is v2026.8.9.2 and today is 2026-08-10, so
the plan's expected `2026.8.9.3` is behind -- recomputed at cut time as that
plan's own constraint requires. No `.0` for a routine release.
…ntime family at a time

Two failures, both invisible from Linux.

**Windows has been red for four consecutive HEADs** (6f229b1, 7ada4cc, a6d13e2,
3a8676b) on one line:

    src/core/subos.cppm:131: error: too many arguments provided to
    function-like macro invocation
      next[j + 1] = std::min({prev[j + 1] + 1, next[j] + 1, replace});
    note: macro 'min' defined here    (windows.h)

windows.h defines min/max as function-like macros. Three of the four modules
that include it already defined NOMINMAX first; subos.cppm was the exception.
The error names the algorithm and says nothing about the include, and it cannot
reproduce on Linux or macOS -- so every local gate stayed green through all
four runs.

tests/scripts/test_windows_header_hygiene.py now asserts the rule at the source
level, where a Linux machine can check it. Writing it immediately found a
SECOND module with the same latent problem (src/core/subos/sandbox.cppm), which
had simply not been hit yet because nobody had written the call there. Both are
fixed; the check is registered in xlings-ci-linux.

**glibc and musl are not each other's core runtime.** The loader/libc rule
compared any core-runtime file against any other, so a glibc binary carrying a
musl toolchain's libdir on its RUNPATH -- which is what a musl cross-compiler
bakes in -- was reported as a loader/libc split. It never was one: a glibc
binary asks for `libc.so.6`, which a musl libdir does not contain under any
name, so that path resolves nothing.

Comparison is now within one family, with Unknown on either side still
comparing so an unrecognised payload is never silently excused. Verified
against the real home: the two genuine godot findings (our glibc loader with
the host's glibc libc) still fire, and `closure_guard_differential_test.sh`
passes again -- it had been failing locally where the rig's RUNPATH reaches a
real musl-gcc payload that CI runners do not have.
@Sunrisepeak

Copy link
Copy Markdown
Member Author

Checkpoint:第二轮评审的修复已全部推入,版本 2026.8.10.1

远端 HEAD 59b6661。8 个 additive commit,无 amend/rebase/force-push。

头条实测(真实 71 GB home 的 hardlink 切片)

命令 2026.8.9.2 本 PR
self doctor(默认) 195.16s 0.63s

跑完 slice-real-home.sh verify-untouched 证明真实 store 未被改动。

这一轮修掉的 9 个问题

R0 —— 升级过的老 home 会变成「按新规则永久不合规」。
真实 home 普查:~25 个 SubOS 只有 3 个有 subos_info.runtime,其余全部 ABSENT,
升级时被 preserved_runtime 的常量兜底盖成 [email protected],而它们实际在跑 2.39。
叠上本 PR 把 D5 从 Warning 提成 Error、use 新增拒绝,结果是
doctor 变红 + use glibc 2.39(它本来就在跑的版本)被拒,
而提示的唯一出路「新建 SubOS」是假死局 —— 正向迁移一直是通的。
修法:声明的第二来源改为 observed_runtime(读同一个文件里 workspace 的 active 版本),
--fix 采纳已盖坏的 home,两处提示改成命名两条真实存在的出路。
「不写 runtime」不可行:validate_block 要求合法 binding。

R4 —— ELF 规则在真实 home 上报 147 个 broken payload,其中 143 个是误报。
PT_INTERP 指向 SubOS 视图(symlink farm)时 payload_of 返回空,被当成「宿主 loader」。
RUNPATH 一侧早就 weakly_canonical 穿链接了,只穿一侧两侧就不可能一致。
修后 143 → 0,剩下 2 条是真的:godot 用我们的 glibc loader 配 /usr/lib 的宿主 libc
—— 旧规则的同 provider 过滤结构性看不到它。

Windows 已经红了四个 HEAD(6f229b1→3a8676b),一行:
std::min({...}) 撞上 windows.h 的 min 宏,而 subos.cppm 是唯一没写 NOMINMAX 的模块。
诊断只指算法不指 include,且在 Linux/macOS 上不可能复现。
新增 tests/scripts/test_windows_header_hygiene.py 在源码层断言这条规则(Linux 上可跑,已注册进 CI),
写完立刻又找出第二个同样的地雷 subos/sandbox.cppm。

其余:R1(subos use --sandbox --cmd 缺名字时 exit 0 且不执行 —— 正是本轮验收命令的形状)、
R2(list <filter> 可能是 list 的真子集)、R3(remove 退出码与自己的注释矛盾,拆成
裸名 exit 0 / @版本 exit 1)、R6、R7、glibc/musl 跨 family 误判。

两条我自己的判断被测量推翻,都留在文档里:R5(我把 payload_of 的返回读反了,
它返回原始拼写,本来就一致 —— 既有测试挡住了我的「修复」)、R2(b)(by_identity
在 store 名不等时 reset,身份不会被改写)。

本地门禁

unit 36/36;E2E run_all.sh 81/81(含新增 E2E-78 三态);
test_generated_command_reference / test_cli_spec_parity(240 + 64)/ test_docs_examples /
test_windows_header_hygiene / no_xlings_version_pin_check 全过;
Linux static release candidate 已构建(xlings-2026.8.10.1-linux-x86_64.tar.gz)。
push 前 whitespace、本机身份/路径/凭据扫描通过。

文档

  • .agents/docs/2026-08-10-pr519-review-and-completion-design.md —— 评审 + 每条发现的实测结论
  • .agents/plans/2026-08-10-pr519-completion-implementation.md —— 八角度拆分、三对冲突的裁法、跨仓 DAG
  • 另外两份从未提交的设计(instant-query 架构、44 条 open issue 触诊)也一并落盘

剩余

全平台 CI terminal green → squash merge → release → 本地 gtc 补 GitCode → GET+sha256 →
pointer A → xlings subos <name> --sandbox --cmd 真实验证。
mcpp #392 不依赖本 PR 发布,可立即并行开工。

Written for someone upgrading, not for someone who read the PR. Leads with the
number that matters (self doctor 195.16s -> 0.63s on a real 71 GB home) and
says plainly that the upgrade needs no action -- and what the one command is
if a home was already stamped by 2026.8.9.1/.2.

Frames the ELF change as "more accurate, not stricter", because that is what
the measurement showed: 143 false positives removed, 2 real findings added.
The earlier figure ("~25 SubOS, 3 declared") came from a listing I had
truncated with `head -25` and then read as if it were the whole set. The full
count is larger and the ratio is worse:

    total subos                                    35
      with a subos_info.runtime declaration         2
      ABSENT                                       33
        of those, with an active glibc             20   <- would be declared
                                                          against a runtime they
                                                          never ran

Twenty is the number that matters: those are the SubOS an upgrade would have
stamped with [email protected] while they ran 2.39. It does not change any conclusion
or any fix -- it makes the case stronger than it was stated.
…ls it

With the NOMINMAX fix in place, Windows got far enough to RUN this suite for
the first time in four HEADs -- and four assertions failed there and only
there. All four are of the form "the diagnostic must contain this path", and
all four compare a POSIX-shaped test literal against a path std::filesystem
handed back after normalising it.

`/home/u/.xlings/...` is not an absolute path on Windows, so it goes through
`lexically_normal()` and comes back with backslashes; canonicalisation can also
change case. Neither says anything about the behaviour under test -- these
tests are about the loader/libc pairing rule, which is Linux-only in
production, and about whether `describe()` names both payloads.

So compare in one spelling and one case. The paths are still compared whole:
this loosens the rendering, not the claim.
…arators

Second Windows round. Two causes behind five failures, and the first fix only
addressed one of them.

**8.3 short paths.** GitHub's Windows runners return
`C:\Users\RUNNER~1\AppData\Local\Temp` from `temp_directory_path()`, while the
code under test canonicalises through `weakly_canonical` and gets
`C:\Users\runneradmin\...`. Those are the same directory and never the same
string -- and no amount of case or separator folding reconciles `RUNNER~1` with
`runneradmin`, which is why the previous commit's `names()` helper still
returned false for every TempTree-based assertion. Canonicalise the fixture
root up front so both sides start from the same spelling.

**Round-tripped vs. handed-through spellings.** `f.interpPayload` is sliced
from the string the caller passed, so it keeps forward slashes;
`f.rpathPayload` has been through `fs::path` and `lexically_normal()` and comes
back with native separators. The two are compared against the same POSIX-shaped
literal. Compare through `gen()`, which is about the separator, not the path.

Neither is a defect in the rule: the loader/libc pairing is Linux-only in
production. Both were fixtures asserting a spelling the platform owns.
@Sunrisepeak
Sunrisepeak marked this pull request as ready for review August 9, 2026 19:08
@Sunrisepeak
Sunrisepeak merged commit 65002df into main Aug 9, 2026
8 checks passed
@speak-agent

Copy link
Copy Markdown
Collaborator

发布后闭环证据(2026.8.10.1)

全部针对已发布产物,不是本地构建。

发布链路

结果
release run 全部 job success(4 平台构建 + 4 候选验证 + create-release + publish-index + mirror-binaries + bump-index)
GitHub assets 4 tarball + 4 sha256 sidecar 齐全
GitCode 镜像 tools/mirror-latest.sh xlings,8/8 已镜像
GET + sha256 8/8 一致(GitHub 与 GitCode 各 4,全部 GET 跟随重定向,非 HEAD)
xim-pkgindex pointer A #586 已合并;三个平台块一致更新,无 partial bump
公共索引解析 aliases latest -> 2026.8.10.1

bump-index 依旧是「开 PR 但不合并」,pointer A 是手动合的 —— 这是已知形态,不是本次异常。

冷 home(用 tarball 自带的 self install,不是 quick_install)

list        0.00s
info gcc    0.01s
self doctor 0.00s

真实 sandbox 路径 —— 本轮的验收命令

$ xlings subos use ecoverify --sandbox --cmd 'echo ECO_SANDBOX_OK; id -u; uname -m'
ECO_SANDBOX_OK
1000
x86_64
exit 0

R1:缺名字 + 执行型修饰符

命令 exit
subos use --sandbox --cmd '…' 1(命令未执行,标记字符串出现 0 次)
subos use --shell 1
subos use --global 1
subos use(无参数) 0,列候选

R0:老 home 升级(最关键的一条)

构造一个 2026.8.5.1 之前的 home —— 没有 subos_info 块,workspace 实际在跑 glibc 2.39,
全局同时存在 2.39 与 2.44 两份 payload:

BEFORE runtime declaration : ABSENT
AFTER  doctor --fix        : [email protected]     <- 不是 2.44 默认值
subos runtime findings     : 0
use glibc 2.39             : 未被 runtime guard 拒绝

(该 fixture 的 doctor/use 仍以 1 退出,是 fixture 自身的噪声——没建 shim、bindingGroup 没有
bindingMembers——use 的失败发生在 binding manifest 阶段,不在 runtime guard。)

冷意图仍然只是 warning

新建 SubOS 声明 [email protected] 而尚未安装它:⚠ warning,self doctor exit 0。
「声明了但还没 active」和「声明与 active 冲突」是两种状态,没有被混为一谈。


一个已知代价,不是回归:self doctor --fix 在 71 GB home 上 >10 分钟,因为 --fix 蕴含 --deep
且每轮 repair 后的 refresh 会重跑整个 payload 审计。旧版默认路径同样慢(195s),所以不是本轮引入的。
把 --fix 需要的 catalog 与它不需要的 ELF 扫描拆开是明确的后续优化。

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.

2 participants