Skip to content

fix(filters): repair never-activating filters and make the test harness check match_command - #3424

Open
RawNuke wants to merge 4 commits into
rtk-ai:developfrom
RawNuke:fix/dead-toml-filters-and-test-harness
Open

RawNuke wants to merge 4 commits into
rtk-ai:developfrom
RawNuke:fix/dead-toml-filters-and-test-harness

Conversation

@RawNuke

@RawNuke RawNuke commented Aug 4, 2026

Copy link
Copy Markdown

Closes #3402

What was wrong

Three TOML filters could never fire, and the test harness validated only the transform (apply_filter) — never match_command — so rtk verify and CI reported them green.

  1. gradle.toml: ^(gradle|gradlew|\./)gradlew?\b demanded the literal text twice (gradle build and gradlew build never matched; only ./gradlew did, which file_name() strips and which clap routes to the Rust Gradlew module before fallback anyway).
  2. gcc.toml: ^g(cc|\+\+)\b could never match g++ — there is no word boundary after +.
  3. dotnet-build.toml / uv-sync.toml: shadowed by clap (Commands::Dotnet, Commands::Uv route before run_fallback consults filters).

The fix

  • gradle.toml: ^gradle\b — the half that actually reaches the TOML fallback (gradlew is clap-routed; verified with RTK_TOML_DEBUG=1: rtk gradle build matches the filter, rtk gradlew build never reaches it).
  • gcc.toml: ^(gcc|g\+\+)(\s|$) — gcc -c main.c and g++ -o main main.cpp both verified to match.
  • dotnet-build.toml / uv-sync.toml: deleted — they could never activate; their inline tests were always-green noise.

The harness now checks activation

[[tests.X]] accepts an optional command field. When present, the harness asserts the filter's match_command actually matches that command; a dead pattern fails instead of passing transform-only tests. The gradle and gcc tests carry activation commands, so this class can't recur silently.

The drift guard

RUST_HANDLED_COMMANDS had drifted from the clap enum — that is why the existing shadow warning never caught dotnet-build and uv-sync. It is now completed (dotnet, uv, gradlew, mvn, gt, sbt, oc, rg, jest, rake, rspec, rubocop, pest, ecs, pint, php, phpunit, phpstan, paratest, cc-economics, session, telemetry, learn, run, hook, hook-audit, untrust, glab), and a new test derives every clap subcommand name from Cli::command() and asserts each is reserved — it flagged telemetry and untrust during development, and will flag any future variant the moment it is added.

Verification

  • rtk verify: 150/150 tests pass.
  • cargo test: 2571 pass, 0 fail.
  • cargo clippy --all-targets: clean.
  • Manual: gradle build, gcc -c main.c, g++ -o main main.cpp all activate their filters; no spurious shadow warning.

RawNuke added 4 commits August 5, 2026 00:14
yadm manages a separate dotfiles repository whose work-tree is HOME.
The git rewrite rule enumerated yadm in its pattern and rewrite
prefixes, so yadm commit/push/checkout/add were rewritten to 'rtk git'
and acted on whatever project the shell was standing in. Remove yadm
from the rule; the yadm filter now routes yadm to the yadm binary as
'rtk yadm <subcommand>', matching the already-correct 'yadm list' path.

run_add also injected '.' when git add had no pathspec, turning real
git's deliberate no-op into a whole-worktree stage. A bare 'rtk git add'
now passes no pathspec, so nothing gets staged implicitly.

