Repository navigation
Conversation
`rtk gain`'s overuse warning counted every history line whose env prefix contained `RTK_DISABLED=`, while `rtk discover` splits the chain and only counts a segment that is supported and that the hook would have rewritten absent the prefix. So `RTK_DISABLED=1 xargs -n1 git show` inflated gain's warning, and `git status && RTK_DISABLED=1 git diff` was missed by it. Move the per-segment decision into one shared gate in discover (`classify_bypass`, wrapped by `line_has_counted_bypass` for whole lines) and use it from both. `CoverageContext::load_without_hook_log` builds the context gain needs; gain loads it lazily, only once a line contains `RTK_DISABLED=`. Drop the now-unused `cmd_has_rtk_disabled_prefix`. Fixes rtk-ai#4277
📊 Automated PR Analysis
SummaryFixes a discrepancy where Review Checklist
Linked issues: #4277 Analyzed automatically by wshm · This is an automated analysis, not a human review. |
Resolve conflicts with rtk-ai#3808, which reworked discover's RTK_DISABLED= handling (wrapper-aware `strip_disabled_prefix_for_analytics` and `judge_disabled_segment`). Keep develop's per-segment logic as the one gate and route `line_has_counted_bypass` (gain's count) through it, replacing this branch's own `classify_bypass`. Drop `cmd_has_rtk_disabled_prefix` again: gain was its only caller. Its rtk-ai#3808 regression cases move to `line_has_counted_bypass` tests.
Resolve conflicts: keep line_has_counted_bypass with develop's rtk proxy -> rtk bypass doc rename, and accept develop's removal of AWARENESS_CONFIG.md (this branch only fixed one reference in it).
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.
fix(gain): count RTK_DISABLED bypasses with discover's gate
Fixes #4277
Problem
rtk gainandrtk discoverdisagreed on what counts as anRTK_DISABLED=bypass:check_rtk_disabled_bypass) checked each whole, unsplit history line and counted it whenever its leading env prefix containedRTK_DISABLED=.would_be_covered_without_bypass).So gain over-counted, for example
RTK_DISABLED=1 xargs -n1 git show, which the hook never rewrites, and under-counted bypasses in later segments, for examplegit status && RTK_DISABLED=1 git diff.Change
src/discover/mod.rsclassify_bypassreturningNotBypassed | Counted | Uncovered | Irrelevant. Discover's loop now uses it (same behaviour as before).line_has_counted_bypass(raw_cmd, ctx)splits the chain and returns true if any segment isCounted.CoverageContext::load_without_hook_log()loads hook-installed status, config exclusions and transparent prefixes, and permission rules.discover::runuses it and adds its measured hook log on top. The counterfactual never reads that log.src/analytics/gain.rs: counts a line only vialine_has_counted_bypass. A cheapcontains("RTK_DISABLED=")check runs first, and the context is built lazily on the first matching line, so lines without the prefix cost nothing extra.src/discover/registry.rs: removed the now-unusedcmd_has_rtk_disabled_prefix. Its test now coversprefix_contains_rtk_disabled+strip_disabled_prefix. Fixed a stale reference to it inAWARENESS_CONFIG.md.The runtime #508 hint emitted by the hook is unchanged and is left for a follow-up.
Tests
New regression tests in
discover::tests(written first; 3 failed against the old whole-line logic):RTK_DISABLED=1 xargs -n1 git showis not countedRTK_DISABLED=1 git statusis countedgit status && RTK_DISABLED=1 git diffis countedcargo fmt --check,cargo clippy --all-targets(clean) and the fullcargo testsuite pass.