Fix wily rank to reconstruct full project state at latest revision (#262)#268
Open
tonybaloney wants to merge 1 commit into
Open
Fix wily rank to reconstruct full project state at latest revision (#262)#268tonybaloney wants to merge 1 commit into
tonybaloney wants to merge 1 commit into
Conversation
) rank built its per-revision lookup from rows whose `revision` exactly matched the target revision. Because v2 storage is delta-based (a full seed revision plus only the files changed in each later revision), the latest revision only contains the file(s) touched in that commit, so `wily rank` on a real repository listed roughly one file by default. Reconstruct each file's value from the most recent row at or before the target revision's date, and rank file-level rows only (skipping directory/ root aggregates and function/class detail rows that previously appeared with identical values). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #268 +/- ##
==========================================
- Coverage 90.36% 90.00% -0.36%
==========================================
Files 20 20
Lines 1193 1201 +8
Branches 161 163 +2
==========================================
+ Hits 1078 1081 +3
- Misses 87 89 +2
- Partials 28 31 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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 #262.
Problem
wily rank(without--revision) ranks against the most recent revision. But wily v2 stores metrics as deltas — a full "seed" revision plus only the files that changed in each subsequent revision. The previous implementation built its lookup from rows whoserevisionexactly matched the target revision:So on any real repository, the latest revision contains only the file(s) changed in the last commit, and
wily ranklisted ~1 file by default. The no-path variant also surfaced directory/root aggregate rows that all shared an identical value.Before (microsoft/graphrag, default latest revision)
After
Fix
In
src/wily/commands/rank.py, reconstruct the project state at the target revision by taking, for each file path, the most recent row at or before the target revision's date — instead of exact-matchingrevision. Ranking is also restricted topath_type == "file"rows, so directory/root aggregates and function/class detail rows no longer pollute the table with duplicate values.Tests
Added
test_rank_latest_includes_unchanged_files, which builds a repo wheresrc/stable.pyexists only in the seed commit andsrc/churn.pyis modified in a later commit, then asserts both appear when ranking the latest revision. (The existinggitdirfixture has a single file that changes in every commit, so it never exercised this bug.)All
test/integration/test_rank.pytests pass (16 passed);ruff checkis clean.