Closes rtk-ai#3408
The uninstall dispatcher routed Hermes, Droid, Cursor and Pi explicitly
and sent everything else to the Claude uninstaller. Windsurf, Cline,
Kilocode, Antigravity and Kimi fell into that else arm with both the
cursor and pi flags false, which is exactly the Claude path: the
uninstall deleted ~/.claude/RTK.md, rewrote ~/.claude/CLAUDE.md and
stripped the hook from ~/.claude/settings.json while removing nothing
for the named agent (issue rtk-ai#3404).

Replace the if/else chain with an explicit match on AgentTarget. The
five unwired agents now return 'uninstall is not supported for
--agent <name>' instead of silently uninstalling a different agent, and
the compiler flags the next variant someone adds to the enum.

Tests cover Hermes, Cursor, Pi routing, the Claude default, and
fail-closed errors for all five unwired agents without touching the
standard uninstaller.

Closes rtk-ai#3404
…ss check match_command

Three of the TOML filters could never fire, and the test harness only
exercised the transform, never match_command, so they reported green in
rtk verify and CI (issue rtk-ai#3402).

- gradle.toml: pattern ^(gradle|gradlew|\./)gradlew?\b demanded the
  literal text twice; no real invocation matched. The gradlew half is
  routed to the Rust Gradlew module by clap before fallback, so the
  filter now matches ^gradle\b (the half that actually reaches it).
- gcc.toml: ^g(cc|\+\+)\b could never match g++ (no word boundary
  after +). Now ^(gcc|g\+\+)(\s|$).
- dotnet-build.toml and uv-sync.toml were shadowed by clap subcommands
  (Commands::Dotnet, Commands::Uv route before run_fallback) and could
  never activate. Deleted, per the issue's suggested direction.

The harness now supports an optional command field on [[tests.X]]: when
present it asserts the filter's match_command actually matches that
command, so a dead pattern fails instead of passing on transform-only
tests. gradle/gcc tests carry activation commands.

RUST_HANDLED_COMMANDS had drifted from the clap enum (that is why the
shadow warning never caught dotnet-build and uv-sync). It is now
completed, and a new test derives every clap subcommand name from
Cli::command() and asserts each one is reserved, so a new Commands
variant is flagged the moment it is added.

Closes rtk-ai#3402
@CLAassistant

CLAassistant commented Aug 4, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@KuSh KuSh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I re-verified this PR's claims against current develop (005eb9c5) with stand-in tools, and the three filter findings all still hold:

$ rtk g++ -o main main.cpp
raw 137 bytes -> rtk 137 bytes          # gcc.toml never matches g++; \b cannot follow +

$ 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)"

The g++ half of gcc.toml is the one I'd have missed reading the pattern quickly, and the Cli::command() drift guard is the part of this PR I value most — a stale RUST_HANDLED_COMMANDS is exactly why dotnet-build and uv-sync were never warned about, and deriving it from the enum closes that for good. The optional command field on [[tests.X]] is the other one: it turns "a dead pattern passes its transform tests" into a failing test, which is the class rather than the instances.

Where I'd ask you to narrow, so the verified parts can land without waiting on the rest:

1. Drop the gradle.toml hunk. #2709 deletes that file instead of repairing it, which will give you a modify/delete conflict here. There is also a reason not to keep it alive: filters are ordered by filter name (BTreeMap<String, TomlFilterDef>) and first match wins, and gradle sorts before spring-boot. So any pattern that matches gradle bootRun takes that command away from spring-boot.toml. On #2709's earlier ^(\./)?(gradlew?)\b head I measured that as 240 bytes containing the ERROR … Application run failed and BUILD FAILED lines becoming 6779 bytes containing neither — the head cut from max_lines = 50 fills up with INFO first. ^gradle\b matches gradle bootRun too, so I expect the same outcome, though I have not run it against this head. ^gradle\b also matches gradle-profiler benchmark (\b sits happily before -), which pulls an unrelated tool into that same 50-line head cut.

2. The counts then become 60 and 61. This PR currently sets 61/62 (63 − 2, keeping gradle). With #2709 in, src/filters/ starts at 62, so removing dotnet-build and uv-sync leaves 60, and the concat test 61.

3. Consider splitting out the two fixes that aren't in the title. append_add_pathspecs (bare git add staying a no-op, #3408) and dropping yadm from the git rewrite rule both look like real bugs to me — the yadm one especially, since rewriting yadm status to rtk git acts on the wrong repository. They're independent of the filter work and would be quicker to review and land on their own than bundled here.

That leaves this PR as gcc.toml + the two deletions + the harness command field + the drift guard, which is a tight, well-evidenced change. It'll need a rebase either way — it currently shows as conflicting.

Happy to do the rebase and the count arithmetic as a fixup on your branch if that's easier than redoing it yourself; equally happy to leave it with you. I've added the two extra holes I found in the same class to #3402, including the fact that test_builtin_all_expected_filters_present cannot see either gcc or spring-boot.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants