Repository navigation
rust2 wave2: 15 library-form commands + differential gate (#1488) - #1551
Merged
Merged
Conversation
caomengxuan666
force-pushed
the
rust2/wave2-commands
branch
from
November 9, 2026 07:27
ff27c1d to
6dfccaa
Compare
…ted variants and BLAKE2b (RFC 7693), std-only FIPS 180-4 NIST vectors (abc / empty / two-block) and RFC 7693 Appendix B vectors are asserted in-tree; the long-input vectors are cross-checked against WSL GNU coreutils 9.4 (sha224sum/sha384sum/b2sum). The truncated variants are the exact cores with the RFC 6234 section 6 chaining IVs (SHA-224 IV h5/h6/h7 = 68581511 / 64f98fa7 / befa4fa4) and shorter output. BLAKE2b follows RFC 7693 with the standard param-block init; streaming update/finish matches the one-shot digests for every chunk shape. Part of the wave2 batch for WinuxCmd 2.0 library-form commands (#1488).
b64core is the shared engine; every decode branch is byte-verified against
WSL GNU coreutils 9.4 (target/gnu-probe/bd*.txt): newline skipping, -i that
never skips '=', pad placement rules (base64 '=' at quantum positions 2-3,
base32 n+p==8 runs), error-time flushing (base64 floor(bits/8), base32
complete 5-char groups), EOF partial flushing for base64 only ('Zm9' ->
'fo' rc 1, 'MZ' -> empty rc 1), and xstrtoimax wrap parsing (junk ->
'invalid wrap size' rc 1, overflow -> wrap 0 with no trailing newline).
RFC 4648 encode vectors asserted. Part of #1488 wave2.
Probed against WSL GNU coreutils 9.4 (target/gnu-probe/p1.sh, p2.sh,
p12.sh): whoami rejects operands and a bare -h ('invalid option -- 'h''
rc 1 — GNU registers no -h short opt) while --help/--version stay rc 0;
nproc follows lib/nproc.c parse_omp_threads_env (valid OMP_NUM_THREADS
replaces the count unclamped, unparsable values are unset, '3,1' nests,
' 5 ' tolerates blanks) and nproc.c xnumtoumax --ignore (leading '+',
clamp at 1, 'invalid number' rc 1); unlink enforces the one-operand shape
with GNU usage rc 1 on '--'/zero/two operands; sleep parses strtod
subjects (decimal + glibc hex floats incl. 0x10 without exponent,
inf/infinity, suffixes s/m/h/d case-sensitive), reports every invalid
interval, and keeps sleep.c's argc==1 missing-operand test so 'sleep --'
sleeps 0 rc 0. whoami/nproc value output is the 1.x C++ model
(GetUserNameW / affinity popcount via winsys — committed next).
Part of #1488 wave2.
src/tac.c (coreutils 9.4) is the specification; every case below is probed
byte-for-byte against WSL GNU coreutils 9.4 (target/gnu-probe/p8.sh-p20.sh):
literal separators carve backward from past_end-(sep_len-1) with the
sentinel semantics that make an empty separator ('-s ""') print the input
unchanged; -b emits the trailing separator first ('-b' on 1\n2\n3\n gives
\n\n3\n21); -r uses the glibc BRE dialect where plain | ( ) are literals
('tac -r -s X|Y' is identity) while + ? . [classes] and backslashed \|
are operators, searching backward for the rightmost start with matches
confined to buf[..match_start) and tac.c's first_time rule at the buffer
end ('[0-9]+' on a1b22c333 starts 33c32b2a1). Missing files report
'failed to open' rc 1 and later files still run. bre.rs documents the
supported subset (literals, ., classes, *, +, ?, anchors, \| alternation;
no groups/intervals/backreferences). Part of #1488 wave2.
Probed against WSL GNU coreutils 9.4 (target/gnu-probe/p10.sh, p11.sh,
p18.sh): SIZE takes one leading modifier (+ grow, - shrink clamped at 0
rc 0, / round down, % round up, < at most, > at least) before an optional
sign, decimal digits, and a unit (K/M/G/T/P/E/Z/Y/R/Q and KiB.. are
1024-based, kB/MB/GB/TB are 1000-based — '1m' is accepted as MiB);
junk, an empty string, '+50%' and overflow are 'Invalid number' rc 1 and
%0 //0 are 'division by zero' rc 1. Missing files are created unless
-c/--no-create skips them rc 0; --reference stats the reference
('cannot stat' rc 1) and sizes the operand; a directory operand fails
'cannot open for writing' rc 1 while the other operands still run.
Growth fills NULs via set_len. Part of #1488 wave2.
Format probed byte-for-byte against WSL GNU coreutils 9.4: '<hex> <file>'
with ' *' under -b, '-' for stdin, NUL terminator with -z, --tag BSD form
'BLAKE2b (file) = <hex>' (single terminator — the tag line must not double
the newline). b2sum -l/--length: last occurrence wins, 1..=512 multiple of
8 with GNU's second diagnostic lines ('length is not a multiple of 8' /
'maximum digest length for BLAKE2b is 512 bits') rc 1. Files run
sequentially; missing files and directories report per operand and the
aggregate rc is 1. --check machinery (-c --quiet --status --strict -w
--ignore-missing) is a documented deferred subset. Part of #1488 wave2.
winsys.rs carries the raw FFI (kernel32/advapi32/ntdll, zero crates). uname mirrors src/commands/uname.cpp: Windows_NT / GetComputerNameW / RtlGetVersion major.minor+build / GetNativeSystemInfo machine / processor "unknown" / "PC" / "Windows_NT", GNU -a order, operands rc 1 (#1215). id mirrors src/commands/id.cpp incl. win32_account_id_from_sid (win32.cppm): RID = last subauthority remapped 0x30000+RID for S-1-5-21-... accounts and 0x60000+RID for S-1-16 integrity SIDs, the "None" primary group unresolvable (#1024), GNU's only/name/zero/context error set rc 1 (probed). hostname follows main's src/commands/hostname.cpp (#1526): -F reads the first non-comment line, trims isspace, validates RFC 1035 check_name, rejects >64 bytes ("name too long"), completes rc 0 without setting (documented Windows [DIFFERS]); operand+-F is the Debian usage on stderr exit 255; one operand reports "cannot set name to" rc 1; net-tools options are rejected like coreutils hostname. getconf carries the C++ variable table (#1134: ARG_MAX 32767, MAX_PATH 260, page counters via FFI) with glibc error semantics: "Unrecognized variable \`X'" rc 2, no-variable usage rc 1, case-insensitive lookup, pathconf form with the C++ existence check. Part of #1488 wave2.
caomengxuan666
force-pushed
the
rust2/wave2-commands
branch
from
November 9, 2026 07:55
6dfccaa to
e379e64
Compare
This was referenced Nov 9, 2026
Closed
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.
Part of #1488 (WinuxCmd 2.0 命令库化). Implements the wave2 batch as rust2 library-form commands with the wave1 shape contract (
Io/Ctx/CmdResult, explicit IO, explicit env/cwd, status code instead ofexit(), std-only zero crates) plus the three-way differential gate (Rust driver / WSL GNU coreutils 9.4 oracle / C++ Debug dispatcher).Commands (15)
whoami, nproc, unlink, sleep, base64, base32, b2sum, sha224sum, sha384sum, tac, truncate, uname, id, hostname, getconf
Highlights
digest.rs— in-tree SHA-256/SHA-512 cores plus SHA-224/SHA-384 (RFC 6234 IVs) and BLAKE2b (RFC 7693). NIST FIPS 180-4 + RFC 7693 vectors asserted; long-input vectors cross-checked against GNU.b64core.rs/basenc.rs— RFC 4648 codec with GNU's exact decode behavior (pad rules, error/EOF flush asymmetry between base64 and base32,=never skipped by-i), every branch probed byte-for-byte against coreutils 9.4.tac.rs/bre.rs— tac.c buffer algorithm;-rseparators use the glibc BRE dialect (plain|/(/)are literals —tac -r -s 'X|Y'is identity), verified against GNU.truncate.rs— full GNU size grammar:+ - / % < >modifiers,K/M/G/T/...1024-based andkB/MB/...1000-based units,--reference,-c, div-by-zero and overflow errors.winsys.rs/uname.rs/id.rs/hostname.rs/getconf.rs— the Windows value model of the 1.x C++ applets (uname fields via RtlGetVersion/GetNativeSystemInfo; id via thewin32_account_id_from_sidRID remap 0x30000+RID / 0x60000+RID with the [gap] groups/id/stat: unresolvable group name prints literal 'None' #1024 "None" group rule; hostname hostname: -F is advertised in help, rejected by the parser, and its read branch is dead code #1526-F/--filepipeline incl. RFC 1035 check_name, >64-byte rejection and the operand-conflict exit 255; getconf getconf: ARG_MAX prints "undefined" (GNU prints the limit) #1134 table with glibc error semantics).lib/nproc.cOMP parsing (OMP_NUM_THREADS replaces unclamped, nesting lists, blanks) and xnumtoumax--ignore.Gate results (GATE-REPORT.md wave2 section)
348 new cases (>= 20 per command; strict/exit/win classified): GNU-gated (strict+exit) 246/246 GREEN, win-gated 102/102 GREEN, C++ parity 320/348. Raw artifacts under
rust2/target/gate/(ledger.tsv, gnu stderr samples).cargo test: 125 unit tests green (SHA NIST/RFC 7693 vectors, RFC 4648 vectors, GNU probed decode/semantic vectors);
cargo fmt --checkclean.Subset (documented)
b2sum/sha224sum/sha384sum implement the digest-printing surface (
--tag,-b/-t,-z, b2sum-lwith GNU validation errors); the--checkmachinery (-c --quiet --status --strict -w --ignore-missing) is a documented deferred subset for a later wave.