Repository navigation
feat(managed): select declaring types in inspect_managed_members - #1706
Conversation
Large assemblies such as a .NET base class library could not be inspected: inspect_managed_members returned coverage "unavailable" with a representation-budget resource limit (mscorlib.dll from Unity's Mono 2.0 profile, 2.5 MB). Two causes, both fixed: - Custom-attribute constructor names resolved their declaring type by rescanning the TypeDef table for every attribute, charging the decode budget per row read (about 64 MB on mscorlib before any member was decoded). MethodList starts are now read once per layout and searched; unordered or unreadable TypeDef rows keep the original row scan. - Every member was always fully decoded. A new optional type_names input (MCP) / repeatable --type option (CLI) decodes signatures and method bodies only for the selected exact declaring types. Unselected members keep their names so call edges and field accesses stay labelled. The result reports selection.type_names and selection.unmatched_type_names; selection is null when every type is inspected. Managed tool arguments were previously dropped before reaching the provider on both the MCP and CLI paths; they are now passed through, and the CLI Evidence records them. Verified on the real mscorlib.dll: --type System.Threading.Monitor returns the 17 Monitor methods in under 2 s using about 10 MB of the budget. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1fa6d3575f
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
A type_names selection emits members of the selected declaring types only, but consumers read it as a whole-assembly inventory: - compare_managed_members reported members outside the other side's selection as added or removed. Absence is now observed only within the opposite side's selection, and observations with different selections compare as partial with a limitation. - project_managed_application_graph reported complete-within-inputs for a selected inspection. A selection now marks the graph partial. - Evidence recorded before selection existed lacks the field and failed managedMemberInspectionSchema; a missing selection now parses as null. The type_names description now says a nested type's bare name selects every nested type of that name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5188383164
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| types: | ||
| selected === null | ||
| ? parsedTypes.types | ||
| : parsedTypes.types.filter((type) => selected.has(type.token)), |
There was a problem hiding this comment.
Decode only selected TypeDefs before filtering
When type_names is used on a type-heavy assembly, parseTypes has already materialized every TypeDef and recharged every row and cached name before this post-filter runs. Enough unselected types therefore exhaust the 64 MiB representation budget and make the selected request return unavailable even when the requested type and its members are tiny; after the minimal identity scan needed for selection, fully decode only the selected TypeDef rows.
AGENTS.md reference: AGENTS.md:L42-L42
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changed in this PR: parseTypes materializes every TypeDef exactly as it did before selection existed, so this is no regression, and selection already skips member signatures and bodies, which dominate the budget (Unity's mscorlib: 1,828 TypeDefs, ~10 MB with a selection vs. unavailable before). Decoding only selected TypeDef rows would change types/declaring-type resolution for every caller, so it seems better as a follow-up if maintainers want it.
🤖 Addressed by Claude Code
…dable names - The MethodList-start index reserved metadataRowCursor's 256-byte per-row bookkeeping for every TypeDef row, although it retains one number per row. It now reserves 8 bytes per row once and reads rows without the per-row charge, so building it cannot exhaust the budget where the row scan it replaces would not have. - When a TypeDef name cannot be read, a requested name reported in selection.unmatched_type_names may belong to that row. The result now carries a limitation saying so, alongside the parse issue that already makes coverage partial. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dfa756b064
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| name, | ||
| declaringType: declared?.fullName ?? null, | ||
| }); | ||
| if (!isSelected(selected, declared)) return; |
There was a problem hiding this comment.
Skip unselected member rows before reserving their names
For a valid assembly with few TypeDefs but roughly 262k unselected MethodDef/Field rows, a small or even unmatched type_names request still reaches this guard only after creating a metadataRowCursor (which reserves 256 bytes), decoding the name, and inserting a core entry for every row. Separate from the already flagged TypeDef pass, these unselected rows alone can exhaust the 64 MiB budget, after which the resource-limit failure makes the inspector discard the selected result as unavailable; defer name/core decoding to tokens referenced by selected bodies or iterate selected row ranges.
AGENTS.md reference: AGENTS.md:L42-L42
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changed in this PR, for the same reason as the TypeDef pass above: name/core decoding of every MethodDef and Field row is what inspection did before selection existed, so this is no regression, and selection already removes the dominant per-member cost (signatures and bodies). Restricting row iteration to selected ranges and deferring names to referenced tokens changes how edges are labelled for every caller, so it fits better as a separate follow-up if maintainers want it.
🤖 Addressed by Claude Code
When two inspections select different declaring types, keyMembers paired members before the selections were consulted, so a same-IL method in a type only the left selected could be reported as an exact remap of one in a type only the right selected. Members whose declaring type the other side did not observe now skip pairing and stay one-sided, where the selection already keeps them unknown. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d594052934
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…n CLI help - A comparison of two inspections with the same type selection reported complete-within-inputs with no sign that its totals cover only those types. It now carries a limitation naming the selected types. - The CLI --type help now says a nested type is named by its bare name, matching the MCP type_names contract. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f1983ed2af
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const declared = declaringType(row); | ||
| const token = metadataToken(4, row); | ||
| core.set(token, { token, name }); | ||
| if (!isSelected(selected, declared)) return; |
There was a problem hiding this comment.
Dereference member-pointer tables before type filtering
On a valid unoptimized (#-) assembly with reordered FieldPtr or MethodPtr rows, TypeDef FieldList/MethodList ranges index the pointer tables, but these loops feed raw Field/MethodDef row numbers to createDeclaringTypeLookup and then filter on that owner. Since ManagedMetadataLayout.ts:285 admits #- metadata but the pointer rows are never dereferenced here, selecting type A can emit B's member as A and omit A's actual member while reporting complete coverage; resolve pointer rows before applying the selected-token filter for both fields and methods.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changed in this PR: REA does not dereference FieldPtr/MethodPtr anywhere on main. createDeclaringTypeLookup already maps raw Field/MethodDef rows to owners there, so declaring_type labels on reordered #- assemblies are already affected without a selection, and the selection filter only inherits that owner. Pointer-table support belongs in the shared range/owner resolution for all managed tools, so it seems better as its own fix.
🤖 Addressed by Claude Code
…rage A selected member inspection marked the projected graph partial through partialInput, which then claimed "At least one supplied managed Evidence record has partial coverage" even when every source parsed completely. The selection is now tracked on its own: it still makes the graph partial, and the limitation names the selected declaring types instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 81b4b1a973
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (!sameSelection(left, right)) | ||
| limitations.push( | ||
| "The observations select different declaring types; a member outside the other side's selection is unknown, not added or removed.", |
There was a problem hiding this comment.
Retain both differing type selections
Fresh evidence after the common-scope fix is that when the left and right records choose different sets (for example A versus B), this branch still emits only a generic warning while sideManifest contains no selection. If either selected type has no members or is unmatched, the retained comparison cannot reveal which side's totals and unknown items were scoped to which names without fetching both source records; preserve both selections in the side manifests or name each scope here.
AGENTS.md reference: AGENTS.md:L42-L42
Useful? React with 👍 / 👎.
|
TL;DR: The new I tested the latest head, 81b4b1a, which has 6 commits. The base is 13e03e9 (#1694). Thanks, skoodster, for the quick review fixes. Results
The wider PR test command (22 files, 175 tests, 3 skipped) also passes on Node 24. I used two real assemblies. The first is
The Mono file in the PR reports partial for a whole-file call. This 4.8 MB file reports unavailable. The error text is What I saw:
MCP call time was about 0.3 s for one Mono type and 0.4 to 0.5 s for three. That clock covers the call only, with the server already running. Peak server memory was 379 MB. An idle server that had just rejected a call already held about 320 MB. CLI wall time was 1.3 to 2.7 s. The box was shared, with a load average of 6 to 10 out of 24 threads. Not run
All MCP cases on headEach case ran twice. Times are the call only, run 1 and run 2. Base rejected every
Commands
Test setup
🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊 |
Reuse the merged metadata row accounting and declaring-type lookup owner. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> Co-authored-by: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com>
Preserve the verified native profile and current capability projections. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> Co-authored-by: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com>
Advertise unique type selections after JSON Schema conversion and verify the actual MCP schema. Preserve malformed attribute facts during main integration and document the scope and limits of selected member inspection. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> Co-authored-by: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com>
Preserve both null and out-of-range cases with exact value hashes and scoped parse reasons, without duplicated assertion blocks. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> Co-authored-by: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com>
Retain shared target classification and recovery from main. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> Co-authored-by: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 61b4e856c4
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@CassieFox23 thanks for the thorough run. About the oddity of
🤖 Posted by Claude Code |
|
@skoodster, thank you for carrying type selection all the way from repeatable CLI/MCP inputs to decoding and Evidence coverage. Selecting before signatures and CIL are expanded gives analysts a practical way to inspect known types, and preserving unmatched names and partial scope keeps the result honest. Welcome to REA! |
Summary
inspect_managed_memberscan decode the members of exact caller-selected declaring types before expanding signatures and CIL. The optional MCPtype_namesinput and repeatable CLI--typeoption 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
selection.type_namesandselection.unmatched_type_names; preserve null when no selection is supplied and accept older Evidence without the field.uniqueItemsafter SDK JSON Schema conversion. Preserve readable malformed-attribute values/hashes with unknown constructor identity.Contract and boundary impact
type_namesand repeatable--type; outputselectionis null or{type_names, unmatched_type_names}. Advertised input/output schemas are validated through the actual SDK boundary.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
selection: {type_names: ["Example.Parser", "Missing.Type"], unmatched_type_names: ["Missing.Type"]}; only selected members are described, with explicit scope limitations.For evidence-bearing changes:
Validation performed
node scripts/verify/managed/conformance.mjs— 11 verified controls; optional operator/decompiler-oracle scenarios remain unsupported in this environment.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:checkandnpm 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.Compatibility, safety, and release
selection: null, and legacy Evidence omitting selection remains readable.Review checklist
type(scope): outcome.