Repository navigation
feat(2.0): rust2 wave1 pilot — library-form commands + differential gate (#1488) - #1548
Merged
Merged
Conversation
…ate (#1488) First pilot batch of the 2.0 library-form track: 15 wave-1 commands (true false test [ basename dirname printenv pwd mkdir rmdir readlink realpath chmod chown df) implemented as library functions with injected IO, explicit env/cwd, no process globals, status code returned instead of exit(). Workspace (rust2/, std-only, MSVC target): - winux-core: shape contract (Io / EnvSource / Ctx / CmdResult), ABI failure status 125, in-memory test support. - winux-cmds: command modules aligned to GNU coreutils 9.4 (probed on WSL), Windows-permission subsets documented in module docs (chmod owner-write -> readonly attr; chown validated no-op with LookupAccountNameW; df local volumes via raw kernel32 FFI). - winuxcmd-ffi: cdylib C ABI (winuxcmd_run/free_buf/has_command) with catch_unwind at the boundary; explicit argv/envp/cwd strings and byte buffers only — no environment stdio crosses the ABI. - winuxcmd-driver: thin CLI adapter (the only process-state reader), used by the differential gate. Differential gate (gate/): three-way Rust vs GNU (WSL coreutils 9.4, `env <name>` so argv[0] prefixes match) vs C++ Debug dispatcher (build-vs/usr/bin/winuxcmd.exe). 338 generated cases (gen-cases.py — hand-edited tab columns had mis-aligned; generator is the fix), modes strict/exit/win/note: stdout bytes + exit status byte-equal to GNU on every strict case. Result: 307 GNU-gated + 31 win-only + 3 notes, all GREEN, stable across consecutive runs (GATE-REPORT.md, regenerate with gate/make-report.sh). Unit tests: 53, all green (in-memory IO + scratch dirs); test threads pinned at 4 in .cargo/config.toml (libtest capture deadlock at 32 logical CPUs on this host). Scope guards: no C++ changes, no dispatcher/package wiring (belongs to the replacement wave), chmod/chown/df implemented to the documented platform subset only. Refs #1488
This was referenced Nov 10, 2026
Merged
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
First pilot batch of #1488 (命令库化): the 15 wave-1 commands implemented as library-form functions in Rust — explicit injected IO, explicit env/cwd, no process-global state, status code returned instead of
exit().Shape (the point of the pilot)
Io { stdin: &mut dyn Read, stdout/stderr: &mut dyn Write }— injected; commands never touch process stdio. Verbose output (mkdir -v,rmdir -v) goes to stdout with straight quotes and is byte-gated, exactly like GNU.Ctx { cwd, env: &dyn EnvSource }— explicit; the driver'sProcessEnvdoes exact-name lookup (Windows env is case-insensitive; GNUprintenv gfoomust not findGFoo).winuxcmd-ffi(cdylib):winuxcmd_runpasses argv/envp/cwd as C strings and stdio as explicit byte buffers;catch_unwindat the boundary maps panics to status 125. No CRT fd binding crosses the ABI.Workspace
rust2/(std-only, zero crates):winux-core(contract) →winux-cmds(15 commands) →winuxcmd-ffi(ABI) →winuxcmd-driver(gate adapter). Location rationale inrust2/README.md(keeps Rust out of the CMake glob; mirrors the branch name).Differential gate (three-way)
bash gate/run-gate.sh— Rust driver vs GNU coreutils 9.4 (WSL, native ext4 scratch,env <name>so argv[0] prefixes match) vs C++ Debug dispatcher (build-vs/usr/bin/winuxcmd.exe).gate/gen-cases.py; ≥16 per command, 45 fortest), modesstrict/exit/win/note— rules inGATE-REPORT.md.-a-tighter-than--oprecedence, 2/3-argtesterror wording,readlink -f -elast-wins,chmod --referencehas no MODE operand,chown 0:isinvalid spec,mkdir -v/rmdir -vverbose goes to stdout,basename ab abkeepsab.Completion of the 15
LookupAccountNameWresolution →invalid user/invalid group/invalid spec), df (local volumes via raw kernel32 FFI;--outputnot implemented →note).Scope guards
No C++ changes; no dispatcher/package wiring (belongs to the replacement wave itself); unit tests 53/53 green (
cargo t, threads pinned at 4 — libtest capture deadlock at 32 logical CPUs);cargo fmt --checkclean.Refs #1488