Skip to content

fix(discover): classify universal-passthrough git subcommands as supported - #1926

Closed
dparikh79 wants to merge 1 commit into
rtk-ai:developfrom
dparikh79:fix/1897-discover-git-passthrough
Closed

dparikh79 wants to merge 1 commit into
rtk-ai:developfrom
dparikh79:fix/1897-discover-git-passthrough

Conversation

@dparikh79

Copy link
Copy Markdown

Summary

rtk discover was flagging git checkout, git clone, git remote and other unhandled-by-name git subcommands in its TOP UNHANDLED COMMANDS -- open an issue? section, even though rtk git <anything> already works via the universal run_passthrough handler in src/cmds/git/git.rs. The report would prompt users (and AI assistants following RTK instructions) to file unnecessary "add git X support" issues, or worse, to conclude rtk git checkout does not work and to keep using bare git checkout without the proxy.

Root cause

The git rule in src/discover/rules.rs enumerates only the subcommands with dedicated filters:

pattern: r"^(?:git|yadm)\s+(?:-[Cc]\s+\S+\s+)*(status|log|diff|show|add|commit|push|pull|branch|fetch|stash|worktree)"

Anything else (checkout, clone, remote, fetch-pack, cat-file, ...) falls through classify_command to Classification::Unsupported, which populates the unsupported bucket that the report renders under TOP UNHANDLED COMMANDS.

Fix

Add passthrough_parent_classification to classify_command as a fallback before the existing Unsupported return. For commands whose parent has a run_passthrough handler (git, yadm), classify as Supported { rtk_status: Passthrough } so the report shows them under MISSED SAVINGS with status passthrough instead of TOP UNHANDLED. estimated_savings_pct: 0.0 keeps the savings totals honest (no filter-based compression on the passthrough path).

The fallback runs only after the existing rule-matching fails, so:

  • Known git subcommands (git status, git diff, ...) keep their dedicated-filter classification with status: Existing and the per-subcommand savings_pct (70%, 80%, etc).
  • Yadm continues to share git's rewrite path (already configured via rewrite_prefixes: ["git", "yadm"] on the existing rule).

Test plan

5 regression tests added to mod tests in src/discover/registry.rs:

  • test_classify_git_checkout_passthrough (the issue's example: git checkout -b my-branch)
  • test_classify_git_clone_passthrough
  • test_classify_git_remote_passthrough
  • test_classify_yadm_checkout_passthrough (yadm parity)
  • test_classify_git_status_still_uses_dedicated_filter (sentinel that the new fallback does not shadow the existing rule for known subcommands, since matches.last() picks the more specific later match)

All checks pass:

  • cargo test: 1875 passed, 0 failed, 6 ignored.
  • cargo fmt --check: clean.
  • cargo clippy --all-targets -- -D warnings: clean.

Scope

Git/yadm only, matching the issue. Other universal-proxy parents (cargo, pnpm, go, gh, glab, dotnet, pip) also have run_passthrough handlers; the same fix could extend to those once the maintainer signals the direction is right.

Fixes #1897.

…orted

`rtk discover` was flagging `git checkout`, `git clone`, `git remote`
and other unhandled-by-name git subcommands in its 'TOP UNHANDLED
COMMANDS -- open an issue?' section, even though `rtk git <anything>`
already works via the `run_passthrough` handler in `src/cmds/git/git.rs`.
This caused noise in the report and prompted users (and AI assistants
following RTK instructions) to file unnecessary 'add git X support'
issues, or worse, to conclude `rtk git checkout` doesn't work and keep
using bare `git checkout` without the proxy.

Root cause: the git rule in `src/discover/rules.rs` enumerates only the
subcommands with dedicated filters
(`status|log|diff|show|add|commit|push|pull|branch|fetch|stash|worktree`).
Anything else falls through `classify_command` to `Unsupported`, which
populates the 'TOP UNHANDLED' bucket.

Fix: add `passthrough_parent_classification` to `classify_command` as
a fallback before the `Unsupported` return. For commands whose parent
has a `run_passthrough` handler (git, yadm), classify as
`Supported { rtk_status: Passthrough }` so the report shows them under
'MISSED SAVINGS' with status 'passthrough' instead of 'TOP UNHANDLED'.
`estimated_savings_pct: 0.0` keeps the savings totals honest (no
filter-based compression on the passthrough path).

The fallback runs only after the existing rule-matching fails, so:
- Known git subcommands (`git status`, `git diff`, ...) keep their
  dedicated-filter classification with `status: Existing` and the
  per-subcommand savings_pct (70%, 80%, etc).
- Yadm continues to share git's rewrite path (already configured via
  `rewrite_prefixes: ["git", "yadm"]` on the existing rule).

5 regression tests added:
- `test_classify_git_checkout_passthrough` (the issue's example)
- `test_classify_git_clone_passthrough`
- `test_classify_git_remote_passthrough`
- `test_classify_yadm_checkout_passthrough` (yadm parity)
- `test_classify_git_status_still_uses_dedicated_filter` (sentinel
  that the new fallback doesn't shadow the existing rule for known
  subcommands)

Scope: git/yadm only, matching the issue. Other universal-proxy parents
(`cargo`, `pnpm`, `go`, `gh`, `glab`, `dotnet`, `pip`) also have
`run_passthrough` handlers; the same fix could extend to those once
the maintainer signals the direction is right.

All checks pass: cargo test 1875/1875, cargo fmt --check clean,
cargo clippy --all-targets -- -D warnings clean.

Fixes rtk-ai#1897.
@CLAassistant

CLAassistant commented May 16, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@rtk-release-bot

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale due to 90 days of inactivity. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. Your contribution is very much appreciated — we're sorry we haven't been able to review it yet.

@rtk-release-bot rtk-release-bot Bot added the stale label Sep 3, 2026
@rtk-release-bot

Copy link
Copy Markdown
Contributor

Closing this pull request after a prolonged period of inactivity. If this is still relevant, please ask for it to be reopened. Thank you!

@rtk-release-bot rtk-release-bot Bot closed this Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rtk discover: false positives for git subcommands (checkout, clone, remote)

2 participants