Skip to content

fix(executor): E400-aware sentinel decode family for marker output boundary - #947

Merged
caomengxuan666 merged 2 commits into
masterfrom
fix/840
Oct 20, 2026
Merged

caomengxuan666 merged 2 commits into
masterfrom
fix/840

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Summary

Fixes #840 — three divergences in the "typed bytes reinterpreted at a render boundary" family, all one root cause: registry-zone sentinels were restored by blind .replace() chains that read the escaped member of an E400 + c literal-char pair (typed $'\uE3xx'/$'\uE0xx' user data via push_literal_char) as live protocol.

  • Divergence 1 (array-element render leaks E400 prefix): a=($'\uE314Z'); declare -p a printed ([0]="<E400><E314>Z"). fold_indexed_storage_dupes now resolves E400 + c → c at the display boundary. The cell/mirror transport convention is untouched — cell still stores the pair, read-back still sees it — so the typed-read debug_assert parity holds (decoding in quote_array_value/cell writers was tried and violates it).
  • Divergence 2 (printf/echo re-decode typed lookalike): user-literal __RUBASH_CSB1_<hex>; was consumed into its payload byte. The comsub payload introducer moved off typeable ASCII to registry-zone U+E319 (COMSUB_PAYLOAD_SENTINEL): a bare sentinel is always protocol; the typed ASCII lookalike is now pure user data and passes verbatim. contains_command_substitution_payload / decode_command_substitution_payload are E400-aware.
  • Divergence 3 (assignment-tail unescape eats typed PUA): a=($'\uE30D')-class words had the E30x member eaten, leaving a dangling E400. Every registry-zone .replace() chain in the family (assignment tail restores, decode_compound_expansion_carriers, unquote_storage_value, restore_quote_carriers, dequote_storage_marks, eval_source_for_reparse, split_indexed_tagged_token, quote_array_value, xtrace/conditional strips) now restores via restore_bare_sentinels (bare = protocol, pair = data).

New markers.rs helpers: restore_bare_sentinels / decode_bare_sentinels (one-pass E400-aware rule sets), contains_bare_sentinel (admission gates — replaces .contains(E30x) misfires), trim_bare_sentinel_suffix / ends_with_bare_sentinel (E302-wrap edge trims that read a pair member as a delimiter). Char scanners (split_requoted_hoisted_compound_word, word_level_quote_syntax, split_indexed_tagged_token, StorageWordIter) copy E400 pairs verbatim.

GNU contract: subst.c:4807 dequote_string / strtrans.c ansic_quote — the rendered boundary restores user data; protocol is bare-only.

Test plan

  • issue824_marker_decode_boundary_regressions 8/8
  • marker_leak_golden 8/8
  • decode_to_visible_text pass
  • Probes byte-verified: a=($'\uE314Z') → [0]="<U+E314>Z"; a+=( $'\uE30D' ) → [1]="<U+E30D>"; x='__RUBASH_CSB1_41;' → verbatim at printf/echo/declare -p; v=$'\uE30D' → "<U+E30D>"; arr=($'\uE30A'..$'\uE30F') → raw chars
  • typed-cell/mirror debug_assert holds (declare -a d=($'\uE314Z'); echo ${d[0]}; d+=(x))
  • pre-existing cd.rs test-build error unrelated (HashMap vs VarTable API drift on base)

Generated with Devin

caomengxuan666 and others added 2 commits October 21, 2026 02:39
…undary (rubash#840)

The three divergences share one root cause: registry-zone sentinels were
restored by blind .replace() chains that read the escaped member of an
E400 + c literal-char pair (typed `$'\uE3xx'`/`$'\uE0xx'` user data,
push_literal_char) as live protocol.

- Divergence 1: `a=($'\uE314Z')` stored the pair into the array mirror;
  declare -p printed a stray E400 prefix. fold_indexed_storage_dupes now
  decodes E400 + c -> c at the display boundary (cell/mirror transport
  parity preserved — the typed-read assert stays satisfied).
- Divergence 2: user-literal `__RUBASH_CSB1_<hex>;` was re-decoded to its
  payload byte at printf/echo. The payload introducer moved off typeable
  ASCII to registry-zone U+E319 (COMSUB_PAYLOAD_SENTINEL) — bare sentinel
  is always protocol; typed lookalike passes verbatim. Decode is E400-aware.
- Divergence 3: `v=$'\uE30D'`-class typed PUAs were eaten by the
  assignment-tail unescape (ASSIGN_EXPANSION_BACKSLASH et al.), leaving a
  dangling E400. Every registry-zone .replace() chain in the family now
  restores via restore_bare_sentinels (bare = protocol, pair = data).

New markers.rs helpers: restore_bare_sentinels / decode_bare_sentinels
(one-pass E400-aware rule sets), contains_bare_sentinel (admission
gates), trim_bare_sentinel_suffix / ends_with_bare_sentinel (E302-wrap
edge trims that read a pair member as a delimiter). Scanners
(split_requoted_hoisted_compound_word, word_level_quote_syntax,
split_indexed_tagged_token, StorageWordIter) copy E400 pairs verbatim.
GNU subst.c:4807 dequote_string / strtrans.c ansic_quote contract: the
rendered boundary restores user data; protocol is bare-only.

Fixes #840

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
… (rubash#840)

Follow-up to 8f532b0: the comsub payload introducer moved off the
typeable `__RUBASH_CSB1_<hex>;` ASCII form to registry-zone U+E319
(COMSUB_PAYLOAD_SENTINEL), but three test sites and several comments
still encoded the old form.

- command_prepare command_word_materialization_tests: the two argv-
  boundary asserts now feed the sentinel form; renamed
  materializes_legacy_payload_at_single_boundary accordingly and pinned
  the typed-ASCII lookalike passing verbatim (divergence 2).
- substitution_metadata payload_protection_boundary test: the
  "existing token" input uses the sentinel form so it still exercises
  the contains_command_substitution_payload early exit.
- issue824 regressions: the NOTE recording the (then out-of-scope)
  printf `%s` decode divergence is updated — fixed by this change — and
  a new end-to-end pin asserts typed `__RUBASH_CSB1_<hex>;` prints
  verbatim through printf/echo (GNU 5.3.0 prints it literally).
- Stale comments naming `__RUBASH_CSB1_` as the live payload form in
  command_prepare.rs field-split, arrays.rs finalize_comsub_element and
  locale.rs decode tables now reference the U+E319 sentinel.

Drive-by (test-only, pre-existing on the base): src/builtins/cd.rs's
two #[cfg(windows)] tests still built HashMap::new() for
execute_with_io after 4aaedfb (#916 follow-up) moved the parameter to
&mut VarTable — `cargo test --lib` did not compile on Windows. The
tests are cfg'd out on Linux/macOS CI, so the break was invisible
there; VarTable derefs to the value map, bodies unchanged.

No production-code change; test + comment updates only.

Refs #840

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@caomengxuan666

Copy link
Copy Markdown
Member Author

Follow-up commit 307e36c fixes the "Rust tests" CI failure: two command_word_materialization_tests asserts still fed the retired ASCII __RUBASH_CSB1_<hex>; form — updated to the U+E319 sentinel, with a new verbatim pin for the typed lookalike (divergence 2). Also retires remaining stale __RUBASH_CSB1_ references (substitution_metadata test input, comments in command_prepare/arrays/locale) and adds the end-to-end printf/echo pin in tests/issue824_marker_decode_boundary_regressions.rs.

Drive-by (test-only): src/builtins/cd.rs's two #[cfg(windows)] tests still built HashMap::new() for execute_with_io after 4aaedfb moved the parameter to &mut VarTable — cargo test --lib did not compile on Windows (cfg'd out on Linux/macOS CI).

CI: Rust tests / goldens / shell functionality / cross-target all green; Rust tests (macOS) queued on runner availability.

Generated with Devin

@caomengxuan666

Copy link
Copy Markdown
Member Author

验证通过,实跑复核(本地 build @307e36c0,GNU 对照 = WSL bash 5.3.0(1) LC_ALL=C.UTF-8,两侧字节 cmp):

票面三分歧(stdin shell 面,逐字节一致 9/9 探针)

  • 形1 a=($'\uE314Z'); declare -p a:master 打 [0]="<E400><E314>Z" → 本分支 = GNU(([0]="<U+E314>Z") 原字节)✓
  • 形1b 读回 ${a[0]}、f4 a+=($'\uE30D')、f5 arr=($'\uE30A'..$'\uE30F')、f6 typed-cell 读回 + d+=(x):全部 = GNU(形3 的 v=$'\uE30D' printf/declare 双脸同样一致)✓
  • 形2 x='__RUBASH_CSB1_41;' printf/echo/declare -p 三路:master 解码成 A → 本分支逐字打印 ✓

家族回归 34/34 绿(debug 构建):issue843(#853) 12、issue735 5、issue824 9(8 旧 + 新增 typed-CB1 pin)、marker_leak_golden 8。

引用链覆盖:command_prepare.rs(materialize 快路径改 contains_word_marker_bytes 门 + E400-aware restore;U+E319 带 0xEE 字节被快路径探针覆盖,核对过 markers.rs:448)、assignment_expansion.rs(restore_sq_content_markers、E302 尾 trim 全部 trim_bare_sentinel_suffix 化、decode_compound_expansion_carriers 六哨兵规则表)。全 src 扫描无剩余注册区盲 .replace(唯一命中是 conditional.rs:520 的生产侧 escape,正确保留)。

一个非阻塞残留(记档):rubash -c "printf '%s\n' '__RUBASH_CSB1_41;'" 在本分支仍解码成 A(master 同样 A,非本 PR 引入/恶化;-c 脸与 stdin 脸走不同 materialize 入口)。票面三分歧在 shell stdin 面(票的复现面)已全清;-c 脸的形2 建议开后续票跟进。CI 的 macOS Rust tests job 是 cancelled(15m 无失败步骤、无断言日志;同套件在 #944 run 绿)——基础设施取消,非本 PR。

合并(--squash --admin)。

@caomengxuan666
caomengxuan666 merged commit 7aff1b7 into master Oct 20, 2026
11 of 12 checks passed
caomengxuan666 added a commit that referenced this pull request Oct 21, 2026
…is double-escape only (rubash#948)

The -c face skipped entry escaping entirely, so a literal marker-zone
char in a user-supplied command string (e.g. a typed U+E319 sentinel or
U+E000 introducer) was read as live protocol and decoded into its payload
char where GNU prints the literal glyph. stdin/script faces were already
protected by bytes_to_script_text / bytes_to_shell_text (#856/#947).

Semantic boundary, aligned with the #947 respawn comment: the exclusion
is a DOUBLE-ESCAPE exclusion only, not an all-`-c` exclusion. Respawned
`&`/coproc children (RESPAWNED_CHILD via __RUBASH_SHELL_PID /
__RUBASH_COPROC_CHILD, incl. __RUBASH_CMD_FILE transport) receive
serialized AST already in transport spelling and keep skipping entry
escaping. Every other -c string is fresh source like a script file and
is now escaped by new substitution_metadata::command_string_entry_text —
which additionally preserves an existing E400+zone pair verbatim because
a rubash parent's argv materialization emits pairs when it launches
another rubash -c (plain spawned children, not only & respawns, can carry
transport spelling). A lone typed U+E400 remains the documented
ambiguous seam.

Probes: rubash -c 'echo "x<U+E319>41;y"' -> x<U+E319>41;y (was xAy);
typed A via -c verbatim; respawned-child transport
spelling still decodes as protocol (no double-escape). Residual noted
for follow-up: a parent-side argv materialize mangles a literal U+E000
word to bare E400+payload when spawning a child — separate root cause
outside the -c entry boundary.

Fixes #948

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@caomengxuan666
caomengxuan666 deleted the fix/840 branch October 21, 2026 08:12
caomengxuan666 added a commit that referenced this pull request Oct 21, 2026
…chanism at the U+E319 sentinel

#947 retired the ASCII `__RUBASH_CSB1_<hex>;` payload spelling in favour
of `U+E319<hex><hex>;` (COMSUB_PAYLOAD_SENTINEL, markers.rs). Resolution
keeps the #729 extension and swaps only the spelling:

- execution_misc.rs protect_command_substitution_output: extended byte
  set preserved (registered C0 markers 0x01/0x02/0x03/0x05 +
  0x10..=0x1f), emitted as sentinel+hex+';' per #947's grammar.
- conditional/pattern.rs: sides_need_byte_char_matching gates on
  COMSUB_PAYLOAD_SENTINEL (its 0xEE lead-byte probe already covered the
  E3xx plane); decode_payload_prefixes_to_pairs rewritten as
  decode_payload_sentinels_to_pairs with the same E400-aware grammar as
  execution_misc decode_command_substitution_payload. The four
  case_pattern_matches* entry points all use the wider gate (master's
  narrower either_side_needs_byte_char_matching removed; the '['
  exclusion dropped — flattened_literal_backslash_marker_matches_backslash
  requires the gate to fire on '['-bearing patterns).
- markers.rs: stale COMSUB_PAYLOAD_PREFIX MarkerInfo row deleted (the
  sentinel row already carries Output+Storage); the boundary-owner list
  and first-codepoint honesty table repointed to the sentinel names.
- manifest.tsv: union — master's issue rows + the two carrier-729/735
  rows (LF).

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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.

marker 输出边界残留三分歧(#824 审计副产品,非 debug 形状分歧,GNU 对照在案)

1 participant