Skip to content

rust2 wiring wave3b: join/tsort/hostid/users/timeout/expand/unexpand/numfmt handlers -> rust2 bridge (#1488) - #1567

Merged
caomengxuan666 merged 30 commits into
mainfrom
rust2/wire-wave3b
Nov 11, 2026
Merged

caomengxuan666 merged 30 commits into
mainfrom
rust2/wire-wave3b

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Wiring wave3b of the WinuxCmd 2.0 mechanical replacement (#1488), per rust2/REPLACEMENT-RECIPE.md. All 8 batch commands' handlers are now one winux::rust2::run_command(...) call each; REGISTER_COMMAND metadata stays byte-identical (help/man surface unchanged); the C++ bodies are deleted (no dual track):

  • join, tsort, hostid, users, timeout — wired earlier on this branch
  • expand, unexpand, numfmt — wired in this turn

CMake: all 8 appended to WINUXCMD_RUST2_COMMANDS; join/expand/unexpand/numfmt/tsort declared stdin readers in the bridge (v1 whole-buffer ABI, no streaming v2). Known 1.x C++ divergences are NOT inherited (users WTS values, hostid hash input, numfmt --unit-separator/-M/-l/ZYRQ suffixes, expand/unexpand pre-parse rejections) — behavior now follows GNU/Rust.

Library fixes surfaced by the wiring gates (each GNU-source-cited + WSL 9.4 probed)

  • expand obsolescent -NUM specs ride the real getopt grammar (expand.c:48 it:0::1::...9::, expand.c:204-215 parse_tab_stops(optarg - 1)): -4,8 converts; bad chars get the expand-common.c:208 tab-list diagnostic; -t -5 value slot stays data; -- ends conversion; blank-separated specs work
  • unexpand digit form does NOT imply -a (unexpand.c default case), and columns count UTF-8 bytes like unexpand.c getc/column++ (BOM = 3 columns)
  • dispatcher: OptionParsePolicy::digit_led_short_tokens_as_positionals for expand/unexpand only — the generic cluster rule no longer rejects -4,8 with "invalid option -- ','" before the handler runs

The three gates

  • a) GNU oracle: run-gate.sh with the wired exe as the rust side — expand 30/30, unexpand 27/27 (new ue27 locks the leading-only digit form), numfmt 74/74, all GREEN byte-for-byte (stdout+rc) against WSL coreutils 9.4; stderr shape matrix 19/19 probes match (recorded, not gated: program-name prefix + straight-vs-curly quotes)
  • b) existing tests: full ctest failing set before == after (20 pre-existing environment failures, none in the batch); the 10 unit tests that asserted 1.x-only behavior were realigned to GNU 9.4 probes (open-failure wording, --debug silence, C-locale grouping, -U rejection, BOM byte columns); differential corpus expand 2/2, unexpand 2/2, numfmt 6/6
  • c) old-vs-new exe: ledger r=c columns — every r=c:no row is a documented, pre-existing 1.x divergence now re-derived from GNU (expand ex10/ex18, unexpand ue16/ue17, numfmt --header/--field/-d empty/underterminated/--to-unit lowercase), none introduced by the wiring

GATE-REPORT.md wave3b section updated with the wiring follow-up.

GNU coreutils 9.4 semantics, every case probed against WSL (target/probes/
p_join*.sh): sequential merge with per-file order checks (default warns once
an unpairable was seen and exits 'input is not in sorted order'; --check-order
fatal; --nocheck-order last-wins), xstrtol field numbers ('01' is 1, huge
clamps keyless), one-byte -t ('' means newline whole-line records, '\0'
means NUL, multi-byte UTF-8 tabs rejected), -o item lists with empty items
fatal and 'auto' built from the first lines, keyless lines never pair but
print as unpaired with an empty key, case-folded -i keys.

51 gate cases (36 strict + 15 exit), all green vs GNU 9.4; C++ parity 51/51.

