Repository navigation
Closed
Labels
Description
master --lib 在 Windows 上红:/mnt/c verbatim 断言与 #444 的"全类翻译"互相矛盾(边界契约审计)
来源:边界契约审计(branch docs/boundary-contract-audit,对 master eb062957 跑全量时发现;预存失败,与审计分支的增量改动无关——审计只加 tests/ 与 docs/)。
现象(确定性复现,Windows 10 19045 x64)
cargo test --lib executor::path::tests::virtual_system_root_operand_resolution_keeps_option_b_and_legacy_verbatim
thread panicked at src\executor\path.rs:4482:
assertion `left == right` failed: "/mnt/c" must stay verbatim for the applet
left: ["C:\\"]
right: ["/mnt/c"]
cargo test(不带 --no-fail-fast)在 --lib 处中止,后续测试二进制全部不跑。
根因:两个测试各自锁着相反的契约
- 46d7942(fix(path): translate /mnt/X drive argv for every child class (niubash#164) #444,niubash#164,2026-10-09)把
/mnt/X从 verbatim 集合移入"每个子类都翻译":当时的前提是 winuxcmd 的normalize_api_operand_w只折叠/d/x、/cygdrive/d/x,不认/mnt/X,ls /mnt/c会失败。该提交同步更新了windows_mnt_drive_argument_translates_for_every_child,但漏改了兄弟测试virtual_system_root_operand_resolution_keeps_option_b_and_legacy_verbatim——它仍把/mnt/c放在 verbatim 列表里(该断言来自 [bug] 反引号替换体中单引号内的 ` 被当替换收尾:替换体拆词、凭空执行命令、结果错(cmake bootstrap line 67 实伤) #177/ea364107)。两测试从此矛盾,Windows lib 套件恒红。
审计实证:#444 的前提在当前工具链上已过时
WinuxCmd 1.1.5(usr/bin 工具直打,无 rubash 介入):
ls.exe /mnt/c/Windows/System32/attrib.exe # -> C:\\Windows\\System32\\attrib.exe rc=0
touch.exe /mnt/c/Users/.../mnttest # -> 文件落在 C:\\... rc=0
即当前工具链的 native 层已经能解析 /mnt/X(与 /d/x 同权)。#444 时代的工具缺口不再存在,现在的状态是:
- 引擎对 POSIX-aware 子进程仍预翻译
/mnt/X(违背 invariant C"verbatim 到 POSIX-aware 子进程"的一般规则,属于 fix(path): translate /mnt/X drive argv for every child class (niubash#164) #444 的显式 carve-out); - 该 carve-out 的存在理由(工具不认 /mnt)已被工具链演进消解;
- 契约测试套件一红一绿互相指证。
请 owner 裁决(本 issue 只记录不修,两个方向二选一)
- 方向 A(维持 fix(path): translate /mnt/X drive argv for every child class (niubash#164) #444):更新
virtual_system_root_operand_resolution_keeps_option_b_and_legacy_verbatim,把/mnt/c从 verbatim 列表移除(对齐windows_mnt_drive_argument_translates_for_every_child),lib 套件回绿;engine 继续兜底旧工具链。 - 方向 B(回归 Option-B 纯度):工具链已自解析
/mnt/X,撤掉windows_mnt_drive_argument的全类翻译、恢复 verbatim(normalize_api_operand_w已实证覆盖),并把 fix(path): translate /mnt/X drive argv for every child class (niubash#164) #444 的新测试反转。需先确认旧版工具链用户占比。
无论哪个方向,请同步审计文档 docs/windows-path-contract.md §2 L2 的 /mnt 注记(该文件随审计 PR 下发,当前按 #444 现状描述并指向本 issue)。
边界契约测试
tests/path_contract_boundary_*.rs(审计分支)不受此矛盾影响(未锁 /mnt 形态),15 用例全绿;#444 方向裁决后可在 posix_forms 套件补 /mnt 的正/反用例。
Activity
caomengxuan666 commentedon Oct 12, 2026
裁决落地(方向 A/C):维持 #444 全类翻译,修 verbatim 测试 — "审计实证"段结论更正
owner 裁决(2026-10-12):本帖"审计实证"段的结论不成立——"工具链已自解析 /mnt"是 Git Bash argv 转换造成的测量污染。按方向 A/C 落地:#574。原帖按惯例不改写,此评论更正结论。
四路复测(推翻"审计实证"段)
ls.exe /mnt/c/...rc=0 是假象:bat 观测显示 bash 传给 native 子进程的 argv 已是C:\Windows——MSYS2 运行时 WSL-interop 在 spawn 前转换(/mnt/c→C:\、/d/repo→D:\repo);ARG_CONV_EXCL/MSYS_NO_PATHCONV在该环境未生效。rc=0 测的是 Git Bash 的转换层,不是 WinuxCmd。本帖 touch "rc=0 文件落在 C:" 是同一签名(文件按已转换路径落盘)。/d/repo✅、/cygdrive/d/repo✅、/mnt/c/Windows❌ cannot access;touch /mnt/c/...❌ rc=1 ENOENT 未落盘。ls.exe 纯 native(无 msys-2.0.dll 依赖)。normalize_api_operand_w(native_path.cppm:101)仅 /cygdrive 折叠(L112-137)+ 单字母/X/分支(L138-153,要求[2]为分隔符;/mnt/c的[2]='n'不满足);全 src/ 无 "mnt" 字样。git log -S '/mnt' -- src/v1.1.2..v1.1.6 零提交;v1.1.4→v1.1.5 的 native_path 变化只有 cygdrive 折叠(6410315,[bug] Unset-PATH external-failure message differs (rc same) #1145)。对本帖各节的更正效力
落地内容(#574)
virtual_system_root_operand_resolution_keeps_option_b_and_legacy_verbatim([bug] 反引号替换体中单引号内的 ` 被当替换收尾:替换体拆词、凭空执行命令、结果错(cmake bootstrap line 67 实伤) #177/ea364107)verbatim 循环删/mnt/c,注释声明边界(形状类测试自证windows_virtual_system_root_argument("/mnt/c") == false)并把 /mnt 契约移交 fix(path): translate /mnt/X drive argv for every child class (niubash#164) #444 测试独占;fix(path): translate /mnt/X drive argv for every child class (niubash#164) #444 测试未动。docs/windows-path-contract.md§2 L2 的"工具侧同样可解析(1.1.5 实测)"污染注记已更正;违规台账条目同步。cargo test --lib executor::path68 全绿(原 67 绿/1 红,唯一红即本帖引述断言);全量cargo test --no-fail-fast失败集与 fresh master 逐名双向一致;fmt 干净。@审计发起人 请过目更正证据链;如对四路复测有异议,欢迎在 WinuxCmd#1172 或此处附复现环境。
fix(paths): retire /mnt/c from the verbatim loop per the #568 adjudic…
fix(path): POSIX drive-form operand pre-translation covers every chil…
docs(changelog): fold the post-0d99ae2c wave into the 1.4.0 section (#…