Skip to content

perf(managed): add retained member summary and pages - #3061

Merged
kaoru0822-kitauji merged 6 commits into
mainfrom
perf/managed-member-summary
Oct 14, 2026
Merged

kaoru0822-kitauji merged 6 commits into
mainfrom
perf/managed-member-summary

Conversation

@kaoru0822-kitauji

@kaoru0822-kitauji kaoru0822-kitauji commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Closes #3010.

inspect_managed_members always returns the assembly-wide member_refs and exported_types, and type_names doesn't narrow them. So one selected type, or a name that matches nothing, still returns megabytes. Over MCP, an ordinary assembly with no selection fails outright with resource_constraint.

This adds the same opt-in delivery that inspect_managed_artifact got in #2413:

  • detail: "summary" retains the complete Evidence and returns a linked inspect_analysis_view summary. It contains:
    • identity and metadata status
    • the selection, with its unmatched names
    • coverage/issues and the separate user-string coverage
    • limitations
    • per-collection counts
  • kind: "managed-members" pages cover types, exported_types, fields, methods, member_refs, call_edges, field_accesses and user_strings (the literals). They return original rows in order. Each page also carries the source selection, coverage and build-local token scope.
  • Older Evidence that never examined exported types or user strings reports a null count and refuses those pages instead of returning an empty one.
  • Defaults are unchanged: an omitted or complete detail returns the same complete result as before.

Bug found while testing against real data

My first version used z.union over the row array schemas, like the artifact view does. Sealing re-parses the page through that union, and the first schema that matches wins. The member row schemas are non-strict and share keys, so method rows parsed as types rows and silently lost rva, impl_flags and body. Each page now has the shape {collection, rows} in a discriminatedUnion("collection"). The boundary test rebuilds every collection page by page and compares it exactly. (The existing artifact view's reference/resource/attribute rows each have distinct required keys, and its pages are exact on both assemblies below, so it is left unchanged.)

Related cleanup

  • The token-scope, missing-subject and unknown-MVID unknowns now have a single owner, managedViewIdentityUnknowns, shared by both managed views.
  • After merging main, the member view parses its parent with main's parseAnalysisViewResult, and managed registration uses main's retainedSummaryDelivery instead of its own preflight and projection hooks. Summary is now refused before admission, like the artifact and native families.
  • tests/boundary/mcp/browserComparisonInput.test.ts fails locally on plain origin/main (bcc1415) as well; it's unrelated and untouched.

Verification

Real data: two .NET assemblies from NuGet, parsed and never loaded or run.

  • ICSharpCode.Decompiler.dll 9.1.0.7988 (netstandard2.0, 2,558,464 bytes)
  • Newtonsoft.Json.dll 13.0.3 (net45 and net6.0)

Calls went over real MCP stdio (rea mcp) on macOS with Node 26.

Correctness: every collection was rebuilt through pages and compared exactly (isDeepStrictEqual) with the complete result. The summary's non-collection fields matched exactly.

Case Counts (types/fields/methods/member_refs/call_edges/field_accesses/user_strings) Pages rebuilt exactly
Decompiler, type_names=[CSharpDecompiler] 1 / 12 / 81 / 4,967 / 1,464 / 341 / 50 all 8 collections
Decompiler, unmatched No.Such.Type 0 / 0 / 0 / 4,967 / 0 / 0 / 0; unmatched_type_names reported all 8
Newtonsoft net45, type_names=[JsonConvert] 1 / 8 / 72 / 2,125 / 195 / 15 / 16 all 8
Newtonsoft net6.0, no selection (compared with CLI complete JSON; MCP complete can't deliver it) 494 / 2,204 / 4,208 / 2,149 / 19,137 / 9,901 / 784 all 8 (38,877 rows)

Size and time: before = merge base 30128a03c; after = this branch. Same machine, three runs each; the runs were identical to within a few ms. Token counts are tokenx estimates of the serialized replies, not model usage.

Analyst question Before After
Is CSharpDecompiler present and which direct calls does it declare? 1 call, 6,750,791 B (~2.30M est. tokens), 230 ms summary + 3 call_edges pages of 500 = 4 calls, 904,558 B (~293k est. tokens), 211 ms
Does No.Such.Type exist? 4,890,827 B 15,441 B summary
What does Newtonsoft.Json (net6.0, no selection) declare? resource_constraint error, no result 13,495 B summary; pages on demand

For the first question, the whole client+server process ran two passes of the task (first call in a fresh server, then a repeat in the same session):

  • Wall time: 1.24 s → 0.90 s
  • User CPU: 1.73 s → 1.26 s
  • Peak RSS of one process: 651 → 396 MiB

The repeat pass is only about 10 ms faster in both builds, since the parser doesn't cache across calls.

Paging cost (after review): a sealed retained parent is validated once and its report is reused for later pages; unsealed inline input is still validated on every call. Paging all 19,137 Newtonsoft (net6.0) call edges over MCP, 39 pages of 500, two runs each:

Page time (sum) Process wall User CPU Peak RSS (one process)
54e89bd (parse every page) 1.74 s 3.16 s 4.18 s 715 MiB
7c6368f (validate once) 0.19 s 1.57 s 2.05 s 421 MiB

Response bytes are identical (10,667,479). In process, one 64-row page drops from ~36 ms to 0.6–2.2 ms.

Costs: the advertised catalog grows by 20,098 B (about 6k estimated tokens). inspect_analysis_view gains 16 KB for the eight row schemas and inspect_managed_members gains 4 KB. Summary-first only pays off when a reply would otherwise be large. I did not run real-model (Codex) trials, so I'm not claiming any model-token saving.

Tests:

  • New tests/boundary/mcp/managedMemberSummaryMcp.test.ts (fixture with an exported type, a #US literal, a field access and a call edge; every collection must be non-empty) covers:
    • Ajv validation of the SDK-converted input/output schemas
    • selected and unmatched names
    • unchanged complete and omitted delivery
    • rebuilding every collection page by page after the file is deleted
    • unchanged retained parent and portable inline view
    • historical Evidence with unexamined collections refusing pages
  • managedArtifactSummaryMcp.test.ts now:
    • accepts detail on members (native boundaries still reject it)
    • checks that a server without retention refuses member summary before file access
  • Passing: npm run check:fast, npm run check:changed (58 files), npm run docs:check, npm run jscpd (3.14% < 3.5%), and npm run test:focused on 66 MCP catalog/schema/analysis-view suites plus the managed boundary/acceptance suites.

Not verified: Windows and the issue's exact ILSpy.dll, real-model trials, and the CLI. The CLI has no MCP response budget, so like #2413 this delivery option is MCP-only; inspect-analysis-view accepts the new view kind through its shared schema.

🤖 Generated with Claude Code

inspect_managed_members always returned the assembly-wide member_refs, so
one selected or unmatched type produced megabytes, and an unselected
ordinary assembly exceeded the MCP response budget. Add opt-in
detail: "summary" that retains the complete Evidence and returns identity,
selection with unmatched names, coverage, user-string coverage, limitations
and per-collection counts. Page original rows through inspect_analysis_view
with kind managed-members; each page names its collection so no row schema
is chosen by union order. Complete delivery stays the default.

Refs #3010

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kaoru0822-kitauji kaoru0822-kitauji added performance Performance regressions, scaling limits, and bounded-resource work track:perf Performance track PRs (issues & perf loop) labels Oct 14, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 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 ✅ Completed 2026-10-14T00:46:07.556223Z 54e89bd 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.

@greptile-apps

greptile-apps Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new actionable issue was found.

Summary

Adds opt-in summaries and retained pages for inspect_managed_members, while keeping complete delivery as the default.

  • Managed member inspection can return a summary and paged rows.
  • Retained member pages can reuse one validated report.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A["inspect_managed_members"] --> B{"detail"}
  B -->|omitted or complete| C["Complete Evidence"]
  B -->|summary| D["Check retention before analysis"]
  D --> E["Retain complete Evidence"]
  E --> F["Return linked summary"]
  E --> G["inspect_analysis_view"]
  G --> H["Page selected collection"]
Loading

Reviews (6) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

Each managed-members page reparsed the whole parent report, about 35 ms
for an 18 MB assembly result regardless of the page size. The analysis
view service now reports whether the parent Evidence is a sealed
snapshot, and the member view reuses the validated report for that
sealed result through a weak reference. Unsealed input is still
validated on every call.

The round-trip test fixture now carries an exported type, an ldstr
literal, a field access and a call edge, and requires every collection
to be nonempty so a row schema that drops facts cannot pass on empty
arrays.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

Resolve analysis-view conflicts with the Interface Builder views, and
adopt main's single owners: parseAnalysisViewResult for the member parent
parse and retainedSummaryDelivery for managed summary delivery.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

Comment thread src/server/registerManagedTools.ts Resolved
Summary, omitted and complete delivery of the same managed inspection
now retain one parent record, as inspect_macho already does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@kaoru0822-kitauji
kaoru0822-kitauji merged commit 7484401 into main Oct 14, 2026
37 checks passed
@kaoru0822-kitauji
kaoru0822-kitauji deleted the perf/managed-member-summary branch October 14, 2026 06:16
@morluto morluto mentioned this pull request Oct 14, 2026
3 tasks done
@morluto morluto added the area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior label Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior performance Performance regressions, scaling limits, and bounded-resource work track:perf Performance track PRs (issues & perf loop)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Perf] Add caller-selected retained delivery for managed member inspections

2 participants