Skip to content

docs(builtins): document the pipeline-stage and $(…) substitution fast-path arms, guarded - #722

Merged
caomengxuan666 merged 2 commits into
masterfrom
docs/706-fastpath-arms
Oct 17, 2026
Merged

caomengxuan666 merged 2 commits into
masterfrom
docs/706-fastpath-arms

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Follow-up to the fast-path differential audit in #706.

What

docs/builtins.md recorded only the hidden fast-path builtins
(sleep/dirname/basename, plus uname/arch). The audit's inventory
adds two more layers of in-process fast path that the never documented — and
the doc-sync test could not see them because it parses only the
builtins-list/fastpath-list machine blocks:

layer code arms
pipeline stage execute_pipeline_stage_inner, pipeline_exec.rs match name true : false echo printf trap head cat sed grep wc tr — 12
command substitution filter command_substitution_pipeline_filter, command_substitution_values.rs sort sed tr head grep wc tail uniq (+ generic-external _ fallback) — 8

Doc section (§3.1)

Both lists are inside two new machine blocks in the same fenced grammar
the doc-sync test already parses (<!-- pipeline-fastpath-list … -->,
<!-- substitution-fastpath-list … -->), so they are now guarded rather than
prose. One honest sentence per group: the pipeline arms run in-process on
pipes until they hit a shape the arm declines, then fall back to the external
winuxcmd binary; the substitution arms produce the $() value in-process and
otherwise hand off to the generic-external branch. The section links to
docs/audit/fast-path-differential.md
(added here so the link resolves before #706 merges) for the per-arm accept
shapes, decline conditions and the confirmed divergence catalogue (§3:
wc/tr carrier-byte counting, head's silently-defaulted flags,
dirname/basename edge cases) and the tracking table (§8: #707–#710,
WinuxCmd#1196, already-tracked niubash#383 / #695).

The substitution paragraph also records audit §2.5's reachability finding:
after rubash#117's triviality gate these 8 arms are unreachable for
ordinary $( … | … ) bodies — the table describes code shape, not
observable behaviour, which is exactly the kind of claim that must not read
as an active-behaviour promise.

Doc-sync guard

The test fixture in src/executor/builtin_names.rs gains two cases in the
existing style (frozen expected sets — the arms are inline match branches,
so there is no table to derive the lists from):

  • doc_pipeline_fastpath_list_matches_pipeline_arms
  • doc_substitution_fastpath_list_matches_substitution_filter_arms

Adding, removing or renaming an arm without updating the doc now fails
cargo test --lib builtin_names. Verified both directions: all 8 tests pass
on this branch, and deleting one line from a machine block fails the
matching case (docs/builtins.md substitution-fastpath-list is out of sync with the filter arms …).

Scope

Doc-only. Code touched: the one doc-sync test fixture (frozen expected sets
and doc comments) — no runtime behaviour. The main worktree's staged
deletions and niubash's PR branch are untouched.

cmx and others added 2 commits October 17, 2026 13:18
…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
caomengxuan666 merged commit 8a92ee4 into master Oct 17, 2026
6 checks passed
@caomengxuan666
caomengxuan666 deleted the docs/706-fastpath-arms 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.

1 participant