Repository navigation
fix(discover): count RTK_DISABLED bypasses behind any wrapper - #4457
Open
SunilRathod27 wants to merge 1 commit into
Open
SunilRathod27 wants to merge 1 commit into
SunilRathod27 wants to merge 1 commit into
Conversation
…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
📊 Automated PR Analysis
SummaryFixes 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
Linked issues: #4278 Analyzed automatically by wshm · This is an automated analysis, not a human review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4278
Summary
strip_disabled_prefix_for_analyticsgave up as soon as a word beforeRTK_DISABLED=was notsudo,env, an assignment, or a flag. Sonice RTK_DISABLED=1 docker ps,timeout 30 RTK_DISABLED=1 docker ps, andcommand RTK_DISABLED=1 docker pslanded in TOP UNHANDLED under the wrapper, even thoughrtk rewriteon the same line prints the RTK_DISABLED warning.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 existingjudge_disabled_segmentgate. The gate already knows the built-in wrappers andhooks.transparent_prefixes, so the peel keeps no wrapper list of its own.ssh host RTK_DISABLED=1 docker psanddocker run -e RTK_DISABLED=1 git statuswould 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. Ifrtklands in front of them, the assignment is an argument of a filtered command and the peel falls back tostrip_disabled_prefixas before. User prefixes and excludes remain the gate's decision.gain,strip_disabled_prefix, andENV_PREFIXare 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,xargspeel) andtest_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 totest_disabled_segment_is_judged_as_typed_without_the_bypass: built-in wrappers ->Bypass, usermywrap->Bypassonly when configured intransparent_prefixes,xargs->Unbypassed.cargo fmt --all && cargo clippy --all-targets && cargo testManual testing:
rtk <command>output inspected