[PR #2075] [MERGED] fix(managed): classify ReadyToRun images without ILONLY as modern .NET #5007

Closed
opened 2026-10-31 00:57:57 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/2075
Author: @TonyWu2333
Created: 10/12/2026
Status: ✅ Merged
Merged: 10/13/2026
Merged by: @morluto

Base: main ← Head: fix/managed-readytorun-classification


📝 Commits (3)

  • 4a459da fix(managed): classify ReadyToRun images without ILONLY as modern .NET
  • df03377 fix(managed): share ReadyToRun classification with partial metadata reports
  • acaa88f test(managed): exhaust capacity through inspected assembly references

📊 Changes

2 files changed (+71 additions, -4 deletions)

View changed files

📝 src/dotnet/ManagedArtifactInspector.test.ts (+57 -0)
📝 src/dotnet/ManagedArtifactInspector.ts (+14 -4)

📄 Description

Summary

inspect_managed_artifact misclassifies real ReadyToRun assemblies as C++/CLI mixed-mode images. crossgen2 clears COMIMAGE_FLAGS_ILONLY (and sets COMIMAGE_FLAGS_IL_LIBRARY) on ReadyToRun output. The classifier checks the clear ILONLY flag before the ReadyToRun signature, so every crossgen2 image reports:

  • runtime_family: "mixed-clr-native" with cli-il-only-clear evidence
  • implementation: "cpp-cli-mixed"

As a result, cil-and-ready-to-run is unreachable for actual crossgen2 output. The existing ReadyToRun fixtures pass because they keep the fixture default cliFlags: 1 (ILONLY set).

No linked issue: I found this while running the managed inspectors over the .NET 8 SDK (8.0.425, osx-arm64) on macOS.

Problem and expected behavior

Before, for shared/Microsoft.NETCore.App/8.0.31/Microsoft.CSharp.dll (CLI flags 0xc = IL_LIBRARY | STRONGNAMESIGNED, ReadyToRun signature present):

{"runtime_family":"mixed-clr-native","implementation":"cpp-cli-mixed","managed_architecture":"arm64","evidence":["cli-header-observed","cli-il-only-clear","managed-architecture-derived"]}

After:

{"runtime_family":"modern-dotnet","implementation":"cil-and-ready-to-run","managed_architecture":"arm64","evidence":["cli-header-observed","ready-to-run-signature-observed","managed-architecture-derived"]}

Across the 595 uniquely named DLLs in that SDK, all 330 ReadyToRun images had the first classification; they now have the second. The IL-only and metadata-only assemblies are unchanged.

A C++/CLI image has no ReadyToRun header, so the ReadyToRun signature can safely take precedence over the ILONLY flag.

Change and scope

  • implementationFor checks the ReadyToRun signature before the ILONLY flag.
  • runtimeFamilyFor takes the mixed-clr-native branch only when ILONLY is clear and there is no ReadyToRun signature. ReadyToRun images then reach the existing ready-to-run-signature-observed / modern-dotnet branch.
  • managed_architecture derivation and the native-boundary inspector are unchanged. (mixed_mode_or_native_header already reports true for a native header.)

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/dotnet/ManagedArtifactInspector.ts classification
  • CLI and MCP/tool-catalog contract: no schema change. Classification values change for ReadyToRun images with ILONLY clear.
  • Provider, bridge, target-format, or platform compatibility: none
  • Evidence, artifact, provenance, or reconstruction contract: classification evidence for those images now cites the ReadyToRun signature instead of cli-il-only-clear
  • Process execution, authorization, cleanup, or containment impact: none
  • Generated metadata, package, or installation impact: none

Evidence and regression coverage

  • Tests added or updated: src/dotnet/ManagedArtifactInspector.test.ts adds "managed implementation classification":

    • a ReadyToRun fixture with crossgen2's cliFlags: 0xc classifies as modern-dotnet / cil-and-ready-to-run without cli-il-only-clear evidence
    • a fixture with ILONLY clear and no ReadyToRun signature still classifies as mixed-clr-native / cpp-cli-mixed
  • Base reproduction or other evidence: the ReadyToRun case fails on d864ad5 and passes with this change. The SDK scan results above were run before and after.

  • User-visible CLI/MCP output: shown above (rea inspect-managed-artifact <Microsoft.CSharp.dll> --format json)

  • Remaining proof gaps: I have no real C++/CLI assembly on this host. The mixed-mode branch is covered by the fixture only.

  • 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

  • npx vitest run src/dotnet: 185 passed
  • npx vitest run tests/acceptance/managedCliOutput.test.ts: 5 passed
  • npm run check:fast: passed
  • npx oxfmt --check on the changed files: clean
  • Direct scan of inspectManagedArtifactBytes / inspectManagedMembersBytes / inspectManagedNativeBoundariesBytes over the SDK's 595 unique DLLs: no exceptions, and the classification counts described above

Compatibility, safety, and release

  • Breaking changes or migration steps: callers that relied on cpp-cli-mixed / mixed-clr-native for ReadyToRun assemblies now get cil-and-ready-to-run / modern-dotnet, which is the documented value for those images
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable (static PE/CLI parsing). Verified against .NET 8.0.425 osx-arm64 SDK assemblies.
  • Package or release metadata impact: none
  • Security, privacy, process, or containment review: none

Review checklist

  • This PR addresses a concrete problem or an agreed enhancement.
  • 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.

🔄 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/2075 **Author:** [@TonyWu2333](https://github.com/TonyWu2333) **Created:** 10/12/2026 **Status:** ✅ Merged **Merged:** 10/13/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/managed-readytorun-classification` --- ### 📝 Commits (3) - [`4a459da`](https://github.com/morluto/rea/commit/4a459da669d9453541c9d3dc9f5271e5238b3dd6) fix(managed): classify ReadyToRun images without ILONLY as modern .NET - [`df03377`](https://github.com/morluto/rea/commit/df03377341b87986aa0cc8ccccd88afacef0a6dd) fix(managed): share ReadyToRun classification with partial metadata reports - [`acaa88f`](https://github.com/morluto/rea/commit/acaa88fbab714cb4a54ce4c188e86a2116652ff4) test(managed): exhaust capacity through inspected assembly references ### 📊 Changes **2 files changed** (+71 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `src/dotnet/ManagedArtifactInspector.test.ts` (+57 -0) 📝 `src/dotnet/ManagedArtifactInspector.ts` (+14 -4) </details> ### 📄 Description ## Summary `inspect_managed_artifact` misclassifies real ReadyToRun assemblies as C++/CLI mixed-mode images. crossgen2 clears `COMIMAGE_FLAGS_ILONLY` (and sets `COMIMAGE_FLAGS_IL_LIBRARY`) on ReadyToRun output. The classifier checks the clear ILONLY flag before the ReadyToRun signature, so every crossgen2 image reports: - `runtime_family: "mixed-clr-native"` with `cli-il-only-clear` evidence - `implementation: "cpp-cli-mixed"` As a result, `cil-and-ready-to-run` is unreachable for actual crossgen2 output. The existing ReadyToRun fixtures pass because they keep the fixture default `cliFlags: 1` (ILONLY set). No linked issue: I found this while running the managed inspectors over the .NET 8 SDK (8.0.425, osx-arm64) on macOS. ## Problem and expected behavior Before, for `shared/Microsoft.NETCore.App/8.0.31/Microsoft.CSharp.dll` (CLI flags `0xc` = IL_LIBRARY | STRONGNAMESIGNED, ReadyToRun signature present): ```json {"runtime_family":"mixed-clr-native","implementation":"cpp-cli-mixed","managed_architecture":"arm64","evidence":["cli-header-observed","cli-il-only-clear","managed-architecture-derived"]} ``` After: ```json {"runtime_family":"modern-dotnet","implementation":"cil-and-ready-to-run","managed_architecture":"arm64","evidence":["cli-header-observed","ready-to-run-signature-observed","managed-architecture-derived"]} ``` Across the 595 uniquely named DLLs in that SDK, all 330 ReadyToRun images had the first classification; they now have the second. The IL-only and metadata-only assemblies are unchanged. A C++/CLI image has no ReadyToRun header, so the ReadyToRun signature can safely take precedence over the ILONLY flag. ## Change and scope - `implementationFor` checks the ReadyToRun signature before the ILONLY flag. - `runtimeFamilyFor` takes the `mixed-clr-native` branch only when ILONLY is clear and there is no ReadyToRun signature. ReadyToRun images then reach the existing `ready-to-run-signature-observed` / `modern-dotnet` branch. - `managed_architecture` derivation and the native-boundary inspector are unchanged. (`mixed_mode_or_native_header` already reports `true` for a native header.) ## Contract and boundary impact - Semantic owner and earliest changed stage: `src/dotnet/ManagedArtifactInspector.ts` classification - CLI and MCP/tool-catalog contract: no schema change. Classification values change for ReadyToRun images with ILONLY clear. - Provider, bridge, target-format, or platform compatibility: none - Evidence, artifact, provenance, or reconstruction contract: classification evidence for those images now cites the ReadyToRun signature instead of `cli-il-only-clear` - Process execution, authorization, cleanup, or containment impact: none - Generated metadata, package, or installation impact: none ## Evidence and regression coverage - Tests added or updated: `src/dotnet/ManagedArtifactInspector.test.ts` adds "managed implementation classification": - a ReadyToRun fixture with crossgen2's `cliFlags: 0xc` classifies as `modern-dotnet` / `cil-and-ready-to-run` without `cli-il-only-clear` evidence - a fixture with ILONLY clear and no ReadyToRun signature still classifies as `mixed-clr-native` / `cpp-cli-mixed` - Base reproduction or other evidence: the ReadyToRun case fails on `d864ad5` and passes with this change. The SDK scan results above were run before and after. - User-visible CLI/MCP output: shown above (`rea inspect-managed-artifact <Microsoft.CSharp.dll> --format json`) - Remaining proof gaps: I have no real C++/CLI assembly on this host. The mixed-mode branch is covered by the fixture only. - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed - `npx vitest run src/dotnet`: 185 passed - `npx vitest run tests/acceptance/managedCliOutput.test.ts`: 5 passed - `npm run check:fast`: passed - `npx oxfmt --check` on the changed files: clean - Direct scan of `inspectManagedArtifactBytes` / `inspectManagedMembersBytes` / `inspectManagedNativeBoundariesBytes` over the SDK's 595 unique DLLs: no exceptions, and the classification counts described above ## Compatibility, safety, and release - Breaking changes or migration steps: callers that relied on `cpp-cli-mixed` / `mixed-clr-native` for ReadyToRun assemblies now get `cil-and-ready-to-run` / `modern-dotnet`, which is the documented value for those images - Real Hopper/Ghidra, browser, or OS coverage: not applicable (static PE/CLI parsing). Verified against .NET 8.0.425 osx-arm64 SDK assemblies. - Package or release metadata impact: none - Security, privacy, process, or containment review: none ## Review checklist - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [x] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 00:57:57 +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#5007
No description provided.