fix(canonicalization): predicate-based call lookup + skip double-canon on auto-resolve

Two findings from Greptile review on PR #302:

1. tests/test_cli_v3.py:302 - The test asserted run_mock.call_args_list[0]
   was the main runner's invocation, but fanout.run_competitor_fanout
   submits main + competitors to a ThreadPoolExecutor and iterates with
   as_completed. With zero-latency mocks, thread scheduling determines
   which pipeline.run call lands first, so the competitor's call could
   take index [0] and flake CI. Replace [0] indexing with a predicate
   match on the canonicalized github_repos kwargs.

2. skills/last30days/scripts/last30days.py:662 - When auto_resolve returns
   github_repos, it has already run canonicalize_github_repos(cap=5) and
   ranked by relevance. The downstream block then re-canonicalized with
   cap=None, which can re-sort by topic-slug match and clobber the
   auto_resolve relevance order. Guard the second canonicalization with
   a repos_from_auto_resolve flag so it only fires for user-supplied
   --github-repo input.
This commit is contained in:
Trevin Chow
2026-05-17 00:51:21 -07:00
parent d0b990e211
commit 8ccd778366
2 changed files with 22 additions and 7 deletions
+13 -6
View File
@@ -289,12 +289,19 @@ class CliV3Tests(unittest.TestCase):
with redirect_stdout(stdout), redirect_stderr(stderr):
rc = cli.main()
self.assertEqual(0, rc)
# In vs-mode the main_runner is the first pipeline.run call; sub-runs
# for competitor entities follow with their own per-entity github_repos.
kwargs = run_mock.call_args_list[0].kwargs
self.assertEqual(
["openai/codex", "anthropics/claude-code"],
kwargs["github_repos"],
# In vs-mode main + competitors run in parallel via ThreadPoolExecutor,
# so the order of pipeline.run invocations is non-deterministic. Find
# the main runner's call by predicate on the canonicalized github_repos
# rather than by index.
expected_repos = ["openai/codex", "anthropics/claude-code"]
main_call = next(
(c for c in run_mock.call_args_list if c.kwargs.get("github_repos") == expected_repos),
None,
)
self.assertIsNotNone(
main_call,
f"No pipeline.run call had github_repos={expected_repos}; "
f"saw {[c.kwargs.get('github_repos') for c in run_mock.call_args_list]}",
)
self.assertIn("[GitHub] Canonicalized repos:", stderr.getvalue())