Repository navigation
Conversation
This was referenced Sep 19, 2026
KuSh
marked this pull request as ready for review
September 19, 2026 16:21
KuSh
force-pushed
the
lex/10-consolidation
branch
from
September 19, 2026 21:14
a6ebc5a to
28cf256
Compare
KuSh
force-pushed
the
lex/10-consolidation
branch
from
September 20, 2026 23:23
28cf256 to
1296a25
Compare
4 of 5 tasks
KuSh
force-pushed
the
lex/10-consolidation
branch
from
September 25, 2026 22:55
1296a25 to
e90ef60
Compare
KuSh
force-pushed
the
lex/10-consolidation
branch
from
September 25, 2026 23:15
e90ef60 to
7a1a303
Compare
KuSh
force-pushed
the
lex/10-consolidation
branch
2 times, most recently
from
September 25, 2026 23:29
a68e00e to
a4e60f8
Compare
KuSh
force-pushed
the
lex/10-consolidation
branch
from
September 26, 2026 17:56
a4e60f8 to
50faaf8
Compare
KuSh
force-pushed
the
lex/10-consolidation
branch
2 times, most recently
from
October 19, 2026 16:38
0f544ae to
e72bf70
Compare
KuSh
force-pushed
the
lex/10-consolidation
branch
2 times, most recently
from
October 26, 2026 11:29
51cc76b to
bce37a3
Compare
KuSh
force-pushed
the
lex/10-consolidation
branch
3 times, most recently
from
October 31, 2026 16:42
5a3fb0d to
8e72f99
Compare
KuSh
force-pushed
the
lex/10-consolidation
branch
from
November 1, 2026 15:19
8e72f99 to
4ae034f
Compare
TaKO8Ki
force-pushed
the
lex/10-consolidation
branch
from
November 2, 2026 11:31
4ae034f to
ae5f10a
Compare
KuSh
force-pushed
the
lex/10-consolidation
branch
from
November 3, 2026 00:58
ae5f10a to
656de3d
Compare
KuSh
force-pushed
the
lex/10-consolidation
branch
from
November 3, 2026 06:27
656de3d to
9f0c9e5
Compare
KuSh
marked this pull request as draft
November 4, 2026 07:41
KuSh
force-pushed
the
lex/10-consolidation
branch
from
November 5, 2026 11:48
9f0c9e5 to
849c9a7
Compare
KuSh
marked this pull request as ready for review
November 5, 2026 12:22
KuSh
force-pushed
the
lex/10-consolidation
branch
from
November 17, 2026 01:42
849c9a7 to
7056177
Compare
KuSh
force-pushed
the
lex/10-consolidation
branch
2 times, most recently
from
November 19, 2026 01:12
f707648 to
c17363d
Compare
KuSh
force-pushed
the
lex/10-consolidation
branch
from
November 21, 2026 09:57
c17363d to
97b6460
Compare
Three things were written down more than once, and each duplicate cost a bug. **Where a substitution begins and ends** was counted separately by the segmenter and by the emitter. They walk the same tokens and have to reach the same answer, and twice they did not: once over an operator inside a substitution, which the segmenter knew was not a boundary and the emitter did not, so `echo $(git status && git log)` was rewritten into the string it captures; once over a bracket nested in a substitution, which the emitter counted and the segmenter did not, so the closing `)` went missing from the segment. Both were of the shape "the other copy learned this and I did not". `SubstitutionDepth` now holds that counting, in `lexer.rs` with the tokens and the other low-level scanning, and `registry.rs` uses it. The emitter's four guarded match arms become one skip above the match, because "nothing inside a substitution is a boundary and nothing inside one is rewritten" is one statement rather than four. **Quoting** was tracked by `QuoteScan` for most callers and hand-rolled by two others: `contains_substitution` with its own `in_single`/`in_double` pair, and `word_end_from` with its own `Option<u8>`. Both re-derived the same rules and either could drift from the shared one. They now read `QuoteScan`. `QuoteScan` itself used to step over an escaped byte without reporting it. That suits the six callers asking about syntax — `\(` is not a bracket, `\#` is not a comment, `\'` opens nothing — and it silently failed the one asking where words are, for which an escaped byte is text like any other. A word made only of escapes, such as a lone `\'`, went unreported and vanished from the split, taking the next word with it: `FOO=bar \' BAZ=1 git status` read as an env prefix running through `BAZ=1`, making a real assignment part of the prefix rather than a command's environment. Rather than have the caller rebuild what the scan withheld, the scan now reports every byte and marks which are escaped, and `significant()` is the word the six say. The choice sits at each call site instead of inside the iterator, where it was a default nobody could see. `word_spans` is the helper whose absence made a second scanner look necessary: `coalesce_words` merges *adjacent* tokens, which suits argv and not the question of where a word ends. **The report's two savings tables** had the same columns, widths, totals line and estimate note, written out twice and differing only in heading and in what their total means. `append_savings_table` takes those two differences as arguments. A column added to one can no longer go missing from the other, and the four `total_*` methods that existed to feed the duplicated footers go with them, since the shared writer sums what it is given. The execution oracle is hardened alongside. It passed on any command whose programs are all unstubbed — both traces empty, empty equals empty, success reported having run nothing. Shown with `head -5 f` against `rtk read f --head-lines 999`, a deliberately wrong line count, which passed. A trace is now required to be non-empty. That also names what the oracle cannot do: `head -5 f` becomes a different program with reordered operands, and "the same programs ran" is not the test for that. And `timeout` is coreutils, which macOS does not ship while CI runs there — absent, the stub's bounded read of a `/dev/fd` failed and recorded an empty value on both sides, so the process-substitution cases kept passing while comparing nothing. Availability is decided once at setup and those cases are not claimed when it is missing. No behaviour change beyond the escaped-word fix: the rendered report is the same report, and the differential harness over 13,020 commands agrees with the frozen walker as before. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
KuSh
force-pushed
the
lex/10-consolidation
branch
from
November 25, 2026 02:13
97b6460 to
311c61e
Compare
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.
Three things were written down more than once, and each duplicate cost a bug.
Where a substitution begins and ends was counted separately by the segmenter
and by the emitter. They walk the same tokens and have to reach the same answer,
and twice they did not: once over an operator inside a substitution, which the
segmenter knew was not a boundary and the emitter did not, so
echo $(git status && git log)was rewritten into the string it captures; onceover a bracket nested in a substitution, which the emitter counted and the
segmenter did not, so the closing
)went missing from the segment. Both wereof the shape "the other copy learned this and I did not".
SubstitutionDepthnow holds that counting, in
lexer.rswith the tokens and the other low-levelscanning, and
registry.rsuses it. The emitter's four guarded match armsbecome one skip above the match, because "nothing inside a substitution is a
boundary and nothing inside one is rewritten" is one statement rather than four.
Quoting was tracked by
QuoteScanfor most callers and hand-rolled by twoothers:
contains_substitutionwith its ownin_single/in_doublepair, andword_end_fromwith its ownOption<u8>. Both re-derived the same rules andeither could drift from the shared one. They now read
QuoteScan.QuoteScanitself used to step over an escaped byte without reporting it. Thatsuits the six callers asking about syntax —
\(is not a bracket,\#is not acomment,
\'opens nothing — and it silently failed the one asking where wordsare, for which an escaped byte is text like any other. A word made only of
escapes, such as a lone
\', went unreported and vanished from the split,taking the next word with it:
FOO=bar \' BAZ=1 git statusread as an envprefix running through
BAZ=1, making a real assignment part of the prefixrather than a command's environment. Rather than have the caller rebuild what
the scan withheld, the scan now reports every byte and marks which are escaped,
and
significant()is the word the six say. The choice sits at each call siteinstead of inside the iterator, where it was a default nobody could see.
word_spansis the helper whose absence made a second scanner look necessary:coalesce_wordsmerges adjacent tokens, which suits argv and not the questionof where a word ends.
The report's two savings tables had the same columns, widths, totals line
and estimate note, written out twice and differing only in heading and in what
their total means.
append_savings_tabletakes those two differences asarguments. A column added to one can no longer go missing from the other, and
the four
total_*methods that existed to feed the duplicated footers go withthem, since the shared writer sums what it is given.
The execution oracle is hardened alongside. It passed on any command whose
programs are all unstubbed — both traces empty, empty equals empty, success
reported having run nothing. Shown with
head -5 fagainstrtk read f --head-lines 999, a deliberately wrong line count, which passed. Atrace is now required to be non-empty. That also names what the oracle cannot
do:
head -5 fbecomes a different program with reordered operands, and "thesame programs ran" is not the test for that. And
timeoutis coreutils, whichmacOS does not ship while CI runs there — absent, the stub's bounded read of a
/dev/fdfailed and recorded an empty value on both sides, so theprocess-substitution cases kept passing while comparing nothing. Availability is
decided once at setup and those cases are not claimed when it is missing.
No behaviour change beyond the escaped-word fix: the rendered report is the same
report, and the differential harness over 13,020 commands agrees with the frozen
walker as before.
Test plan
cargo fmt --all && cargo clippy --all-targets && cargo test --all— 5920 passing, clippy clean, at this commit rather than only at the tip of the stackPart of #4315 (#4129 → #4138). Based on #4137. Each commit gates green on its own, so the stack is bisectable.
🤖 Generated with Claude Code