Repository navigation
fix(path): fold carrier colons per component in both fold twins (#1874) - #1876
Conversation
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.
|
CAPTAIN-VERIFY — merging. Reviewed head
Fail-first reds carry the exact expected signatures; the full-consumer differential against pristine is name-set identical (the one red, |
Refs #1874 — UNVERIFIED-BY-CAPTAIN
Defect
fold_carrier_colons(winux-core) and its C++ twinfold_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\zall 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_operandandnormalize_api_operand_w/canonicalize_path_wpick 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:
plain.txt:streamis one encoded file on disk, no base file, no stream) — encode, no ADS exemption.D:is a relative colon name, not the drive: Git Bash'sls D:does not name the drive, andtouch D:creates the carrier fileD<F03A>in the cwd. It now folds likeD: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).Z:\nope\D:\…,a/D:/b) folds as an ordinary component.\\?\,\\.\) 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.
winux-corepin:fold_carrier_colons("D:")wasNone("the drive itself"), nowSome("D<F03A>").canonboundary pin:prepare_operand("D:")was"D:", now the carrier spelling; the pin comment is rewritten to state the new contract.D:name, final-component shapes, the C++ applet tests) are unchanged and still pass.What this PR deletes
rfindseparator /find_last_of), the tail-only replacement loop, and the two-character bare-drive exemption — replaced by the exempt-index scan.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 commit7f576d1): +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)
NonevsSome("x<F03A>y/z"); canon:"D:"vs"D<F03A>"); after the fix all pass.3940c003— failure name sets identical (sole reddf::tests::type_filters, a host-environment leftover reproduced on pristine, as recorded in [bug] operands with a..component fail across fs applets (stat/touch/fmt family) — split from #1869 #1872/[mkdir] -p 接盘符绝对路径:同盘 cwd 下「D:/…」按盘符相对落盘(目标不建、cwd 长树),反斜杠写法又不建父级 #1870).mkdir -p q:w/cbuild + roundtrip) flips red→green, guards (encoded spelling, plain operands) green on both.fold_carrier_colons_wwas extracted mechanically from both revisions into a standalone MinGW harness: old function 8 failures on the pin table, new function 17/17. The C++ applet pins in this PR (ls/stat, modeled on the find hard-crashes (0xC0000409) on trailing-dot dirs and >MAX_PATH recursion; 'D:name' operand resolves 3 different ways across applets #1283 tests) run under CI.ls.exename in the W2 niu tree, niu's by-name relativels x:y/zgoes rc=2 → rc=0 andstat x:y/zrc=1 → rc=0 (the #4188 residual). The bundled tree was restored byte-identically afterwards (sha256 verified).No user-visible text changes; no I18N catalog impact.