GitNexus/gitnexus/bench
Gergő Magyar 51fb64c976
fix(swift): model Swift modules like the compiler (nested packages, Xcode targets, linear visibility) (#3387)
* fix(swift): discover nested Package.swift manifests for module grouping

A Swift monorepo laid out as Core/<pkg>/Package.swift has no root manifest
and no root Sources/, so every Swift file fell into one __default__ module.
The Swift resolver now walks the repo (bounded, skipping dot, ignored, and
Xcode bundle directories) and adds each nested package's targets, keyed by
repo-relative directory and ordered deepest-first so first-match grouping
picks the most specific target. Import resolution keeps the root view.

Refs #3355

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(swift): bound implicit IMPORTS edges by a total budget

Implicit same-module IMPORTS are n*(n-1) edges per module, and the graph
keeps every relationship in one Map capped by V8 at 2^24 entries. Emission
now fills a 4M-edge budget smallest module first and skips, with a warning,
any module that does not fit, so no module layout can crash analyze.

Refs #3355

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(swift): skip pairwise sibling passes for oversized modules

The target-siblings and sibling-type-bindings passes copy every file's
declarations into every other file of a module, so heap grows as n^2:
about 3.8 GB at 1,000 files with 15 defs each, about 15 GB at 2,000.
Modules over 1,000 files now skip both passes with a warning and resolve
through the global name fallback. GITNEXUS_SWIFT_MAX_MODULE_FILES changes
the ceiling.

Refs #3355

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(swift): cover nested SwiftPM packages end to end

A fixture with three nested Package.swift manifests (two declaring a target
named Net) and no root manifest. Each target gets its own implicit IMPORTS,
none cross packages, and Config() resolves to the caller's own package.
The Swift capture golden and scope-capture fingerprint grow with the new
fixture corpus only.

Refs #3355

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(review): apply review findings

- Rebase nested target paths with the existing Zig path helpers, which also
  reject Windows drive paths and paths that resolve to the repo root (whose
  empty prefix would group every file into one target).
- Document GITNEXUS_SWIFT_MAX_MODULE_FILES in the README env table.
- State that skipped modules resolve through lower-confidence fallback edges,
  why nested-type fragments still run for oversized modules, and fix a stale
  loader name in the target-grouping header.

Refs #3355

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(swift): cover every skipped Xcode bundle suffix in the package walk

Refs #3355

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(swift): model modules the way the compiler does

Replace the caps from the first round with representations that stay
linear, and derive module identity from the same sources the compiler uses.

- Same-module visibility is one File -> Module IMPORTS edge per file
  (reason `module-membership`) instead of an edge per ordered file pair.
  Incremental importer expansion treats files sharing a Module hub as
  importers of each other. The 4M edge budget is gone.
- Sibling declarations and type bindings live in one shared table per
  module in the namespace channel C# uses since #1871, instead of being
  copied into every file. The 1,000-file ceiling and
  GITNEXUS_SWIFT_MAX_MODULE_FILES are gone.
- Modules come from root and nested SwiftPM manifests (Sources, Source,
  src, srcs; plugins under Plugins; the newest Package@swift-X.Y.swift)
  and from Xcode native targets in project.pbxproj, including Xcode 16
  synchronized folders. Target paths are matched from the repo root, so
  a vendored copy of the same layout is no longer grouped into a root
  target (this reverses #2931's floating match).
- `import X` resolves to the modules named X instead of any folder named
  X. A name no module carries is external when every manifest and
  project was read completely.
- The global-name-fallback veto uses the same membership, so test
  targets, custom-path targets and Xcode targets have module identity.

Refs #3355

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(bench): move the Swift package bench to module grouping

The bench still imported the removed groupSwiftFilesBySpmTarget. Its
first-wins probe keeps its meaning under root-anchored grouping: the
clash file sits under Sources/Mod0, and the Sources/Mod1 further down its
path is a vendored copy.

Plugins are now non-importable modules under Plugins/, so parse_targets
counts importable source targets (still 3) and parse_binary_skipped also
checks that the plugin is recorded that way. Baseline values unchanged;
the notes say why the definitions moved.

Refs #3355

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(swift): match compiler module names, manifests, and target filters

- Module names follow the compiler's c99 mangling (`my-lib` imports as
  `my_lib`); Xcode targets use a literal PRODUCT_MODULE_NAME or
  PRODUCT_NAME when the project sets one.
- Package manifests are one-file modules, as SwiftPM compiles them. Files
  outside every target are one-file modules once every manifest and
  project was read; otherwise they keep the shared __default__ module.
- Xcode 16 synchronized-folder exceptions add a file to a target that
  does not list the folder, and remove it from one that does.
- SwiftPM `sources:` / `exclude:` narrow a target; a computed list marks
  the manifest unreadable.
- The default target folder is chosen once per package, as SwiftPM does,
  instead of per target.

Refs #3355

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* Address PR review feedback (#3387)

- Inferred Swift folders keep SwiftPM's first predefined parent when a
  target name repeats (Sources before srcs).
- The pbxproj parser rejects a \U escape without four hex digits instead
  of decoding garbage, so the project reads as incomplete.
- Extension owners are stamped in every Xcode membership of a shared file.
- A plugin name never reaches a plugin: neither the fallback veto nor the
  folder-index fallback treats a known non-importable module as imported.
- A file an Xcode target compiles keeps that membership even when it also
  lies under a SwiftPM target directory.
- The workspace scan bounds the queue, not only the directories read.
- Integration tests require each module hub to exist before comparing.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Gergo Magyar <gergomagyar0@gmail.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-27 06:24:35 +01:00
..
callable-value-flow fix(scope-resolution): parse def coordinates after file paths (#2743) 2026-07-30 07:34:32 +01:00
cfg feat(impact): opt-in PDG-backed impact mode - statement + inter-procedural slicing, resolved-callee-id soundness, mutation-oracle validated (#2227) 2026-06-20 12:04:32 +01:00
cpp-qualified-ns perf(cpp): index qualified namespace members once per pipeline run (#2788) (#2794) 2026-08-02 15:52:33 +01:00
cross-repo-trace fix(group)!: stop group sync claiming matching it never did (#3020) 2026-08-27 18:27:32 +01:00
emit-persistence feat(indexing): add Objective-C semantic indexing support (#3179) 2026-09-09 09:40:21 +00:00
finalize-reexport fix(python): resolve calls through __init__.py re-exports (#2864) 2026-08-09 12:21:06 +01:00
impact-pdg fix(impact-pdg): make the Impact PDG Mutation Report workflow pass (3 latent oracle bugs) (#2258) 2026-06-20 20:40:28 +01:00
import-target fix(dart): resolve package imports by pubspec identity (#3369) 2026-09-26 13:21:09 +01:00
java-lombok-synthesis feat(jvm): synthesize Lombok and Kotlin JVM accessor methods (#2885) 2026-08-31 17:55:52 +00:00
java-wildcard-route-constants feat(jvm): fold Java static wildcards and Kotlin star imports for route constants (#3110) 2026-08-31 21:58:40 +00:00
kotlin-import-target fix(kotlin): resolve imports from declared packages (#2990) 2026-08-18 20:47:30 -07:00
kotlin-jvm-accessors feat(jvm): synthesize Lombok and Kotlin JVM accessor methods (#2885) 2026-08-31 17:55:52 +00:00
kotlin-star-route-constants feat(jvm): fold Java static wildcards and Kotlin star imports for route constants (#3110) 2026-08-31 21:58:40 +00:00
lib feat(ingestion): add tRPC procedure detection and MCP chain/route surfacing (#3339) 2026-09-21 09:44:42 +01:00
mcp-tools-list feat(storage): add configurable index storage and content retention tiers (#3060) 2026-09-12 20:31:55 +00:00
objective-c-resolution feat(indexing): add Objective-C semantic indexing support (#3179) 2026-09-09 09:40:21 +00:00
parse-dispatch-rounds perf(parse): tighten the dispatch-round memory bound and unclamp the worker-pool override (#3200) 2026-09-07 13:53:31 +01:00
python-scope fix(impact): fail closed on id-less targets and follow ??/||/?: callable values (#3354) (#3373) 2026-09-25 21:43:24 +01:00
python-workspace-import-scan fix(group): detect function-local Python imports (#3254) 2026-09-11 06:23:52 +00:00
receiver-resolution feat: add Zig language support (#1432) 2026-09-03 13:29:42 +01:00
ruby-gem-resolution fix(ruby): guard gem requires with dependency metadata (#3096) 2026-09-10 16:04:11 +01:00
rust-cargo-targets fix(rust): respect Cargo target boundaries in name fallback (#3294) 2026-09-16 11:36:07 +01:00
schema-pairs fix(scope-resolution): link Record graph nodes (#2871) 2026-08-07 18:33:27 +01:00
scope-capture fix(swift): model Swift modules like the compiler (nested packages, Xcode targets, linear visibility) (#3387) 2026-09-27 06:24:35 +01:00
scope-emission fix(scope-resolution): resolve calls through a closure-valued binding across languages (#2693) (#2695) 2026-07-27 07:52:18 +01:00
spring-conditionals feat(spring): model profiles, conditions, and auto-configuration (#2678) 2026-07-28 07:05:41 +01:00
spring-config-bindings feat(kotlin): bind Spring config consumers on Kotlin sources (#3126) 2026-09-01 10:32:09 +00:00
swift-package-imports fix(swift): model Swift modules like the compiler (nested packages, Xcode targets, linear visibility) (#3387) 2026-09-27 06:24:35 +01:00
trpc-route-extractor feat(ingestion): add tRPC procedure detection and MCP chain/route surfacing (#3339) 2026-09-21 09:44:42 +01:00
v8-sidecar perf(store): V8 sidecars plus hardlinked ParsedFile restore (#3099) 2026-08-30 20:50:20 +00:00
value-ref-resolution fix(zig): model callable-value references, and stop reporting their absence as exact (#3219) 2026-09-09 20:12:17 +00:00
zig-cross-file-resolution fix(zig): resolve cross-file static gates (#3185) 2026-09-07 07:19:30 +01:00
analyze-phase-breakdown.md perf(scope-resolution): stop re-scanning the ParsedFile store once per language (#3211) 2026-09-08 13:48:30 +01:00
parse-throughput.md fix(parse): correct worker-pool docs drift + surface worker-side stack on crash (#2068) (#2070) 2026-06-08 07:20:12 +01:00