Skip to content

fix(discover): count RTK_DISABLED bypasses behind any wrapper - #4457

Open
SunilRathod27 wants to merge 1 commit into
rtk-ai:developfrom
SunilRathod27:fix/discover-wrapper-bypass
Open

SunilRathod27 wants to merge 1 commit into
rtk-ai:developfrom
SunilRathod27:fix/discover-wrapper-bypass

Conversation

@SunilRathod27

@SunilRathod27 SunilRathod27 commented Oct 5, 2026 •

Copy link
Copy Markdown

Fixes #4278

Summary

  • strip_disabled_prefix_for_analytics gave up as soon as a word before RTK_DISABLED= was not sudo, env, an assignment, or a flag. So nice RTK_DISABLED=1 docker ps, timeout 30 RTK_DISABLED=1 docker ps, and command RTK_DISABLED=1 docker ps landed in TOP UNHANDLED under the wrapper, even though rtk rewrite on the same line prints the RTK_DISABLED warning.
  • The peel now walks coalesce_words (same shape as fix(discover): count expanded-value sudo RTK_DISABLED bypasses #4414, so the two should reconcile easily), finds the assignment anywhere in the first simple command, and hands the line minus the assignment to the existing judge_disabled_segment gate. The gate already knows the built-in wrappers and hooks.transparent_prefixes, so the peel keeps no wrapper list of its own.
  • One guard, because the gate only sees the line without the assignment: ssh host RTK_DISABLED=1 docker ps and docker run -e RTK_DISABLED=1 git status would otherwise count as bypasses, although the hook rewrites them as typed (rtk ssh host …). The peel asks the rewriter (built-in wrappers only, &[] config) whether the words before the assignment stay in place. If rtk lands in front of them, the assignment is an argument of a filtered command and the peel falls back to strip_disabled_prefix as before. User prefixes and excludes remain the gate's decision.

gain, strip_disabled_prefix, and ENV_PREFIX are untouched; #4277 is a separate change.

Test plan

New tests, both failing on develop:

  • registry.rs: test_strip_disabled_prefix_for_analytics_sees_through_any_wrapper (nice, nice -n5, nice -n 5, timeout 30, command, nice + timeout, RTK_DISABLED=$CI, xargs peel) and test_strip_disabled_prefix_for_analytics_keeps_a_supported_commands_argument (docker run -e, npx cross-env, ssh host, and a chained segment stay un-peeled).

  • mod.rs: end-to-end cases added to test_disabled_segment_is_judged_as_typed_without_the_bypass: built-in wrappers -> Bypass, user mywrap -> Bypass only when configured in transparent_prefixes, xargs -> Unbypassed.

  • cargo fmt --all && cargo clippy --all-targets && cargo test

  • Manual testing: rtk <command> output inspected

$ cargo fmt --all -- --check
(clean)

$ cargo clippy --all-targets
0 warnings

$ cargo test --bin rtk
test result: ok. 3854 passed; 0 failed; 8 ignored

$ cargo test discover:: --bin rtk
test result: ok. 645 passed; 0 failed

…rough

The analytics peel gave up as soon as a word before `RTK_DISABLED=` was
not `sudo`, `env`, an assignment or a flag, so `nice RTK_DISABLED=1
docker ps`, `timeout 30 RTK_DISABLED=1 …` and `command RTK_DISABLED=1 …`
were never counted even though the hook flags them. It now finds the
assignment anywhere in the first simple command and lets
`judge_disabled_segment` decide, since that gate already knows which
wrappers the hook rewrites through.

Instead of a wrapper list, the peel asks the rewriter whether the words
before the assignment stay in front once it is removed; if `rtk` lands
ahead of them (`ssh host RTK_DISABLED=1 docker ps`, `docker run -e
RTK_DISABLED=1 …`) the assignment is an argument of the filtered
command and the peel falls back as before.

Fixes rtk-ai#4278
@rtk-wshm-sync-bot rtk-wshm-sync-bot Bot added analytics bug Something isn't working discover labels Oct 5, 2026
@rtk-wshm-sync-bot

Copy link
Copy Markdown

wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟢 Risk low

Summary

Fixes strip_disabled_prefix_for_analytics so RTK_DISABLED bypasses are counted correctly even when wrapped by arbitrary commands like nice, timeout, or command, not just sudo/env/assignments/flags. The peel now locates the RTK_DISABLED= assignment anywhere in the first simple command via coalesce_words and defers to the existing judge_disabled_segment gate, with a guard that falls back to strip_disabled_prefix when the rewriter would place rtk in front of the wrapper words (e.g. ssh host or doc…

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #4278


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

@CLAassistant

CLAassistant commented Oct 5, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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

Labels

analytics bug Something isn't working discover

Projects

None yet

Development

Successfully merging this pull request may close these issues.

discover/gain: RTK_DISABLED= after a wrapper the hook rewrites through (nice, timeout, command) is never counted as a bypass

2 participants