Swift multi-package repository: scopeResolution hits Map maximum size in implicit imports
Area
gitnexus (CLI / core / indexing)
Summary
gitnexus analyze fails on a large Swift monorepo during scopeResolution: emitSwiftImplicitImportEdges inserts enough relationships to exceed V8's Map capacity. This appears related to the large-repository failure reported in #772, which is closed as completed; the specific Swift grouping path may be a distinct remaining issue or regression.
Context
The repository has multiple nested Swift packages under Core/<package>/Package.swift and Features/<package>/Package.swift, plus Xcode application/extension targets. Generated code, build outputs, dependencies, and Xcode generated project files are excluded using a repo-root .gitnexusignore. About 5,200 non-generated Swift files remain; they belong to many separate modules, not one target. The repository is private, so I cannot link it.
Expected behavior
A single complete repository index, with Swift implicit visibility confined to each actual target. A large but modular repository should not require excluding production source to index.
Actual behavior
The analysis fails and gitnexus status reports Repository not indexed. The Swift config loader in 1.6.9 checks only root-level Sources/, Package/Sources/, and src/; it does not discover the nested package manifests. With no discovered targets, groupSwiftFilesBySpmTarget puts every Swift file in __default__. emitSwiftImplicitImportEdges then generates a directed IMPORTS relationship for every pair of files in that bucket (about 27 million candidate edges for 5,200 files). This cause is inferred from the source and failing stack; the number of edges was not logged directly.
Steps to reproduce
- Use a Swift monorepo with multiple nested packages (for example,
Core/A/Package.swift,Features/B/Package.swift, each containingSources/<Target>/) and enough total Swift files to exceed ~4,100 files after exclusions. Do not add a root-levelSources/directory. - Run
gitnexus analyzefrom the repository root. - Run
gitnexus statusafter the failure.
Environment
- GitNexus: 1.6.9 (installed CLI)
- Node: 24.18.1 (V8 13.6.233.17-node.50)
- OS: macOS Darwin 25.5.0, arm64
Logs
GitNexus Analyzer
Skipped 1 large files (>512KB, likely generated/vendored)
- tools/graphql/schema/schema.graphqls
Analysis failed: Phase 'scopeResolution' failed: Map maximum size exceeded
Caused by: RangeError: Map maximum size exceeded
at Map.set (<anonymous>)
at writeRel (gitnexus/dist/core/graph/graph.js:45:25)
at Object.addRelationship (gitnexus/dist/core/graph/graph.js:85:9)
at Object.emitSwiftImplicitImportEdges (gitnexus/dist/core/ingestion/languages/swift/implicit-imports.js:46:23)
at runScopeResolution (gitnexus/dist/core/ingestion/scope-resolution/pipeline/run.js:328:39)gitnexus status: Repository not indexed. Run: gitnexus analyze.
The one skipped GraphQL schema file is unrelated to the failing Swift import-edge path.
Source: abhigyanpatwari/GitNexus