GitNexus/gitnexus/test/integration/resolvers
Gergő Magyar 05d269ec28
feat(ruby): migrate Ruby to scope-based resolution (RFC #909 Ring 3) (#1831)
* feat(ruby): migrate Ruby to scope-based resolution (RFC #909 Ring 3)

Implement the full scope-resolution pipeline for Ruby following the
PR #1639 (Rust migration) standard, targeting registration in
MIGRATED_LANGUAGES with 100% scope parity.

Scope resolver hooks (languages/ruby/):
- query.ts: RUBY_SCOPE_QUERY covering scopes, declarations, imports,
  type-bindings (constructor inference via .new), and references
- captures.ts: emitRubyScopeCaptures orchestrator with import
  decomposition, receiver-binding synthesis, method reclassification,
  and arity metadata for both declarations and calls
- receiver-binding.ts: self type-binding synthesis for instance methods,
  singleton methods, and class << self blocks
- interpret.ts: interpretRubyImport (wildcard semantics) and
  interpretRubyTypeBinding (YARD, constructor, alias sources)
- import-target.ts: resolveRubyImportTarget adapting the existing
  suffix resolver for require/require_relative/load
- merge-bindings.ts: tier-based shadowing (local > namespace > import)
- arity.ts: Ruby arity check with *args/**kwargs/&block support
- scope-resolver.ts: rubyScopeResolver with custom buildRubyMro
  (kind-aware IMPLEMENTS partitioning: prepend > direct > include;
  extend excluded from instance MRO per legacy semantics)
- simple-hooks.ts: bindingScopeFor, importOwningScope, receiverBinding

Wiring:
- ruby.ts provider gains 7 scope-resolution hooks
- Registered in SCOPE_RESOLVERS map and MIGRATED_LANGUAGES
- 127 legacy tests wired with createResolverParityIt('ruby')
- 27 new scope-specific tests in ruby-scope.test.ts

Parity: 89/127 legacy tests pass under registry-primary; 38 are
heritage/property/YARD gaps expected in V1. All 127 pass under legacy.

Closes #931

* feat(ruby): add emitHeritageEdges hook, YARD parsing, bare calls, property emission

Extend the scope-resolution pipeline with a new optional `emitHeritageEdges`
hook (ScopeResolver contract + run.ts wiring) that runs between
`preEmitInheritanceEdges` and `buildMro`. This lets languages whose heritage
declarations are syntactic method calls (Ruby include/extend/prepend) emit
IMPLEMENTS edges from the scope-resolver without touching the legacy pipeline.

Ruby scope-resolution improvements:
- Heritage: intercept include/extend/prepend in captures.ts, encode as
  special imports, emit IMPLEMENTS edges via emitHeritageEdges hook
- Properties: intercept attr_accessor/attr_reader/attr_writer, emit
  Property nodes + HAS_PROPERTY edges via the same hook
- Bare calls: add (body_statement (identifier)) capture to scope query,
  matching the legacy query pattern for zero-arity method calls
- YARD parsing: second-pass comment scanner for @param/@return/@type
  annotations with findFollowingMethod that handles body_statement nesting
- Query fixes: @declaration.trait for modules (was @declaration.module
  which normalizeNodeLabel didn't recognize), constant constructor
  bindings (SERVICE = UserService.new), call-return inference

Parity: 114/127 legacy tests pass under registry-primary (up from 89).
Remaining 13 are advanced type-inference chain resolution (compound
receiver, cross-file return-type propagation, for-in element types).

* feat(ruby): achieve 100% scope-resolution parity (127/127)

Fix all 13 remaining type-inference failures:

- Add expandsWildcardTo hook (expandRubyWildcardNames) so finalize can
  materialize individual bindings from require/require_relative wildcard
  imports, unblocking cross-file return-type propagation
- Add member-call-return type binding synthesis in captures.ts for
  assignments like `x = obj.method()` — enables compound receiver
  chaining through member call return types
- Add YARD @return support for attr_accessor/attr_reader/attr_writer
  calls, creating field-type bindings for chain resolution
- Add @declaration.property captures alongside __property__ imports so
  properties register in localDefs → model.fields → write-access
- Add constructor-return inference for methods ending with Foo.new()
- Add for-loop variable type aliasing in scope query
- Rebuild nodeLookup after emitHeritageEdges in run.ts so Property
  nodes created by the heritage hook are visible to downstream passes
- Extend compound-receiver resolver to handle compound member-call
  rawNames with () and increase max depth from 4 to 8
- Extend receiver-bound-calls Case 3b for compound rawNames

All 127 legacy Ruby tests pass under both REGISTRY_PRIMARY_RUBY=0
(legacy) and =1 (registry-primary). Ruby is now fully registered
in MIGRATED_LANGUAGES with 100% scope parity.

* test(ruby): add pipeline benchmark exercising heritage emission

Synthetic Ruby codebases at 100/250/500 files with include + extend +
prepend mixins, diamond mixin patterns (shared BaseMixin modules),
attr_accessor properties, YARD annotations, and cross-file imports.

Strict equality assertions verify exact IMPLEMENTS and HAS_PROPERTY
edge counts: 4 IMPLEMENTS per class (include x2, extend, prepend)
plus 1 per non-base mixin module, 3 HAS_PROPERTY per class.

Dedup in emitRubyMixinEdges prevents double-counting when the worker
path (repos >= 15 files) already created Property/IMPLEMENTS edges
before scope-resolution runs.

Scaling: 0.76x and 1.40x (both linear, well under 3x threshold).

* ci: retrigger build

* fix(ci): resolve format, registry-primary-flag, and sequential-mixin test failures

- Run prettier on all changed files (captures.ts, run.ts, ruby-scope.test.ts,
  ruby.test.ts, ruby-pipeline-benchmark.test.ts)
- Update registry-primary-flag.test.ts: use Swift (not in MIGRATED_LANGUAGES)
  instead of Ruby for the isolation and env-var mutation tests
- Pin ruby-sequential-mixin.test.ts to REGISTRY_PRIMARY_RUBY=0 (legacy mode)
  since it tests inferImplicitReceiver + selectDispatch hooks that live in the
  legacy call-processor (gated off under registry-primary)

---------

Co-authored-by: Test <test@example.com>
2026-05-26 16:16:49 +01:00
..
api-deep-flow.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
c.test.ts feat: migrate C to scope-based resolution (RFC #909 Ring 3) (#1481) 2026-05-11 09:02:00 +01:00
cobol.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
cpp.test.ts fix(cpp): dependent-base resolution across nested/inline namespaces (#1634) (#1814) 2026-05-25 12:36:06 +01:00
csharp.test.ts fix(csharp): include generic typed properties in context and impact (#1399) 2026-05-09 09:07:24 +01:00
dart.test.ts [dart] Add call patterns for await, cascade, lambda, and widget-tree contexts (#801) 2026-04-13 11:21:11 +01:00
express-routes.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
go.test.ts feat(go): implement scope resolution hooks for Go language support (#1302) 2026-05-04 07:29:11 +01:00
helpers.ts feat(ruby): migrate Ruby to scope-based resolution (RFC #909 Ring 3) (#1831) 2026-05-26 16:16:49 +01:00
java.test.ts fix(ingestion): Prioritize same-module Java type resolution for duplicate FQNs across modules (#1712) 2026-05-20 08:00:03 +01:00
javascript.test.ts feat(ingestion): Link object literal methods to exported bindings (#1718) 2026-05-21 17:18:27 +01:00
kotlin.test.ts feat(lang-kotlin): flip Kotlin to MIGRATED_LANGUAGES + close #1756 / #1757 (refs #1746) (#1782) 2026-05-23 07:24:35 +01:00
php-response-shapes.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
php.test.ts feat(php): migrate PHP to scope-based resolution model (#938) [supersedes #1124] (#1497) 2026-05-12 16:56:31 +01:00
python-mcp-tools.test.ts fix(mcp): project tool_map flows from handlers (#1113) 2026-04-27 17:13:02 +01:00
python.test.ts fix(python): make multi-segment suffix fallback deterministic (#1253) 2026-05-02 11:36:28 +01:00
route-mapping.test.ts feat: configure eslint with unused import removal (#564) 2026-03-28 15:28:09 +00:00
ruby-scope.test.ts feat(ruby): migrate Ruby to scope-based resolution (RFC #909 Ring 3) (#1831) 2026-05-26 16:16:49 +01:00
ruby-sequential-mixin.test.ts feat(ruby): migrate Ruby to scope-based resolution (RFC #909 Ring 3) (#1831) 2026-05-26 16:16:49 +01:00
ruby.test.ts feat(ruby): migrate Ruby to scope-based resolution (RFC #909 Ring 3) (#1831) 2026-05-26 16:16:49 +01:00
rust-scope.test.ts feat(rust): Migrate Rust to scope-based resolution (RFC #909 Ring 3) (#1639) 2026-05-25 13:20:08 +01:00
rust.test.ts Extract resolveMemberCall from resolveCallTarget (SM-11) (#744) 2026-04-09 09:52:12 +01:00
shape-check.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
swift.test.ts fix(swift): use official prebuilt parser runtime (#1130) 2026-04-28 09:57:42 +01:00
typescript-esm-js-extension.test.ts fix: resolve TypeScript ESM .js extension imports to .ts source files (#1525) 2026-05-12 16:05:58 +01:00
typescript-hoc-wrapped.test.ts fix(typescript): name HOC-wrapped const declarations (forwardRef / memo / useCallback / useMemo / observer) (#1261) 2026-05-03 13:58:09 +01:00
typescript-hof-callbacks.test.ts fix(typescript): anchor pair-with-arrow @declaration.function on inner arrow 2026-04-30 18:26:51 +03:00
typescript-jsx-as-call.test.ts fix(typescript): address review findings — formatting + tighter test assertions 2026-04-29 15:51:01 +03:00
typescript.test.ts feat(ingestion): Link object literal methods to exported bindings (#1718) 2026-05-21 17:18:27 +01:00
vue.test.ts feat(vue): Vue SFC support + destructured call result tracking (#604) 2026-04-03 14:18:55 +05:30