gabriel / muse public
feat BREAKING graph task/walk-dag-phase1 #2 / 3
AI Agent gabriel · 125 days ago · May 9, 2026 · Diff

feat(graph): Phase 2 — migrate 7 inline BFS/DFS sites to iter_ancestors/walk_dag

- bisect._ancestors: replace list+deque DFS with iter_ancestors (BFS), reversed for oldest-first - bisect._reachable_from_good: replace inline DFS with ancestor_ids - branch._commit_ancestors: replace inline DFS with ancestor_ids - pack.build_mpack: replace 15-line BFS block with iter_ancestors(exclude=have_set) - pack.collect_object_ids: replace 15-line BFS block with iter_ancestors(exclude=have_set) - _query.walk_commits_bfs: replace inline BFS with iter_ancestors(prune=stop_at_commit_id) - midi/_query.walk_commits_for_track: replace while-loop with iter_ancestors(first_parent_only=True) - iter_ancestors gains prune= parameter, forwarded to walk_dag

Add tests/test_phase2_bfs_migration.py: 27 tests (7 structural + 20 behavioral) covering all 7 migration sites. 86/86 passing.

sha256:6f56135116d5b7b40455fa039c5ba2967a8f07832f3ffe7204585dc598755c89 sha
+56 ~8 symbols
sha256:47a29c2b7eb5eb892cf04f64ec2a56a1d505b6ad83b545d5674899babffdd1df snapshot
+56
symbols added
~8
symbols modified
0
dead code introduced
Semantic Changes 64 symbols
~ tests/test_phase2_bfs_migration.py .py 56 symbols added
+ TestBisectAncestors class class TestBisectAncestors L90–132
+ _fn method method _fn L91–93
+ test_diamond_no_duplicates method method test_diamond_no_duplicates L124–132
+ test_linear_chain_all_ancestors_returned method method test_linear_chain_all_ancestors_returned L102–108
+ test_returns_oldest_first method method test_returns_oldest_first L110–117
+ test_single_commit method method test_single_commit L119–122
+ test_structural_no_inline_bfs method method test_structural_no_inline_bfs L95–100
+ TestBisectReachableFromGood class class TestBisectReachableFromGood L139–178
+ _fn method method _fn L140–142
+ test_empty_good_ids method method test_empty_good_ids L175–178
+ test_multi_source_union method method test_multi_source_union L159–165
+ test_shared_ancestor_once method method test_shared_ancestor_once L167–173
+ test_single_good_includes_ancestors method method test_single_good_includes_ancestors L151–157
+ test_structural_no_inline_bfs method method test_structural_no_inline_bfs L144–149
+ TestBranchCommitAncestors class class TestBranchCommitAncestors L185–218
+ _fn method method _fn L186–188
+ test_diamond_no_duplicates method method test_diamond_no_duplicates L206–213
+ test_returns_set_including_self method method test_returns_set_including_self L197–204
+ test_single_commit method method test_single_commit L215–218
+ test_structural_no_inline_bfs method method test_structural_no_inline_bfs L190–195
+ TestPackBuildMpackBFS class class TestPackBuildMpackBFS L225–283
+ test_have_set_excludes_old_commits method method test_have_set_excludes_old_commits L234–283
+ test_structural_no_inline_bfs method method test_structural_no_inline_bfs L226–232
+ TestPackCollectObjectIds class class TestPackCollectObjectIds L290–338
+ test_have_excludes_known_objects method method test_have_excludes_known_objects L299–338
+ test_structural_no_inline_bfs method method test_structural_no_inline_bfs L291–297
+ TestWalkCommitsBfs class class TestWalkCommitsBfs L345–395
+ _fn method method _fn L346–348
+ test_max_commits_returns_truncated_true method method test_max_commits_returns_truncated_true L377–385
+ test_merge_commit_visits_both_parents method method test_merge_commit_visits_both_parents L387–395
+ test_returns_all_commits_no_stop method method test_returns_all_commits_no_stop L357–364
+ test_stop_at_commit_id_excludes_boundary method method test_stop_at_commit_id_excludes_boundary L366–375
+ test_structural_no_inline_bfs method method test_structural_no_inline_bfs L350–355
+ TestWalkCommitsForTrack class class TestWalkCommitsForTrack L402–445
+ _fn method method _fn L403–405
+ test_first_parent_only_skips_second_parent method method test_first_parent_only_skips_second_parent L424–436
+ test_linear_chain_all_returned method method test_linear_chain_all_returned L415–422
+ test_max_commits_cap method method test_max_commits_cap L438–445
+ test_structural_no_inline_while method method test_structural_no_inline_while L407–413
+ _BASE_DT variable variable _BASE_DT L30–30
+ _make_repo function function _make_repo L37–43
+ _no_inline_bfs function function _no_inline_bfs L81–83
+ _write_commit function function _write_commit L46–78
+ CommitRecord import import CommitRecord L26–26
+ SnapshotRecord import import SnapshotRecord L26–26
+ annotations import import annotations L17–17
+ compute_commit_id import import compute_commit_id L27–27
+ compute_snapshot_id import import compute_snapshot_id L27–27
+ datetime import import datetime L19–19
+ inspect import import inspect L20–20
+ json import import json L21–21
+ muse_dir import import muse_dir L28–28
+ pathlib import import pathlib L22–22
+ pytest import import pytest L24–24
+ write_commit import import write_commit L26–26
+ write_snapshot import import write_snapshot L26–26
~ muse/core/bisect.py .py 2 symbols modified
~ muse/core/graph.py .py 1 symbol modified
~ muse/core/pack.py .py 2 symbols modified
~ muse/plugins/code/_query.py .py 1 symbol modified

0 comments

No comments yet. Be the first to start the discussion.

To add a comment, use the Muse CLI: muse hub commit comment sha256:6f56135116d5b7b40455fa039c5ba2967a8f07832f3ffe7204585dc598755c89 --body "your comment"