Skip to content

fix: align path-form expectations with rubash #556 POSIX persona - #283

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix/path-form-alignment-556
Oct 13, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix/path-form-alignment-556

Conversation

@caomengxuan666

@caomengxuan666 caomengxuan666 commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Background

rubash#556 (P0 rubash#537, owner-adjudicated 2026-10-12) made the engine render $PWD/pwd in the POSIX persona form (/c/...) unconditionally and retired the native-style hatch that starved nvm's find_up loop. It reached niubash through the branch = master git dependency (CI clones rubash master into ../rubash; the lock only pins the version), turning command_mode_compound_commands_keep_home_paths_native (tests/repl_command.rs:191) red on every PR — #278 was the first to hit it.

What the failing test originally protected

Introduced in e10b9f0 ("Prepare plugin-first 0.10.0 release"), the test pinned two contracts on one compound -c line:

  1. PWD rendering form — under the pre-style: cargo fmt — clear master fmt debt from #544 #556 ruling, echo PWD=$PWD; pwd had to stay native (!stdout.contains("/c/")). cat ~/.niubashrc >/dev/null redirects the cat shim's arg= echo to /dev/null, so the /c/ scan could only ever trip on the PWD/pwd output — it is purely a PWD-rendering assertion.
  2. Win32 spawn boundary — catrc:ok: the tilde-expanded argv handed to an external cat.cmd must stay usable; the shim exits /b 12 on a slash-drive first argument.

