Skip to content

fix/issues-68-71: Apply go.mod replace directives, and keep provides_imports whole under -t - #85

Merged
rahlk merged 1 commit into
mainfrom
fix/issues-68-71-dependencies
Nov 30, 2026
Merged

rahlk merged 1 commit into
mainfrom
fix/issues-68-71-dependencies

Conversation

@rahlk

@rahlk rahlk commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Fixes #68. Fixes #71.

Dependencies now follow go.mod replace directives, and a -t run gives the same provides_imports as a full run.

Motivation and Context

  • Dependencies ignore go.mod replace directives #68: a replace directive makes the build use another module, another version or a local directory instead of the required one. go.sum records the replacement. The lock lookup used the required version, so a replaced dependency had no locked_version, no lockfile prov and no LOCKS edge. The dependency now follows the replace, by Go's rule: a replace of the required version wins over a version-less one.
    • replace x => y v1.2.0: the dependency keeps name x and its spec, so the code's imports of x still match it. It gets replaced_by y@v1.2.0 and takes locked_version from y v1.2.0 in go.sum.
    • replace x => ../x: the dependency is kept, with replaced_by ../x and "replace" in prov. It has no locked_version, because a local directory has no version.
  • Under -t, provides_imports covers only the target files #71: under -t, the symbol table has only the target packages, so provides_imports missed the imports of all other packages. A -t run now reads the import paths of every project package with a light package load (names and imports, no types; the build tags and the test setting of a full run). If that load fails, the run writes a warning and uses the imports of the target files.

How Has This Been Tested?

  • Unit tests:
    • a module replace;
    • a local replace;
    • two replaces for one module (the version-specific one wins only for its version);
    • the Neo4j projection (replaced_by on DECLARES_DEPENDENCY; LOCKS from the replacement's go.sum line).
  • A CLI test compares provides_imports of a -t run with a full run. It uses a local library module, so it needs no network.
  • Each of these tests fails on the old code. go test ./... and golangci-lint pass.

Breaking Changes

None. dependencies[].replaced_by is a new field, left out when no replace applies. The DECLARES_DEPENDENCY edge gets a replaced_by property only when a replace applies.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the Codellm-Devkit Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

  • The Python and TypeScript analyzers have no equivalent of replace, so replaced_by is a Go field.
  • A -t run now costs one more go list of the project.
  • Spec: docs/design/specs/v2-artifacts.md (the dependency fields, "replace directives", and provides_imports).

…mports whole under -t (#68, #71)

- #68: go.sum records what the build uses, which is the replacement when a
  replace applies. The lock lookup used the required version, so a replaced
  dependency had no locked_version and no LOCKS edge. Facts now applies the
  replace by Go's rule (a replace of the required version wins over a
  version-less one):
  - replace x => y v1.2.0: the dependency keeps name x and spec, gets
    replaced_by "y@v1.2.0" and locked_version from y v1.2.0;
  - replace x => ../x: it is kept, with replaced_by "../x", "replace" in
    prov, and no locked_version (a local directory has no version).
  replaced_by is a new, omitted-when-empty field on the JSON dependency and a
  property on the DECLARES_DEPENDENCY edge.
- #71: under -t the symbol table holds only the target packages, so
  provides_imports missed every other package's imports. A -t run now reads
  the import paths of every project package with a light package load
  (names, files and imports, no types; the full run's ./... and test
  setting), so it gets the same provides_imports as a full run. If that load
  fails, it warns and uses the symbol table's imports.

Tests: module replace, local replace, two replaces, the Neo4j edge, and a -t
run against a full run (a local library module, so no network). Each fails
on the old code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rahlk rahlk added the bug Something isn't working label Nov 30, 2026
@rahlk
rahlk merged commit 729d07e into main Nov 30, 2026
3 checks passed
@rahlk
rahlk deleted the fix/issues-68-71-dependencies branch November 30, 2026 15:49
rahlk added a commit that referenced this pull request Nov 30, 2026
fix/issues-68-71: Apply go.mod replace directives, and keep provides_imports whole under -t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Under -t, provides_imports covers only the target files Dependencies ignore go.mod replace directives

1 participant