Skip to content

fix(blast-radius): order the impact list by count then path so identical runs render identically - #223

Merged
JordanCoin merged 1 commit into
mainfrom
fix/blast-impact-order
Oct 11, 2026
Merged

JordanCoin merged 1 commit into
mainfrom
fix/blast-impact-order

Conversation

@JordanCoin

Copy link
Copy Markdown
Owner

Symptom

codemap blast-radius --ref HEAD~5 . on a 59-file gumroad diff gave three different texts for three runs (md5 ace30d851a, 6e117c8171, 3f63e35233). The header and counts were stable since #203; the ⚠ X is used by N other files footer was reordered among equal counts, and because the output budget trims the tail, SearchPopover.tsx and CustomersPage.tsx appeared in one run and not another. The JSON impact array had the same unstable order.

Cause

scanner.AnalyzeImpactFromAnalyses builds the list from the usageCounts map and sorted by UsedBy alone (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.go and 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 with tie not broken by path: c09.ts before c04.ts, passes after, identical across 8 runs.
  • gumroad, three runs with the fixed binary: one distinct md5.
  • go build ./... && go test ./... && gofmt -l . clean.

Refs #153

🤖 Generated with Claude Code

https://claude.ai/code/session_01NRaBgKRAZMX9hjbkkefA7T

…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
Copilot AI balanced review requested due to automatic review settings October 11, 2026 22:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@JordanCoin
JordanCoin merged commit 1fae668 into main Oct 11, 2026
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants