Skip to content

#1488 wave3b: join/tsort/hostid/users/timeout/expand/unexpand/numfmt - #1559

Merged
10 commits merged into
mainfrom
rust2/wave3b
Nov 11, 2026
Merged

10 commits merged into
mainfrom
rust2/wave3b

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Ref #1488 (wave3b, 8 commands).

What lands

  • 8 library-form commands in rust2/crates/winux-cmds: join, tsort, hostid, users, timeout, expand, unexpand, numfmt — each a plain fn run(args, io, ctx) -> CmdResult, std-only, with per-command unit tests (196 total, green) and GNU coreutils 9.4 as the measured oracle (probe scripts under rust2/target/probes/p_*.sh, WSL coreutils 9.4).
  • Gate: 276 new case tables (gate/gen-cases.py, generated TSVs): join 51, tsort 25, hostid 20, users 20, timeout 30, expand 30, unexpand 26, numfmt 74. Three-way gate (Rust driver / WSL GNU 9.4 / Debug C++ winuxcmd.exe): 285 GNU-gated + 79 win + 3 note, all GREEN; full-suite gate re-run green (817 GNU-gated + 145 win, includes all wave1/wave2 tables).
  • C++ 1.x parity: 240/276 cases byte/rc-equal; the 36 divergences are recorded per-case in target/gate/ledger.tsv and are inherited 1.x behaviors re-derived from GNU (users WTS value model, hostid hash input, tsort -w accepted by C++ but rejected by GNU 9.4, numfmt 9.4 option-set cuts like --unit-separator/-M/-l and ZYRQ unit suffixes, expand/unexpand message wording).
  • argopt: two getopt_long invariants — flags reject inline arguments ('--x=v' errors) and unambiguous long-option abbreviation resolution; the FULL existing gate was re-run green with these.
  • lib.rs: registrations for the 8 commands plus a restore of the wave2 value-model registrations (uname/id/hostname/getconf) whose registry lines were lost in the wave2 merge — their tables were green in the report but the driver answered 'unknown command'. Conflict note for the coordinator: only these hunks touch lib.rs.

Notes for review

  • timeout's children are platform-specific by nature (sleep/ping under WSL vs sleep.exe/cmd.exe on Windows), so its rows gate exit status; the status contract (124/143/137/126/127/125) is GNU-probed.
  • hostid keeps a stable per-machine 32-bit id but hashes COMPUTERNAME (FNV-1a) instead of the C++ MSVC-std::hash of MachineGuid (registry reads are unreachable from the std-only crate); win-mode gates rc only, value divergence recorded.
  • join's keyless-line behavior (a line whose join field is missing never pairs, even against another keyless line) was probed and modeled explicitly.

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)
@caomengxuan666 caomengxuan666 closed this pull request by merging all changes into main in e466808 Nov 11, 2026
@caomengxuan666
caomengxuan666 deleted the rust2/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