Judgment (per the #556 ruling; no re-litigation)

Assertion (1) is a PWD-rendering pin → aligned to the persona form. Assertion (2) is the spawn boundary → kept as-is; empirically it still passes post-#556. No #556 overreach regression found — nothing to escalate upstream on that front.

Finding: niubash's own remaining hatch

With post-#556 rubash, niu's PWD form was shape-dependent: the host cwd sync (Shell::new startup + sync_process_cwd_from_executor_pwd per command) re-stamped the executor PWD into native drive form, so niu -c 'cd X; pwd' printed native while niu -c 'cd X && pwd' printed persona. That is precisely the inconsistency the ruling retires, so this PR routes every host PWD stamp through rubash's own canonical renderer (shell_pwd_display_path, after the root mapping). The spawn boundary is untouched: process cwd sync, PATH translation, child argv, TMPDIR exports all keep native spelling.

Also drops the inert NIU_SHELL_PATH_STYLE / WINUXSH_SHELL_PATH_STYLE exports (rubash#556 deleted the engine-side readers — "no remaining readers"; AGENTS.md's bridge policy requires removal once rubash retires its readers) and updates the AGENTS.md bridge line accordingly.

Alignment list

  • tests/repl_command.rs: command_mode_compound_commands_keep_home_paths_native → command_mode_compound_commands_posix_pwd_and_native_spawn_argv (persona PWD/pwd expected; catrc:ok kept; ruling cited in the doc comment).
  • tests/host_contract.rs: cwd_cd_pwd_and_windows_child_process_agree, slash_drive_paths_are_compat_input_not_default_output (renamed slash_drive_input_cd_works_and_pwd_renders_persona_form), slash_drive_root_cd_switches_to_drive_root, native_backslash_drive_paths_work_for_cd, drive_only_cd_and_bare_drive_commands_switch_to_drive_root, tilde_resolves_to_normal_windows_home — pwd lines expect persona; cmd.exe /C cd child lines keep native expectations.
  • tests/cwd_state.rs: normalize() maps drive-colon paths onto the persona form — the suite keeps pinning the cwd-state contract, not the rendering form.
  • crates/niubash-runtime/src/shell.rs: persona PWD stamps + unit test interactive_cd_syncs_process_cwd_and_normalizes_pwd aligned.
  • Unchanged by design (rubash#556-preserved, verified green): slash_drive_mktemp_template_creates_file (mktemp native output is upstream-locked), issue162 TMPDIR child boundary, issue153 bare-slash argv.

Rebase on #281/#262 and the merge-ref CI incident

Verification

Reproduced first with a post-#556 rubash checkout, then re-verified after the rebase against rubash tip f9fe68c6:

rubash#556 (P0 rubash#537) made the engine render $PWD/`pwd` in the
POSIX persona form (/c/...) unconditionally and retired the native-style
hatch. It reached niubash through the branch = master git dependency (CI
clones rubash master into ../rubash), turning
command_mode_compound_commands_keep_home_paths_native red on every PR
(#278 first).

The owner ruling: PWD form is shell semantics (msys persona consistency,
nvm find_up death loop, GNU parity); native drive spelling is correct
only at the Win32 spawn boundary (path contract).

Engine-side alignment (niubash-runtime):
- The host cwd sync (startup + per-command) re-stamped the executor PWD
  into native drive form, making the rendered form depend on which route
  executed (simple sequences native, compound lines/cmdsub persona) -
  exactly the inconsistency the ruling kills. The stamps now go through
  rubash's own canonical renderer (shell_pwd_display_path) after the
  root mapping, so PWD is persona everywhere while the process-cwd sync,
  PATH translation, and child argv stay native spawn-boundary behavior.
- Drop the inert NIU_SHELL_PATH_STYLE / WINUXSH_SHELL_PATH_STYLE
  exports: rubash#556 deleted the engine-side readers, so the vars only
  misinformed children (the AGENTS.md bridge policy requires removal
  once rubash retires its readers).

Test alignment (assertions updated, with the ruling cited inline):
- repl_command: command_mode_compound_commands_keep_home_paths_native ->
  command_mode_compound_commands_posix_pwd_and_native_spawn_argv; PWD/
  pwd expected persona, catrc:ok spawn-boundary guard kept. The persona
  assertions pin the FORM (drive prefix + home basename, native drive
  spelling asserted absent) instead of full-path bytes: the first cut
  compared full strings and was red on the CI merge-ref while green
  locally, so environment path-spelling variance is explicitly out of
  the contract under test.
- host_contract: cwd_cd_pwd_and_windows_child_process_agree,
  slash_drive_paths_are_compat_input_not_default_output (renamed to
  slash_drive_input_cd_works_and_pwd_renders_persona_form),
  slash_drive_root_cd_switches_to_drive_root,
  native_backslash_drive_paths_work_for_cd,
  drive_only_cd_and_bare_drive_commands_switch_to_drive_root,
  tilde_resolves_to_normal_windows_home: pwd lines expect persona;
  cmd.exe child lines keep native expectations.
- cwd_state: normalize() maps drive-colon paths onto the persona form so
  the suite keeps pinning the cwd-state contract, not the rendering.
- shell.rs unit test interactive_cd_syncs_process_cwd_and_normalizes_pwd
  expects the persona form.

Unchanged by design (rubash#556-preserved): mktemp native output
(slash_drive_mktemp_template_creates_file), TMPDIR child boundary
(issue162), bare-slash argv (issue153), PATH translations.
@caomengxuan666
caomengxuan666 force-pushed the fix/path-form-alignment-556 branch from d3a5031 to 52cd888 Compare October 12, 2026 07:01
@caomengxuan666
caomengxuan666 merged commit 88aa66b into master Oct 13, 2026
11 of 27 checks passed
@caomengxuan666
caomengxuan666 deleted the fix/path-form-alignment-556 branch October 13, 2026 02:06
caomengxuan666 added a commit that referenced this pull request Oct 13, 2026
…1.4.0 section (#326)

- The [Unreleased] entries (#284/#287, #293-#304, #313) move into
  [1.4.0]; [Unreleased] is empty again.
- Newly recorded (today's wave): Git Bash compatible factory default
  prompt (#292, headline), WT-form shortcuts (#290/#211), the paste
  burst trailing-Enter fix (#308/#291), self-update SHA256 + release
  pinning (#311/#312), managed-block convergence (#324), completion
  tables/NIU_COMPDEFS/NIU_ENV probe (#305-#307), -s on-demand stdin
  (rubash#586 host half), bash/rbash invocation faces (#321/#322).
- Older gaps recorded: closed-stdout pipe contract (#245/#286), history
  session-end write-back (#265), sh POSIX contract (#262), PWD persona
  alignment (#283), one-shot fast path (#270), --cwd-state (#272),
  --encoded-command (#271), REPL-command highlighting (#281), docs
  passes (#255/#225/#226/#227), MSRV (#267), easter-egg prune (#264).

CHANGELOG-only change; no version claims.
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