GitNexus/gitnexus/test/unit/scope-resolution
Lucas van Staden 1c4993251c
fix(php): synthesize module scope for namespace-less PHP files (.phtml) (#1801)
* fix(php): phtml scope synthesis with full-file range + O(1) Step 4 lookup (#1801, #1803)

Address PR #1801 review findings and complete #1803 fix:

scope-extractor.ts:
- Synthetic Module scope uses full-file range (computed from existing
  drafts) so positionIndex containment works for top-level references
  in ERROR-root .phtml files
- Orphan scope re-parenting done on drafts in extract() by replacing
  with new drafts — no mutation of readonly fields, no PHP-specific
  logic in shared buildScopeTree
- Dead matchCount parameter removed from ensureModuleScope

namespace-siblings.ts:
- Step 4 parsedFiles.find() replaced with pre-built Map for O(1) lookup
  (was O(n²) with 16K files = ~256M comparisons)

* test(php): add pipeline benchmark for scaling regression detection

Synthetic PHP fixture generator (N files × M namespaces × K classes)
with cross-namespace imports and calls. Measures wall-clock, peak heap,
node/edge counts at 100/250/500 file scales with worker pool enabled.

Results on current branch:
- 100 files: 982ms, 65MB (9.8ms/file)
- 250 files: 1310ms, 70MB (5.2ms/file)
- 500 files: 2006ms, 92MB (4.0ms/file)
- Scaling: sublinear (0.53x-0.77x ratio)

Gated behind GITNEXUS_BENCH=1 so it does not run in normal CI.

* chore: trigger CI

* fix: prettier formatting + update scope-extractor test for synthesis behavior

* fix: extend synthetic Module range to all captures + update integration test

Address CI failure and review findings:
- ensureModuleScope now computes range from ALL captures (scope,
  declaration, reference, type-binding) not just scope drafts. This
  ensures top-level references after the last inner scope are covered.
- Update parse-worker-scope-integration test for synthesis behavior.
- Update extract() docstring to document synthesis contract.

---------

Co-authored-by: Test <test@example.com>
Co-authored-by: Gergő Magyar <gergomagyar@icloud.com>
2026-05-24 20:37:17 +01:00
..
c feat: migrate C to scope-based resolution (RFC #909 Ring 3) (#1481) 2026-05-11 09:02:00 +01:00
cpp feat(cpp): Add pointer nullptr ellipsis conversion ranks (#1708) 2026-05-20 12:06:51 +01:00
csharp fix(csharp): include generic typed properties in context and impact (#1399) 2026-05-09 09:07:24 +01:00
go fix(go): use loose equality for Array.find() null checks (#1384) 2026-05-06 17:57:19 +01:00
python fix(ingestion): index Python repos with empty __init__.py and >32 KB files (#1163) 2026-04-30 19:24:04 +01:00
typescript fix(workers): resilient + zero-copy ingestion worker pool — prevent analyze hangs on TS-root-scale loads (#1693) 2026-05-20 20:39:35 +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
emit-references.test.ts feat(ingestion): emit-references drains ReferenceIndex to graph edges (#925, RFC #909 Ring 2 PKG) (#973) 2026-04-18 23:36:10 +01:00
finalize-algorithm.test.ts feat(ingestion): TypeScript registry-primary scope resolution (Ring 3) (#1050) 2026-04-26 08:23:08 +01:00
finalize-orchestrator.test.ts fix(scope-resolution): avoid variadic reference site aggregation (#1112) 2026-04-27 12:44:21 +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
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
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
overload-narrowing.test.ts feat(cpp): sfinae filter (#1623) 2026-05-16 20:23:13 +01: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
pick-implicit-this-overload.test.ts feat(php): migrate PHP to scope-based resolution model (#938) [supersedes #1124] (#1497) 2026-05-12 16:56:31 +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
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
reconcile-ownership.test.ts perf(scope-resolution): use owner-keyed lookup for Step 2 member resolution (#1657) 2026-05-18 13:14:27 +01:00
registries.test.ts perf(scope-resolution): use owner-keyed lookup for Step 2 member resolution (#1657) 2026-05-18 13:14:27 +01:00
resolve-references.test.ts perf(scope-resolution): use owner-keyed lookup for Step 2 member resolution (#1657) 2026-05-18 13:14:27 +01:00
resolve-type-ref.test.ts chore(shared): apply Ring 2 SHARED review follow-ups in one diff (#964) 2026-04-18 18:40:29 +01:00
resolver-parity-expected-failures.test.ts feat: C++ ADL V2: include base-class associated namespaces via MRO (#1597) 2026-05-15 07:54:23 +01:00
scope-extractor.test.ts fix(php): synthesize module scope for namespace-less PHP files (.phtml) (#1801) 2026-05-24 20:37:17 +01: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-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
shadow-harness.test.ts feat(ingestion): shadow-mode parity harness + static dashboard (#923, RFC #909 Ring 2 PKG) (#972) 2026-04-18 21:30:43 +01:00
validate-bindings-immutability.test.ts fix(ingestion): two-channel binding lifecycle (closes #1066) + scope-resolution I8 hardening (#1082) 2026-04-26 12:16:09 +01:00
walkers-augmentations.test.ts fix(ingestion): two-channel binding lifecycle (closes #1066) + scope-resolution I8 hardening (#1082) 2026-04-26 12:16:09 +01:00
workspace-index.test.ts fix(ingestion): classify Python class methods as Method (#1102) 2026-04-27 09:04:50 +01:00