Repository navigation
fix(blast-radius): order the impact list by count then path so identical runs render identically - #223
Merged
Conversation
…cal runs render identically AnalyzeImpactFromAnalyses built the impact list from a map and sorted by usage count alone, so changed files with equal counts came out in map order. On gumroad (`--ref HEAD~5`, 21 impact entries, many ties) three consecutive runs produced three different texts: the footer lines were reordered and the output budget then kept a different subset each time, so the shown set changed, not only its sequence. JSON carried the same unstable order. One sort before the basename mapping: usage count descending, then full path ascending, so same-named files in different directories still order the same. Three runs on gumroad now hash identically. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NRaBgKRAZMX9hjbkkefA7T
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.
Symptom
codemap blast-radius --ref HEAD~5 .on a 59-file gumroad diff gave three different texts for three runs (md5ace30d851a,6e117c8171,3f63e35233). The header and counts were stable since #203; the⚠ X is used by N other filesfooter was reordered among equal counts, and because the output budget trims the tail,SearchPopover.tsxandCustomersPage.tsxappeared in one run and not another. The JSONimpactarray had the same unstable order.Cause
scanner.AnalyzeImpactFromAnalysesbuilds the list from theusageCountsmap and sorted byUsedByalone (sort.Slice, unstable), so ties stayed in map iteration order.Fix
One sort at the single producer, before the basename mapping: usage count descending, then full path ascending. The tie-break is the full path rather than the rendered basename so same-named files in different directories order the same.
render/tree.goand the JSON encoder read the same slice, so both are fixed by the one sort; nothing was added to the renderer.Proof
TestAnalyzeImpactOrderIsDeterministicAcrossTies(scanner/impact_order_test.go): 12 changed files all tied at 2 importers plus one leader; fails on main withtie not broken by path: c09.ts before c04.ts, passes after, identical across 8 runs.go build ./... && go test ./... && gofmt -l .clean.Refs #153
🤖 Generated with Claude Code
https://claude.ai/code/session_01NRaBgKRAZMX9hjbkkefA7T