Skip to content

fix(managed): classify ReadyToRun images without ILONLY as modern .NET - #2075

Merged
morluto merged 3 commits into
morluto:mainfrom
TonyWu2333:fix/managed-readytorun-classification
Oct 13, 2026
Merged

morluto merged 3 commits into
morluto:mainfrom
TonyWu2333:fix/managed-readytorun-classification

Conversation

@TonyWu2333

Copy link
Copy Markdown
Contributor

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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-12T06:37:02.685000Z fe408fd PR opened
ℹ️ 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.

crossgen2 clears COMIMAGE_FLAGS_ILONLY and sets IL_LIBRARY on ReadyToRun output. inspect_managed_artifact checked the clear ILONLY flag before the ReadyToRun signature, so real ReadyToRun assemblies were reported as runtime_family mixed-clr-native and implementation cpp-cli-mixed, and cil-and-ready-to-run was unreachable for crossgen2 output. Check the ReadyToRun signature first; a clear ILONLY flag without it still reports mixed CLR/native code.
@TonyWu2333
TonyWu2333 force-pushed the fix/managed-readytorun-classification branch from fe408fd to 4a459da Compare October 13, 2026 02:01
@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

@greptileai review

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the previous capacity-test failure is addressed.

Summary

ReadyToRun images with ILONLY clear now receive the intended .NET classification.

  • ReadyToRun images with a clear ILONLY flag get their own classification.

Reviews (3) · Last reviewed commit: "test(managed): exhaust capacity through ..." · Reviewed by Greptile

Comment thread src/dotnet/ManagedArtifactInspector.ts Resolved
@morluto
morluto merged commit cdc41fc into morluto:main Oct 13, 2026
3 checks passed
@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Review findings addressed at their producing boundaries and consumers. Latest changes were reviewed from source; tests and provider runs were skipped at the maintainer's request. Findings requiring separate decisions or verification remain open.

  1. thread 1

Source changes are on acaa88f. Complete and partial metadata paths share the header-owned ReadyToRun/mixed-runtime classification, so ILONLY-clear ReadyToRun images remain modern .NET after a capacity failure. The capacity regression now enlarges an assembly-reference name that inspectManagedArtifactBytes actually decodes, replacing the unread field-name fixture; the intended fallback and assertion are source-grounded but unexecuted.

Source inspection and git diff checks completed. Tests, typecheck/lint, generated-schema checks and real-provider lanes were not run for this final revision at the user's explicit request.

@morluto morluto added bug Something isn't working area: domain Domain logic, errors, and pure functions labels Oct 14, 2026
rjvaleo pushed a commit to rjvaleo/rea that referenced this pull request Dec 1, 2026
morluto#2075)

* fix(managed): classify ReadyToRun images without ILONLY as modern .NET

crossgen2 clears COMIMAGE_FLAGS_ILONLY and sets IL_LIBRARY on ReadyToRun output. inspect_managed_artifact checked the clear ILONLY flag before the ReadyToRun signature, so real ReadyToRun assemblies were reported as runtime_family mixed-clr-native and implementation cpp-cli-mixed, and cil-and-ready-to-run was unreachable for crossgen2 output. Check the ReadyToRun signature first; a clear ILONLY flag without it still reports mixed CLR/native code.

* test(managed): exhaust capacity through inspected assembly references

---------

Co-authored-by: morluto <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: domain Domain logic, errors, and pure functions bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants