Skip to content

docs(audit): fast-path differential catalogue and harness (niubash#383) - #706

Merged
caomengxuan666 merged 2 commits into
masterfrom
audit/fast-path-differential
Oct 17, 2026
Merged

caomengxuan666 merged 2 commits into
masterfrom
audit/fast-path-differential

Conversation

@caomengxuan666

@caomengxuan666 caomengxuan666 commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

What

Audit-only. Maps every rubash in-process fast path against its WinuxCmd
fallback and GNU coreutils at the byte level, adds a repeatable differential
harness, and records the results. No engine code is changed.

  • docs/audit/fast-path-differential.md — inventory, reachability, the
    confirmed divergence table (with byte evidence, classification and code
    locations), the clean-shape list, systemic classes, and a full 179-case
    appendix.
  • scripts/fast-path-differential.py — the matrix runner.

Inventory (from the code)

  • 12 pipeline-stage arms in pipeline_exec.rs: true/:/false/echo/
    printf/trap/head/cat/sed/grep/wc/tr.
  • 8 command-substitution filter arms in command_substitution_values.rs:
    sort/sed/tr/head/grep/wc/tail/uniq.
  • Documented behaviours sleep/dirname/basename/uname/arch and
    in-process env.

docs/builtins.md only lists sleep/dirname/basename (+ uname/arch in
the rubash copy); the 20 inline arms are undocumented and outside the doc-sync
guard. The substitution filter arms are additionally unreachable for ordinary
$( … | … ) bodies after rubash#117's triviality gate — the observable $()
behaviour comes from the pipeline arms via the real executor.

Confirmed divergences (not already tracked)

class repro FAST fallback/GNU
payload decoding printf 'a\033b\nc\n' | tr '[:cntrl:]' X a\x1bbXcX aXbXcX
flag parsing printf 'a\nb\nc\n' | head -n abc a\nb\nc\n rc 0 error rc 1
flag parsing printf 'a\nb\nc\n' | head -n -1 all 3 lines a\nb
string edge case dirname // / //
string edge case basename '' / empty

Already tracked (not re-filed): the wc carrier class — niubash#383 / #695;
dirname /a/b → A: — niubash#346, fixed by #649 + niubash#371.

Harness

python scripts/fast-path-differential.py

Runs against the installed niu, the absolute WinuxCmd binaries, and
Git-for-Windows GNU coreutils. stdout and exit status are compared byte for
byte; stderr is compared only for the four diagnostic cases
(sleep_missing, sleep_invalid, sleep_badunit, basename_extra) and
asserted empty for the fixture-backed cat cases (Appendix A tags both). A
Python script (not a Rust #[test]) is used because the matrix must spawn three
external toolchains and diff raw child bytes.

Fixes applied after the adversarial review:

  • Concurrency-safe fixtures. Per-PID scratch dir (mkdtemp), removed in a
    finally; an integrity gate plus a stderr-empty guard so a missing fixture
    can never be recorded as FAST/EXT agreement.
  • Toolchain preflight. Missing NIU/WX_BIN is a fatal exit-2 diagnostic;
    --no-ext opts out explicitly and the run header records
    EXT=DISABLED (--no-ext). Toolchains are overridable via
    NIU/WX_BIN/GNU_BASH/GNU_PATH/AUDIT_TMP.
  • --only with no match exits 1 with a message.
  • grep_utf8_i locale pin (LC_ALL=C/LANG=C for all legs) so the
    console locale cannot flip the verdict.
  • Duplicate dirname_letter case removed.

Observed on the installed toolchain (niu 1.4.0 / e785c3c, WinuxCmd 1.1.12):

FAST=...\niu.exe  EXT=...\winuxcmd\usr\bin  GNU=D:\Git\bin\bash.exe
cases=179 pass=146 known=27 extbugs=2 info=4 regressions=0 fixed=0

EXTBUG = the fast path is right and only the WinuxCmd fallback is wrong
(true -x rc 1, dirname /// → //).

Map every rubash in-process fast path against its WinuxCmd fallback and GNU
coreutils at the byte level, with a repeatable Python harness.

Inventory: 12 pipeline-stage arms (pipeline_exec.rs), 8 command-substitution
filter arms (command_substitution_values.rs), the documented sleep/dirname/
basename/uname/arch behaviours, and in-process env.

Confirmed rubash fast-path divergences, filed as #707 (tr [:cntrl:]), #708
(head flag parsing), #709 (dirname/basename // and empty operand), #710
(command_substitution_values.rs arms unreachable); WinuxCmd#1196 (true,
dirname ///). The wc carrier class is already tracked (niubash#383 / PR #695);
the dirname /a/b -> A: translation is niubash#346 (fixed by rubash#649).

Harness: scripts/fast-path-differential.py (180 cases, FAST vs absolute
WinuxCmd vs GNU; exits non-zero on regression or a known case going green).
@caomengxuan666

Copy link
Copy Markdown
Member Author

Re: making the arm set registered rather than restated.

Reading docs/pitfall-taxonomy-and-governance.md §3.1 and docs/semantic-ownership.tsv, you already have this pattern twice — so this is a "apply your own §3.1 to the arms", not a new mechanism:

  • §3.1 mandates a marker registry (markers.rs): every sentinel declared once, with byte meaning + encode/decode pair + consumer-boundary list + user_reachable, bare literals banned, and a gold assertion that markers never reach stdout / declare -p / xtrace.
  • semantic-ownership.tsv is the machine-readable owner registry for the semantic families (GNU source → contract → Rust owner → status → evidence → Next gate).

The 20 inline arms are the one route family with no registry row and no guard, which this PR's own inventory documents ("undocumented and outside the doc-sync guard"). The arm table lives in prose in the catalogue while the real list lives in two source files, so an arm can land without a catalogue row.

Three asks, cheapest first:

1. Derive the arm set instead of restating it. A test that unions the arms from pipeline_exec.rs / command_substitution_values.rs with the harness case ids and the docs/builtins.md rows, and fails on an arm with no case id or no doc row. No runtime change; it converts "20 arms undocumented" into a build error, the same way §3.1 converted bare literals into a build error.

2. Give the harness a third verdict. It already fails on regressions>0 and on a known divergence that starts matching — good. Add unregistered>0, so "add an in-process arm" and "add a case" become the same commit.

3. Record reachability next to the arm. #710 shows the 8 substitution-filter arms are unreachable on origin/master yet still carry the carrier-defect class. Each arm wants one of live / unreachable (with the reachability-proof link) / deleted — otherwise the catalogue rots silently and the dead arms stay a latent bug cache, which is the S1/M7 pattern from §1.

One more: the extbugs=2 rows (fast path right, WinuxCmd fallback wrong — true -x, dirname ///) exist only in harness output today. Those are a different repo, so they probably want stable ids so they can be tracked in WinuxCmd rather than rediscovered every run.

Filed the context dimension separately as #713 — no overlap with this catalogue (this is the route axis, that is the context axis). I've also commented there narrowing it after reading §1 of the taxonomy doc.

@caomengxuan666

Copy link
Copy Markdown
Member Author

Case grep_utf8_i is environment-dependent, not code-dependent — observed while certifying the fast-path fix PRs (#718) with this harness:

  • Inline grep -i arm always performs Unicode case folding (locale-independent): FAST returned the folded match, rc 0.
  • The external WinuxCmd grep and GNU grep returned rc 1 (no match) in the console locale of the verifying session (C/ASCII), where \xc3\xa9 is not folded.
  • The SAME case passed in the original audit run — the original session's GNU grep folded UTF-8.

So the case's verdict flips with the console locale, which means it will intermittently report a false regression or a false "fixed". Suggest pinning a locale for the EXT/GNU invocation of this case (or splitting it into LC_ALL=en_US.UTF-8 and LC_ALL=C variants). Only this one non-ASCII fold case is affected; plain grep_utf8 is deterministic (pass everywhere).

@caomengxuan666 caomengxuan666 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adversarial review of the audit artefacts (I ran the harness and the catalogue against the installed toolchain; nothing here edited the PR's files). Verdict up front: the science is real, and the harness can fail — merge after three small fixes.

Verified (what I ran)

  1. Full run reproduces the claimed result exactly. python scripts/fast-path-differential.py on niu 1.4.0/e785c3c8, WinuxCmd 1.1.12, D:/Git coreutils: cases=180 pass=146 known=28 extbugs=2 regressions=0 fixed=0, exit 0. Scratch files (fpd-large-*, fpd-plain.txt, fpd-esc.txt) are removed at both normal exit and --json exit.
  2. Catalogue↔harness consistency is exact. Appendix A has 180 rows, --list emits 180 unique ids, and the two sets are identical; every row's recorded result (146 PASS / 28 KNOWN / 2 EXTBUG / 4 INFO) matches a live run row-for-row — no missing or phantom case.
  3. Inventory claims check out in source. execute_pipeline_stage_inner at pipeline_exec.rs:2567, match name at :2807 with the 12 arms; grep:3100, sed:3089, cat:2898, trap:2840, printf:2823, head:2865; wc at :3154 (as_bytes :3166, split_whitespace :3168, default :3181-3185); translate_tr :3413 (walks chars()), inline_expand_tr_set :3435; head_line_count :3383 with the caller's unwrap_or(10). Substitution filter fn at command_substitution_values.rs:5 with 8 arms + _ fallback; the reachability chain (trivial gate command_substitution.rs:792/:2217 rejects |) is genuine — the dead-arm finding is sound. Carrier encoding (substitution_metadata.rs E000+E0xx pairs) matches §3.1.
  4. Byte-for-byte re-run of 21 divergence rows (independent script, raw child bytes, foreign to the harness plumbing): wc -c/-w/default on CTRL/FF, wc -c with echo/printf producers, sub wc -c ctrl, head -n -1/-n abc, sub head -n -1, tr [:cntrl:]/[:space:]/mixed, dirname /a/b/c // /// '', basename '' //, uname -s — every FAST/EXT/GNU triple matches the doc's table, including both EXTBUGs (true -x rc 1, dirname /// → //) and the shared basename // non-divergence. I also reproduced §4's uncased claim head -n +2 (FAST=EXT=GNU).
  5. Selectors work. --list exit 0; --only (substring semantics) still computes and propagates the exit code (demonstrations below use --only); --json is semantically stable across two full runs (statuses and all captured bytes identical).

Demonstrations (exact commands and output)

Real-regression detection — a copy of the script with the FAST leg corrupted for the inline sed arm (simulating the product breaking -e support), run unmodified-comparator:

$ python copy_regress.py --only sed_e
[DIVERGE] sed_e
    FAST  out=b'Omega\nbetA\ngAmma\n' rc=0
    EXT   out=b'Alpha\nbetA\ngAmma\n' rc=0
    GNU   out=b'Alpha\nbetA\ngAmma\n' rc=0
cases=2 pass=1 known=0 extbugs=0 regressions=1 fixed=0
REGRESSIONS: sed_e
     (exit 1)

Silent-fix detection — how it works in code: match = stdout== && rc== (plus stderr for the 5 stderr= cases); if case["known"] and match → status FIXED? and appended to quietly_fixed; else status KNOWN; plain DIVERGE → regressions. Exit 1 iff regressions or quietly_fixed.

Demo 1, a known divergence starts matching (copy simulating head -n abc now erroring like its fallback):

$ python copy_fixed.py --only head_badnum
[FIXED? ] head_badnum              flag parsing: accepted, rc 0 vs error rc 1
[FIXED? ] sub_head_badnum          flag parsing
cases=2 pass=0 known=0 extbugs=0 regressions=0 fixed=2
KNOWN CASES NOW MATCHING (update expectations): head_badnum, sub_head_badnum
     (exit 1) — substring --only also caught sub_head_badnum

Demo 2, expectation updated to demand a match while the bug still exists (same copy with known flag removed from head_negn1):

$ python copy_expect.py --only head_negn1
[DIVERGE] head_negn1               GNU -n -1 = all but last line (expectation now demands a match)
cases=2 pass=0 known=1 extbugs=0 regressions=1 fixed=0
REGRESSIONS: head_negn1
     (exit 1)

Blocking

B1 — Concurrent runs silently false-PASS. The two file-fixture cases use fixed paths (fpd-plain.txt, fpd-esc.txt) and each run deletes them at exit. Two harness instances sharing the same temp root step on each other, and the failure mode is the worst possible one: all three legs agree on the error, so the case stays green. Reproduced deliberately (full run in background, foreground run cleaning up mid-flight): cat_file/cat_file_ctrl/cat_file_n all recorded PASS with empty stdout and cat: ...fc\pd-plain.txt: No such file or directory on stderr. Sequential runs are clean — this only bites two operators/CI jobs at once — but "idempotent, safe to re-run" (§7) is not true concurrently. Fix is small: mkstemp/per-PID fixture names (like fpd-large-*) and, belt-and-braces, assert the fixture-backed cases' stderr is empty so a fixturing failure can never masquerade as agreement.

B2 — The stated comparison contract is stronger than the code. §1 (line 30) and the PR body say "stdout, stderr and exit status are compared as raw bytes", but stderr is compared only for the five stderr=True cases (script lines 732–734; the script's own docstring correctly says stdout + exit status). Demonstrated: simulated stderr-only chatter on the FAST leg of printf … | wc -l → cases=5 pass=5, regressions=0, exit 0 — undetected. For a differential inventory, a fast path that starts shouting on stderr while stdout stays identical would pass. Either compare stderr everywhere (noisy on fallback diagnostics that legitimately differ, e.g. dirname: invalid option vs unknown option) or fix the §1/PR-body wording to "stdout and exit status; stderr for the cases that print diagnostics".

Non-blocking

N1 — Missing toolchains degrade badly. NIU pointing at a nonexistent file → raw FileNotFoundError traceback (no message). WX_BIN missing → ext_cmd silently returns None, the reference quietly becomes GNU, and e.g. wc_m (FAST 13 vs GNU 23) is reported as a rubash DIVERGE that is really "winuxcmd not found" (the EXT line even prints GNU's output). A startup sanity check with one clear fatal message per missing tool would fix both.
N2 — --only that matches nothing runs cases=0 ... and exits 0; a warning (or nonzero) would prevent a mistaken green.
N3 — No finally around fixture cleanup: an exception mid-run leaks the scratch files (they're overlay-created next run, so cosmetic after B1's naming fix).
N4 — Machine-specific defaults (C:\\Users\\cmx\\…, D:\\Git) are committed; the env overrides exist but aren't mentioned in §7 — one sentence in the doc (plus deriving the default from NIU_SHELL/WINUXCMD_HOME) would make the script portable-by-intent.

Nits

  • dirname_letter is a straight duplicate of dirname_simple (disclosed in its note) — it inflates the pass count by 1.
  • grep_utf8_i is labelled "unicode case fold" but all three legs return rc 1 — nothing in the matrix actually case-folds the accented pattern, so the note reads as a pass-verified fold it isn't.
  • When there is no EXT counterpart, the DIVERGE/FIXED? block prints the GNU values twice (once as the "reference", once as GNU).

The catalogue's science is reproducible end to end (including the unreachable-arms finding and both EXTBUG rows). Fix B1/B2 (a few lines + two sentences) and this is ready.

caomengxuan666 pushed a commit that referenced this pull request Oct 17, 2026
…706 review)

B1: fixtures now live in a per-PID scratch dir created with mkdtemp, cleaned
in a finally, with an integrity gate and a stderr-empty guard on the
fixture-backed cat cases so a fixturing error can never be recorded as
FAST/EXT agreement.

B2: the comparison contract now reads stdout + exit status, with stderr
compared only for the four diagnostic cases (stderr=True) and asserted empty
for the fixture cases; Appendix A gains a stderr column.

grep_utf8_i pins LC_ALL=C/LANG=C for all three legs, removing the
console-locale nondeterminism (under C none of the installed legs fold).

Cheap fixes: missing NIU/WX_BIN is a fatal exit-2 diagnostic (--no-ext opts
out explicitly and is recorded in the run header); --only with no match exits
1; the duplicate dirname_letter case is removed. Totals re-synced:
cases=179 pass=146 known=27 extbugs=2 info=4 regressions=0 fixed=0.
@caomengxuan666
caomengxuan666 force-pushed the audit/fast-path-differential branch from ed40910 to b666d5e Compare October 17, 2026 03:04
caomengxuan666 pushed a commit that referenced this pull request Oct 17, 2026
…706 review)

B1: fixtures now live in a per-PID scratch dir created with mkdtemp, cleaned
in a finally, with an integrity gate and a stderr-empty guard on the
fixture-backed cat cases so a fixturing error can never be recorded as
FAST/EXT agreement.

B2: the comparison contract now reads stdout + exit status, with stderr
compared only for the four diagnostic cases (stderr=True) and asserted empty
for the fixture cases; Appendix A gains a stderr column.

grep_utf8_i pins LC_ALL=C/LANG=C for all three legs, removing the
console-locale nondeterminism (under C none of the installed legs fold).

Cheap fixes: missing NIU/WX_BIN is a fatal exit-2 diagnostic (--no-ext opts
out explicitly and is recorded in the run header); --only with no match exits
1; the duplicate dirname_letter case is removed. Totals re-synced:
cases=179 pass=146 known=27 extbugs=2 info=4 regressions=0 fixed=0.
…706 review)

B1: fixtures now live in a per-PID scratch dir created with mkdtemp, cleaned
in a finally, with an integrity gate and a stderr-empty guard on the
fixture-backed cat cases so a fixturing error can never be recorded as
FAST/EXT agreement.

B2: the comparison contract now reads stdout + exit status, with stderr
compared only for the four diagnostic cases (stderr=True) and asserted empty
for the fixture cases; Appendix A gains a stderr column.

grep_utf8_i pins LC_ALL=C/LANG=C for all three legs, removing the
console-locale nondeterminism (under C none of the installed legs fold).

Cheap fixes: missing NIU/WX_BIN is a fatal exit-2 diagnostic (--no-ext opts
out explicitly and is recorded in the run header); --only with no match exits
1; the duplicate dirname_letter case is removed. Totals re-synced:
cases=179 pass=146 known=27 extbugs=2 info=4 regressions=0 fixed=0.
@caomengxuan666
caomengxuan666 force-pushed the audit/fast-path-differential branch from b666d5e to 4f57579 Compare October 17, 2026 03:04
@caomengxuan666

Copy link
Copy Markdown
Member Author

Thanks for the adversarial pass — all four named items are in 4f575795, pushed to the branch (PR updates automatically). One comment, as asked.

B1 — concurrent fixtures (blocking)

Fixtures now live in a per-process scratch directory created with
tempfile.mkdtemp(prefix="fpd-<pid>-") under AUDIT_TMP, removed in a
finally, and are integrity-checked (read-back must equal the expected bytes)
before the matrix starts. Belt-and-braces, the three fixture-backed cat cases
carry require_empty_stderr — a fixturing error on any leg can no longer be
recorded as FAST/EXT agreement even if all three legs agree on it.

Two full instances run concurrently (two Popen of the unmodified script,
separate --json), 34.1s wall:

run1 exit=0  cases=179 pass=146 known=27 extbugs=2 info=4 regressions=0 fixed=0
run2 exit=0  cases=179 pass=146 known=27 extbugs=2 info=4 regressions=0 fixed=0
same id set: True ; status diffs: none
cat_file       PASS  FAST.err=''
cat_file_ctrl  PASS  FAST.err=''
cat_file_n     PASS  FAST.err=''

Before this change two instances sharing the temp root deleted each other's
fpd-plain.txt/fpd-esc.txt; now they cannot see each other's scratch dir.

B2 — stderr contract (blocking)

Fixed by wording, not by widening coverage (conservative): the docstring, §1 and
the PR body now say stdout + exit status; stderr additionally for the four
stderr=True cases
(sleep_missing, sleep_invalid, sleep_badunit,
basename_extra), and Appendix A gains a stderr column: yes for those four,
empty for the fixture-backed cat cases (stderr asserted empty), -
otherwise. I deliberately did not compare stderr for every case: FAST-vs-EXT
diagnostics legitimately differ in wording (WinuxCmd head: invalid option -- 'x' vs GNU head: unknown option -- x), so a blanket compare would add noise,
not signal. The simulated stderr-only defect on wc -l you demonstrated is now
documented as out of the contract rather than silently implied to be covered.

grep_utf8_i determinism (nit + real observation)

Pinned LC_ALL=C and LANG=C for all three legs of the case. Measured on
the installed toolchain (2026-10-17, exact body bytes):

locale grep -i É (input café) FAST EXT (WinuxCmd) GNU
unset / LC_ALL=C rc 1 rc 1 rc 1
LC_ALL=C.UTF-8 rc 1 rc 1 rc 0 (folds)
LC_ALL=en_US.UTF-8 rc 1 rc 1 rc 0 (folds)

So under C none of the installed legs fold → deterministic PASS; under a UTF-8
locale only GNU folds and WinuxCmd does not. The inline arm uses Rust
to_lowercase() (locale-independent): if a future build's inline arm folds
non-ASCII under C it will show up as a real FAST-vs-EXT divergence instead of
console noise — which is the point of pinning. The case note no longer claims a
"unicode case fold" the installed legs don't perform. (Answering the
environment-dependent comment directly: niu's grep -i does not fold
café/É on this installed build under any of the tested locales; GNU folds
under UTF-8 locales only; WinuxCmd never folds.)

Cheap list

  • Missing NIU or WX_BIN → one-line diagnostic, exit 2 (no traceback);
    WX_BIN no longer silently degrades the reference to GNU. --no-ext is the
    explicit opt-out and the run header records EXT=DISABLED (--no-ext).
  • --only matching nothing → message + exit 1.
  • Duplicate dirname_letter removed (it was KNOWN, not PASS, so the pass count
    is unchanged; known drops by one).
  • Numbers re-synced: §7 recorded run, Appendix A partition (179 rows: PASS 146 /
    KNOWN 27 / INFO 4 / EXTBUG 2). Full-run fatal path also verified
    (NIU=C:/nope/niu.exe → exit 2; WX_BIN=C:/nope/wx → exit 2;
    --no-ext with the same missing WX_BIN → runs, header shows DISABLED).

New totals:

cases=179 pass=146 known=27 extbugs=2 info=4 regressions=0 fixed=0

(180→179 and 28→27 are the duplicate removal; info=4 is now surfaced.)

Deliberately not changed

  • The registry/derive-the-arm-set asks (arm set registered, unregistered>0
    third verdict, per-arm live/unreachable status, stable ExtBug ids) are a
    larger design change than this audit PR; left for a follow-up rather than
    smuggled into a review fix. Happy to take it as its own PR.
  • The command-builtin carrier leak and WinuxCmd sort CR behaviour stay
    documented-and-not-filed as before (not fast paths / platform text mode).
  • Hardcoded machine defaults remain, now documented in §7 as the
    NIU/WX_BIN/GNU_BASH/GNU_PATH/AUDIT_TMP overrides.
  • The "GNU printed twice" cosmetic nit (unchanged).

@caomengxuan666
caomengxuan666 merged commit 000ba29 into master Oct 17, 2026
6 checks passed
caomengxuan666 pushed a commit that referenced this pull request Oct 17, 2026
…ith doc-sync guards

PR #706's differential audit (docs/audit/fast-path-differential.md, included
here so the links resolve) inventoried three layers of in-process fast paths,
but docs/builtins.md recorded only the hidden-builtin one (sleep/dirname/
basename + uname/arch). The other two were invisible to the doc-sync test:

- 12 pipeline-stage arms (execute_pipeline_stage_inner, pipeline_exec.rs
  `match name`): true, :, false, echo, printf, trap, head, cat, sed, grep,
  wc, tr — the stage runs in-process on the pipe until the arm declines a
  shape (head -c, regex metacharacters in grep, '-'-words in tr, ...), then
  falls back to the external winuxcmd binary.
- 8 command-substitution filter arms (command_substitution_pipeline_filter,
  command_substitution_values.rs): sort, sed, tr, head, grep, wc, tail, uniq
  (+ generic-external fallback). Audit §2.5 additionally shows these are
  unreachable for ordinary $( … | … ) bodies after rubash#117's triviality
  gate, so the table describes code shape, not observable behaviour.

docs/builtins.md gains §3.1 with both lists inside two new machine blocks
(pipeline-fastpath-list, substitution-fastpath-list) in the same fenced
grammar the doc-sync test parses, plus one honest sentence per group and a
link to the audit's divergence catalogue (§3) and tracking table (§8).

The doc-sync test in builtin_names.rs gets two new cases pinning each list
against a frozen expected set (the arms are inline match branches, so the
expected set cannot be derived from a table); adding, removing or renaming an
arm without updating the doc now fails `cargo test --lib builtin_names`.

cargo test --lib builtin_names: 8 passed, 0 failed.
caomengxuan666 added a commit that referenced this pull request Oct 17, 2026
…t-path arms, guarded (#722)

* docs(builtins): fast-path arms in pipelines and $(…) substitutions, with doc-sync guards

PR #706's differential audit (docs/audit/fast-path-differential.md, included
here so the links resolve) inventoried three layers of in-process fast paths,
but docs/builtins.md recorded only the hidden-builtin one (sleep/dirname/
basename + uname/arch). The other two were invisible to the doc-sync test:

- 12 pipeline-stage arms (execute_pipeline_stage_inner, pipeline_exec.rs
  `match name`): true, :, false, echo, printf, trap, head, cat, sed, grep,
  wc, tr — the stage runs in-process on the pipe until the arm declines a
  shape (head -c, regex metacharacters in grep, '-'-words in tr, ...), then
  falls back to the external winuxcmd binary.
- 8 command-substitution filter arms (command_substitution_pipeline_filter,
  command_substitution_values.rs): sort, sed, tr, head, grep, wc, tail, uniq
  (+ generic-external fallback). Audit §2.5 additionally shows these are
  unreachable for ordinary $( … | … ) bodies after rubash#117's triviality
  gate, so the table describes code shape, not observable behaviour.

docs/builtins.md gains §3.1 with both lists inside two new machine blocks
(pipeline-fastpath-list, substitution-fastpath-list) in the same fenced
grammar the doc-sync test parses, plus one honest sentence per group and a
link to the audit's divergence catalogue (§3) and tracking table (§8).

The doc-sync test in builtin_names.rs gets two new cases pinning each list
against a frozen expected set (the arms are inline match branches, so the
expected set cannot be derived from a table); adding, removing or renaming an
arm without updating the doc now fails `cargo test --lib builtin_names`.

cargo test --lib builtin_names: 8 passed, 0 failed.

* docs: repoint gap-ledger authority to tracker + git history instead of dangling TASK-BOARD path (#716)

---------

Co-authored-by: cmx <[email protected]>
@caomengxuan666
caomengxuan666 deleted the audit/fast-path-differential branch October 18, 2026 09:28
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.

2 participants