Skip to content

fix(path): fold carrier colons per component in both fold twins (#1874) - #1876

Merged
caomengxuan666 merged 2 commits into
mainfrom
fix/1874-fold-carrier-components
Nov 25, 2026
Merged

caomengxuan666 merged 2 commits into
mainfrom
fix/1874-fold-carrier-components

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Refs #1874 — UNVERIFIED-BY-CAPTAIN

Defect

fold_carrier_colons (winux-core) and its C++ twin fold_carrier_colons_w (native_path.cppm) encoded only the operand's final component. Any literal colon in a non-final component passed through to Win32, so bundled applets could not resolve the carrier tree the shell itself creates: ls x:y/z, ls ./x:y/z, ls C:\…\x:y\z all failed while the U+F03A spellings worked (real-host separation evidence in #1874; this is also the winuxcmd-side residual of rubash #4188, whose shell funnel went per-component in rubash #4198).

Fix (one mechanism, both twins, byte-identical)

Both folds now encode every component, exempting exactly one colon: the path's own drive designator in its absolute form (D:\ / D:/). Implementation is an exempt-index scan replacing the tail scan in both files; no consumer was patched individually — normalize_operand/prepare_operand and normalize_api_operand_w/canonicalize_path_w pick the new behavior up through the shared fold, as before.

Contract points, each probed against Git Bash (MSYS) on a real Windows host before landing:

  • ADS-shaped spellings are carrier names in every component (plain.txt:stream is one encoded file on disk, no base file, no stream) — encode, no ADS exemption.
  • A bare D: is a relative colon name, not the drive: Git Bash's ls D: does not name the drive, and touch D: creates the carrier file D<F03A> in the cwd. It now folds like D:name (find hard-crashes (0xC0000409) on trailing-dot dirs and >MAX_PATH recursion; 'D:name' operand resolves 3 different ways across applets #1283 contract preserved and extended).
  • A designator-shaped component mid-path (Z:\nope\D:\…, a/D:/b) folds as an ordinary component.
  • Verbatim/device spellings (\\?\, \\.\) keep passing through untouched — the caller's own responsibility, as before (deliberate boundary kept; the rubash funnel differs here because its input is shell spellings, never raw verbatim).

Contract change / pin re-baseline (called out per the cross-implementation rule)

This is a cross-implementation contract change: both folds move together, and the pin baseline moves with them.

What this PR deletes

  • The final-component mechanism in both folds: the tail scan (rfind separator / find_last_of), the tail-only replacement loop, and the two-character bare-drive exemption — replaced by the exempt-index scan.
  • The superseded contract text in both doc comments ("final component", "the bare drive keeps its drive meaning").
  • Two superseded pin expectations (listed above). No functions, files, or user-visible messages are removed.

Net-line accounting

Total +193/−40 across 5 files. Tests (pin commit 32406e3): +128/−3 (winux-core unit pins, canon boundary pins, C++ ls/stat applet pins). Production (fix commit 7f576d1): +65/−37 (winux-core/src/path.rs, src/utils/native_path.cppm — the increase is mostly the new contract documentation in both twins).

Verification (devin-windows, Windows Server 2022; gnu toolchain + winuxcmd-driver as the acceptance vehicle, same precedent as #1872/#1873)

No user-visible text changes; no I18N catalog impact.

Fail-first pins for the per-component fold contract: winux-core unit
pins (non-final components, ADS-shaped spellings, mid-path designator
shapes, bare D: as a relative colon name), canon boundary pins through
prepare_operand, and C++ ls/stat applet pins against an on-disk
carrier tree. The bare-D: and canon pins are re-baselined to the
#1874 contract ruled with the rubash #4198 caliber and probed against
Git Bash on a real host.
fold_carrier_colons (winux-core) and fold_carrier_colons_w
(native_path.cppm) encoded only the final component, so operands
with a literal colon in a non-final component (x:y/z, ./x:y/z,
C:\x:y\z) never resolved the carrier tree the shell creates.
Both folds now encode every component, byte-identically: the one
exemption is the path's own drive designator in its absolute form
(D:\ / D:/); a bare D: is a relative colon name and folds like
D:name (MSYS contract, probed against Git Bash); designator-shaped
components mid-path fold as ordinary components; verbatim/device
spellings keep passing through untouched.
@caomengxuan666

Copy link
Copy Markdown
Member Author

CAPTAIN-VERIFY — merging.

Reviewed head 7f576d1. Both carrier folds — Rust fold_carrier_colons and its C++ twin fold_carrier_colons_w — now encode per component under one exemption scan: the only exempt colon is the path's own absolute drive indicator. The pre-work probes carry the two judgment calls in this PR, and both are accepted:

  • ADS: plain.txt:stream lands on disk as a single carrier-named file with no base file — it is a carrier name, never a stream, so there is no ADS exemption to preserve. Settled by the on-disk name dump, not by assumption.
  • Bare D:: the old exemption (bare drive letter keeps drive meaning) contradicts the MSYS contract the probes measured — Git Bash does not resolve ls D: to the drive, and touch D: creates the encoded name in the cwd. The contract change and the two re-baselined pins (path.rs, canon.rs) are flagged in the PR as required; this also brings this repo into line with the rubash funnel ruling in #4198. Verbatim/device prefixes still pass through under the existing dual-implementation pin contract, with the divergence from the rubash funnel noted and reasoned in the PR.

Fail-first reds carry the exact expected signatures; the full-consumer differential against pristine is name-set identical (the one red, df::tests::type_filters, is the known host leftover on both sides); the host matrix runs 14/14 against pristine's 5/14; the C++ twin was validated 17/17 through an extracted harness with the in-PR applet pins executing in CI (28 pass / 4 skipping / 0 fail). The niu-side residual from rubash #4188 (by-name relative ls x:y/z) was reproduced red with the shipped exe and is green with this build, the bundled tree restored and hash-verified afterwards.

@caomengxuan666
caomengxuan666 merged commit f60a74a into main Nov 25, 2026
32 checks passed
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