From 517fd313947386cc008cfca293ba0d730cb473bf Mon Sep 17 00:00:00 2001 From: Pablo Date: Sun, 10 May 2026 23:16:23 -0600 Subject: [PATCH] fix: sort deps deterministically to prevent worst case scenario orders that could increase runtime drastically --- main.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index be49512..45df17c 100644 --- a/main.go +++ b/main.go @@ -159,7 +159,11 @@ func (s *state) sawMod(path string) { func (s *state) transitiveReduction() { noPath := make(map[string]map[string]struct{}) // [path][path] - for m, deps := range s.deps { + + // Iterate modules in a stable order + mods := slices.Sorted(maps.Keys(s.deps)) + for _, m := range mods { + deps := s.deps[m] s.deps[m] = slices.DeleteFunc(deps, func(d string) bool { // BFS for indirect paths to d, tracking nodes we touch along the way var touched []string