GitNexus/gitnexus/test/unit/scope-resolution
Nguyễn Đăng Minh Lực 5c3961756b
fix(ingestion): preserve Go method ownership across files (#3559)
* fix(ingestion): re-point Go struct member edges when struct is declared in a sibling file (#3558)

findEnclosingClassInfo mints a Go method's owner id from the file
containing the method (Struct:<methodFile>:<Type>), while the Struct
node is keyed by the file declaring the struct (parse-worker uses
declFile). Same package, different file => the HAS_METHOD edge's
sourceId points at a node that does not exist and the edge is silently
dropped at COPY into LadybugDB.

Add reconcileGoStructOwnerEdges, run at the end of the parse phase
after ALL worker chunks are merged so every package's structs are
visible. It rewrites only edges that would otherwise dangle, and only
when exactly one Struct node shares the dangling id's package directory
and simple name; 0 or >=2 candidates keep the old drop behavior (a
wrong owner is worse than a dropped edge).

Index build is lazy: dangling Struct sources are rare (struct fields
never dangle — they live in the struct's own file), so the common
non-Go or fully-same-file case pays two per-type edge scans and no
whole-node pass.

Regression test: test/integration/go-cross-file-struct-owner.test.ts
(fails-before: 1 HAS_METHOD edge; passes-after: 3).

* fix(ingestion): scope Go struct-owner reconcile by language and package

Address PR #3559 review findings:

- Scope the pass to Go: dangling HAS_METHOD/HAS_PROPERTY owner ids whose
  Struct:<file>:<name> file is not Go source (Rust, Swift, ...) are never
  re-pointed, and only Struct nodes stamped language 'go' (the marker the
  worker sets on every declared symbol) are candidates. Negative test pins
  a Rust-shaped dangling edge staying untouched beside a same-name Go
  struct.

- Key candidate structs by (dir, declared package clause, name) instead of
  (dir, name): one directory can carry 'package pkg' and external-test
  'package pkg_test' files declaring the same type name, which the old key
  saw as ambiguous and dropped fail-closed. Clauses are read via the shared
  inferGoPackageName derivation with a call-scoped cache. Integration test
  covers the 3-file layout (pkg decl, pkg_test decl, pkg_test methods file)
  and asserts the edge lands on the pkg_test.Widget node.

- Keep the direct call in parse-impl with a TODO: the pass needs a
  graph-level post-merge hook, which no LanguageProvider/ScopeResolver hook
  provides today.

* refactor(ingestion): remove Go graph repair from shared parse phase

* fix(ingestion): resolve Go ownership during ingestion (language-provider.ts)

* Add resolveDetachedOwnerName function to Go config

* Refactor method owner population logic in Go

* Refactor receiver binding to handle unnamed receivers

* Enhance route handler method resolution logic

Refactor route handler to improve ownership resolution and method indexing.

* Add emitPostResolutionEdges to scope resolver

* fix(ingestion): resolve Go ownership during ingestion (ownership.ts)

* fix(ingestion): resolve Go ownership during ingestion (ast-helpers.ts)

* Add resolveDetachedOwnerName to provider methods

* Update SCHEMA_BUMP to 141

Increment schema version to 141 for new features and fixes.

* fix(ingestion): resolve Go ownership during ingestion (decl.go)

* fix(ingestion): resolve Go ownership during ingestion (external_decl_test.go)

* fix(ingestion): resolve Go ownership during ingestion (external_methods_test.go)

* fix(ingestion): resolve Go ownership during ingestion (foreign.rs)

* fix(ingestion): resolve Go ownership during ingestion (go.mod)

* fix(ingestion): resolve Go ownership during ingestion (local.go)

* fix(ingestion): resolve Go ownership during ingestion (methods.go)

* fix(ingestion): resolve Go ownership during ingestion (go-cross-file-struct-owner.test.ts)

* Refactor comments and method registration in tests

Updated comments for clarity and modified method registration to include qualified names and ownership.

* fix(ingestion): resolve Go ownership during ingestion (has-method.test.ts)

* Update SCHEMA_BUMP to 141 in tests

* refactor(ingestion): remove obsolete Go struct owner reconciliation

* fix(go): model build constraints for method ownership

* test(go): cover build constraint grammar and platform variants

* fix(go): resolve method owners across compatible build variants

* test(go): verify variant ownership through ingestion pipeline

This test verifies that build-variant owners are consistent across different workers, the semantic registry, and the graph. It sets up various scenarios to ensure that ownership is correctly resolved and that there are no dangling edges in the ownership graph.

* fix(go): reject impossible known constraints when peer is unknown

Address PR #3559 review feedback. Regression coverage follows in this update.

* feat(ingestion): allow providers to group incremental resolution files

Add the optional language-neutral hook used by the Go ownership writeback fix for PR #3559.

* fix(go): group sibling files for incremental ownership resolution

Use the existing Go package-directory key for the provider hook.

* fix(incremental): collect sibling resolution groups for changed paths

Keep group keys local to each provider and include current siblings of deleted files.

* fix(analyze): persist ownership changes in unchanged Go siblings

Expand changed and deleted resolution groups before importer traversal. Use the same effective file set for deletion and writeback so package-wide ownership changes reach the database.

* test(incremental): cover provider-local resolution groups

Cover changed, added, deleted and unrelated paths for the new sibling expansion helper.

* test(go): compare incremental ownership writes with cold rebuilds

Reproduce ownership changes after deleting and restoring a Windows declaration while the shared method file stays unchanged. Verify incremental writes and persisted ownership parity with forced rebuilds.

* test(go): exclude impossible owners with unknown method constraints

Use real parsing to cover impossible owner edges and valid owners hidden by impossible competitors.

* test(go): pin filename rules and unknown constraint overlap

Document Go first-dot filename behavior and verify impossible known constraints in both operand orders.

* test(go): register incremental ownership coverage across platforms

Include the new database-backed Go ownership suite in the cross-platform test list.

* test(go): schedule incremental ownership suite with native database tests

Complete PR #3559 review fixes. Local validation: 47 focused tests across five suites passed; build and source/test type checks passed. The full suite was interrupted without a result.

* refactor(ingestion): centralize worker owner hook forwarding

Pass the language provider into the private cached owner lookup instead of repeating four owner hooks at five call sites. Keep qualified-name selection explicit and preserve the exported helper signature.

Validation: CLI/shared build and test typecheck pass; repository lint has no errors; 591 tests pass with one skipped across 13 ownership and worker suites. Web typecheck is blocked by uninstalled web dependencies. Graph checks are unavailable because this checkout has no registered index.

* test(rename): add Go cross-file fixture module

Part of the cross-file method ownership regression for PR #3559. The completed fixture uses real indexing, public rename preview/apply, warm cache replay and post-rename reindexing. All 14 Go rename integration cases pass locally.

* test(rename): add cross-file fixture before/types.go

* test(rename): add cross-file fixture before/methods.go

* test(rename): add cross-file fixture before/callers.go

* test(rename): add cross-file fixture after/go.mod

* test(rename): add cross-file fixture after/types.go

* test(rename): add cross-file fixture after/methods.go

* test(rename): add cross-file fixture after/callers.go

* Add test case for renaming pointer receiver method

Complete the real persisted-index regression fixture for PR #3559. The type, pointer receiver method and callers are in separate Go files. Public rename preview/apply must make exactly four edits across the structural interface family while preserving an unrelated same-name method, comments and strings.

The fixture checks six exact ownership, interface and call edges before rename, after warm parse-cache replay and after reindexing the edited sources. All 14 Go rename integration cases pass. Formatting and the CLI typecheck pass. Graph impact/detect-changes could not run because this checkout has no registered index.

---------

Co-authored-by: System administrator <root@nixos-infra.home>
Co-authored-by: Gergő Magyar <gergomagyar@icloud.com>
2026-10-15 10:36:13 +00:00
..
c fix(rename): extend safe refactoring and flow coverage across languages (#3557) 2026-10-13 08:38:17 +03:00
cpp fix(rename): extend safe refactoring and flow coverage across languages (#3557) 2026-10-13 08:38:17 +03:00
csharp fix(rename): extend safe refactoring and flow coverage across languages (#3557) 2026-10-13 08:38:17 +03:00
go fix(ingestion): preserve Go method ownership across files (#3559) 2026-10-15 10:36:13 +00:00
java fix(rename): extend safe refactoring and flow coverage across languages (#3557) 2026-10-13 08:38:17 +03:00
javascript feat(ingestion): add tRPC procedure detection and MCP chain/route surfacing (#3339) 2026-09-21 09:44:42 +01:00
objective-c feat(indexing): add Objective-C semantic indexing support (#3179) 2026-09-09 09:40:21 +00:00
php fix(rename): extend safe refactoring and flow coverage across languages (#3557) 2026-10-13 08:38:17 +03:00
python fix(python): resolve calls through module-returning accessors (#3542) 2026-10-10 18:41:51 +01:00
ruby fix(scope): keep nested declarations out of module bindings (#3502) 2026-10-08 11:05:41 +03:00
rust fix(deps): upgrade native tree-sitter to 0.25.1 (#3531) 2026-10-10 13:07:59 +03:00
swift fix(swift): avoid false calls for injected closure properties (#3434) 2026-10-02 23:31:14 +01:00
typescript fix(rename): extend safe refactoring and flow coverage across languages (#3557) 2026-10-13 08:38:17 +03:00
vue fix(scope): resolve local imports by lexical ownership (#3532) 2026-10-10 08:13:55 +03:00
c3-linearize-strategy.test.ts fix(python): resolve mixin calls with CPython C3 order (#3393) 2026-09-28 08:55:13 +00:00
callable-flow-captures.test.ts fix(impact): fail closed on id-less targets and follow ??/||/?: callable values (#3354) (#3373) 2026-09-25 21:43:24 +01:00
callable-value-flow-env.test.ts feat: make MAX_CALLABLE_VALUE_TARGETS configurable via env (#2725) 2026-08-01 12:42:36 +01:00
callable-value-flow-worklist.test.ts fix(test): align fixtures and mocks with current types (#3471) 2026-10-05 04:47:37 +01:00
callable-value-target-index.test.ts fix(scope-resolution): parse def coordinates after file paths (#2743) 2026-07-30 07:34:32 +01:00
cobol-import-target-parity.test.ts fix(cobol): prefer copybook dirs so COPY EXTERNAL does not hit vendor decoys (#3240) 2026-09-10 15:42:59 +01:00
construction-syntax-wiring.test.ts fix(test): align fixtures and mocks with current types (#3471) 2026-10-05 04:47:37 +01:00
def-index.test.ts feat(shared): DefIndex / ModuleScopeIndex / QualifiedNameIndex (#913, RFC #909 Ring 2 SHARED) (#958) 2026-04-18 15:59:34 +01:00
definition-id.test.ts fix(scope-resolution): parse def coordinates after file paths (#2743) 2026-07-30 07:34:32 +01:00
emit-references.test.ts fix(test): align fixtures and mocks with current types (#3471) 2026-10-05 04:47:37 +01:00
esm-export-marker.test.ts fix(test): align fixtures and mocks with current types (#3471) 2026-10-05 04:47:37 +01:00
external-import-conformance.test.ts fix(#2965): system headers must not resolve to in-repo files (#3341) 2026-09-27 13:40:54 +01:00
finalize-algorithm.test.ts fix(scope): resolve local imports by lexical ownership (#3532) 2026-10-10 08:13:55 +03:00
finalize-orchestrator.test.ts fix(python): resolve classes through module imports (#2770) 2026-08-01 06:02:47 +01:00
free-call-fallback-guess-taint.test.ts fix(rename): extend safe refactoring and flow coverage across languages (#3557) 2026-10-13 08:38:17 +03:00
function-local-import-chain.test.ts fix(check): stop reporting erased and deferred imports as initialization cycles (#2934) 2026-08-12 17:09:32 +00:00
generic-instantiation.test.ts fix(scope-resolution): make interface dispatch generic-instantiation aware (#2912) (#2939) 2026-08-13 14:50:53 +01:00
graph-bridge-label-split.test.ts fix: type an inference-typed class field so it can act as a call receiver (#2807) (#2810) 2026-08-04 19:31:25 +01:00
heritage-type-arguments.test.ts fix(scope-resolution): make interface dispatch generic-instantiation aware (#2912) (#2939) 2026-08-13 14:50:53 +01:00
import-scope-provenance.test.ts fix(resolution): label fallback guesses and preserve export visibility (#3190) 2026-09-10 11:38:19 +01:00
import-target-adapter.test.ts feat(ingestion): per-language resolveImportTarget adapter (#922, RFC #909 Ring 2 PKG) (#971) 2026-04-18 21:11:24 +01:00
import-target-index-parity.test.ts fix(test): align fixtures and mocks with current types (#3471) 2026-10-05 04:47:37 +01:00
import-target-index-reuse.contract.test.ts fix(#2965): system headers must not resolve to in-repo files (#3341) 2026-09-27 13:40:54 +01:00
imported-return-types.test.ts fix(ingestion): two-channel binding lifecycle (closes #1066) + scope-resolution I8 hardening (#1082) 2026-04-26 12:16:09 +01:00
imports-to-edges-deferred.test.ts fix(check): stop reporting erased and deferred imports as initialization cycles (#2934) 2026-08-12 17:09:32 +00:00
imports-to-edges-type-only.test.ts fix(check): stop reporting erased and deferred imports as initialization cycles (#2934) 2026-08-12 17:09:32 +00:00
lexical-name-claims.test.ts fix(scope): resolve local imports by lexical ownership (#3532) 2026-10-10 08:13:55 +03:00
method-dispatch-index.test.ts chore(shared): apply Ring 2 SHARED review follow-ups in one diff (#964) 2026-04-18 18:40:29 +01:00
module-scope-index.test.ts feat(shared): DefIndex / ModuleScopeIndex / QualifiedNameIndex (#913, RFC #909 Ring 2 SHARED) (#958) 2026-04-18 15:59:34 +01:00
name-fallback-summary.test.ts fix(resolution): label fallback guesses and preserve export visibility (#3190) 2026-09-10 11:38:19 +01:00
name-fallback-visibility.test.ts fix(ci): require every test to execute across the CI matrix (#3479) 2026-10-06 07:34:17 +03:00
namespace-channel-lookup.test.ts fix(csharp): eliminate global-namespace typeBindings O(files²) OOM (#1871) (#1954) 2026-05-31 18:21:07 +01:00
namespace-member-visibility.test.ts fix(rename): extend safe refactoring and flow coverage across languages (#3557) 2026-10-13 08:38:17 +03:00
namespace-target-cache.test.ts fix(scope): resolve local imports by lexical ownership (#3532) 2026-10-10 08:13:55 +03:00
namespace-targets-import-path.test.ts fix(python): resolve calls through aliased package re-exports (#3504) 2026-10-08 13:51:20 +03:00
node-lookup-determinism.test.ts fix(rename): extend safe refactoring and flow coverage across languages (#3557) 2026-10-13 08:38:17 +03:00
overload-narrowing.test.ts fix(scope): resolve local imports by lexical ownership (#3532) 2026-10-10 08:13:55 +03:00
parse-worker-scope-integration.test.ts fix(php): synthesize module scope for namespace-less PHP files (.phtml) (#1801) 2026-05-24 20:37:17 +01:00
php-import-target-parity.test.ts fix(test): align fixtures and mocks with current types (#3471) 2026-10-05 04:47:37 +01:00
pick-implicit-this-overload.test.ts fix(swift): resolve inherited protocol extension calls (#3309) 2026-09-19 07:44:35 +01:00
pick-unique-global-callable.test.ts perf(ingestion): Linux-kernel-scale analysis — worker-pool parse + finalize O(n²) + scope-resolution memory wall (#1983) (#2038) 2026-06-06 22:46:34 +01:00
pick-unique-global-class.test.ts feat(swift): migrate Swift to scope-based registry resolution (#937) (#1948) 2026-05-31 16:56:47 +01:00
position-index.test.ts chore(shared): apply Ring 2 SHARED review follow-ups in one diff (#964) 2026-04-18 18:40:29 +01:00
property-dispatch-fanout-env.test.ts feat: make MAX_PROPERTY_DISPATCH_FANOUT configurable via env (#2726) 2026-08-01 12:18:07 +01:00
property-name-index.test.ts fix(test): align fixtures and mocks with current types (#3471) 2026-10-05 04:47:37 +01:00
qualified-name-index.test.ts chore(shared): apply Ring 2 SHARED review follow-ups in one diff (#964) 2026-04-18 18:40:29 +01:00
receiver-chain-fold.test.ts fix(resolution): resolve Go pointer-receiver calls, and report the program boundary instead of hedging (#2766) (#2782) 2026-08-01 22:42:18 +01:00
receiver-chain-wiring.test.ts feat(resolution): type receiver chains from AST structure across all 14 languages (#2708) + epistemic lower-bound (#2744) (#2747) 2026-07-31 07:12:57 +01:00
reconcile-ownership.test.ts fix(test): align fixtures and mocks with current types (#3471) 2026-10-05 04:47:37 +01:00
references-to-edges-call-form.test.ts fix(test): align fixtures and mocks with current types (#3471) 2026-10-05 04:47:37 +01:00
registries.test.ts fix(scope): resolve local imports by lexical ownership (#3532) 2026-10-10 08:13:55 +03:00
resolve-ambiguous-inheritance-base.test.ts fix(ingestion): migrate all languages' inheritance to scope-resolution on the worker path (#1951) (#1956) 2026-06-01 17:04:27 +01:00
resolve-references.test.ts fix(rename): extend safe refactoring and flow coverage across languages (#3557) 2026-10-13 08:38:17 +03:00
resolve-type-ref.test.ts fix(scope): resolve local imports by lexical ownership (#3532) 2026-10-10 08:13:55 +03:00
resolved-callee-names.test.ts fix(test): align fixtures and mocks with current types (#3471) 2026-10-05 04:47:37 +01:00
run-progress.test.ts fix(rename): extend safe refactoring and flow coverage across languages (#3557) 2026-10-13 08:38:17 +03:00
rust-cargo-targets.test.ts fix(scope): resolve local imports by lexical ownership (#3532) 2026-10-10 08:13:55 +03:00
scope-extractor.test.ts fix(scope): resolve local imports by lexical ownership (#3532) 2026-10-10 08:13:55 +03:00
scope-id.test.ts feat(shared): ScopeTree + PositionIndex + makeScopeId (#912, RFC #909 Ring 2 SHARED) (#961) 2026-04-18 16:41:38 +01:00
scope-source-content-policy.test.ts fix(rename): extend safe refactoring and flow coverage across languages (#3557) 2026-10-13 08:38:17 +03:00
scope-tree.test.ts fix(scope-resolution): allow same-range Module-as-parent for top-level scopes (closes #1086) (#1087) 2026-04-27 11:06:54 +01:00
strip-cast-wrappers.test.ts fix: Java cast-wrapped and this.method() call edges (#2357) 2026-07-02 17:19:33 +01:00
swift-extension-owners.test.ts fix(swift): resolve inherited protocol extension calls (#3309) 2026-09-19 07:44:35 +01:00
swift-target-grouping.test.ts fix(swift): model Swift modules like the compiler (nested packages, Xcode targets, linear visibility) (#3387) 2026-09-27 06:24:35 +01:00
type-parameters.test.ts fix(resolution): resolve calls through a generic-typed field receiver in every language (#2833) (#2855) 2026-08-07 17:14:13 +01:00
type-value-namespaces.test.ts fix(scope): resolve local imports by lexical ownership (#3532) 2026-10-10 08:13:55 +03:00
undecided-satisfaction.test.ts fix(go): resolve out-of-repo package qualifiers, and stop reporting an undecided interface check as a decided negative (#2873) (#2921) 2026-08-11 10:36:59 +01:00
unresolved-receiver-files.test.ts fix(go): scope and define each type_spec, not the type_declaration (#2837) (#2843) 2026-08-06 00:55:48 +01:00
unresolved-receivers.test.ts fix(test): align fixtures and mocks with current types (#3471) 2026-10-05 04:47:37 +01:00
validate-bindings-immutability.test.ts fix(csharp): eliminate global-namespace typeBindings O(files²) OOM (#1871) (#1954) 2026-05-31 18:21:07 +01:00
value-ref-dispatchability.test.ts fix(zig): model callable-value references, and stop reporting their absence as exact (#3219) 2026-09-09 20:12:17 +00:00
value-ref-namespace-precedence.test.ts fix(python): resolve calls through aliased package re-exports (#3504) 2026-10-08 13:51:20 +03:00
walkers-augmentations.test.ts fix(test): align fixtures and mocks with current types (#3471) 2026-10-05 04:47:37 +01:00
wildcard-collision-export-evidence.test.ts fix(resolution): label fallback guesses and preserve export visibility (#3190) 2026-09-10 11:38:19 +01:00
wildcard-topLevelOnly-gate.test.ts fix(resolution): label fallback guesses and preserve export visibility (#3190) 2026-09-10 11:38:19 +01:00
workspace-index.test.ts fix(swift): resolve inherited protocol extension calls (#3309) 2026-09-19 07:44:35 +01:00