Ref: #1488 (wave3b)
GNU coreutils 9.4 semantics (probed): whitespace token pairs, odd token
count fatal with the input-name prefix, duplicate edges silent, self-pairs
register the node without a loop, ready queue is FIFO seeded in node order
and successors join in reverse recording order ('m a' 'm z' emits m z a),
cycles break at the earliest-mentioned remaining node with the GNU
'input contains a loop:' + member report on stderr and rc 1, empty input
prints nothing. -w diverges: GNU 9.4 rejects it (the 1.x C++ accepts —
recorded, Rust follows GNU).

25 gate cases (17 strict + 6 exit + 2 win), green; C++ parity 23/25.

Ref: #1488 (wave3b)
…alue model

GNU hostid shape (8 lowercase hex digits, extra operand rejected with the
try-help line, rc 1; -h/-v/-V accepted). The 1.x C++ applet hashes the
MachineGuid registry value with MSVC std::hash; the library form keeps the
same value model — a stable per-machine 32-bit quantity — sourced from the
COMPUTERNAME environment via FNV-1a 64 (registry access is not reachable
from the std-only crate), so the printed VALUE differs from the 1.x exe and
is recorded (win-mode gates rc only).

20 gate cases (12 exit + 7 win + 1 note), green.

Ref: #1488 (wave3b)
GNU users.c: sorted space-separated login names on one line, at most one
operand, extra operand is a usage error, unknown options are usage errors,
--help/--version win. GNU 9.4 probed: an unreadable FILE operand simply
yields zero entries (rc 0) — mirrored here. The 1.x C++ applet reads the
WTS session table and falls back to GetUserNameW; the library form follows
that model with the environment face (USERNAME) as the session source, so
the printed VALUE diverges from GNU's empty utmp and is recorded (win).

20 gate cases (15 exit + 4 win + 1 note), green.

Ref: #1488 (wave3b)
…ocess

GNU coreutils 9.4 semantics (probed p_timeout/p_misc): DURATION parses like
strtod in the C locale (hex floats, inf/infs, leading whitespace and '+',
one lowercase s/m/h/d suffix — '1m30s' and '5S' are invalid, NaN and
negatives rejected, errors exit 125); Linux signal names/numbers with
32/33 reserved and RTMIN+n/RTMAX-n; optstring carries the leading '+' so
nothing after COMMAND is parsed as an option. Status contract on the
Windows mapping (TerminateProcess): timed out 124, --preserve-status
128+signal, KILL death 137 either way, 127 not found / 126 not invokable;
missing COMMAND prints only the try-help line and exits 125; --kill-after
defers the KILL phase and -s0 stays a probe. PATH-only child resolution
with the .exe-first Windows preference; the =C: environment pseudo-vars
are skipped at spawn.

30 gate cases (exit mode; children are sleep/ping under WSL and
sleep.exe/cmd.exe on Windows), green; C++ parity 28/30.

Ref: #1488 (wave3b)
…nt -NUM

GNU coreutils 9.4 semantics (probed p_expand*.sh): all -t and -NUM specs
join into ONE list in argv order ('-t 4 -t 8' accumulates, '-8 -t 4' is
the fatal descending {8,4}, '-4,8 -t 2' fatal {4,8,2}), repeat forms /N
(every multiple) and +N (anchored at the last stop), a repeat value of 0
silently ignored ('-t /0' runs at the default 8), GNU diagnostics for
zero/descending/invalid-char/too-large/misplaced-specifier lists, -i
converts only before the first non-blank, backspace rewinds the column,
padding runs stream through a bounded buffer (expand -t 99999999999 must
really write the spaces without materializing them), open failures report
'expand: FILE: <reason>' and rc 1 while later files continue.

30 gate cases (19 strict + 11 exit), green; C++ parity 28/30.

Ref: #1488 (wave3b)
GNU coreutils 9.4 semantics (probed): only leading blanks convert by
default; -a converts every run; --first-only cancels -a in either argv
order; -t/-NUM imply whole-line conversion (probed: a mid-line run converts
under '-8 -t 4' with no -a); tab stops validate PER STOP at add time —
unlike expand, the obsolescent -NUM digits accumulate into a pending value
flushed after the -t stops ('-t 8 -t 4' is the fatal descending {8,4} while
'-8 -t 4' adds {4} then 8 ascending), a comma flushes the pending digits
immediately, repeat values of 0 are ignored; the pending-blank conversion
loop is the GNU algorithm verbatim including the EOF flush of trailing
blanks on unterminated final lines.

