[PR #4076] [CLOSED] fix(managed): keep runtime-provided methods out of unresolved native bodies #6040

Closed
opened 2026-10-31 01:11:23 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/4076
Author: @Rinkia
Created: 10/15/2026
Status: ❌ Closed

Base: main ← Head: fix/managed-native-runtime-provided


📝 Commits (3)

  • 702ff6b fix(managed): keep runtime-provided methods out of unresolved native bodies
  • d4e0a63 Merge branch 'main' of https://github.com/morluto/rea into fix/managed-native-runtime-provided
  • f0cfba1 Merge remote-tracking branch 'upstream/main' into fix/managed-native-runtime-provided

📊 Changes

2 files changed (+61 additions, -1 deletions)

View changed files

📝 src/domain/managed/managedNativeVerificationMatch.ts (+4 -1)
📝 tests/conformance/providers/managed/managedNativeVerification.test.ts (+57 -0)

📄 Description

Summary

verify_managed_native_boundaries reported every non-P/Invoke row of native_implementations as native_body_unresolved. That included methods the CLR supplies at run time (boundary_kind: "runtime-provided", MethodImplAttributes code type Runtime), which is what every delegate's .ctor, Invoke, BeginInvoke and EndInvoke carry. Those methods have no native body for bridge evidence to map, so they could never resolve. The count now leaves them out. Fixes #4055.

Problem and expected behavior

Smallest trigger: a managed assembly with one verified P/Invoke and one delegate. Before, the summary gave verified: 1, native_body_unresolved: 1, and the reason pointed at "C++/CLI, ReadyToRun, and native-body mappings". Over MCP, native_body_unresolved > 0 also records the "unresolved or contradicted boundaries" unknown (verifyManagedNativeBoundaries.ts:85), so a fully verified P/Invoke surface still left an unknown open.

Real data from #4055: LibGit2Sharp 0.31.0 (lib/net8.0) gave native_body_unresolved: 356, which is 89 delegates × 4 runtime methods. The assembly is IL-only, not ReadyToRun or mixed-mode.

Expected: native_body_unresolved counts only rows that can have a native body to map (native-body, unmanaged-method, mixed-or-unknown).

Change and scope

  • src/domain/managed/managedNativeVerificationMatch.ts: the unresolved-native-body filter also excludes runtime-provided, next to pinvoke. A short comment explains why.
  • tests/conformance/providers/managed/managedNativeVerification.test.ts: a regression test with one verified P/Invoke, one runtime-provided Invoke and one native-body row. It expects native_body_unresolved: 1, i.e. the native-body row still counts.

Not included:

  • No new result field. Runtime-provided rows stay listed in the boundary inspection; the verification summary just stops calling them unresolved native bodies. A separate runtime_provided count could be added if maintainers want it in the verification result.
  • No change to inspect_managed_native_boundaries, whose native_implementation_count still includes these rows, correctly labelled.

Follow the contribution scope.
Scope decision: not applicable (bug fix within the existing static, read-only workflow).

Contract and boundary impact

  • Semantic owner and earliest changed stage: buildVerificationResult in managedNativeVerificationMatch.ts (summary count only).
  • Contribution scope fit and linked maintainer decision: not applicable; bug fix for #4055.
  • CLI and MCP/tool-catalog contract: schema unchanged. native_body_unresolved and native_implementations.unresolved are lower for assemblies with runtime-provided methods. The MCP unknown is no longer raised by runtime-provided rows alone.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: Evidence shape unchanged; the count is more accurate.
  • 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 (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • 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.

Evidence and regression coverage

  • Tests added or updated: leaves runtime-provided methods out of unresolved native bodies (conformance, managed native verification).

  • Base reproduction or other evidence: the new test on main @ 47b4628ba without the fix fails for the expected reason:

    FAIL  tests/conformance/providers/managed/managedNativeVerification.test.ts > leaves runtime-provided methods out of unresolved native bodies
    AssertionError: expected { verified: 1, inferred: +0, …(3) } to match object { verified: 1, …(1) }
    -   "native_body_unresolved": 1,
    +   "native_body_unresolved": 2,
    Tests  1 failed | 12 passed (13)
    

    With the fix: Tests 13 passed (13).

  • User-visible CLI/MCP output (if applicable): CLI repro from #4055 (fixture built with scripts/fixtures/managed/pe.mjs, verified against synthetic function Evidence), after the fix:

    {"fixture":"pinvoke-only","implementations":["native_call:pinvoke"],"summary":{"verified":1,"inferred":0,"unresolved":0,"contradicted":0,"native_body_unresolved":0}}
    {"fixture":"pinvoke-and-runtime-method","implementations":["native_call:pinvoke","Invoke:runtime-provided"],"summary":{"verified":1,"inferred":0,"unresolved":0,"contradicted":0,"native_body_unresolved":0}}
    

    Before the fix, the second line had "native_body_unresolved":1 (#4055).

  • Remaining proof gaps: the LibGit2Sharp numbers in #4055 were measured with rea-agents@6.5.0. I didn't re-run that real-assembly case on this branch: Evidence saved from 6.5.0 is rejected by main ("Evidence semantic identifier does not match its record"), and I didn't regenerate the Ghidra native Evidence. The MCP unknown change is source-derived; I ran the CLI only.

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

Run in node:24-bookworm (Node 24.21.0) on a copy of this branch after npm ci:

  • npx vitest run tests/conformance/providers/managed/managedNativeVerification.test.ts — RED before the fix (1 failed, 12 passed), GREEN after (13 passed)
  • npx vitest run tests/conformance/providers/managed src/dotnet src/domain/managed src/application/managed tests/boundary/mcp/outputSchemaSemanticConstraints.test.ts src/contracts/workflowInputContracts.test.ts — 20 files, 370 tests passed
  • npm run check — passed (module boundaries, architecture guards)
  • npm run docs:check — passed
  • npm run build then node repro.mjs (CLI repro above) — output shown above

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Callers that treated runtime-provided rows as unresolved native bodies will see lower counts.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable (pure verification logic); see the proof gaps above.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no target interaction change.

Author readiness

Human owner: @Rinkia

  • 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.

🤖 Generated with Claude Code


🔄 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/4076 **Author:** [@Rinkia](https://github.com/Rinkia) **Created:** 10/15/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/managed-native-runtime-provided` --- ### 📝 Commits (3) - [`702ff6b`](https://github.com/morluto/rea/commit/702ff6b9bbde21b034b3c705034d28d7e7d700e8) fix(managed): keep runtime-provided methods out of unresolved native bodies - [`d4e0a63`](https://github.com/morluto/rea/commit/d4e0a63bebfeeda94f8cb8f0d03fbc3c1e301ecf) Merge branch 'main' of https://github.com/morluto/rea into fix/managed-native-runtime-provided - [`f0cfba1`](https://github.com/morluto/rea/commit/f0cfba103e8f176bbe0049008e8ebe15286c2b91) Merge remote-tracking branch 'upstream/main' into fix/managed-native-runtime-provided ### 📊 Changes **2 files changed** (+61 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `src/domain/managed/managedNativeVerificationMatch.ts` (+4 -1) 📝 `tests/conformance/providers/managed/managedNativeVerification.test.ts` (+57 -0) </details> ### 📄 Description ## Summary `verify_managed_native_boundaries` reported every non-P/Invoke row of `native_implementations` as `native_body_unresolved`. That included methods the CLR supplies at run time (`boundary_kind: "runtime-provided"`, MethodImplAttributes code type `Runtime`), which is what every delegate's `.ctor`, `Invoke`, `BeginInvoke` and `EndInvoke` carry. Those methods have no native body for bridge evidence to map, so they could never resolve. The count now leaves them out. Fixes #4055. ## Problem and expected behavior Smallest trigger: a managed assembly with one verified P/Invoke and one delegate. Before, the summary gave `verified: 1, native_body_unresolved: 1`, and the reason pointed at "C++/CLI, ReadyToRun, and native-body mappings". Over MCP, `native_body_unresolved > 0` also records the "unresolved or contradicted boundaries" unknown (`verifyManagedNativeBoundaries.ts:85`), so a fully verified P/Invoke surface still left an unknown open. Real data from #4055: LibGit2Sharp 0.31.0 (`lib/net8.0`) gave `native_body_unresolved: 356`, which is 89 delegates × 4 runtime methods. The assembly is IL-only, not ReadyToRun or mixed-mode. Expected: `native_body_unresolved` counts only rows that can have a native body to map (`native-body`, `unmanaged-method`, `mixed-or-unknown`). ## Change and scope - `src/domain/managed/managedNativeVerificationMatch.ts`: the unresolved-native-body filter also excludes `runtime-provided`, next to `pinvoke`. A short comment explains why. - `tests/conformance/providers/managed/managedNativeVerification.test.ts`: a regression test with one verified P/Invoke, one runtime-provided `Invoke` and one `native-body` row. It expects `native_body_unresolved: 1`, i.e. the native-body row still counts. Not included: - No new result field. Runtime-provided rows stay listed in the boundary inspection; the verification summary just stops calling them unresolved native bodies. A separate `runtime_provided` count could be added if maintainers want it in the verification result. - No change to `inspect_managed_native_boundaries`, whose `native_implementation_count` still includes these rows, correctly labelled. Follow the [contribution scope](https://github.com/morluto/rea/blob/main/CONTRIBUTING.md#contribution-scope). Scope decision: not applicable (bug fix within the existing static, read-only workflow). ## Contract and boundary impact - Semantic owner and earliest changed stage: `buildVerificationResult` in `managedNativeVerificationMatch.ts` (summary count only). - Contribution scope fit and linked maintainer decision: not applicable; bug fix for #4055. - CLI and MCP/tool-catalog contract: schema unchanged. `native_body_unresolved` and `native_implementations.unresolved` are lower for assemblies with runtime-provided methods. The MCP unknown is no longer raised by runtime-provided rows alone. - Provider, bridge, target-format, or platform compatibility: none. - Evidence, artifact, provenance, or reconstruction contract: Evidence shape unchanged; the count is more accurate. - 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 (check known effects; use documentation-only on its own). Unchecked items do not establish absence; leave uncertainties visible. - [x] 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. ## Evidence and regression coverage - Tests added or updated: `leaves runtime-provided methods out of unresolved native bodies` (conformance, managed native verification). - Base reproduction or other evidence: the new test on `main` @ `47b4628ba` without the fix fails for the expected reason: ```text FAIL tests/conformance/providers/managed/managedNativeVerification.test.ts > leaves runtime-provided methods out of unresolved native bodies AssertionError: expected { verified: 1, inferred: +0, …(3) } to match object { verified: 1, …(1) } - "native_body_unresolved": 1, + "native_body_unresolved": 2, Tests 1 failed | 12 passed (13) ``` With the fix: `Tests 13 passed (13)`. - User-visible CLI/MCP output (if applicable): CLI repro from #4055 (fixture built with `scripts/fixtures/managed/pe.mjs`, verified against synthetic function Evidence), after the fix: ```text {"fixture":"pinvoke-only","implementations":["native_call:pinvoke"],"summary":{"verified":1,"inferred":0,"unresolved":0,"contradicted":0,"native_body_unresolved":0}} {"fixture":"pinvoke-and-runtime-method","implementations":["native_call:pinvoke","Invoke:runtime-provided"],"summary":{"verified":1,"inferred":0,"unresolved":0,"contradicted":0,"native_body_unresolved":0}} ``` Before the fix, the second line had `"native_body_unresolved":1` (#4055). - Remaining proof gaps: the LibGit2Sharp numbers in #4055 were measured with `rea-agents@6.5.0`. I didn't re-run that real-assembly case on this branch: Evidence saved from 6.5.0 is rejected by `main` ("Evidence semantic identifier does not match its record"), and I didn't regenerate the Ghidra native Evidence. The MCP unknown change is source-derived; I ran the CLI only. For evidence-bearing changes: - [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 Run in `node:24-bookworm` (Node 24.21.0) on a copy of this branch after `npm ci`: - `npx vitest run tests/conformance/providers/managed/managedNativeVerification.test.ts` — RED before the fix (1 failed, 12 passed), GREEN after (13 passed) - `npx vitest run tests/conformance/providers/managed src/dotnet src/domain/managed src/application/managed tests/boundary/mcp/outputSchemaSemanticConstraints.test.ts src/contracts/workflowInputContracts.test.ts` — 20 files, 370 tests passed - `npm run check` — passed (module boundaries, architecture guards) - `npm run docs:check` — passed - `npm run build` then `node repro.mjs` (CLI repro above) — output shown above ## Compatibility, safety, and release - Breaking changes or migration steps: none. Callers that treated runtime-provided rows as unresolved native bodies will see lower counts. - Real Hopper/Ghidra, browser, or OS coverage: not applicable (pure verification logic); see the proof gaps above. - Package or release metadata impact: none. - Security, privacy, process, or containment review: no target interaction change. ## Author readiness Human owner: @Rinkia - [ ] 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. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:11:23 +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#6040
No description provided.