Repository navigation
fix(tree): stop dropping entries whose names contain 'director'+'file' (output-mangling sweep) - #9
Merged
Merged
Conversation
The tree filter stripped any line matching the loose substring heuristic
`line.contains("director") && line.contains("file")`, intended to drop
tree's trailing summary line (e.g. "5 directories, 23 files"). But this
silently dropped legitimate entries whose filenames contain both words,
e.g. `director-files.txt`, `file_directory.json`, or a path segment like
`my directory with files` — the model never saw those files existed.
Same bug class as the grep BRE-pipe over-match (#6) and the wc
space-filename drop (#8): an output transform that over-matches and
silently strips real content the model reasons over.
Fix: anchor the summary detector to tree's exact summary shape with a
whole-line regex (`^\d+ director(y|ies)(, N files)?(, N links)?$`)
instead of a substring contains-check. Regression tests prove the dropped
filenames now survive and the real summary line is still stripped,
including the `, N links` platform variation.
|
👋 Thanks for the PR! It looks like this targets Please update the base branch:
See CONTRIBUTING.md for details. |
ryanmurf
enabled auto-merge (squash)
May 30, 2026 01:28
This was referenced May 30, 2026
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.
Output-mangling sweep —
treesummary over-match (same class as #6, #8)Systematic audit of the
src/cmds/output filters for the highest-severity bug class in rtk: a filter that parses/transforms command output and silently drops / reorders / truncates / corrupts content the model then reasons over. (Excludesgrep#6 andwc#8, already fixed.)Fixed:
src/cmds/system/tree.rs— silent entry dropThe tree filter stripped tree's trailing summary line (
"5 directories, 23 files") with a loose substring heuristic:This silently dropped any legitimate tree entry whose name contains both substrings — e.g.
director-files.txt,file_directory.json,files-and-directories.md, or a path segment likemy directory with files. The model never saw those files existed. Exact same family as the grep BRE-pipe over-match (#6) and the wc space-filename drop (#8): an output transform that over-matches and strips real content.Fix (mirrors #8's "anchor to the known shape, treat the rest verbatim"):
^\d+ director(y|ies)(?:, \d+ files?)?(?:, \d+ links?)?\.?$(covers0 directories,1 directory, 0 files,5 directories, 23 files, and the BSD/--du, N linksvariant).Sweep verdicts on the other output-transforming filters
system/ls.rssystem/find_cmd.rsfindoutput), so no token-split mangling. But dir-display truncation&dir[dir.len()-47..]is a raw byte-slice that will panic on a multibyte UTF-8 directory path when the boundary lands mid-codepoint. Real but separate (panic, not silent corruption) — left for a focused follow-up to keep this PR reviewable.system/env_cmd.rsshowing N relevant) and PATH-split/value-truncation are explicit. Intentional noise reduction, not silent corruption.system/log_cmd.rstake(10)/take(5)caps are signaled with+N more; char-based truncation is multibyte-safe (.chars().take(97), test present).system/tree.rsgit/diff_cmd.rs(condense_unified_diff)+/-lines in full per file (deliberately never truncates), then prints+N morewhen total>10 even though all are shown — confusingly worded but does not drop data; the existing tests bake this in. Not in the drop/corrupt class.No other filter in the sweep silently drops/reorders/corrupts content. The one additional real defect (find_cmd byte-slice panic) is noted above for follow-up.
Gate (run locally, all green)
cargo fmt --all -- --check✅cargo clippy --all-targets -- -D unsafe_code✅ (matches CI gate)cargo test --all✅ (1732 + 12 passed, 0 failed)cargo build --release✅DeepSeek review: APPROVE — regex correct/comprehensive, regression tests genuine (fail against old code), no panic risk. Its one non-blocking suggestion (tail-only matching to kill the residual "file named like a summary" edge case) was adopted in this PR.