Skip to content

fix(executor): resolve redirect/cd/funsub/type byte spellings through the node (Refs #3372) - #3872

Merged
caomengxuan666 merged 5 commits into
masterfrom
fix/3372-remaining-faces
Nov 18, 2026
Merged

caomengxuan666 merged 5 commits into
masterfrom
fix/3372-remaining-faces

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

fix(executor): resolve redirect/cd/funsub/type byte spellings through the node (Refs #3372)

#3218 residual: the sibling consumers of the #3368/#3218 node-key funnel
still consulted the folded-string record, so same-string collisions
survived for the pre-create opens, the external stdout/cat-output
opens, cd, $(<file), and the type display face.

Root cause: a="$(printf 'x\234')" (raw byte 0x9C) and b=x$'\u009c'
(genuine U+009C, UTF-8 C2 9C) fold to the same string. GNU hands each
redirect its own expanded bytes (redir.c:298 redirection_expand) and
opens them verbatim (redir.c:702 redir_open); cd chdirs the verbatim
bytes (builtins/cd.def change_to_directory); $(<file) reads the
verbatim bytes (subst.c command_substitute); type prints the name and
the find_user_command hit verbatim (builtins/type.def describe_command).
The consumers below took the folded-string record instead, so a
transport sibling's spelling steered the genuine leg onto the raw-byte
file (or vice versa).

Fix (same mechanism as #3368): consumers that hold the node resolve the
byte spelling through the node's own record; no record falls back to the
plain funnel; the string-keyed record is never consulted.

  • source_type_state.rs / function_calls.rs pre-create opens take
    Some(redirect) (create_redirect_output_prepared[_open]_for).
  • external_redirects.rs apply_external_stdout_target and
    external_finish.rs open_cat_output[_sink] take the node and use
    create_redirect_output_for / open_append_target_for.
  • cd takes the byte spelling computed before the fold
    (transport_name_spelling_bytes) on unix (cd_filesystem_path).
  • $(<file) takes the pre-fold byte spelling on unix.
  • type / type -p / command -v / type -a write describe lines
    byte-wise (write_describe_line + describe_display_bytes) in both
    describe_name_with_io and describe_name_all_with_io; with no
    transport the byte spelling is the folded name's UTF-8 bytes, so
    plain names print exactly as before.

Regression pins (6 stems, 12 tests; expectations from GNU bash 5.3.20
oracle probes, LC_ALL=C.UTF-8):

  • tests/issue3372_precreate_node_spelling.rs (3)
  • tests/issue3372_external_stdout_node_spelling.rs (2)
  • tests/issue3372_cat_output_node_spelling.rs (2)
  • tests/issue3372_cd_byte_spelling.rs (2; marker landing, not pwd output)
  • tests/issue3372_funsub_input_byte_spelling.rs (2)
  • tests/issue3372_type_display_byte_spelling.rs (1)

UNVERIFIED-BY-CAPTAIN: no build route was available (X299 tunnel down,
local build banned, box wallet empty), so the pins were not run and no
cargo check/test ran. The captain verifies fail-first on base and green
on this head on a live route before merge.

Known residuals (see lane REPORT): pwd/PWD display of a raw-byte
directory still diverges from GNU (byte-level pwd output is a separate
face, deliberately not pinned); function-definition printing in type
Verbose still goes through folded AST text; external_redirects.rs has 6
pre-existing rustfmt-drift hunks unrelated to this change.

本 PR 删除了什么

无删除。纯增量修法 + 6 个新钉文件;既有 tests/issue3372_append_funnel_node_spelling.rs 未动。

… the node (Refs #3372)

#3218 residual: the sibling consumers of the #3368/#3218 node-key funnel
still consulted the folded-string record, so same-string collisions
survived for the pre-create opens, the external stdout/cat-output
opens, `cd`, `$(<file)`, and the `type` display face.

Root cause: `a="$(printf 'x\234')"` (raw byte 0x9C) and `b=x$'\u009c'`
(genuine U+009C, UTF-8 C2 9C) fold to the same string. GNU hands each
redirect its own expanded bytes (redir.c:298 redirection_expand) and
opens them verbatim (redir.c:702 redir_open); cd chdirs the verbatim
bytes (builtins/cd.def change_to_directory); `$(<file)` reads the
verbatim bytes (subst.c command_substitute); `type` prints the name and
the find_user_command hit verbatim (builtins/type.def describe_command).
The consumers below took the folded-string record instead, so a
transport sibling's spelling steered the genuine leg onto the raw-byte
file (or vice versa).

Fix (same mechanism as #3368): consumers that hold the node resolve the
byte spelling through the node's own record; no record falls back to the
plain funnel; the string-keyed record is never consulted.
- source_type_state.rs / function_calls.rs pre-create opens take
  `Some(redirect)` (`create_redirect_output_prepared[_open]_for`).
- external_redirects.rs `apply_external_stdout_target` and
  external_finish.rs `open_cat_output[_sink]` take the node and use
  `create_redirect_output_for` / `open_append_target_for`.
- `cd` takes the byte spelling computed before the fold
  (`transport_name_spelling_bytes`) on unix (`cd_filesystem_path`).
- `$(<file)` takes the pre-fold byte spelling on unix.
- `type` / `type -p` / `command -v` / `type -a` write describe lines
  byte-wise (`write_describe_line` + `describe_display_bytes`) in both
  `describe_name_with_io` and `describe_name_all_with_io`; with no
  transport the byte spelling is the folded name's UTF-8 bytes, so
  plain names print exactly as before.

Regression pins (6 stems, 12 tests; expectations from GNU bash 5.3.20
oracle probes, LC_ALL=C.UTF-8):
- tests/issue3372_precreate_node_spelling.rs (3)
- tests/issue3372_external_stdout_node_spelling.rs (2)
- tests/issue3372_cat_output_node_spelling.rs (2)
- tests/issue3372_cd_byte_spelling.rs (2; marker landing, not pwd output)
- tests/issue3372_funsub_input_byte_spelling.rs (2)
- tests/issue3372_type_display_byte_spelling.rs (1)

UNVERIFIED-BY-CAPTAIN: no build route was available (X299 tunnel down,
local build banned, box wallet empty), so the pins were not run and no
cargo check/test ran. The captain verifies fail-first on base and green
on this head on a live route before merge.

Known residuals (see lane REPORT): `pwd`/PWD display of a raw-byte
directory still diverges from GNU (byte-level pwd output is a separate
face, deliberately not pinned); function-definition printing in `type`
Verbose still goes through folded AST text; external_redirects.rs has 6
pre-existing rustfmt-drift hunks unrelated to this change.

## 本 PR 删除了什么

无删除。纯增量修法 + 6 个新钉文件;既有 `tests/issue3372_append_funnel_node_spelling.rs` 未动。
@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-AUDIT】PR #3872 第2轮(l1 续作)— 接手修编译错
head: 88570ac
续作内容:CI 暴露 src/executor/external_finish.rs open_cat_output_sink 内 Option<&Box> 传入 Option<&Redirect> 形参(:161/:164 两处 E0308),本地 cargo check --lib 复现同样 2 错。修法:match 元组绑定处 Some(&**redirect)/Some(&**append) 显式降层,与 write_cat_output 内 Some(redirect) 的期望类型传播写法等价但此处 Option 已先行成型、无传播位。修后跑全腿:六钉自跑+fail-first+lib双边+warnings+卫生+CI归因+WSL GNU 5.3.20 对照。

@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-AUDIT】PR #3872 第3轮(l1 续作)— 建议:FAIL
head: 4ab4f49 base(merge-base): 59d1c2b 文件: 见 gh 实时值
关联 issue: #3372(状态:open,核于 2026-11-18 03:35 +08)

机制核查:

续作记录(本轮动过代码):

  • 200585c fix(executor): deref boxed redirect nodes in open_cat_output_sink — 修外部_finish.rs 的 Option<&Box>→Option<&Redirect> 编译错。
  • 4ab4f49 test(3372): fix octal escape depth so $a carries raw byte 0x9C — 六个钉文件的 PRELUDE 把 printf 写成 'x\\234'(四层反斜杠),shell 实际得到字面量 x\234 而非裸字节 0x9C;GNU 5.3.20 实测 a=78 5c 32 33 34(字面量)。修正为 \234(两层)后 a=x+0x9C、b=x+C2 9C,钉才真正区分两种拼写。新 head: 4ab4f49。

腿(WSL Linux 原生,/root/l1-rubash + /root/l1-target,GNU oracle /usr/local/bin/bash 5.3.20):

  • 钉自跑 @4ab4f4908:issue3372_precreate_node_spelling 2/3;issue3372_external_stdout_node_spelling 0/2;issue3372_cat_output_node_spelling 2/2;issue3372_cd_byte_spelling 0/2;issue3372_funsub_input_byte_spelling 2/2;issue3372_type_display_byte_spelling 0/1。合计 8/12 绿。
  • fail-first @59d1c2b4(钉文件原样放入 base 树):precreate 0/3、external_stdout 0/2、cat_output 0/2、cd_byte 0/2、type 0/1 全红——除 funsub 2/2 在 base 也绿(该钉不区分缺陷,形同虚设)。红名集合与 PR 声称一致。
  • 红的形状(修正转义后):precreate/external_stdout 只建出裸字节名文件、UTF-8 名缺失(两拼写被折叠为一);cd_byte 普通形 mkdir 报 'x\u{9c}': File exists(b 的 UTF-8 拼写被折叠成裸字节);cd 混合形建出的目录名是 é+C2 9C 而非 é+0x9C(裸字节被 UTF-8 化),且 marker 落错目录;type 形 >"$a" 建错名字导致 chmod x\u{9c} No such file。即折叠残差仍在 redirect 预建/external stdout/cd/type 四个面,cat_output 与 funsub 两面已绿。
  • lib 双边:head(e9e513c 同代) 1376/1 vs base 1376/1,唯一失败 api::consumer_tests::issue2084_session_end_restores_host_process_state 两侧同名——基线,非本 PR 账。
  • -D warnings:cargo check --lib --bins 0 警告(head 200585c)。
  • 卫生:marker-lint ok、utf8 ok;cargo fmt 全仓跑不了(Windows os error 206 路径长),逐文件 rustfmt 已过;cli_tests 475/8 与 regression 164/70 与其余三条 PR 完全同名同数——基线/环境账,唯一可疑项 c_command_substitution_captures_type_t_output_without_leak(file vs emulation)在四条 PR head 上同现,非本 PR 独有。
  • CI:GNU regression goldens 与 Regression pin stem census 红(与基线金丝雀失败同族,未见本 PR 独有新红);Rust tests/CLI/Cross-target 全绿。

F 点:

  • F1: 四个面仍折叠字节拼写——issue3372_precreate_node_spelling.rs:108、issue3372_external_stdout_node_spelling.rs:92/97、issue3372_cd_byte_spelling.rs:62/118、issue3372_type_display_byte_spelling.rs:68 在 head 4ab4f49 真实红(复现:WSL cargo test --test )。GNU 应然:裸字节 0x9C 与 UTF-8 C2 9C 是两个不同名字,mkdir/cd/redirect/type 各自按节点拼写解析。机制缺口在节点解析未覆盖的剩余路径(折叠记录仍被查询),非钉期望错误——已用 GNU 5.3.20 实测核过 a/b 两值的真实字节。
  • F2: issue3372_funsub_input_byte_spelling 两钉在未修复 base 上也绿(2/2),不区分本 issue 的缺陷——钉形同虚设,需补能在 base 上红的断言或移除。

未跑/VOID 的腿:无(判词已由钉红定案;cli/regression 基线归因按同名同数推断,未跑 base 侧 cli/regression 对照——记为部分 VOID)。

@caomengxuan666
caomengxuan666 marked this pull request as ready for review November 18, 2026 08:29
@caomengxuan666
caomengxuan666 merged commit efc5413 into master Nov 18, 2026
10 of 12 checks passed
@caomengxuan666
caomengxuan666 deleted the fix/3372-remaining-faces branch November 18, 2026 08:29
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