Repository navigation
Conversation
Emit omission markers at each discontinuity and preserve source line numbers through max and tail windows. Handle zero-line windows safely and give stdin the same non-empty filter fallback as file reads.
HetCreep
left a comment
There was a problem hiding this comment.
Built fix/read-honest-truncation at b93dd68 and ran the full verification independently (release build, cargo test --bin rtk, cargo test --all, plus the original #3421 reproducer by hand).
All three core problems from #3421 are genuinely fixed:
- Gap markers now appear at every real discontinuity, not just at the end. Re-running the
auth.rs/--max-lines 10example from the issue: theis_bannedguard's droppedreturn false;now shows[1 line omitted]right where it was removed, instead of silently vanishing intoif user.is_banned { }. -nnow prints the file's real line numbers for kept lines (omission markers left unnumbered), not a sequential kept-line count.--max-lines 0returns cleanly (empty output, exit 0) — no underflow, no hang.cargo test --bin rtk: 2623 passed, 0 failed, 8 ignored.cargo test --all: 17 passed, 0 failed, including the newread_integrity_test.rs(truncation_marks_removed_guard_body_at_the_gap,numbered_truncation_uses_source_line_numbers,zero_line_window_is_empty_without_panicking,stdin_falls_back_when_filter_removes_nonempty_input).
Nice work — the inline-marker approach is exactly what the issue asked for, and the regression coverage is real (I ran it, not just read it).
One thing worth flagging for @rtk-ai maintainers before merge, not a correctness objection: this PR's diff is wider than its own description states ("keep the change scoped to read/smart_truncate"). Alongside the read.rs/filter.rs changes, it also touches:
src/cmds/git/git.rs(+466/-…) — agit log -- <path>fix citing #1215 (a real, closed issue — thetrailing_var_arg/--bug apparently never got the same fixgit logthatgit diffgot). Comes with its own regression test (git_log_dash_p_pathspec_after_double_dash_is_not_patch_flag), which I also ran — passes.src/core/tee.rs(+45/-…) — reworks slug truncation for tee recovery filenames (readable-prefix + hash instead of a hard 40-char cut, to avoid collisions on long embedded paths).scripts/benchmark.sh(+8/-…) — fixesrm -rf "$BENCH_DIR"deleting tracked benchmark-harness files on every local run.
Each of those looks like a legitimate, independently-motivated fix with its own justification in the diff — I'm not saying any of them is wrong. But bundled together with #3421 in one PR, a maintainer reviewing this has to sign off on four unrelated concerns at once, and if any one of them needs discussion the whole PR (including the already-verified #3421 fix) sits blocked. Might be worth splitting git.rs/tee.rs/benchmark.sh into their own PRs so the #3421 fix — which is fully verified and ready — isn't held hostage to review of the other three.
(Disclosure, matching this PR's own AI-assistance note: this review was carried out with AI (Claude) assistance, human-directed — I built the branch and ran every command above myself rather than trusting the PR description.)
|
Thanks for independently running the reproducer and full test suites. I rechecked the scope concern against the actual PR head and base: commit |
|
You're right, and I was wrong — sorry for the noise. Root cause on my end: my local Re-ran it properly against Retracting the scope note entirely — this PR is scoped exactly as described. The functional verification (build, |
|
Merged develop b748a5f normally in 9ab008f. Kept upstream chunked-head reading alongside the existing numbered truncation function. The only extra test adjustment is the numbered-tail expectation (source line 4, not renumbered line 1). Format, Clippy, 3,742 unit tests, and all 9 targeted read integration tests passed. The full run still hits the two previously documented, unrelated Git integration assertions; details are in the refreshed description. No new tests or refactors added. AI-assisted resolution and verification. |
|
Merged develop Format, workspace Clippy, focused read/filter tests, and both read integration suites passed. The final full test command passed 4,664 tests with 8 ignored and no failures. The PR remains limited to four files. AI-assisted resolution; no force-push. |
|
Heads-up for the rebase: #4647 changes the |
Summary
rtk read --max-lines Ncan remove the body of a guard and display its braces together, making the shortened code appear to mean something different. Mark every omitted span at its actual position, and preserve source line numbers for numbered truncation and tail windows. Also retain nonempty stdin when a source filter removes all of it.The head rewrite, byte-faithful head/tail windows, zero-budget handling, chunked head reading, and quoted tracking labels remain as upstream implements them.
Closes #3421
Upstream sync
Normally merged develop
5eb0509. The CLI's gap-aware selection remains insrc/core/filter.rs, using the sharedrtk_textimport/signature predicates and the new language-independent function signatures. The shared text and engine window behavior is unchanged. The diff remains limited to the four read/filter/test files.The original binary regressions now use upstream's
common::rtk_command()so their children have isolated data directories. The existing numbered-tail expectation remains source line 4 rather than renumbered line 1.Verification
On Rust 1.99.0:
cargo test --locked --quiet: 4,664 tests passed, 8 ignored, no failures. No tests were skipped beyond the upstream ignored tests, and no timeout settings changed.OpenAI Codex assisted with implementation, conflict resolution, and verification.