[PR #1208] [MERGED] fix(ghidra): classify modern Swift manglings in swift type analysis #2721

Closed
opened 2026-10-17 21:09:29 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/1208
Author: @sx4im
Created: 10/9/2026
Status: ✅ Merged
Merged: 10/9/2026
Merged by: @morluto

Base: main ← Head: fix/swift-type-analysis-modern-manglings


📝 Commits (2)

  • 82dd6d6 fix(ghidra): classify modern Swift manglings in swift type analysis
  • 6e9e34a fix(swift): retain provider aliases and category unknowns

📊 Changes

13 files changed (+968 additions, -31 deletions)

View changed files

📝 docs/testing.md (+7 -0)
📝 package.json (+1 -0)
➕ scripts/verify-real-ghidra-swift.mjs (+160 -0)
📝 src/application/EnhancedTools.ts (+25 -3)
📝 src/contracts/enhancedInputs.ts (+4 -2)
📝 src/contracts/enhancedToolContracts.ts (+1 -1)
📝 src/contracts/toolOutputSchemaGroups.ts (+13 -1)
➕ src/domain/swiftSymbolClassification.ts (+70 -0)
📝 src/domain/symbolAnalysis.test.ts (+161 -0)
📝 src/domain/symbolAnalysis.ts (+86 -24)
➕ tests/boundary/mcp/enhancedTools.swiftTypes.test.ts (+149 -0)
➕ tests/conformance/swift/type-inventory.swift (+10 -0)
➕ tests/fixtures/swift/ghidraInventory.ts (+281 -0)

📄 Description

analyze_swift_types returned an empty inventory for a modern Swift binary even though the same provider session reported Swift procedures. The classifier in src/domain/symbolAnalysis.ts only accepted procedure names containing the legacy _Tt marker, so every modern $s mangling was dropped before counting. The native metadata classifier in src/domain/native/objcSwiftMetadata.ts already recognizes /^(?:_?\$s|_Tt)/, so the domain classifier was behind the rest of the codebase.

Changed categorizeSwiftTypes to treat names starting with $s (or _$s at Mach-O boundaries) as Swift symbols, alongside the legacy _Tt check, which is unchanged. Modern manglings land in the existing other bucket, since the class/struct/enum/protocol/extension prefixes only describe the legacy _Tt families. C, ObjC, and C++-style names are still excluded.

Verification:

  • New Vitest cases assert $s4main4PairVMa, $s4main6ScorerVMa, and _$s4main4PairVMa are counted in other and deduplicated, and that non-Swift names stay out:
    ✓ src/domain/symbolAnalysis.test.ts (6 tests) 10ms
    Test Files  1 passed (1)
         Tests  6 passed (6)
    
  • npm run check:fast: typecheck + lint green.
  • npm run verify:test-discovery: 661 test files discovered exactly once.
  • Affected suites (tool contracts, enhanced-tools input validation and MCP boundary): all green.

Real Ghidra verification was not possible in this environment: the issue's reproduction needs a Swift toolchain, Ghidra 12, and a macOS host, so verification is at the classifier level only.

Fixes #1187.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/1208 **Author:** [@sx4im](https://github.com/sx4im) **Created:** 10/9/2026 **Status:** ✅ Merged **Merged:** 10/9/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/swift-type-analysis-modern-manglings` --- ### 📝 Commits (2) - [`82dd6d6`](https://github.com/morluto/rea/commit/82dd6d60e4ab70022c6bf59ea346c086a4dc28a5) fix(ghidra): classify modern Swift manglings in swift type analysis - [`6e9e34a`](https://github.com/morluto/rea/commit/6e9e34a1e3f94dbd04e114e77d35ba4a382c7c50) fix(swift): retain provider aliases and category unknowns ### 📊 Changes **13 files changed** (+968 additions, -31 deletions) <details> <summary>View changed files</summary> 📝 `docs/testing.md` (+7 -0) 📝 `package.json` (+1 -0) ➕ `scripts/verify-real-ghidra-swift.mjs` (+160 -0) 📝 `src/application/EnhancedTools.ts` (+25 -3) 📝 `src/contracts/enhancedInputs.ts` (+4 -2) 📝 `src/contracts/enhancedToolContracts.ts` (+1 -1) 📝 `src/contracts/toolOutputSchemaGroups.ts` (+13 -1) ➕ `src/domain/swiftSymbolClassification.ts` (+70 -0) 📝 `src/domain/symbolAnalysis.test.ts` (+161 -0) 📝 `src/domain/symbolAnalysis.ts` (+86 -24) ➕ `tests/boundary/mcp/enhancedTools.swiftTypes.test.ts` (+149 -0) ➕ `tests/conformance/swift/type-inventory.swift` (+10 -0) ➕ `tests/fixtures/swift/ghidraInventory.ts` (+281 -0) </details> ### 📄 Description `analyze_swift_types` returned an empty inventory for a modern Swift binary even though the same provider session reported Swift procedures. The classifier in `src/domain/symbolAnalysis.ts` only accepted procedure names containing the legacy `_Tt` marker, so every modern `$s` mangling was dropped before counting. The native metadata classifier in `src/domain/native/objcSwiftMetadata.ts` already recognizes `/^(?:_?\$s|_Tt)/`, so the domain classifier was behind the rest of the codebase. Changed `categorizeSwiftTypes` to treat names starting with `$s` (or `_$s` at Mach-O boundaries) as Swift symbols, alongside the legacy `_Tt` check, which is unchanged. Modern manglings land in the existing `other` bucket, since the class/struct/enum/protocol/extension prefixes only describe the legacy `_Tt` families. C, ObjC, and C++-style names are still excluded. Verification: - New Vitest cases assert `$s4main4PairVMa`, `$s4main6ScorerVMa`, and `_$s4main4PairVMa` are counted in `other` and deduplicated, and that non-Swift names stay out: ``` ✓ src/domain/symbolAnalysis.test.ts (6 tests) 10ms Test Files 1 passed (1) Tests 6 passed (6) ``` - `npm run check:fast`: typecheck + lint green. - `npm run verify:test-discovery`: 661 test files discovered exactly once. - Affected suites (tool contracts, enhanced-tools input validation and MCP boundary): all green. Real Ghidra verification was not possible in this environment: the issue's reproduction needs a Swift toolchain, Ghidra 12, and a macOS host, so verification is at the classifier level only. Fixes #1187. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-17 21:09:29 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#2721
No description provided.