Repository navigation
fix(gradle): remove the unreachable gradle.toml filter - #2709
Conversation
KuSh
left a comment
There was a problem hiding this comment.
Reviewed at head 0801879b, built and tested merged into today's develop (5e10aa64), not on the branch alone. Merges cleanly; CLA signed; all 12 checks green. Real binaries, real producer shims, LC_ALL=C.
The regex reading in #2708 is correct — ^(gradle|gradlew|\./)gradlew?\b really does require an impossible gradlegradle. But the stated impact is not, and that changes what the fix should be.
The premise doesn't hold
src/discover/rules.rs:785 already rewrites the whole gradle family. Confirmed against both binaries:
rtk rewrite "gradle build" → rtk gradlew build (identical on develop and this PR)
rtk rewrite "gradle bootRun" → rtk gradlew bootRun
rtk rewrite "gradlew build" → rtk gradlew build
rtk rewrite "./gradlew build" → rtk gradlew build
So gradle build was never "falling through to unfiltered output" — it goes to the Rust gradlew_cmd, which even falls back to the system gradle binary when no wrapper exists (gradlew_cmd.rs:72-78).
The ./ rows of the table are also wrong: run_fallback matches against the basename of args[0] (main.rs:1483-1487), so ./gradlew arrives as gradlew. The old regex matched nothing at all, and the new (\./)? group is unreachable at the only call site.
gradle.toml has in fact never filtered a single invocation: the basename logic landed adda2537 (2026-03-10), the file was added 8fae5b06 (2026-03-18). It was born unreachable.
Two regressions from widening it
Details in the inline comments. In short: the widened pattern feeds the hook's rewrite decision, so gradle-profiler and gradle.bat are now actively routed into a lossy filter (201 lines → 52, result line discarded); and it shadows spring-boot.toml, turning a diagnosed startup failure into 50 lines of INFO noise.
The regex is the wrong lever
gradle.toml is dead from unreachability, not redundancy — gradlew_cmd classifies build/test/lint/dependencies/connected and drops everything else into GradlewTask::Other → run_passthrough, fully unfiltered:
rtk gradlew bootRun 164 lines in → 164 out
rtk gradlew publish 164 lines in → 164 out
rtk gradlew build 164 lines in → 2 out
So the noise this filter targets is exactly the noise gradlew_cmd declines to touch, and routing guarantees they never meet. Widening the match_command can't fix that; it only makes the filter capture neighbouring tools instead.
Two coherent ways forward:
- Delete
src/filters/gradle.toml. Costs nothing — it has never filtered anything. Updatetest_builtin_filter_count63→62 and drop"gradle"from the expected-names list. Leavesspring-boot.tomlworking. - Make it reachable properly — let default passthrough consult TOML filters. Filed as #3904 with the design;
FilterMode::Bufferedalready exists unused for exactly this. That is core-architecture work and explicitly not something to ask of this PR.
Also worth noting: nothing anywhere tests which filter a command line selects — run_filter_tests only runs the [[tests.*]] pipeline cases and never evaluates match_command. A table-driven selection test would have caught both regressions at author time.
Thanks for the careful regex analysis in #2708 — the reading is right, it's the routing underneath that makes the conclusion come out differently.
Its match_command, `^(gradle|gradlew|\./)gradlew?\b`, needs a doubled token (`gradlegradle`) or a literal `./gradle…`. Both call sites reduce argv[0] to its basename before the lookup — `run_fallback` in main.rs and `strip_absolute_path` on the hook rewrite path — so the `./` branch is unreachable too. The filter has matched nothing since it landed: the basename logic arrived in adda253 (2026-03-10), the file in 8fae5b0 (2026-03-18). Deleting it changes no output. `src/discover/rules.rs` already routes the whole gradle family (`gradle`, `gradlew`, `./gradlew`, `gradlew.bat`) to `rtk gradlew` and the Rust gradlew_cmd, and `gradle … bootRun` is filtered by spring-boot.toml. Widening the regex instead would have shadowed spring-boot.toml — first match wins, ordered by filter name — and pulled gradle-profiler and gradle.bat into a head-truncating filter. Making TOML filters reachable from the default passthrough is a separate design question, tracked in rtk-ai#3904. Refs rtk-ai#2708
0801879 to
757188f
Compare
|
@KuSh you're right on all counts. I checked each claim against binaries before deleting anything: the rewrite rule already covers the whole gradle family, both TOML lookup call sites reduce So I went with your option 1. The regex commit is replaced by a single commit that deletes Proof it changes nothing: |
The module map in the search-strategy rule still counted 63 TOML filter configs; src/filters/ now holds 62.
KuSh
left a comment
There was a problem hiding this comment.
Round 2 of 3 — APPROVED
Claim: delete src/filters/gradle.toml, a built-in filter that has never been reachable, and correct the two hard-coded built-in counts.
Scope: accept. (Round 1 predates the current review template; verdict stated here and frozen.)
Ran: stand-in gradle/gradlew/gradle-profiler/gradle.bat replaying this repo's own captured fixtures (tests/fixtures/gradlew_{build,build_failed,test,test_failed,lint}_raw.txt) plus spring-boot.toml's committed bootRun input — 9 rewrite spellings + 18 execution rows (green, failing, empty, noise-only, missing-tool) + split streams + 5 exit codes + rtk verify, develop vs head-merged-on-develop, binaries md5-distinct; invariants: under the hook, split streams, every decision branch, over-cap accounting; savings 74% on the bootRun row against the 20% floor (CONTRIBUTING.md).
CI @3729bc41: 11/11 pass, including macOS, Ubuntu and Windows.
Blocks merge (0)
Both round-1 blockers are dissolved rather than waived: they were anchored on the widened match_command line, and that line no longer exists.
Every gradle-family spelling is byte-identical before and after, exit codes included:
| row | develop | this PR |
|---|---|---|
rtk rewrite × 9 spellings |
— | identical |
gradle build / test / lint / publish / tasks |
raw passthrough | byte-identical |
gradlew build / test / lint / bootRun |
— | byte-identical |
gradle bootRun |
88 B (spring-boot keep-list) | 88 B, identical |
gradle-profiler / gradle.bat |
raw | raw |
| split streams (large stderr) | 1385 + 8530 B | identical |
| exit codes 0/1/2/42/127 | propagated | identical |
rtk verify |
154/154 | 151/151 |
Two of those carry the weight. gradle build's output is byte-identical to the raw fixture on develop, which is the direct proof the filter never fired rather than an inference from the pattern. And rtk verify drops exactly 3, matching the file's three inline [[tests.gradle]] blocks, so the accounting closes with nothing unexplained. gradle bootRun keeps spring-boot.toml's filtering on both sides, verified by mechanism — the output is exactly that filter's keep-list — not by the byte count alone.
Both new pins are live gates at their new values, not merely self-consistent: adding a filter file fails test_builtin_filter_count with "got 63" against 62, and test_new_filter_discoverable_after_concat with "Expected 63". develop carries 63 filter files, this branch 62.
Re-checked before approving: src/filters/, src/core/toml_filter.rs and build.rs are unchanged on develop since the matrix run, so the count of 62 is still right at merge time. Gate on the pushed commit merged onto current develop: fmt clean, clippy --all-targets 0 warnings, cargo test --all 3937 passed / 0 failed.
Fixup pushed
3729bc41 — .claude/rules/search-strategy.md:65 still described src/filters/ as holding 63 TOML filter configs. One line, docs only; it touches no code path and no matrix row, and CI's doc review job is green on it.
Filed as follow-ups
Both pre-existing and untouched by this diff, so evidence went to #3402 (which already owns this class) rather than into new issues:
test_builtin_all_expected_filters_presentcalls itself "the safeguard against accidentally deleting a filter file" but lists only 41 of the 62 names. Verified by mutation: deleteturbo.toml, bump the two counts, and all four enumerating tests stay green. This PR is exactly the case that comment claims to cover, and the only thing that actually noticed was the hand-maintained count pin — which you updated correctly, including the second one.build.rs:54's duplicate-filter-name detection is unreachable: the combined document's own parse rejects a duplicate key first. Duplicates are still caught loudly, so it is a dead diagnostic rather than a hole.
Checked and correct — no need to re-verify
- "gradle" is absent from
test_builtin_all_expected_filters_present's list, so nothing there needed changing; you were right. - Nothing else enumerates, counts, hashes or name-looks-up the built-in blob:
active_filter_summariesandcount_custom_toml_filtersread only on-disk project and global filters, the pinned SHA-256s ininit.rscover the awareness payloads rather than the filter blob, and the anchoring and inline-test sweeps iterate whatever is present. - Removing the key cannot reorder the rest (
BTreeMapkeyed by filter name), and the old pattern matched only./gradle…forms, so it never shadowed another filter. - No doc other than the one in the fixup carried a filter count.
Hypotheses built and dropped
- "
spring-bootbecomes newly reachable forgradle bootRun" — dropped: it already matched ondevelop, because the old gradle pattern never matched that string. The 88-byte output is identical on both sides. - "
./gradle <task>loses its only handler" — dropped: no rule rewrites it in either tree, and the wrapper is always namedgradlew.
Your questions
- "Two count pins needed updating rather than one" → correct, and both values are individually right; mutation-confirmed.
- "
test_builtin_all_expected_filters_presentdoesn't list gradle, so nothing changed there" → confirmed. It also cannot see 21 of the 62, but that gap is #3402's, not this PR's. - "I've left #3904 alone" → the right call. #3904 turned out to overlap #3402, which predates it; I've commented on both to sort that out.
Next
Nothing — approving. Thank you for re-deriving the findings against binaries yourself before deleting anything, and for writing up why the original premise was wrong; that made this round short.
Rounds: 2/3. Threads: 0 open, 2 resolved this round.
What changed
Deletes
src/filters/gradle.tomland updates the two hard-coded built-in filter counts (63 -> 62 intest_builtin_filter_count, 64 -> 63 intest_new_filter_discoverable_after_concat).Why: the original premise was wrong
This PR first proposed widening
match_commandto^(\./)?(gradlew?)\b. KuSh's review showed that fixes nothing and breaks two things, and I reproduced his findings independently:src/discover/rules.rsalready routes the whole family:gradle build,gradle bootRun,gradlew build,./gradlew buildandgradlew.bat cleanall rewrite tortk gradlewand reach the Rustgradlew_cmd, which even falls back to the systemgradlebinary. Nothing was falling through unfiltered.argv[0]to its basename first (run_fallbackinmain.rs,strip_absolute_pathon the hook path), so the./branch, the regex's only real match, is unreachable at every call site.gradle.tomlhas filtered nothing since it landed: basename logicadda2537(2026-03-10), file added8fae5b06(2026-03-18). Verified with a stand-ingradle:rtk gradle buildreturns byte-identical raw output today, not what the filter's own inline test expects.spring-boot.toml(BTreeMapordered by filter name, first match wins,gradle<spring-boot), turning a diagnosedbootRunfailure into head-truncated INFO noise, and would pullgradle-profiler/gradle.batinto amax_lines = 50head cut that discards the result line.Proof it changes nothing
Built both binaries and compared
rtk rewritefor nine gradle spellings (gradle build,gradle bootRun,gradlew build,./gradlew build,gradlew.bat clean,gradle test,gradle clean assemble, and the two that must not rewrite,gradle-profiler benchmarkandgradle.bat build), plus real execution ofrtk gradle build|bootRun|testandrtk gradlew buildthrough stand-in tools: identical on every one.rtk gradle bootRunkeeps itsspring-boot.tomlfiltering.cargo test --allmatches the baseline (3734 passed), clippy 0 warnings, fmt clean.Making TOML filters reachable from the default passthrough is the separate design question in #3904 and is deliberately not attempted here.
Refs #2708