Skip to content

gradle, dotnet-build and uv-sync filters can never activate — and rtk verify reports them green because the test harness never exercises match_command #3402

Open

Description

@HetCreep

Three of the 63 TOML filters cannot fire. Their inline tests all pass, so nothing surfaces the problem — the test harness validates the transformation but never the matching.

Provenance: AI-assisted source audit, human-directed, at v0.44.2 (700bdde). All 63 filter files were read; the regex claims were verified by executing the patterns. No wrapped tool was run.

Why the tests cannot catch it

src/core/toml_filter.rs:761:

for test in tests {
    let actual = apply_filter(compiled, &test.input);

The harness feeds test.input straight into apply_filter. match_command is never evaluated. So a filter whose pattern can never match a real command still reports every test green, in rtk verify and in CI.

1. gradle.toml:3 — the pattern requires the literal text twice

match_command = "^(gradle|gradlew|\./)gradlew?\b"

The alternation consumes gradle/gradlew/./, and then gradlew? demands another gradle or gradlew. Verified by executing the pattern:

  • gradle build → no match
  • gradlew build → no match
  • ./gradlew build → matches

And even that last case does not reach the filter: src/main.rs:1306-1309 takes file_name() before lookup, which strips ./, and Commands::Gradlew (main.rs:814 → 2411) routes it to the Rust module first anyway.

Net: 35 lines of configuration and 3 always-green tests for a filter that cannot activate. The intended pattern is presumably ^(\./)?gradlew?\b.

2 & 3. dotnet-build.toml and uv-sync.toml are shadowed by clap subcommands

rtk dotnet build is handled by Commands::Dotnet (main.rs:282 → 1899-1900, dotnet_cmd::run_build), and rtk uv … by Commands::Uv (main.rs:780 → 2383). Clap routes both before run_fallback ever consults the TOML filters, so neither definition is reachable — 64 and 37 lines respectively, plus 5 green tests.

The guard that exists for exactly this is stale

src/core/toml_filter.rs:315-326 already warns about this situation:

// Shadow warning: if match_command matches a Rust-handled command, this filter
// will never activate (Clap routes before run_fallback). Warn the author.
for cmd in RUST_HANDLED_COMMANDS {
    if match_regex.is_match(cmd) { ... }
}

But RUST_HANDLED_COMMANDS (:250-300) has drifted from the clap enum. Comparing the two, these subcommands exist in Commands but are absent from the list:

dotnet, uv, gradlew, mvn, gt, sbt, oc, rg, jest, rake, rspec, rubocop, pest, ecs, pint, and the php* family.

That is why dotnet-build and uv-sync were not caught by the mechanism written to catch them.

Suggested directions (untested)

  • Fix the harness first — have the test runner check match_command against a sample command (either a new test.command field, or by asserting the pattern matches at least one plausible invocation). Without that, this class recurs silently.
  • Derive RUST_HANDLED_COMMANDS from the clap enum rather than maintaining it by hand, so it cannot drift again. If that is awkward, a test asserting every Commands variant name appears in the list would catch the drift.
  • Then decide per filter: fix gradle.toml's pattern, and delete dotnet-build.toml / uv-sync.toml (or keep them as documentation with a comment saying they are shadowed).

One more in the same family

src/filters/gcc.toml:3 is ^g(cc|\+\+)\b. \b cannot follow +, so g++ -o a main.cpp does not match (verified). The gcc half works; the g++ half is dead while gcc.toml:2 describes the filter as handling "gcc/g++". Harmless — it falls through to raw passthrough — but the description overstates what it does.

Activity

  1. added
    bug
    help wanted
    on Aug 4, 2026
  2. pszymkowiak commented on Aug 4, 2026

    @pszymkowiak
    Collaborator

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟡 Priority medium
    🎯 Confidence 90%

    Summary

    Three TOML filters (gradle, dotnet-build, uv-sync) can never match/activate because the test harness never exercises match_command and the shadow-warning guard's RUST_HANDLED_COMMANDS list has drifted from the clap enum; fix the harness to test matching, resync/derive the shadow list, and correct or remove the dead filters.

    📁 Relevant files
    • src/core/toml_filter.rs
    • src/filters/gradle.toml
    • src/filters/dotnet-build.toml
    • src/filters/uv-sync.toml
    • src/filters/gcc.toml
    • src/main.rs

    Triaged automatically by wshm · This is an automated analysis, not a human review.

  3. KuSh commented on Sep 24, 2026

    @KuSh
    Collaborator

    Re-verified this whole list against develop (005eb9c5) with stand-in tools, since the audit was done at v0.44.2. Everything here still holds, and I have two more in the same family.

    gradle.toml is about to be handled differently from the rest: #2709 deletes it rather than repairing its pattern. Widening it turned out to be actively harmful — gradle sorts before spring-boot in the name-ordered BTreeMap and first match wins, so any pattern that matches gradle bootRun takes that command away from spring-boot.toml and replaces a diagnosed startup failure with head-truncated INFO noise. So item 1 here is closed by removal, and the filter's own inline tests go with it.

    The other three are unchanged on current develop:

    $ rtk dotnet build      # stdout: clean build, "0 Warning(s) / 0 Error(s)"
    fail dotnet build: 1 projects, 0 errors, 0 warnings (00:00:02.34)   # Rust module, not "ok (build succeeded)"
    
    $ rtk uv sync
    Resolved 42 packages in 123ms
    Audited 42 packages in 0.05ms                                      # raw, not "ok (up to date)"
    
    $ rtk g++ -o main main.cpp
    raw 137 bytes -> rtk 137 bytes                                     # gcc.toml never matches g++
    

    Two more holes in the same class

    1. test_builtin_all_expected_filters_present guards only 41 of the filters. It documents itself as "the safeguard against accidentally deleting a filter file", but its expected array is a hand-maintained subset. Verified by mutation: delete src/filters/turbo.toml, bump test_builtin_filter_count and test_new_filter_discoverable_after_concat by one, and all four enumerating tests pass — the filter is silently gone. The unguarded names are basedpyright, biome, bundle-install, gcc, jira, jj, jq, just, mise, nx, ollama, oxlint, skopeo, spring-boot, ssh, stat, task, turbo, ty, xcodebuild, yadm.

    Worth noting that gcc and spring-boot are both on that list, so the two filters this issue cares about most are also the ones the safeguard cannot see. Deriving the list from src/filters/*.toml at build time would close it.

    2. build.rs:54's duplicate-filter-name detection is unreachable. Verified by adding a copy of make.toml: the build fails earlier, at build.rs:48, with TOML validation failed for combined filters: duplicate key makein tablefilters`` — the combined document's own parse rejects the duplicate key before parsed.get("filters") runs. Duplicates are still caught loudly, so this is a dead diagnostic rather than a hole, but the dedicated message never fires.

    On the harness

    The command field on [[tests.X]] proposed in #3424 is the right shape for this — it makes a dead pattern fail instead of passing transform-only tests, which is what would have caught all four of these at authoring time. Combined with completing RUST_HANDLED_COMMANDS from Cli::command(), that closes the class rather than the instances.

  4. HetCreep commented on Oct 14, 2026

    @HetCreep
    Author

    Re-checked on v1.0.0 (stable, 2026-10-13): the official release binary plus the v1.0.0 source. Provenance: AI-assisted check, human-directed. "ran" = executed against rtk 1.0.0 with a control; "read" = verified from source only.

    Fixed: item 1. gradle.toml was removed in 757188f8; rtk rewrite "gradle build" now goes to rtk gradlew build (ran). Thanks.

    Still live at v1.0.0 (read + ran):

    • dotnet-build.toml and uv-sync.toml are still shadowed: Commands::Dotnet (src/lib.rs:405) and Uv (:992) route first; RUST_HANDLED_COMMANDS (src/core/toml_filter.rs:266-318) still lacks dotnet/uv (and others), so rtk verify cannot say they are dead.
    • The test harness (toml_filter.rs:874) calls apply_filter(compiled, &test.input) and never evaluates match_command.
    • gcc.toml:3 pattern ^g(cc|\+\+)\b: the g++ half does not match g++ -o a main.cpp; rtk rewrite "g++ -o a main.cpp" exits 1 with no output, control gcc a.c -> rtk gcc a.c. rtk verify reports 151/151 pass.

    main.rs is now a stub, so the routing cites are in src/lib.rs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:ciarea:clibughelp wantedpriority:medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions