[PR #1706] [MERGED] feat(managed): select declaring types in inspect_managed_members #4768

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

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/1706
Author: @skoodster
Created: 10/11/2026
Status: ✅ Merged
Merged: 10/12/2026
Merged by: @N0zoM1z0

Base: main ← Head: feat/managed-member-type-selection


📝 Commits (10+)

  • 1fa6d35 feat(managed): select declaring types in inspect_managed_members
  • 5188383 fix(managed): keep type-selected inspections out of complete inventories
  • dfa756b fix(managed): charge the TypeDef index per retained start; flag unreadable names
  • d594052 fix(managed): pair compared members only within mutually observed types
  • f1983ed fix(managed): state a shared selection in comparisons; nested names in CLI help
  • 81b4b1a fix(managed): report a graph's selected scope apart from partial coverage
  • 5662258 chore: sync main into managed type selection
  • 23d529b chore: sync current native and MCP contracts into managed selection
  • ccaf1aa fix(managed): preserve selection contracts through SDK conversion
  • f6425a3 test(managed): cover invalid attribute constructors together

📊 Changes

21 files changed (+646 additions, -91 deletions)

View changed files

📝 docs/managed-code-analysis.md (+28 -0)
📝 src/application/DirectAnalysis.ts (+8 -3)
📝 src/cli/managedCommands.ts (+15 -2)
📝 src/contracts/managed/managedToolContracts.ts (+31 -2)
📝 src/contracts/managed/managedWorkflowExamples.ts (+1 -0)
📝 src/domain/managed/managedApplicationGraph.ts (+5 -0)
📝 src/domain/managed/managedApplicationGraphCoverage.ts (+12 -5)
📝 src/domain/managed/managedArtifact.ts (+8 -0)
📝 src/domain/managed/managedMemberComparison.ts (+7 -0)
📝 src/domain/managed/managedMemberComparisonCoverage.ts (+25 -1)
📝 src/domain/managed/managedMemberComparisonItems.ts (+33 -4)
📝 src/domain/managed/managedMemberComparisonMatch.ts (+62 -10)
📝 src/dotnet/ManagedArtifactInspector.test.ts (+48 -34)
📝 src/dotnet/ManagedMemberInspector.test.ts (+65 -0)
📝 src/dotnet/ManagedMemberInspector.ts (+70 -6)
📝 src/dotnet/ManagedMemberRows.ts (+35 -18)
📝 src/dotnet/ManagedStaticProvider.ts (+11 -4)
📝 src/server/registerManagedTools.ts (+1 -0)
📝 tests/boundary/mcp/managedMcp.test.ts (+53 -0)
📝 tests/boundary/providers/managed/managedMemberComparisonFromMetadata.test.ts (+76 -2)

...and 1 more files

📄 Description

Summary

inspect_managed_members can decode the members of exact caller-selected declaring types before expanding signatures and CIL. The optional MCP type_names input and repeatable CLI --type option allow useful inspection of large assemblies within the existing representation budget.

Refs #1878

Problem and expected behavior

Whole-assembly member expansion can reach the 64 MiB representation budget before returning useful members. Callers need to narrow decoding to known declaring types, retain the chosen names in Evidence, and distinguish selected coverage from whole-assembly observations.

Change and scope

  • Forward managed arguments through the shared application workflow, CLI and MCP adapters, then select declaring-type tokens before member signatures and bodies are decoded.
  • Report selection.type_names and selection.unmatched_type_names; preserve null when no selection is supplied and accept older Evidence without the field.
  • Retain unselected member names for edge labels. Member references and exported-type declarations remain assembly-wide inventories; output size is not guaranteed to be small.
  • Keep members outside the opposite observation's selection unknown during comparison. Prevent cross-selection remaps and mark selected application graphs partial.
  • Reuse main's existing metadata row-accounting and declaring-type lookup owner; remove the superseded duplicate index from the earlier branch.
  • Advertise the runtime uniqueness rule as uniqueItems after SDK JSON Schema conversion. Preserve readable malformed-attribute values/hashes with unknown constructor identity.

Contract and boundary impact

  • Semantic owner and earliest changed stage: managed provider member decoding selects exact declared type tokens; shared application adapters preserve caller arguments, and domain comparison/graph consumers retain selection scope.
  • CLI and MCP/tool-catalog contract: additive optional type_names and repeatable --type; output selection is null or {type_names, unmatched_type_names}. Advertised input/output schemas are validated through the actual SDK boundary.
  • Provider, bridge, target-format, or platform compatibility: static PE/CLI inspection only; no native provider or execution support changes.
  • Evidence, artifact, provenance, or reconstruction contract: caller names, artifact SHA-256/MVID, original CIL hashes, unknown names and selected coverage remain explicit. Legacy Evidence remains readable.
  • Process execution, authorization, cleanup, or containment impact: no target assembly is loaded or executed; existing read-only lifecycle and resource policy remain.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: ignored catalogs regenerate from source contracts; authored managed documentation and examples are updated. No generated output, binary or dependency additions.

Evidence and regression coverage

  • Tests added or updated: selected/unmatched types, legacy Evidence, comparison pairing and unknown absence, graph scope, actual SDK-advertised input/output validation, duplicate input rejection, malformed metadata facts and source hashes.
  • Base reproduction or other evidence: without selection, large assemblies can return unavailable coverage with the existing representation-budget reason. Managed arguments were previously discarded by the shared CLI/MCP application path.
  • User-visible CLI/MCP output: selection: {type_names: ["Example.Parser", "Missing.Type"], unmatched_type_names: ["Missing.Type"]}; only selected members are described, with explicit scope limitations.
  • Real release artifacts: two unchanged managed DLLs yielded 102 and 16 selected methods; all 118 raw CIL hashes independently matched PE-mapped original file bytes. Actual CLI/fresh stdio MCP normalized results and caller arguments matched exactly. Both selected views reported complete coverage with no resource-limit issue; unmatched-only requests retained their explicit selection.
  • Remaining proof gaps: arbitrary full-assembly workloads can still exhaust the unchanged budget. Nested names currently use reported bare names and can select multiple types. The follow-up was executed on Linux x64; other clients and providers were not verified by these runs. Reconstruction/native-runtime semantics are outside this selection proof.

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

  • Focused managed source/domain/application/MCP/provider/graph tests — 229 passed across 21 files. Final grouped malformed-attribute assertions — 20 passed.
  • Actual SDK Schema regression — duplicate selection passed the advertised schema before the follow-up and was rejected afterward, matching runtime validation.
  • node scripts/verify/managed/conformance.mjs — 11 verified controls; optional operator/decompiler-oracle scenarios remain unsupported in this environment.
  • Real public CLI/MCP selected-member replay — two DLLs, 118 independent original-CIL hash checks, exact result parity, unmatched controls, responsiveness and unchanged source digests passed. One CPU, peak approximately 1.46 GiB, zero memory-limit/OOM/OOM-kill events.
  • npm run check:ci — all eight static tasks and architecture guards passed before the final format-diagnostics main sync; CI validates the published integrated head.
  • npm run docs:check and npm run check:fast — passed after final main integration.
  • npm run verify:ghidra:mips-shared — all eight real native CLI/MCP controls passed on this final integrated head using Linux x64 Ghidra 12.1.4/JDK 21/GNU 2.40; cleanup verified with zero surviving owned descendants. Peak approximately 1.50 GiB with zero memory-limit/OOM/OOM-kill events.
  • Fresh full-capacity controls — both original DLLs returned complete artifact/native-boundary metadata without resource limits; unselected member inspection still reported the unchanged 67,108,864-byte limit. Peak approximately 0.90 GiB, zero memory-limit/OOM/OOM-kill events.

Compatibility, safety, and release

  • Breaking changes or migration steps: none; existing calls retain full inspection with selection: null, and legacy Evidence omitting selection remains readable.
  • Real Hopper/Ghidra, browser, or OS coverage: no native engine is involved; follow-up real release-artifact CLI/MCP replay on Linux x64 only.
  • Package or release metadata impact: additive authored contracts, examples and documentation; no installer/dependency changes.
  • Security, privacy, process, or containment review: no code execution or byte mutation; caller-selected names and original artifact identity are preserved. Input and representation budgets are unchanged.

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/1706 **Author:** [@skoodster](https://github.com/skoodster) **Created:** 10/11/2026 **Status:** ✅ Merged **Merged:** 10/12/2026 **Merged by:** [@N0zoM1z0](https://github.com/N0zoM1z0) **Base:** `main` ← **Head:** `feat/managed-member-type-selection` --- ### 📝 Commits (10+) - [`1fa6d35`](https://github.com/morluto/rea/commit/1fa6d3575f29b365b6e73dcbb101b7ea7a27e395) feat(managed): select declaring types in inspect_managed_members - [`5188383`](https://github.com/morluto/rea/commit/518838316483670e959d756ccc686a0f924a5ad8) fix(managed): keep type-selected inspections out of complete inventories - [`dfa756b`](https://github.com/morluto/rea/commit/dfa756b064dbe199402ba2f70a50737b65efe8dc) fix(managed): charge the TypeDef index per retained start; flag unreadable names - [`d594052`](https://github.com/morluto/rea/commit/d594052934431a9ce06d3bba0af955a340babdbe) fix(managed): pair compared members only within mutually observed types - [`f1983ed`](https://github.com/morluto/rea/commit/f1983ed2af824c7a915ff9ae76119cfdf232d966) fix(managed): state a shared selection in comparisons; nested names in CLI help - [`81b4b1a`](https://github.com/morluto/rea/commit/81b4b1a973932b5a31b5af98dc15ae63bff540ff) fix(managed): report a graph's selected scope apart from partial coverage - [`5662258`](https://github.com/morluto/rea/commit/5662258ca020af9521fd36257a3bba8d1d034061) chore: sync main into managed type selection - [`23d529b`](https://github.com/morluto/rea/commit/23d529b85dabcd085479980f4c62765f9c615541) chore: sync current native and MCP contracts into managed selection - [`ccaf1aa`](https://github.com/morluto/rea/commit/ccaf1aa41976f15a80567fe9b5028cc5744bc217) fix(managed): preserve selection contracts through SDK conversion - [`f6425a3`](https://github.com/morluto/rea/commit/f6425a38bcac5124b0fa952d46184a1dfeae2bd7) test(managed): cover invalid attribute constructors together ### 📊 Changes **21 files changed** (+646 additions, -91 deletions) <details> <summary>View changed files</summary> 📝 `docs/managed-code-analysis.md` (+28 -0) 📝 `src/application/DirectAnalysis.ts` (+8 -3) 📝 `src/cli/managedCommands.ts` (+15 -2) 📝 `src/contracts/managed/managedToolContracts.ts` (+31 -2) 📝 `src/contracts/managed/managedWorkflowExamples.ts` (+1 -0) 📝 `src/domain/managed/managedApplicationGraph.ts` (+5 -0) 📝 `src/domain/managed/managedApplicationGraphCoverage.ts` (+12 -5) 📝 `src/domain/managed/managedArtifact.ts` (+8 -0) 📝 `src/domain/managed/managedMemberComparison.ts` (+7 -0) 📝 `src/domain/managed/managedMemberComparisonCoverage.ts` (+25 -1) 📝 `src/domain/managed/managedMemberComparisonItems.ts` (+33 -4) 📝 `src/domain/managed/managedMemberComparisonMatch.ts` (+62 -10) 📝 `src/dotnet/ManagedArtifactInspector.test.ts` (+48 -34) 📝 `src/dotnet/ManagedMemberInspector.test.ts` (+65 -0) 📝 `src/dotnet/ManagedMemberInspector.ts` (+70 -6) 📝 `src/dotnet/ManagedMemberRows.ts` (+35 -18) 📝 `src/dotnet/ManagedStaticProvider.ts` (+11 -4) 📝 `src/server/registerManagedTools.ts` (+1 -0) 📝 `tests/boundary/mcp/managedMcp.test.ts` (+53 -0) 📝 `tests/boundary/providers/managed/managedMemberComparisonFromMetadata.test.ts` (+76 -2) _...and 1 more files_ </details> ### 📄 Description ## Summary `inspect_managed_members` can decode the members of exact caller-selected declaring types before expanding signatures and CIL. The optional MCP `type_names` input and repeatable CLI `--type` option allow useful inspection of large assemblies within the existing representation budget. Refs #1878 ## Problem and expected behavior Whole-assembly member expansion can reach the 64 MiB representation budget before returning useful members. Callers need to narrow decoding to known declaring types, retain the chosen names in Evidence, and distinguish selected coverage from whole-assembly observations. ## Change and scope - Forward managed arguments through the shared application workflow, CLI and MCP adapters, then select declaring-type tokens before member signatures and bodies are decoded. - Report `selection.type_names` and `selection.unmatched_type_names`; preserve null when no selection is supplied and accept older Evidence without the field. - Retain unselected member names for edge labels. Member references and exported-type declarations remain assembly-wide inventories; output size is not guaranteed to be small. - Keep members outside the opposite observation's selection unknown during comparison. Prevent cross-selection remaps and mark selected application graphs partial. - Reuse main's existing metadata row-accounting and declaring-type lookup owner; remove the superseded duplicate index from the earlier branch. - Advertise the runtime uniqueness rule as `uniqueItems` after SDK JSON Schema conversion. Preserve readable malformed-attribute values/hashes with unknown constructor identity. ## Contract and boundary impact - Semantic owner and earliest changed stage: managed provider member decoding selects exact declared type tokens; shared application adapters preserve caller arguments, and domain comparison/graph consumers retain selection scope. - CLI and MCP/tool-catalog contract: additive optional `type_names` and repeatable `--type`; output `selection` is null or `{type_names, unmatched_type_names}`. Advertised input/output schemas are validated through the actual SDK boundary. - Provider, bridge, target-format, or platform compatibility: static PE/CLI inspection only; no native provider or execution support changes. - Evidence, artifact, provenance, or reconstruction contract: caller names, artifact SHA-256/MVID, original CIL hashes, unknown names and selected coverage remain explicit. Legacy Evidence remains readable. - Process execution, authorization, cleanup, or containment impact: no target assembly is loaded or executed; existing read-only lifecycle and resource policy remain. - Generated metadata (`docs/public/product-catalog.json`), package, or installation impact: ignored catalogs regenerate from source contracts; authored managed documentation and examples are updated. No generated output, binary or dependency additions. ## Evidence and regression coverage - Tests added or updated: selected/unmatched types, legacy Evidence, comparison pairing and unknown absence, graph scope, actual SDK-advertised input/output validation, duplicate input rejection, malformed metadata facts and source hashes. - Base reproduction or other evidence: without selection, large assemblies can return unavailable coverage with the existing representation-budget reason. Managed arguments were previously discarded by the shared CLI/MCP application path. - User-visible CLI/MCP output: `selection: {type_names: ["Example.Parser", "Missing.Type"], unmatched_type_names: ["Missing.Type"]}`; only selected members are described, with explicit scope limitations. - Real release artifacts: two unchanged managed DLLs yielded 102 and 16 selected methods; all 118 raw CIL hashes independently matched PE-mapped original file bytes. Actual CLI/fresh stdio MCP normalized results and caller arguments matched exactly. Both selected views reported complete coverage with no resource-limit issue; unmatched-only requests retained their explicit selection. - Remaining proof gaps: arbitrary full-assembly workloads can still exhaust the unchanged budget. Nested names currently use reported bare names and can select multiple types. The follow-up was executed on Linux x64; other clients and providers were not verified by these runs. Reconstruction/native-runtime semantics are outside this selection proof. 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 - Focused managed source/domain/application/MCP/provider/graph tests — 229 passed across 21 files. Final grouped malformed-attribute assertions — 20 passed. - Actual SDK Schema regression — duplicate selection passed the advertised schema before the follow-up and was rejected afterward, matching runtime validation. - `node scripts/verify/managed/conformance.mjs` — 11 verified controls; optional operator/decompiler-oracle scenarios remain unsupported in this environment. - Real public CLI/MCP selected-member replay — two DLLs, 118 independent original-CIL hash checks, exact result parity, unmatched controls, responsiveness and unchanged source digests passed. One CPU, peak approximately 1.46 GiB, zero memory-limit/OOM/OOM-kill events. - `npm run check:ci` — all eight static tasks and architecture guards passed before the final format-diagnostics main sync; CI validates the published integrated head. - `npm run docs:check` and `npm run check:fast` — passed after final main integration. - `npm run verify:ghidra:mips-shared` — all eight real native CLI/MCP controls passed on this final integrated head using Linux x64 Ghidra 12.1.4/JDK 21/GNU 2.40; cleanup verified with zero surviving owned descendants. Peak approximately 1.50 GiB with zero memory-limit/OOM/OOM-kill events. - Fresh full-capacity controls — both original DLLs returned complete artifact/native-boundary metadata without resource limits; unselected member inspection still reported the unchanged 67,108,864-byte limit. Peak approximately 0.90 GiB, zero memory-limit/OOM/OOM-kill events. ## Compatibility, safety, and release - Breaking changes or migration steps: none; existing calls retain full inspection with `selection: null`, and legacy Evidence omitting selection remains readable. - Real Hopper/Ghidra, browser, or OS coverage: no native engine is involved; follow-up real release-artifact CLI/MCP replay on Linux x64 only. - Package or release metadata impact: additive authored contracts, examples and documentation; no installer/dependency changes. - Security, privacy, process, or containment review: no code execution or byte mutation; caller-selected names and original artifact identity are preserved. Input and representation budgets are unchanged. ## 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:54:50 +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#4768
No description provided.