Skip to content

fix(swift): classify private nested types by their own kind - #10085

Merged
morluto merged 3 commits into
morluto:mainfrom
BeqaKs:fix/swift-private-nested-category-7501
Nov 11, 2026
Merged

morluto merged 3 commits into
morluto:mainfrom
BeqaKs:fix/swift-private-nested-category-7501

Conversation

@BeqaKs

@BeqaKs BeqaKs commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #7501

analyze_swift_types files members of a private nested enum, struct, or class under the enclosing type. swiftc places a <length>_<hex>LL file discriminator between the nested name and its own nominal kind, and the classifier was reading that length as the kind.

Problem and expected behavior

  • Trigger: a Swift mangling such as _$s4main8EnvelopeV5State33_06D5FEE0226E625B433890B34489ED31LLO8describeSSyF (Envelope.State.describe, private nested enum).
  • Prior behavior: the discriminator's decimal length was parsed as an identifier, the following L was not a nominal marker, and the member kept the enclosing struct category.
  • Expected: the kind after LL selects the category (O enum, V struct, C class). A private method on the enclosing type stays in that type's category. A length-prefixed identifier that does not start with _ is not treated as this discriminator.

Change and scope

classifySwiftSymbol skips a file discriminator (<length>_<hex>LL) before reading the nominal marker. Zero-prefixed identifiers, substituted contexts, and symbols without this discriminator are unchanged.

Closed #7518 attempted the same correction but was closed because its branch replayed unrelated history. This branch contains only the classifier change and its regression.

Contribution scope: ordinary classification fix inside the existing Swift symbol decoder. Maintainer scope decision: not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: classifySwiftSymbol in the domain layer, before CLI/MCP category projection. Symbol strings and procedure identity are unchanged.
  • Contribution scope fit and linked maintainer decision: not applicable.
  • CLI and MCP/tool-catalog contract: none. analyze_swift_types keeps the same inputs and category names; affected symbols move between existing categories.
  • Provider, bridge, target-format, or platform compatibility: none. The decoder does not depend on a provider.
  • Evidence, artifact, provenance, or reconstruction contract: category is still derived from the mangled name. Undecoded symbols stay unresolved.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none.

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

No new target interaction. The change only reclassifies symbol strings already passed to the Swift category decoder.

Evidence and regression coverage

  • Tests added or updated: src/domain/symbolAnalysis.test.ts covers a private nested enum, struct, and class, a private method that stays on the enclosing struct, and a non-discriminator LL that stays on the enclosing class. The private enum is absent from the structs filter.
  • Base reproduction or other evidence: on upstream/main at 37d2d207d, with only the new test applied, npm run test:focused -- src/domain/symbolAnalysis.test.ts failed that case (enums filter total 0). With this change the same file passes, 23 tests.
  • User-visible CLI/MCP output (if applicable): analyze_swift_types reports those members under the nested type's category instead of the enclosing type's.
  • Remaining proof gaps: no swiftc or Ghidra run. The regression uses the mangling shape from [Bug] analyze_swift_types files members of private nested types under the enclosing type's category #7501, not a rebuilt binary.

Boundary regressions: category projection from an already decoded mangled name. Lifecycle regressions: not applicable.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

Node v24.22.1, Linux:

  • npm run test:focused -- src/domain/symbolAnalysis.test.ts on the base classifier — 1 failed, 22 passed (private nested enum not classified as enums)
  • npm run test:focused -- src/domain/symbolAnalysis.test.ts — 23 passed
  • npm run test:focused -- tests/boundary/mcp/enhancedTools.swiftTypes.test.ts — 10 passed
  • npm run check:fast — typecheck and lint passed
  • npm run verify:test-discovery — discovered all 3408 test files exactly once
  • oxfmt --check on the two edited files — passed

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Calls and schemas are unchanged. Private nested members that were previously counted with the enclosing type are now counted with their own kind.
  • Real Hopper/Ghidra, browser, or OS coverage: none. Domain classification only; the existing Swift MCP boundary tests passed.
  • Package or release metadata impact: none
  • Security, privacy, process, or containment review: none

Author readiness

Human owner: @BeqaKs

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

Maintainer integration validation

Integrated main 6b2f9918088c02ea00efc417051362f260d1cee2, including the CI lifecycle repair. Feature diff unchanged; current head a98778dc14d1ab0037aa180c16e01b4d63f9e019. Combined validation of #10138, #10085 and #10044 on this main: 222 passed, 1 host-ELF skip across 15 parser/service/filesystem/CLI/MCP suites; typecheck and lint passed. The CI repair separately passed 373 tests with 3 host-specific skips. Local macOS Node 24.22.1; fresh hosted CI pending. No Windows loader verification is claimed.

Skip swiftc's file discriminator before the nominal marker so a private
nested enum, struct, or class is not filed under its enclosing type.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T23:46:04.869965Z a98778d New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

The original workflow runs stayed queued while later runs on other
pull requests completed.
@morluto
morluto merged commit 9cffd5a into morluto:main Nov 11, 2026
4 of 6 checks passed
@morluto morluto mentioned this pull request Nov 12, 2026
3 tasks done
@morluto morluto added the bug Something isn't working label Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] analyze_swift_types files members of private nested types under the enclosing type's category

2 participants