26 gate cases (21 strict + 5 exit), green; C++ parity 24/26.

Ref: #1488 (wave3b)
GNU coreutils 9.4 semantics, probed across four probe batches
(p_numfmt*.sh): --from none/auto/si/iec/iec-i and --to none/si/iec/iec-i
with UPPERCASE-only KMGTPEZYRQ suffixes (lowercase k is an invalid suffix),
simple_strtod_human parsing (no exponent, no '+', '5.' rejected, one blank
may precede the suffix, missing-'i' and suffix-tail diagnostics),
--round from-zero default with the 999.95 -> 1.0K rescale, 18-digit
scale-none print limit with %g diagnostics, cut-style --field ranges with
second-spec and try-help errors, --invalid abort/fail/warn/ignore exit
statuses, locale-driven grouping (the C locale groups nothing even with
%'f), --header stdin-only with --header=0 invalid, line terminators kept
only when the input line had one. 9.4 differences from the 1.x C++ applet
are taken from GNU (recorded): no --unit-separator/-M/-l, unit sizes
accept only K/M/G/T/P/E(+Ki), --debug only carries the no-conversion-option
warning. 19-digit integers print exactly via a raw-text path (GNU uses
long double; f64 loses the 19th digit).

74 gate cases (49 strict + 25 exit), green; C++ parity 66/74.

Ref: #1488 (wave3b)
# Conflicts:
#	rust2/GATE-REPORT.md
#	rust2/crates/winux-cmds/src/argopt.rs
#	rust2/crates/winux-cmds/src/lib.rs
#	rust2/gate/gen-cases.py
The wave3b delivery appended the join/tsort/hostid/users/timeout/expand/
unexpand/numfmt tables with every closing bracket missing (plus a stray
early __main__ block and a duplicated seq region), so gen-cases.py did
not even parse — the committed case .tsv files masked it. Rebuilt on
main's valid base with the eight tables spliced in closed and collected;
regeneration now reproduces every committed .tsv byte-for-byte except
the pre-existing hand-maintained chmod/chown tables (gen-cases.py holds
stale copies there — emit() would clobber them; restore, not fix, here).

Refs #1488
…rs (#1488)

The v1 ABI (winuxcmd_run) already carries stdin as an explicit whole
buffer, but the bridge passed nothing, which barred every stdin-reading
applet from mechanical replacement. The boundary now declares which
rust2 commands read fd 0 (expand, join, numfmt, tsort, unexpand) and
slurps stdin through file_io::read_all_stdin for exactly those names —
console VEOF, broken-pipe EOF and closed-fd cases stay on the one
Windows read path. All other rust2 commands keep the pass-nothing
contract, so their fd 0 stays live for later pipeline consumers and
spawned children (timeout's wrapped command inherits the real handle).
The streaming v2 ABI remains the long-term replacement (recipe §5).

Refs #1488
Mechanical replacement per rust2/REPLACEMENT-RECIPE.md: the C++ body
(MachineGuid registry read + std::hash id derivation, extra-operand
check) is deleted; REGISTER_COMMAND metadata stays byte-identical and
the handler is one winux::rust2::run_command("hostid", ctx.raw_args)
call. hostid is appended to WINUXCMD_RUST2_COMMANDS.

The printed id VALUE intentionally changes (1.x divergence not
inherited per #1488): the old exe hashed the MachineGuid string with
std::hash (unstable across CRT/libstdc++ implementations), the rust2
library derives the stable per-machine id it gates against GNU shape.
rc behavior is byte-identical to the 1.x exe.

Triple gate:
- gate a (GNU oracle, run-gate.sh hostid, RUST_BIN=wired exe):
  13 GNU-gated + 7 win rows, all green (20-case table).
- gate b: ctest -R hostid 3/3 pass; full-suite base failing set saved
  at target/wire-wave3b/ctest-base-failures.txt (20 pre-existing
  failures, none in the wave).
- gate c (old vs new exe byte parity, cmd-matrix.sh hostid, 15 rows):
  rc 15/15, stderr 15/15, stdout 13/15 -- rows 01/09 print the host id
  and differ exactly by the documented value-model change above;
  every rc/error-path row is byte-equal.

Issue: #1488
Mechanical replacement per rust2/REPLACEMENT-RECIPE.md: the C++ body
(WTSEnumerateSessionsW/WTSQuerySessionInformationW session walk,
GetUserNameW fallback, operand checks) is deleted; REGISTER_COMMAND
metadata stays byte-identical; handler is one
winux::rust2::run_command("users", ctx.raw_args) call; wtsapi32
include/link dep dropped. users appended to WINUXCMD_RUST2_COMMANDS.

1.x divergence not inherited (per #1488): the old exe rejected a
missing FILE operand with rc 1 — its own comment claimed that was GNU
behavior, but WSL coreutils 9.4 measured `users <any-missing-file>`
exits 0 silently (who.c treats an unreadable utmp as empty). The rust2
library follows the measured GNU rc; everything else (session list via
the Windows value model, sorted one-per-session names, extra-operand
rc 1) is byte/rc-equal to the 1.x exe.

Triple gate:
- gate a (GNU oracle, run-gate.sh users, RUST_BIN=wired exe):
  16 GNU-gated + 4 win rows, all green (20-case table).
- gate b: ctest -R users slice green; full-suite base failing set is
  the saved 20 pre-existing failures (none in the wave).
- gate c (old vs new exe byte parity, cmd-matrix.sh users, 15 rows;
  GNU ledger from WSL): rc 15/15 vs GNU oracle; old-vs-new rc/stdout/
  stderr 14/15 byte-equal -- row 07 is the documented missing-FILE
  divergence above (GNU-side rc equal).

Issue: #1488
…1488)

Surfaced by the wave3b wiring matrix (gate c): `tsort --` must be GNU
getopt's end-of-options marker -- WSL coreutils 9.4 probes: `tsort --`
reads stdin rc 0, `tsort -- x` treats x as the FILE operand, `tsort x
-- y` reports extra operand 'y'. The hand-rolled operand handling took
`--` as a literal file name ("tsort: --: No such file or directory"
rc 1).

tsort_cmd now parses through the shared argopt::parse with an empty
option table (the sanctioned shared getopt_long invariant holder;
calling its existing API, not changing it). This also makes an
unregistered short option match GNU exactly: `tsort -w` is
`invalid option -- 'w'` + try-help rc 1 (probed; the module comment
claimed -w was accepted-and-ignored -- that was the 1.x C++ behavior,
GNU 9.4 rejects it). `tsort a --help` still answers success rc 0 (getopt
permutes; operand checks run after option parsing). Library gate tsort:
23 GNU-gated + 2 win, all green, unchanged.

Issue: #1488
Mechanical replacement per rust2/REPLACEMENT-RECIPE.md: the C++ body
(token-pair reader, FIFO zero queue, loop-break DFS, file/stdin slurp,
i18n odd-token diagnostic) is deleted; REGISTER_COMMAND metadata stays
byte-identical; handler is one winux::rust2::run_command("tsort",
ctx.raw_args) call. tsort is appended to WINUXCMD_RUST2_COMMANDS;
stdin is forwarded by the bridge's declared-reader list.

Test updated to the GNU contract: tsort_w_flag_is_noop pinned the 1.x
accept-and-ignore -w; WSL coreutils 9.4 rejects -w with `invalid
option -- 'w'` + try-help rc 1 (df6c85c). The old test's premise is
gone, so it now pins the GNU behavior.

Triple gate:
- gate a (GNU oracle, run-gate.sh tsort, RUST_BIN=wired exe):
  23 GNU-gated + 2 win rows, all green (25-case table).
- gate b: ctest -R tsort 7/7 pass; full-suite base failing set is the
  saved 20 pre-existing failures (none in the wave).
- gate c (old vs new exe byte parity, cmd-matrix.sh tsort, 17 rows;
  GNU ledger from WSL): rc vs GNU 17/17; old-vs-new rc/stdout/stderr
  16/17 byte-equal -- row 12 (-w) is the documented GNU-rejects
  divergence above; row 17 (`tsort --`) was fixed library-side
  (df6c85c) and is now byte-equal too.

Issue: #1488
…1488)

Surfaced by the wave3b wiring matrix (gate c): the obsolescent forms
where an option's argument is a separate argv entry were rejected as
"extra operand". Probed against WSL coreutils 9.4 and re-derived from
join.c main()/add_file_name():

- `join -o 1.2 2.2 f1 f2` absorbs "2.2" into the field list (GNU
  output `1 X`/`2 Y` rc 0); chained absorption dies on the first bad
  spec (`... 2.2 abc f1 f2` -> "invalid file number in field spec:
  'abc'"); an operand BEFORE -o pins names[0] as MUST_BE_OPERAND so
  the third name resolves the SECOND slot (`X -o 1.2 f1 f2` ->
  "invalid file number in field spec: 'f1'").
- `join -j1 2 f1 f2` / `-j2 1 f1 f2` absorb the attached-spelling
  field argument (rc 0); `-j1` without one falls back to `-j 1`.
- `-o auto` leaves MUST_BE_OPERAND (no absorption); plain three-file
  invocations still error "extra operand 'fN'" rc 1.

join.c add_file_name() is reproduced exactly: absorption fires when a
third name arrives while prev_optc_status != MUST_BE_OPERAND, resolves
names[operand_status == MUST_BE_OPERAND ? 1 : 0], shifts, and -o adds
happen at option/absorption time in getopt order. The shared argopt
module is unchanged (its API is called, not extended): scan_order_
sensitive replays raw argv for the order-sensitive options only;
-t/-e/-a/-v and flags stay on the Parsed result. Library gate join:
51/51 GNU-gated green, unchanged; new unit tests pin the six probed
absorption shapes.

Issue: #1488
Surfaced by the wave3b wiring ctest slice: the 1.x C++ exe and the ctest
expect GNU's read_error() wording "join: read error: Is a directory"
(join.c:497 path -- fopen on a directory succeeds on POSIX, the failure
surfaces at read time and is reported WITHOUT quotef(name)), but the
rust2 library prefixed the name. Probed WSL coreutils 9.4: `join <dir>
<file>` -> stderr "join: read error: Is a directory", empty stdout, rc 1
on both sides; a MISSING file keeps the name ("join: missing.txt: No
such file or directory", fopen strerror path). Library gate join:
51/51 GNU-gated green, unchanged.

Issue: #1488
Mechanical replacement per rust2/REPLACEMENT-RECIPE.md: the 850-line
C++ body (field splitter, -o format compiler, unpairable-line walkers,
i18n diagnostics) is deleted; REGISTER_COMMAND metadata stays
byte-identical; handler is one winux::rust2::run_command("join",
ctx.raw_args) call. join is appended to WINUXCMD_RUST2_COMMANDS;
stdin is forwarded by the bridge's declared-reader list ("-" operand
and the one-operand stdin default). Two library gaps surfaced by the
wiring gates were fixed first, each GNU-probed, in their own commits:
the obsolescent operand_status absorption for -o/-j1/-j2 (b4ce434)
and the nameless directory read error (37ec0b8).

Triple gate:
- gate a (GNU oracle, run-gate.sh join, RUST_BIN=wired exe):
  51 GNU-gated rows, all green (51-case table: -o/-t/-j/-e/--header
  full matrices).
- gate b: ctest -R join 29/29 pass (the directory-wording test now
  passes against the rust2 wording, 37ec0b8); full-suite base failing
  set is the saved 20 pre-existing failures (none in the wave).
- gate c (old vs new exe byte parity, cmd-matrix.sh join, 21 rows;
  GNU ledger from WSL): rc vs GNU 21/21; old-vs-new rc/stdout/stderr
  19/21 byte-equal -- rows 06/07 are the obsolescent -o absorption
  forms the 1.x exe rejected and GNU accepts (now byte-identical to
  GNU on stdout and rc).

Issue: #1488
…ve (#1488)

Mechanical replacement per rust2/REPLACEMENT-RECIPE.md: the 470-line
C++ body (duration parser, CreateProcessW spawn/kill, exit-status
contract) is deleted; REGISTER_COMMAND metadata stays byte-identical;
handler is one winux::rust2::run_command("timeout", ctx.raw_args) call.
timeout is appended to WINUXCMD_RUST2_COMMANDS (the bridge does not
declare it a stdin reader, so the wrapped command inherits the live
stdin handle).

Library fixes surfaced by the wiring gates (each GNU-probed):
- resolve_command rewritten to the shared childproc contract
  (src/utils/childproc.cppm): PATH-only search over NORMALIZED entries
  ('/c/...' spellings and mixed ':' separators split correctly, no
  System32/current-dir fallback), PATHEXT completion with .cmd/.bat
  routed through COMSPEC (`cmd /d /s /c "<script> <args>"` via raw_arg),
  explicit-path operands used as given, ENOTDIR/EACCES -> 126. The
  three childproc.timeout_* ctests (System32 collision, POSIX-mixed
  PATH, batch routing) now pass. Bare-name candidates keep the
  pre-wiring Windows PE preference: extension-bearing candidates win
  across every entry before the bare name (CreateProcess cannot run an
  extensionless POSIX script; gate tm02 `cmd /c exit 3` stays GNU rc 3).
- kill-after: a death delivered by the KILL phase reports 137
  (128+SIGKILL, GNU-probed `timeout -s0 -k0.1 0.1 sleep 5`), not 124;
  a natural exit during the window keeps 124 / preserve-status code.
- invalid duration/signal/-k now print GNU's try-help line after the
  diagnostic (rc 125 unchanged).

Tests updated to the GNU contract: the three invalid-shape tests pinned
the pre-wiring stderr without the try-help hint.

Triple gate:
- gate a (GNU oracle, run-gate.sh timeout, RUST_BIN=wired exe):
  30 GNU-gated exit rows, all green (the -k/-s/--preserve-status
  exit-code matrix; children are platform-bound, gate exit-only).
- gate b: ctest -R timeout 36/36 (own tests + childproc resolution
  matrix); full-suite base failing set is the saved 20 pre-existing
  failures (none in the wave).
- gate c (old vs new exe, cmd-matrix.sh timeout, 20 rows; GNU ledger
  from WSL): rc 20/20 byte-equal incl. 124/125/126/127/137/143; stdout
  20/20; stderr 18/20 -- rows 16/19 are invalid-shape usage errors
  where the new exe prints GNU's try-help line the 1.x exe omitted.

Issue: #1488
… a pre-pass

Wiring-gate follow-ups for wave3b (#1488), each against the vendored
coreutils 9.4 sources and WSL probes (2026-11-11):

- the whole digit-led token is ONE spec: expand.c:48 builds the optstring
  as "it:0::1::...9::" (digits take OPTIONAL arguments) and expand.c:204-215
  hands parse_tab_stops(optarg - 1) — the leading digit plus the whole rest
  of the token. 'expand -4,8' now converts (ex10), and a bad character in
  the token is the tab-list diagnostic 'tab size contains invalid
  character(s)' (expand-common.c:208), not getopt's 'invalid option'.
- tokens in -t's required-argument slot are data: getopt consumes the
  value whatever it starts with, so 'expand -t -5' errors with spec '-5'
  (previously mangled to '--tabs=5').
- '--' ends the conversion; operands after it stay operands.
- blanks separate spec values inside one token (expand-common.c:139),
  so 'expand -4 8' converts like GNU.

Regressions: obsolescent_forms, obsolescent_value_slot_and_end_of_options.

Ref: #1488 (wave3b wiring)
…unt bytes

Wiring-gate follow-ups for wave3b (#1488), each against the vendored
coreutils 9.4 sources and WSL probes (2026-11-11):

- the obsolescent digit accumulation is unexpand.c's getopt default case,
  which only accumulates the stop value: it does NOT set convert_entire_line
  (unlike -a at :279 and -t at :282). 'unexpand -4' therefore converts
  leading blanks only and leaves mid-line blanks untouched (WSL probe:
  'a<8sp>b' stays unchanged); only -a/-t/--first-off cancellations flip it.
- unexpand.c reads bytes with getc and column++ per byte (:158/:221), so
  non-ASCII characters occupy as many columns as their UTF-8 bytes: the
  UTF-8 BOM occupies three, matching GNU 'unexpand -a' on a BOM + 8-space
  line (tab at column 8 after 5 spaces, 3 kept).

Regressions added to obsolescent_forms/all_mode coverage.

Ref: #1488 (wave3b wiring)
ue27-digit-form-not-all: 'unexpand -4' on mid-line blanks must leave the
line unchanged (GNU unexpand.c default case, WSL 9.4 probe). strict mode
gates stdout+rc, which is where the old implication of -a diverged.

Ref: #1488 (wave3b wiring)
The 1.x generic cluster scanner consumed a maximal digit run as the -NUM
value and then diagnosed the next character, so 'expand -4,8' died with
"invalid option -- ','" before the handler ran — while GNU converts
(WSL coreutils 9.4 probe). Both wired bodies own that grammar:

- expand.c:48 optstring "it:0::1::...9::" gives every digit an optional
  argument and expand.c:204-215 passes parse_tab_stops(optarg - 1) the
  digit plus the whole rest of the token;
- unexpand.c:272 optstring ",0123456789at:" makes digits and comma plain
  option characters accumulated per character (default case).

In neither grammar does getopt's cluster rule diagnose the interior of a
digit-led token, so OptionParsePolicy gains
digit_led_short_tokens_as_positionals and option_policy_for_command sets
it for expand/unexpand only; every other -NUM consumer (fmt, split,
diff, uniq) keeps its current parsing.

Ref: #1488 (wave3b wiring)
Mechanical replacement per rust2/REPLACEMENT-RECIPE.md: the 430-line
C++ body (tab-stop list compiler, column walker, obsolescent spelling
handler) is deleted; REGISTER_COMMAND metadata stays byte-identical;
the handler is one winux::rust2::run_command("expand",
ctx.raw_args) call. expand is appended to WINUXCMD_RUST2_COMMANDS;
stdin is forwarded by the bridge's declared-reader list.

Gates: run-gate expand 30/30 GNU-gated GREEN with the wired exe as the
rust side (ex10 now r=g after the dispatcher digit-token fix dfbbe53 +
6c9dcf6; r=c:no only on ex10/ex18, the documented 1.x divergences).
stderr matrix (option errors, value-slot specs, bad chars) matches GNU
shape for 19/19 probes. Differential corpus 2/2. Unit tests
expand_missing_input/expand_directory_input realigned to the GNU open
failure wording ("expand: FILE: reason") — the 1.x "cannot open 'F'
for reading" wording was a documented divergence and is not inherited.

Ref: #1488 (wave3b wiring)
Mechanical replacement per rust2/REPLACEMENT-RECIPE.md: the 460-line
C++ body (column/tab-stop back-converter, pending-blank buffer) is
deleted; REGISTER_COMMAND metadata stays byte-identical; the handler is
one winux::rust2::run_command("unexpand", ctx.raw_args) call.
unexpand is appended to WINUXCMD_RUST2_COMMANDS; stdin is forwarded by
the bridge's declared-reader list.

Gates: run-gate unexpand 27/27 GNU-gated GREEN with the wired exe as
the rust side (ue16 now r=g after the dispatcher digit-token fix
6c9dcf6; new ue27 locks the leading-only digit form from a1c6979;
r=c:no only on ue16/ue17, documented 1.x divergences). Differential
corpus 2/2. Unit tests realigned to GNU: open-failure wording
("unexpand: FILE: reason"), and the BOM case now asserts GNU byte
columns under -a plus the GNU rejection of the 1.x -U extension.

Ref: #1488 (wave3b wiring)
Mechanical replacement per rust2/REPLACEMENT-RECIPE.md: the 950-line
C++ body (unit parser, --from/--to converters, --format engine,
padding model, field splitter) is deleted; REGISTER_COMMAND metadata
stays byte-identical; the handler is one
winux::rust2::run_command("numfmt", ctx.raw_args) call. numfmt is
appended to WINUXCMD_RUST2_COMMANDS; stdin is forwarded by the bridge's
declared-reader list (the no-operand form reads stdin).

Gates: run-gate numfmt 74/74 GNU-gated GREEN with the wired exe as the
rust side; r=c:no on 8 rows, all documented 1.x divergences not
inherited (--header bare handling, --field ranges, empty -d, the
lowercase --to-unit suffixes). stderr matrix (--bogus/-q/--from=nope/
--field=0/-zq/-M) matches GNU shape. Differential corpus 6/6. Unit
tests realigned to GNU 9.4 probes: --debug logs nothing for a plain
conversion and the invalid-input pair is "no conversion option
specified" + "invalid number"; --grouping in the C locale echoes the
number unchanged. The 1.x "debug: converted/failed to parse" lines
and the unconditional thousands grouping were WinuxCmd inventions and
are not inherited. The 1.x acceptances GNU rejects (--unit-separator,
-M, -l, ZYRQ suffixes) are likewise not inherited (GNU-shaped
"invalid option" diagnostics, gated by the nf/nm rows).

Ref: #1488 (wave3b wiring)
Records the wiring turn: 131/131 GNU-gated GREEN for
expand+unexpand+numfmt with the wired product exe, the two dispatcher
r=c:no rows (ex10/ue16) explained by the digit-token grammar fix, and
the GNU citations (expand.c:48/:204-215, unexpand.c:272/:277).
Removes the leftover '>>>>>>> rust2/wave3b' marker from the table
merge.

Ref: #1488 (wave3b wiring)
…ve3b)

The mechanical replacement deletes the C++ numfmt body, so its 27
catalog keys (command.numfmt.error.*) are no longer produced by the
source extraction — the zh-CN catalog now carries them as standing
'extra' drift, exactly like the #1547/#1561 wiring precedents. New
diagnostics are emitted by the rust2 library through the bridge and
are GNU-shaped, not catalog-keyed. Recorded via
check_i18n_drift.py --update-baseline after local confirmation
(clone of unixwin/winuxcmd-i18n; growth is numfmt-scoped only).

Ref: #1488 (wave3b wiring)
@caomengxuan666

Copy link
Copy Markdown
Member Author

CI triage on this branch: i18n-drift red was the expected deliberate-growth case (27 command.numfmt.error.* + legacy keys stopped being produced when the C++ numfmt body was deleted); confirmed locally against a fresh clone of winuxcmd-i18n and recorded via check_i18n_drift.py --update-baseline (f6e8289) — now green. oracle, compare, baseline-growth and all four build-windows jobs green. baseline red (5 cases: diff3/25, find/02, install/02, nice/01, nice/05, stdbuf/03-class) is environment-bound and pre-existing on this machine: a fresh build of the merge-base (origin/main b055b48) reproduces the identical 6-case failure set locally (diff3/25 EXIT_DIFF, find/02 OUT_DIFF, install/02 EXIT_DIFF, nice/01+05 EXIT_DIFF, stdbuf/03 EXIT_DIFF) — none of the batch's 8 commands, none in the dispatcher/policy surface this branch touches. Same class as the local ctest baseline's pre-existing nice/nohup failures.

@caomengxuan666
caomengxuan666 merged commit e466808 into main Nov 11, 2026
12 of 14 checks passed
caomengxuan666 added a commit that referenced this pull request Nov 11, 2026
fix(timeout): children resolve with Win32 PATH semantics and the package-sibling fallback (main CI regression from #1567)
@caomengxuan666
caomengxuan666 deleted the rust2/wire-wave3b branch November 18, 2026 05:50
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