gabriel / muse public
fix fix/206-shard-import-edge-resolution #1 / 1
AI Agent gabriel · 4 hours ago · Oct 22, 2026 · Diff

fix: muse coord shard never resolved 'from X import Y' import edges (musehub#206)

_build_import_edges() computed: imported = rec[qualified_name].split(.)[-1].replace(import::, )

qualified_name for an import symbol is ::-separated (e.g. import::auth::login for 'from auth import login'), never dot-separated. Splitting a string with zero . characters on . is a no-op, so [-1] returns the whole string unchanged; the fixed-prefix .replace() then only strips import::, leaving auth::login -- which can never match a bare file stem key like auth in stem_to_file. Every 'from X import Y' statement -- the dominant Python import style -- failed to resolve to a cross-file edge. Only bare 'import x' happened to work, since in that one case the leftover after .replace() really was just the stem.

Confirmed live: a real 4-file codebase (app.py -> auth.py -> db.py, app.py -> billing.py -> db.py, all via from-X-import-Y) produced zero detected edges and cross_shard_edges: 0 regardless of partition -- muse coord shard believed the codebase had no coupling when it demonstrably does.

Fixed by splitting on :: and taking the module segment (index 1), then taking its final .-segment to resolve dotted submodule imports too (e.g. import::billing.utils::charge -> 'billing.utils' -> 'utils', matching billing/utils.py's stem) -- the ticket's suggested one-line fix alone would have missed this dotted-submodule case.

sha256:61123637e12b64a25a38cffb05df8d7932325e379b4c17feb5c0096b69d16066 sha
+3 ~2 symbols
2 changed · 1261 in snapshot files
sha256:b811a180774b06877fb25e86c76ef9ccbf3fa0954fe9f6b88839969e479854f3 snapshot
+3
symbols added
~2
symbols modified
2
files changed
1261
files in snapshot
0
dead code introduced
Semantic Changes 5 symbols
~ tests/test_cmd_shard.py .py 3 symbols added, 1 symbol modified
+ test_bare_import_still_resolves method method test_bare_import_still_resolves L192–209
+ test_from_dotted_submodule_import_edge_is_resolved method method test_from_dotted_submodule_import_edge_is_resolved L171–190
+ test_from_x_import_y_edge_is_resolved method method test_from_x_import_y_edge_is_resolved L151–169
Files Changed
~2
1261 in snapshot
← Older Oldest on fix/206-shard-import-edge-resolution
All commits
Newer → Latest on fix/206-shard-import-edge-resolution

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:61123637e12b64a25a38cffb05df8d7932325e379b4c17feb5c0096b69d16066 --body "your comment"