feat(resolution): mixed iOS / React Native / Expo cross-language bridging (#430)

Implements the design from `docs/design/mixed-ios-and-react-native-bridging.md`.
Closes the cross-language flow gap so `trace` / `callers` / `callees` / `impact` connect end-to-end across language boundaries in real iOS, React Native, and Expo codebases.

## Bridges shipped

| Boundary | Mechanism | Real-codebase validation |
|---|---|---|
| **Swift ↔ Objective-C** | Resolver applying Apple's @objc auto-bridging name math + Cocoa preposition prefixes | Charts (S, 269) · realm-swift (M, 369) · wikipedia-ios (L, 1734) |
| **React Native legacy bridge** | Resolver parsing `RCT_EXPORT_MODULE` / `RCT_EXPORT_METHOD` / `RCT_REMAP_METHOD` (ObjC) + `@ReactMethod` (Java/Kotlin) | AsyncStorage (S, ~60) · react-native-svg (M, ~700) · react-native-firebase (L, ~1100) |
| **React Native TurboModules** | Resolver treating `Native<X>.ts` spec interface as ground truth | via RNSvg + RNFirebase subsets |
| **Native → JS events** | Synthesizer matching native `sendEventWithName:`/`emit(...)` to JS `addListener('e', handler)` keyed by literal event name; falls back to enclosing constant/variable for wrapper-API parameter handlers | RNGeolocation (S) · RNFirebase (L) |
| **Expo Modules** | Framework extract synthesizes `method` nodes from Swift/Kotlin `Module { Name("X"); Function("y") { ... } }` DSL | expo-haptics (S, 14) · expo-camera (M, 72) · ExpoSweep (L, 332, 7 packages) |
| **Fabric + legacy Paper view components** | Extract `component` + `property` nodes from Codegen `codegenNativeComponent<Props>('Name', ...)` specs AND legacy `RCT_EXPORT_VIEW_PROPERTY` / `@ReactProp` macros, then synthesize component → native class by name+suffix convention | react-native-segmented-control (S, legacy) · react-native-screens (M, Codegen) · react-native-skia (L, hybrid monorepo) |

## Bug fixes surfaced along the way

- `tree-sitter.ts` message_expression — multi-keyword ObjC call sites now reconstruct `a🅱️` selectors so they resolve to multi-part method definitions (gap discovered post-#165; 0 → 84 call edges to `GET:parameters:...` style methods on AFNetworking).
- `src/index.ts` resolver lifecycle — `indexAll()` now re-initializes the resolver after extraction so framework `detect()` sees the populated index. Pre-existing latent bug that affected UIKit and SwiftUI resolvers too.
- `src/extraction/index.ts` `buildDetectionContext` — added `listDirectories` so framework detect() can probe monorepo subpackages uniformly (fix needed for react-native-skia detection).

## Regression check on 5 control repos

| Repo | Result |
|---|---|
| Express (small JS) |  unchanged — 266 routes, express framework detected |
| Excalidraw (medium TS/React) |  9284 nodes (CLAUDE.md baseline ~9290); canonical `trace(mutateElement, renderStaticScene)` returns the flow |
| Django realworld (Python) |  django framework detected, 16 routes |
| Spring petclinic (Java) |  spring framework detected, 17 routes |
| Texture (pure ObjC, large) |  exactly matches #165 baseline: 4702 methods, 894 classes, 808/808 file coverage, 913 multi-keyword selectors, 55 protocols, 1036 properties |

## Tests

928 passing (+87 net new bridge tests across the 5 channels); 2 pre-existing skips. The mcp-staleness-banner / watcher parallel flakiness is unchanged by this work (different test fails each run, all pass in isolation; pre-existing on main).

## Documentation

- README: new 'Mixed iOS / React Native / Expo bridging' section with the per-boundary table and validation-corpus links.
- CHANGELOG `[Unreleased]`: full entry per bridge with measurements.
- `docs/design/mixed-ios-and-react-native-bridging.md`: the design doc (§8 measurements filled in across §8a-§8g).
- `docs/design/dynamic-dispatch-coverage-playbook.md` §6 coverage matrix: six new rows.
- `.claude/skills/agent-eval/corpus.json`: four new sections covering 15 real GitHub repos for the eval harness.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
This commit is contained in:
Colby Mchenry
2026-05-26 02:14:00 -05:00
committed by GitHub
parent 1821038e4b
commit 4d1a2b3c4d
22 changed files with 3786 additions and 6 deletions
+85
View File
@@ -84,6 +84,91 @@ and adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
bridge) is **not** in scope for this entry — that's a separate effort
tracked under the dynamic-dispatch coverage playbook.
- **Mixed iOS, React Native, and Expo cross-language bridging.** Real iOS
and React Native codebases live across multiple languages — a Swift caller
invokes an Objective-C selector that's been auto-bridged, JS calls into a
native module via the React Native bridge, JSX delegates to a native view
manager. Static tree-sitter extraction stops at each boundary. CodeGraph
now bridges them so `trace` / `callers` / `callees` / `impact` connect
end-to-end across the gap. Closes the iOS/RN parts of the request thread
for #401. Bridges added:
- **Swift ↔ Objective-C.** Swift `@objc` auto-bridging rules
(`func play(song:)` ↔ ObjC `-playWithSong:`, `init(name:, age:)`
`-initWithName:age:`, `var x: T``-x`/`-setX:`, `@objc(custom:)`
overrides) plus the Cocoa preposition-prefix forms that reverse-import
natively (`objectForKey:`, `stringWithFormat:`, etc.). Validated on
Charts (28 / 1 bridge edges objc→swift / swift→objc), realm-swift
(36 / 1185), wikipedia-ios (52 / 983). The high-confidence direction
is ObjC→Swift, since Swift callsites carry the bare method name only
and many overlap with Cocoa built-ins.
- **React Native legacy bridge + TurboModules.** Parses
`RCT_EXPORT_MODULE` / `RCT_EXPORT_METHOD` / `RCT_REMAP_METHOD` (ObjC
& ObjC++) and `@ReactMethod` (Java/Kotlin) declarations; treats
`Native<X>.ts` TurboModule spec files as ground truth. A JS callsite
of `NativeModules.X.fn(...)` or `import X from './NativeX'; X.fn(...)`
resolves to the matching native method. Validated on AsyncStorage
(8/8 precise), react-native-svg (9 TurboModule bridges to Java),
react-native-firebase (18 precise after `RCTEventEmitter` built-in
blocklist).
- **Native → JS event channel.** Synthesizes cross-language edges
keyed by literal event name: ObjC `sendEventWithName:@"X"` /
Swift `sendEvent(withName: "X", ...)` / Java/Kotlin `.emit("X", ...)`
→ JS `new NativeEventEmitter(...).addListener("X", handler)`.
Falls back to attributing the JS endpoint to an enclosing
`constant`/`variable` for the very common
`const Foo = { watchX(listener) { ... addListener('X', listener) } }`
wrapper-API pattern. Validated on RNFirebase (3 push-notification
flow edges) and RNGeolocation (2 location-event edges).
- **Expo Modules.** Parses Swift/Kotlin Expo DSL —
`Module { Name("X"); Function("y") { ... }; AsyncFunction("z") { ... };
Property("w") { ... } }` — and synthesizes `method` nodes named after
each declaration. JS callsites of `requireNativeModule('X').y(...)`
then resolve via existing name-match. Validated on expo-haptics
(6 method nodes across Swift + Kotlin), expo-camera (41 covering the
full SDK surface), and a 7-package Expo sweep (134 method nodes).
- **Fabric / Codegen + legacy Paper view components.** Parses TS
`codegenNativeComponent<NativeProps>('Name', ...)` Codegen specs AND
legacy `RCT_EXPORT_VIEW_PROPERTY` / `@ReactProp` view-manager
macros. Emits a `component` node per declaration and a `property`
node per declared prop, then a synthesizer links the component to
its native impl class by convention-based name+suffix
(`View`/`ComponentView`/`Manager`/`ViewManager`). The existing JSX
synthesizer then connects consumer JSX `<MyView/>` → component →
native class. Validated on react-native-segmented-control
(legacy Paper — 1 component, 11 props, 4 bridges),
react-native-screens (Codegen Fabric — 27 components, 272 props,
68 bridges), and react-native-skia (hybrid, monorepo — 5 components,
14 props, 15 bridges across Codegen TS specs + Android Java
ViewManagers + iOS ObjC).
Each bridge emits `provenance:'heuristic'` edges with a stable
`metadata.synthesizedBy:` channel name (`swift-objc-bridge`,
`react-native-bridge`, `rn-event-channel`, `fabric-native-impl`,
`expo-modules`) so an agent can tell at a glance how a cross-language
hop got into the graph. Per-bridge precision blocklists prevent
noisy over-linking on generic Cocoa names (`init`, `description`,
`count`, …) and RN event-emitter built-ins (`addListener`, `remove`,
…) that every NSObject / RCTEventEmitter subclass exposes.
Architectural fix surfaced during validation: the resolver's
`initialize()` runs at CodeGraph construction (before any files are
indexed), so framework resolvers whose `detect()` consults the
indexed file list silently dropped themselves. `indexAll()` now
re-initializes the resolver after extraction so all frameworks see
the populated index — a pre-existing latent bug that also affected
the UIKit and SwiftUI resolvers.
Out of scope for this round: bare JSI (non-TurboModule), dynamic
bridge keys (`NativeModules[someVar]`), Android-Java extraction
improvements beyond name-match (we use whatever the existing Java
extractor produces). Anti-goals documented in
`docs/design/mixed-ios-and-react-native-bridging.md`.
### Fixed
- **Git worktrees no longer silently borrow another tree's index (#155).**
When a worktree is nested inside the main checkout — exactly what agent