Skip to content

WIP: fix host external-command channel prefix composition (#1766) - #1779

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix9/carrier-host1766
Oct 26, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix9/carrier-host1766

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Fixes #1766

Cluster: carrier-host1766 (REPORT to follow in workspace rubash-fix9/clusters/carrier-host1766/REPORT.md).

  • Top-level host path: skip appends (dispatch seam already composed them into the table) and strip COMPOUND_ASSIGNMENT_MARKER — mirrors apply_external_environment.
  • Pipeline-stage host path: compose appends as tempenv_scalar_view(export target) + stripped RHS — mirrors the stage spawner (GNU values 145 / 1(9) / 10(30) / ([j]=w) / var=origx).
  • Handler contract untouched; tempenv_scalar_view widened to pub(in crate::executor) for reuse.
  • Regression file tests/issue1766_host_env_prefix_regressions.rs (16 tests, top-level + stage + nameref + restore + no-marker invariant).

Gates NOT yet landed (do not merge until the gate script reports green): issue file + carrier neighbors + lib failure set == this-tree baseline + diffcorpus subset of {ms10} + cargo check + per-file fmt. Known pre-existing caveat: the top-level compound-append exact value (GNU 1(9)) rides the carrier table fix in PR #1767; this PR pins no-marker-leak on that row until then.

…nts instead of re-applying raw values (#1766)

GNU variables.c assign_in_env / execute_cmd.c: prefix assignments are
applied to the shell table before the command runs, and a compound
tempenv word binds as the literal list text; variables.c
make_variable_value with ASS_APPEND composes the window value for
appends. The host channel loop re-applied every prefix assignment's
expanded value into the host env map, so a top-level append overwrote
the composed value with the raw RHS (a+=5 showed 5, not 145), a
compound word leaked the internal marker (a=__RUBASH_CA1__(x y)), and
a pipeline-stage append did the same from the window value — the
rubash#1620 root-cause-2 shape on the embedded-host channel.

Top-level dispatch (assignments already applied by the dispatch seam):
skip appends, inheriting the composed table value, exactly like
apply_external_environment. Pipeline-stage dispatch (assignments never
reach the table): compose tempenv_scalar_view of the export target plus
the marker-stripped RHS, the way the stage spawner does (scalar 145,
indexed element 0, assoc appended list; nameref resolves to its target).
Both paths strip COMPOUND_ASSIGNMENT_MARKER. The handler contract
(FnMut(&[String], &HashMap)) is untouched; tempenv_scalar_view is
widened to pub(in crate::executor) for reuse, as the carrier change
does. The top-level compound-append value (GNU 1(9)) still rides the
carrier table fix (PR #1767); this change pins only the host loop's
no-leak duty on that row until then.

Fixes #1766
@caomengxuan666
caomengxuan666 marked this pull request as ready for review October 26, 2026 12:34
@caomengxuan666
caomengxuan666 merged commit 711d429 into master Oct 26, 2026
10 of 11 checks passed
caomengxuan666 added a commit that referenced this pull request Oct 27, 2026
…s-only) (#1812)

* test(issue1766): forward-port host-env harness drop + upgrade weak compound-append row to exact 1(9)

Forward-port of 35e527a (fix9/carrier-host1766), which missed the
#1779 merge: drop the Executor before unwrapping the capture Arc in
run_host_captures, otherwise all 16 tests panic in try_unwrap before any
assertion runs. Also upgrades the formerly weak top-level compound-append
row (no-marker-leak only) to assert the exact GNU value 1(9); its upgrade
condition is met now that #1767 has merged. The 5 base-clone rows
(marker hits on __RUBASH_LAST/CURRENT_COMMAND, nameref contains_key ref)
are deliberately left untouched pending the parent's ruling on the host
map contract (rescope test invariants vs exported-only host map).

Refs #1766

* fix(executor): drop nameref alias cells from the host env map (rubash#1766)

Adjudication (c) for the last two PR #1812 pins
(issue1766_top/stage_nameref_append_binds_target): the pins are
correct GNU expectations - 'declare -n ref=var; var=orig; ref+=x env'
prints var=origx and NO ref= line - and the product leaked the
nameref cell itself ('ref=var', the target NAME as text) into the
host env map, whose base is a full-table clone.

invoke_host_external_command now removes nameref alias cells from
that base clone, selected by the NAMEREF_VARS attribute set (never
a name blacklist). The target cell stays, so nothing is lost; the
prefix composition below (tempenv_export_name already resolves
prefix names to their targets) is untouched, as is the rest of the
channel contract (the clone still carries unexported non-prefix
cells - issue1766_top_tempenv_restores_after_host_command pins
a=14 in the second capture).

Gate: tests/issue1766_host_env_prefix_regressions.rs 16/16
(was 14/16 on this branch).

---------

Co-authored-by: 曹梦轩 <[email protected]>
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.

Host external-command channel re-applies raw prefix assignments (incl. carrier markers) into the host env map

1 participant