Skip to content

#1488 uutils audit: rust2 self-developed vs uu_* per-command comparison (keep 45 / borrow 2 / adopt 0) - #1562

Merged
caomengxuan666 merged 1 commit into
mainfrom
rust2/uutils-audit
Nov 11, 2026
Merged

caomengxuan666 merged 1 commit into
mainfrom
rust2/uutils-audit

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Read-only audit for #1488 comparing our rust2 implementations (47 command names, main ∪ wave3b) against upstream uutils/coreutils @ 156d715, with WSL GNU coreutils 9.4 as oracle. No command implementation code touched — docs only.

Full report: DOCS/2.0-uutils-audit.md

Verdict: keep self-developed + borrow-algorithm lane

Option Dependency delta #1488 explicit-IO Windows coverage Gate rework
A keep (recommended) 0 already satisfied 47/47 incl. value-model parity 2 algorithm fixes + new cases
B per-command uu_* 53 crates baseline/utility, 220 union fork every crate (no injectable IO upstream) 41/47 — chmod/chown/id/stat/users/getconf missing all adopted strict/exit rerun
C wholesale uutils ≥220 crates incl. fluent host FD-redirection shim = the niubash#727 CRT-stdio hazard same 6 gaps all 1288 cases + C++ parity discarded

Three hard facts behind the verdict (all measured, not assumed):

  1. Explicit IO: every uu crate is uumain(args) -> UResult<()> writing process stdio (stdout().lock() in seq; uucore show_error!) and process::exit via uucore::bin!. Upstream library-ization is an open topic only (discussion #6103, issue #5088).
  2. Windows: uutils' own feature tree (feat_require_unix_core, feat_require_unix_utmpx) excludes chmod/chown/id/stat/users; getconf doesn't exist upstream. That is exactly our C++ parity surface.
  3. Footprint: cargo tree --edges normal — baseline 53 transitive crates per utility (clap+fluent+uucore), b2sum 128, seq 93, numfmt 92, test 97; 40 buildable crates union = 220. Ours: 0.

Empirical three-way (uutils native Windows builds vs our driver vs GNU 9.4)

Command uutils vs GNU ours vs GNU Note
seq 7/7 6/7 our documented f64 vs 80-bit long double gap; uutils' exact-decimal (ExtendedBigDecimal) closes it → borrow strategy
numfmt 14/14 13/14 new gap found: --field reconstruction collapses blanks; GNU/uutils pad the converted field to the original field width (numfmt.c semantics). Gate's 74 numfmt cases missed this shape → borrow + add case
b2sum 13/13 13/13 byte-identical incl. -l 8/256/512, --tag, -z, stdin, -c pass/tampered/quiet. Ticket's "--check deferred" is stale — it is implemented and green

Licenses: MIT, no copyleft transitive (180 deps scanned; only dual-lic edge is self_cell, Apache branch applies).

Bonus findings recorded in the report: main-branch registry drift (uname/id/hostname/getconf implemented but unregistered on main; wave3b registers them but lacks sync), and uutils native Windows binaries work well as a second oracle (34/34 vs GNU on the sample) for the gate's win-class cases.

44+-command per-row comparison of the rust2 hand-written implementations
against upstream uutils/coreutils @ 156d715, WSL GNU coreutils 9.4 as the
oracle, plus a three-way empirical sample (seq/numfmt/b2sum) compiled and
run on MSVC.

Verdict: keep self-developed (45 keep / 2 borrow-algorithm / 0 adopt).
  - uu_* fails the #1488 explicit-IO contract: uumain writes process
    stdio (stdout().lock() in uu_seq; show_error! macros) and exits via
    uucore::bin!; library-ization is an open upstream topic
    (discussion #6103, issue #5088).
  - uutils Windows feature tree excludes chmod/chown/id/stat/users
    (feat_require_unix_core / utmpx); getconf does not exist upstream —
    exactly the C++ value-model parity surface.
  - Dependency footprint measured with cargo tree --edges normal:
    baseline 53 crates per utility (clap+fluent+uucore), b2sum 128,
    seq 93, numfmt 92; union of the 40 buildable crates = 220 vs our 0.
  - Licenses clean: MIT, no copyleft transitive (self_cell dual
    Apache-2.0 OR GPL-2.0, Apache branch applies).

Empirical samples (three-way, stdout bytes + rc):
  - seq: uutils 7/7 vs GNU, ours 6/7 (documented f64 vs 80-bit long
    double; uutils' exact-decimal strategy closes it — borrow).
  - numfmt: uutils 14/14, ours 13/14 — NEW gap found: --field line
    reconstruction collapses blanks instead of padding to the original
    field width (GNU numfmt.c semantics) — borrow + add gate case.
  - b2sum: 13/13 three-way byte-identical incl. -l 8/256/512, --tag,
    -z, stdin, -c pass/tampered/quiet. Ticket's "--check deferred" is
    stale; it is implemented.

Also recorded: main-branch registry drift (uname/id/hostname/getconf
implemented but unregistered; wave3b registers them but lacks sync).
Raw artifacts under target/uutils-audit/ (not committed).
@caomengxuan666
caomengxuan666 merged commit 544382f into main Nov 11, 2026
9 of 10 checks passed
aphrody-labs Bot pushed a commit to aphrody-labs/WinuxCmd that referenced this pull request Nov 15, 2026
…nixwin#1488)

Owner-directed follow-up to unixwin#1562 (which covered only the coreutils
monorepo): audit the four uutils SIBLING repos that own our 2.0 big
unimplemented commands.

Method: shallow clones (target/uutils-siblings/, HEADs 2026-11-10..12),
three-party semantic sampling (WSL GNU 5.3.20 / our C++ build-1496 /
uutils debug builds), 8 cases per command, raw output in
target/uutils-siblings/sampling/threeway_all.txt.

Key findings:
- All four repos outsource regex: grep+findutils delegate to Oniguruma
  C (onig/onig_sys); sed = bre_to_ere translation -> regex crate with
  fancy-regex fallback for backrefs; diffutils ships a 360-line BRE
  translator over the regex crate. NO repo has a portable std-only
  Rust POSIX engine -> regex decision A (port portable_regex) stands;
  sed's bre_to_ere + diffutils bre.rs become cross-check corpora.
- IO: all four are process-level stdio; unixwin#1488 explicit-IO contract
  would require rewriting each repo's output layer (grep worst,
  diffutils lib layer best).
- Deps: 119-167 transitive packages per repo incl. a C library
  (onig_sys) -> route C (adopt crates) conflicts with std-only policy.
- Sampling: grep 8/8, sed 8/8, find 6/8 (uu walks print backslash
  paths while -printf prints forward slashes; localized -newer error),
  diff 7/8 for uu (missing -i) — and two OUR-side 1.x divergences
  found: cmp says "char 7" vs GNU/uu "byte 7"; diff -r recursion
  header prints redundant "diff diff -r ..." full args.
Recommendation: route B (borrow algorithms, unixwin#1575 precedent) as the
mainline with A carrying the engine; per-command table in the doc.
@caomengxuan666
caomengxuan666 deleted the rust2/uutils-audit 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