Skip to content

new: Match package import paths in Go relationship inference - #1

Draft
jonpoole-fluidstack wants to merge 20 commits into
masterfrom
jon/go-single-module-import-inference
Draft

new: Match package import paths in Go relationship inference#1
jonpoole-fluidstack wants to merge 20 commits into
masterfrom
jon/go-single-module-import-inference

Conversation

@jonpoole-fluidstack

Copy link
Copy Markdown
Owner

Moon's Go relationship inference resolves go list -deps output by module path only, so a repo where all projects share one go.mod (like systems) can never infer a project→project edge — every internal package collapses to the root module path (upstream context: moonrepo/moon#2360).

This adds a fallback: each project gets a package prefix — its own go.mod module path, or the nearest ancestor go.mod's module path joined with the project's relative directory — and go list entries that module matching can't resolve are matched by longest import-path prefix instead. go list now emits {{.Module.Path}}|{{.ImportPath}} pairs so both matching modes share one invocation.

before after
multi-module workspace (go.work) edges via module … unchanged (module match takes precedence)
single-module repo no edges edges via package …, e.g. a → b (production)

Non-obvious decisions:

  • Based on the go_toolchain-v1.4.4 tag, not master — master needs proto ≥0.60 / moon 2.5 APIs; this branch builds and loads under moon 2.4.5 for local verification against a real workspace.
  • Import-path edges use the moon project id directly (single-module projects have no alias to resolve through).
  • Edges are deduped per target project, module match first — so existing multi-module behavior and via strings are byte-identical (all 29 pre-existing tests pass unchanged; +1 new single-module test).

Verified end-to-end on a demo single-module workspace: moon project a now reports Depends on: b (production), and touching libs/b marks a affected in moon query projects --affected.

🤖 Generated with Claude Code

@jonpoole-fluidstack
jonpoole-fluidstack force-pushed the jon/go-single-module-import-inference branch from a8b7eb0 to 39cc84f Compare August 12, 2026 09:05
milesj and others added 14 commits August 12, 2026 12:05
go list -deps ./... enumerates every package under the scanned directory,
including packages belonging to projects nested inside it. Those showed up
as inferred dependencies from the parent to each nested child, which forms
a cycle whenever a child declares dependsOn on its parent (verified against
a real workspace with nested projects). Skip anything under the project's
own import path when resolving edges.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@jonpoole-fluidstack
jonpoole-fluidstack force-pushed the jon/go-single-module-import-inference branch from 24c24ba to 84921b1 Compare August 13, 2026 16:34
jonpoole-fluidstack and others added 5 commits August 14, 2026 11:26
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…own file, project graph in tier2

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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