GitNexus/gitnexus/test/fixtures/rename-integration
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
cobol 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
dart 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 fix(rename): extend safe refactoring and flow coverage across languages (#3557) 2026-10-13 08:38:17 +03:00
kotlin fix(rename): extend safe refactoring and flow coverage across languages (#3557) 2026-10-13 08:38:17 +03:00
objective-c fix(rename): extend safe refactoring and flow coverage across languages (#3557) 2026-10-13 08:38:17 +03:00
php fix(rename): extend safe refactoring and flow coverage across languages (#3557) 2026-10-13 08:38:17 +03:00
python fix(rename): extend safe refactoring and flow coverage across languages (#3557) 2026-10-13 08:38:17 +03:00
ruby fix(rename): extend safe refactoring and flow coverage across languages (#3557) 2026-10-13 08:38:17 +03:00
rust fix(rename): extend safe refactoring and flow coverage across languages (#3557) 2026-10-13 08:38:17 +03:00
swift fix(rename): extend safe refactoring and flow coverage across languages (#3557) 2026-10-13 08:38:17 +03:00
typescript fix(rename): extend safe refactoring and flow coverage across languages (#3557) 2026-10-13 08:38:17 +03:00
vue fix(rename): extend safe refactoring and flow coverage across languages (#3557) 2026-10-13 08:38:17 +03:00
zig fix(rename): extend safe refactoring and flow coverage across languages (#3557) 2026-10-13 08:38:17 +03:00
README.md fix(rename): extend safe refactoring and flow coverage across languages (#3557) 2026-10-13 08:38:17 +03:00

Semantic rename integration fixtures

These projects exercise real indexing and the public rename tool in both modes (dry_run: true to preview, dry_run: false to apply). The integration test and its subprocess helper do not mock the parser, semantic resolver, registry, database, graph, filesystem, or rename functions.

Run from gitnexus/:

npm run build
npm test -- test/integration/rename-provider-matrix

Four test files partition the sorted cases evenly so CI can distribute real indexing across its existing shards. Each case runs exactly once.

Use -t 'cpp/' (for example) to select one provider. Rebuild after production changes: the helper loads the built application, including real parse workers. Do not rebuild while this suite is running. The analyzer verifies that its build does not change during indexing.

Each case contains a case.json, an independently authored before/ project, and the complete expected after/ project. Unchanged files are included too. Expected files are never generated by applying the implementation's edits.

For each case, the harness:

  1. Copies the project into an isolated temporary repository and creates a real index, registry entry, and database with PDG enabled.
  2. Checks indexing completeness and selects the target uniquely from persisted declarations. It asserts the specified call, access, or family edges.
  3. Calls rename with dry_run: true and verifies that all source bytes are unchanged.
  4. Calls rename with dry_run: false, checks the exact edit count and agreement with the preview, and compares every source file against after/.
  5. Reindexes successful edits and checks the renamed declaration and the same graph relationships at their source positions.

Refusal cases assert their specific error and planning status and verify that both preview and apply preserve every source byte. They supplement successful cases; the suite requires successful fixtures for every supported language.

target and edge endpoints use name, file, optional kind, and optional zero-based startLine. Add startLine when declarations share a name. An optional expectedTargetName records an escaped graph spelling after rename, such as @Serialize; the generic harness contains no language-specific name rules.

An optional exactOutgoing: true requires every listed source/type pair to have exactly the target set specified in edges, rejecting extra overload or wrong-owner edges. This applies to cold, warm-cache, and post-rename graphs.

An optional warmParseCache: true performs a second forced index before rename, using captures cached by the cold index. It requires cache hits, zero reparsed files and no parse workers, then verifies the same persisted target identity and specified graph edges before public preview/apply. The C++ overload fixture uses this path to preserve signature-specific call edges across cache serialization.

Provider Language behavior exercised
C Header/definition families, function pointers, call chains, deep pointer fields
C++ Overloaded free functions across headers, virtual families, deep pointer fields, language keywords
C# Interface/override families, public fields, escaped overloads, named arguments
COBOL Cross-program calls, paragraph chains, nested qualified data
Dart Interface/override and super calls, deep fields, imports, contextual identifiers
Go Structural interfaces, exported pointer fields, package import aliases, generic type shadowing
Java Interface/override families, overloads, deep public fields, reserved names
JavaScript Inheritance, inferred deep fields, escaped exports, aliases and shorthand
Kotlin Override families, typed callable references, escaped overloads, property writes
Objective-C Protocol selectors, accessors, deep chains, ivars and same-named C symbols
PHP Case-insensitive methods/functions, case-sensitive properties, grouped imports
Python Override families, deep fields, aliases, Unicode names, dynamic attribute safety
Ruby Mixins, predicate methods, chained setters, required qualified constants
Rust Trait families, borrowed field receivers, cross-file import aliases
Swift Protocol/override families, deep properties, escaped names and argument labels
TypeScript Constructor-proven families/chains, aliases/shorthand, structural safety refusals
Vue Script/template/CSS references, components, cross-file calls, opaque raw blocks
Zig Typed container fields, import aliases and call chains

C, COBOL and Zig do not have class polymorphism matching the OO cases. Their fixtures exercise their own callable, program, or container semantics. Vue fixtures additionally cover its embedded and template name surfaces.

TypeScript's structurally typed parameters do not prove a receiver's constructor: unrelated objects can satisfy the same annotation. Open-parameter refusal cases remain unchanged, alongside successful constructor-proven cases. These fixtures are targeted regression coverage, not a claim of complete IDE refactoring parity.

C++ permits restrict as an identifier (C++ keyword table, GCC's explicit clarification). The successful type fixture exercises this spelling. The vendored tree-sitter grammar currently parses an unparenthesized int restrict(...) declarator as a C-style type qualifier, so the separate function fixture expects parse_error and unchanged sources. The parser limitation remains fail-closed.