Skip to content

feat(swift): deepen extraction fidelity and add SwiftPM support#1891

Open
TPAteeq wants to merge 1 commit into
Graphify-Labs:v8from
TPAteeq:feat/swift-fidelity
Open

feat(swift): deepen extraction fidelity and add SwiftPM support#1891
TPAteeq wants to merge 1 commit into
Graphify-Labs:v8from
TPAteeq:feat/swift-fidelity

Conversation

@TPAteeq

@TPAteeq TPAteeq commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR substantially improves Swift graph extraction and adds structural support for Swift Package Manager manifests.

It preserves precise symbol identity across Swift overloads, models protocol contracts and witnesses, improves receiver-aware call resolution, and represents SwiftPM packages, products, targets, dependencies, imports, and accepted source membership.

What changed

Swift declaration fidelity

  • Preserve distinct nodes for overloads differentiated by:
    • parameter types and labels
    • return types
    • static versus instance dispatch
    • generic constraints
    • declarations split across extensions
  • Preserve existing IDs for non-overloaded symbols.
  • Extract associated types and type aliases.
  • Model stored and computed properties with declared type, mutability, and static metadata.
  • Recognize protocol methods, properties, initializers, and subscripts as requirements.
  • Keep protocol-extension default implementations distinct from requirements.

Call resolution

  • Resolve overloads using literal, constructor, typed-identifier, and trailing-closure arguments.
  • Scope receiver types per method so parameter and local names cannot leak between sibling functions.
  • Resolve:
    • typed instance calls
    • static calls without requiring an unrelated type table
    • deep property chains
    • singleton/static-property chains
    • factory-return chains
    • free-function factory chains
    • cross-file overloaded free functions
  • Preserve conservative fail-closed behavior when a receiver or overload remains ambiguous.

Protocol conformance

  • Correct cross-file protocol conformances previously classified as inheritance.
  • Link concrete methods and properties to the protocol requirements they satisfy.
  • Apply associated-type substitutions, including generic aliases such as [String].
  • Validate static/instance dispatch, return types, async/throwing compatibility, property types, and setter requirements before emitting witness edges.
  • Follow inherited protocol requirements.

Swift Package Manager

  • Extract Package.swift into package, product, target, dependency, and source-membership structure.
  • Support library, executable, regular, test, system-library, binary, plugin, and macro targets.
  • Represent internal and external target dependencies without dangling edges.
  • Use manifest-qualified target and product IDs to prevent collisions across packages.
  • Rewire internal Swift imports to their real package targets.
  • Honor target path, sources, and exclude.
  • Resolve membership only against files already accepted by Graphify’s scan, preserving ignore rules and explicit input scope.
  • Recompute membership on every extraction so cached manifests cannot retain deleted sources or miss newly added files.
  • Avoid duplicate file nodes and links to files that failed extraction.

Compatibility and safety

  • Swift extraction remains entirely local and offline through tree-sitter.
  • Existing non-overloaded symbol IDs remain stable.
  • Ambiguous calls are skipped instead of guessed.
  • SwiftPM module nodes are excluded from Swift type resolution.
  • Cross-file extension markers now survive canonical ID remapping.
  • The existing Objective-C/Swift interoperability behavior remains intact.

Validation

  • Full test suite: 3164 passed, 30 skipped
  • New focused Swift fidelity suite: 18 passed
  • Ruff: passed
  • Pyright on new SwiftPM code and tests: zero errors or warnings
  • No net Pyright regression against upstream
  • uv lock --check: passed
  • Generated skill artifacts: all 134 matched
  • git diff --check: passed
  • Built and installed the wheel in a fresh environment
  • Offline installed-wheel Swift and SwiftPM smoke test passed with network connections disabled
  • Three independent review passes completed; all reproduced findings were patched and reverified

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant