Skip to content

fix(managed): pair same-named nested types by their enclosing types - #3079

Merged
N0zoM1z0 merged 9 commits into
morluto:mainfrom
8rulerstar:fix/nested-type-identity
Oct 14, 2026
Merged

N0zoM1z0 merged 9 commits into
morluto:mainfrom
8rulerstar:fix/nested-type-identity

Conversation

@8rulerstar

@8rulerstar 8rulerstar commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fix compare_managed_members confusing same-named nested types in different enclosing types. When A.Inner.M and B.Inner.M swap their bodies, both methods now remain paired with their own enclosing type and report changed, including when callers select only Inner.

Original fix by @8rulerstar; follow-up review integrates #3059's shared metadata/signature owners and latest main ca1b2f860.

Problem and expected behavior

Two compiled .NET 10 libraries contain A.Inner.M() => 1 and B.Inner.M() => 2; the second swaps the return values. The affected main reports changed: 0. The original PR fixes full inventories but still cross-pairs selected Inner inventories.

Actual SDK MCP result on head b2ff7a81f:

{"M":[{"left":"0x06000003","right":"0x06000003","status":"changed"},{"left":"0x06000005","right":"0x06000005","status":"changed"}],"summary":{"unchanged":2,"changed":2,"added":0,"removed":0,"unknown":0}}

Both methods report cil and opcode-shape differences. No linked issue: this defect was reproduced while reviewing the existing comparison.

Change and scope

  • Reuse the NestedClass reader and cached type-name digest owner; remove the duplicate reader and comparison-layer enclosing-path walker.
  • Retain one fixed-size nominal name digest per returned TypeDef before selection discards its enclosing types. Matching consumes parsed identity facts independently of display labels.
  • Validate TypeDef visibility against NestedClass applicability in the shared digest owner. Missing/contradictory parents produce null identity and one offset-backed issue; selected-child coverage includes parent errors discovered during naming.
  • Preserve unresolved current ownership through declared matching, remap ambiguity and one-sided absence. Historical bare-name compatibility cannot repair a known current identity gap.

Contribution scope decision: not applicable; existing offline analysis, with no new provider or target execution/mutation authority.

Contract and boundary impact

  • Owner: managed PE parsing produces identity; shared CLI/MCP comparison and retained views consume it.
  • Additive fields: types[].enclosing_type_token and name_sha256 default null. nesting_read defaults null for historical Evidence, false for incomplete current rows, true for fully read/index-valid rows; individual names can still be unresolved.
  • Summary/pages retain these facts. Inputs, comparison shape, caller selection, display names and provenance remain preserved. Generated catalogs/build outputs are excluded.
  • Nominal name equality does not establish assembly identity or CLR binding. Historical Evidence retains an explicitly limited bare-name mode.

Expected effects:

  • Read existing files or captured data.

Evidence and regression coverage

  • Selected-parent omission, malformed-current nesting and current enclosing-cycle regressions fail on integrated original 717a249a3 and pass with the follow-up.

  • Greptile P1 reproduced on 412a37ba6: 8 regressions fail, including all six nested visibility values, a contradictory parent omitted by selection, and a false unchanged pair against a genuine top-level type. Fixed in 2b85b22d1; coherent PE fixtures preserve the existing nested-signature assertions.

  • Final review reproduced an additional false unchanged claim when historical Evidence meets a current cycle, in both directions on 3fafe0f27; both regressions pass after 2e5bae9b1.

  • Actual pinned SDK MCP reproduces selected cross-pairing on 717a249a3, then verifies the result above on b2ff7a81f. Microsoft's .NET 8/10 System.Collections.Immutable.dll also passes summary, one-type/one-method retained pages and repeated calls. Target SHA-256 remains unchanged; clients, servers and sessions close.

  • Malformed metadata uses authored PE fixtures. Runtime verification is Linux only; no native-provider or Windows/macOS runtime claim.

  • Full .NET 8/10 CoreLib inspection remains unverified: baseline 00ce07d2c and follow-up 3fafe0f27 hit the same existing 64 MiB representation boundary. Actual summary/pages preserve resource-limit, partial metadata and uncertainty; zero returned rows do not establish absence. Product budgets were not relaxed.

  • Observations, derivations and unknowns remain distinguishable.

  • Source identity/provenance and failed attempts remain preserved.

  • Unsupported and incomplete outcomes remain visible.

Validation performed

  • 457 passed / 27 files after the P1 fix and coherent fixture correction. Latest main refresh is sigrok performance experiments only; final static/docs/real SDK checks bind b2ff7a81f.
  • npm run check: passed on final head (types, lint, format, unused code, metadata, architecture guards). npm run docs:check: passed after the compatibility fix, including 5 consistency tests. git diff --check: clean.
  • Real nested SDK workflow: first inspection 5,729 ms including initialization, second 15 ms, comparison 26 ms; peak RSS 638 MiB. Official DLL workflow: warm one-row pages 4–6 ms; peak 674 MiB.
  • Two CPUs, 8 GiB process-family RSS guard: final broad tests peak 2.22 GiB; final cold static/build checks peak 6.36 GiB. No guard stop or OOM. CoreLib's explicit capacity-failure workflow peaked at 926 MiB.

These are single observed trials, not statistical speedup claims. Identity computation reuses per-row/operand caches, caps depth at 64 and reserves representation budget before projection. Summary and explicit pages bound returned context while retaining full source Evidence locally.

Compatibility, safety, and release

No input migration/dependency change. Unresolved current ownership now remains unknown even for a singleton matching payload. Historical comparison limitations are explicit. REA does not load or execute target assemblies.

Author readiness

Human owner: @N0zoM1z0

  • 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 with one focused outcome.
  • Material scope/authority questions are resolved; no new capability approval applies.
  • The title follows type(scope): outcome; the reason for no linked issue is stated.
  • Tests cover changed behavior and meaningful failure paths.
  • Owning docs/contracts are updated; representative output is above.
  • Final diff checked for secrets, unrelated cleanup and unsupported claims.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@greptile-apps

greptile-apps Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the previous missing-parent defect is fixed and no new actionable issues were found.

Summary

This PR pairs same-named nested members using their enclosing types rather than display names.

  • Managed types keep their enclosing identity when callers select them.
  • Comparisons pair same-named nested members by their enclosing types.

The full PR diff was reviewed because the previous and current heads have different merge bases with the supplied target commit. Security checks found no new actionable issue. Tests were inspected, not run. The supersession check could not be completed because GitHub authentication was unavailable.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[TypeDef and NestedClass rows] --> B[Cached type-name digests]
  B --> C[Selected type inventory]
  C --> D{Owner identity known?}
  D -->|Yes| E[Pair by declared type and member]
  D -->|No| F[Keep result unknown]
  E --> G[Compare signatures and bodies]
Loading

Reviews (6) · Last reviewed commit: "chore: sync managed identity follow-up w..." · Reviewed by Greptile

@8rulerstar
8rulerstar force-pushed the fix/nested-type-identity branch from a7f062b to a05e896 Compare October 14, 2026 05:06
@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Oct 14, 2026
N0zoM1z0 and others added 3 commits October 14, 2026 13:22
Reuse the NestedClass owner from morluto#3059 and retain resolved signature comparison and shared member-list facts.

Co-authored-by: Kaoru0822 <[email protected]>
…ries

Share bounded type-name digests between signatures and TypeDef observations, admit projected records before allocation, and preserve current identity gaps instead of returning to bare display names. Use owned identity consistently through matching, contention and absence checks, retain historical comparison limits, and keep omitted display labels independent of known identity.

Co-authored-by: Kaoru0822 <[email protected]>
@N0zoM1z0
N0zoM1z0 marked this pull request as draft October 14, 2026 14:19
@N0zoM1z0

Copy link
Copy Markdown
Collaborator

@greptileai review this draft at head 3fafe0f2717f3b7e476342d1179c5a4e14c881d1 against main 6060de329.

Please check the complete current diff, especially source-owned nested identity when selection omits enclosing types, unknown ownership through matching/absence, and shared parser/digest ownership after #3059. The updated PR body records the executed tests, real SDK evidence, resource measurements and remaining verification gaps.

N0zoM1z0 and others added 2 commits October 14, 2026 14:35
Preserve unresolved current enclosing-name facts before choosing the limited historical bare-name mode. Regress both directions with a parsed cyclic PE fixture; neither may report unchanged.

Co-authored-by: Kaoru0822 <[email protected]>
@N0zoM1z0

Copy link
Copy Markdown
Collaborator

@greptileai review this draft at its current head 412a37ba60af1a2d5fc75f7d38eb5d10eb14aa5e against latest main 0f55f247c.

The prior head is superseded. Final review additionally fixed a reproduced historical/current identity boundary in 2e5bae9b1: historical compatibility cannot hide an observed current enclosing-cycle gap. Please review the complete current diff and the updated test/real SDK evidence in the PR body.

Comment thread src/dotnet/ManagedMemberInspector.ts Resolved
@N0zoM1z0

Copy link
Copy Markdown
Collaborator

Recording the human owner's explicit declaration: @N0zoM1z0 accepts responsibility for the complete PR, has reviewed the final diff and relevant code, has checked the evidence and meaningful gaps, and declares the PR ready for initial maintainer review. The three Author readiness items are filled at the owner's direction.

@N0zoM1z0
N0zoM1z0 marked this pull request as ready for review October 14, 2026 14:49
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

N0zoM1z0 and others added 2 commits October 14, 2026 15:01
Require TypeDef visibility and NestedClass applicability to agree before naming a type. Preserve source fields and one offset-backed issue, including errors discovered while naming a selected child after its parent is omitted. Use coherent nested/top-level PE fixtures and regress all nested visibility values and false unchanged claims.

Co-authored-by: Kaoru0822 <[email protected]>
@N0zoM1z0
N0zoM1z0 merged commit 1438422 into morluto:main Oct 14, 2026
35 of 36 checks passed
@8rulerstar
8rulerstar deleted the fix/nested-type-identity branch October 17, 2026 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants