Skip to content

gain: RTK_DISABLED bypass warning counts commands the hook would not have rewritten anyway #4277

Open

Description

@KuSh

Summary

rtk gain's bypass warning — N commands (P%) used RTK_DISABLED=1 unnecessarily — run \rtk discover` for details— counts every line with a leadingRTK_DISABLED=assignment, whether or not the hook would have rewritten the command without it.rtk discover asks that question (would_be_covered_without_bypass, added in the #3206 review to avoid exactly this false advice); gain` does not.

$ rtk rewrite "xargs -n1 git show"                   → (nothing, exit 1: not rewritten)
$ rtk rewrite "RTK_DISABLED=1 xargs -n1 git show"    → [rtk] RTK_DISABLED=1 detected — …

check_rtk_disabled_bypass (src/analytics/gain.rs) calls cmd_has_rtk_disabled_prefix on whole, unsplit history lines and counts the match. For RTK_DISABLED=1 xargs -n1 git show it reports a bypass although removing the assignment recovers nothing, and the percentage it prints can be higher than anything rtk discover then shows "for details".

Pre-existing on develop (c75f1590).

Direction

Route gain's count through the same gate discover uses (split the chain, ask would_be_covered_without_bypass with the line minus the RTK_DISABLED= assignment), or compute the bypass count once and share it between both reports so they cannot disagree. The runtime #508 hint has the same shape (it fires for the xargs line above); whether it should defer to the same check is worth deciding alongside.

Related: #3756, #3808.

Activity

  1. rtk-wshm-sync-bot commented on Sep 26, 2026

    @rtk-wshm-sync-bot

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟡 Priority medium
    🎯 Confidence 90%

    Summary

    gain's RTK_DISABLED bypass count doesn't check would_be_covered_without_bypass like discover does, so it overcounts and can disagree with discover's percentage.

    📁 Relevant files
    • src/analytics/gain.rs

    Suggested Actions

    1. Route check_rtk_disabled_bypass through the same would_be_covered_without_bypass gate as discover (src/analytics/gain.r…
    2. Consider computing the bypass count once and sharing it between gain and discover to prevent future drift
    3. Decide whether the runtime warn: detect and report RTK_DISABLED=1 overuse in sessions #508 hint should defer to the same check, per the issue's Direction section
    4. Coordinate with related issues discover/gain: RTK_DISABLED= after a wrapper the hook rewrites through (nice, timeout, command) is never counted as a bypass #4278, discover: sudo RTK_DISABLED=1 … is not counted as a bypass when sudo is a transparent prefix #3756, fix(discover): count sudo RTK_DISABLED=1 commands as bypass in analytics #3808 for a unified fix

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

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:clibugpriority:medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions