Skip to content

feat(native): inspect oversized retained function dossiers via bounded views - #1345

Merged
N0zoM1z0 merged 5 commits into
morluto:mainfrom
jhuang-tw:fix/native-dossier-selected-views
Oct 10, 2026
Merged

N0zoM1z0 merged 5 commits into
morluto:mainfrom
jhuang-tw:fix/native-dossier-selected-views

Conversation

@jhuang-tw

@jhuang-tw jhuang-tw commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Refs #1247 and #1065.

A complete native analyze_function dossier can exceed default MCP framing. Extend the existing inspect_analysis_view workflow so callers can read selected native facts from authenticated same-session Evidence or portable inline Evidence without restarting a provider.

Native facets cover procedure, pseudocode, assembly, callers/callees, typed references and high-pcode summaries/operations/def-use/effects/parameters. Offset defaults to 0 and positive caller-selected limit defaults to 64. Pseudocode uses UTF-16 code units, rejects offsets inside surrogate pairs and returns safe continuation offsets. Other pages count rows. Actual serialized bytes govern transport admission; no arbitrary row ceiling substitutes for that check.

Views keep artifact path/hash, exact parent Evidence ID, distinct view digest, procedure address as recorded, provider limitations and explicit unknowns. Unavailable API residual unknowns and decompiler caveats survive selection. Empty recorded addresses and paths stay empty and do not create invalid address/path locations. Malformed native dossiers report the specific field. Complete default analysis and retained Evidence remain available, including an oversized selected row; CLI help, contracts and packaged skill source describe the added views.

Example (replace the placeholder with an actual same-session Evidence ID):

{"source":{"kind":"retained-evidence","evidence_id":"ev_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"},"view":{"kind":"native","facet":"value_flow_operations","offset":0,"limit":32}}

Validation on latest integrated main 4d8ef3f, pinned Node 24.18.0/npm 11.16.0, Linux x64, two CPUs and a 2 GiB process-family RSS guard:

  • 34 focused tests across domain, application, compiled public CLI and SDK MCP boundaries.
  • 11 MiB source-owned retained native fixture produces a <12 KiB selected result; published SDK-converted input/output schemas validate with Ajv2020, including caller limit 500, and subsequent ping succeeds.

  • One native assembly row expands beyond framing: typed transport recovery retains the exact complete selected row, then a smaller view and ping work.
  • Regressions first reproduced four initial defects: caller page rejection, missing API unknowns/caveats, empty address normalization and generic invalid-dossier diagnostics; a follow-up also reproduced rejection of a recorded empty path.
  • Full npm run typecheck -- --singleThreaded, lint/module boundaries, docs generation check, changed-file formatting and Git whitespace checks pass. Runtime compilation uses the same documented single-thread mode. The pinned native TypeScript compiler's documented single-thread mode preserves the full checking scope within the local memory budget.

This covers the selected-facet portion of #1247. Retained-dossier discovery and cross-session snapshot-backed reuse remain open. Our follow-up also ran a real Ghidra 12.1.4 workflow on a 16,784-byte source-owned ELF with JDK 21, a verified 512 MiB JVM heap and two CPUs. Latest main CLI native-view rejection was reproduced; the candidate CLI returns exact pseudocode from that real parent. Candidate stdio MCP verified six native facets with caller limit 500, parent/subject identity, API limitations, text/structured parity, ping and close. The complete native Evidence ID exactly matches main CLI; input bytes remained unchanged. MCP native responses were 15,580–27,676 bytes versus 84,046 bytes for the complete dossier, and selected calls took 4–70 ms after a roughly 91-second cold analysis; these are one small-target observation and byte measurements, not token or provider startup improvements. Family RSS peaked at 1,271,345,152 bytes under the native 3 GiB guard. Hopper was not run. Existing contributor larger-target real-Ghidra observations remain separately attributed in PR comments.

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

@morluto

morluto commented Oct 9, 2026

Copy link
Copy Markdown
Owner

Review of adb96bd: the retained-Evidence projection is the right direction, and the UTF-16 surrogate-boundary checks and explicit truncated-flow unknowns are useful. I reviewed the native projector, request schema and service provenance path.

P2 design issue to resolve before merge: src/domain/analysisView/analysisView.ts:96-97 imposes a hard limit <= 256 on native views, while the existing page-view contract accepts any positive limit. I could not find a format/protocol constraint or measurement establishing 256 as the boundary. A caller cannot request 257 short instruction/reference rows even if the reply is small. Conversely, 256 rows (or the singleton procedure facet) may still contain very large strings/metadata, so that ceiling does not establish transport safety.

Please retain a useful default but either remove the arbitrary ceiling, or document and verify its actual resource basis. If the requirement is a bounded transport result, account for serialized bytes/expansion at the projection boundary and preserve explicit omissions and parent provenance. Include a test for a small page above the former row ceiling and a large single-row/metadata case.

This is a static review of the change, not a fresh real-Hopper/Ghidra verification. GitHub currently reports mergeable but blocked, with no checks attached to this head; the existing injected retained-dossier MCP test is integration evidence, not real-provider evidence.

@CassieFox23

CassieFox23 commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR: I tested this on Linux with real Ghidra. The new views work. A real dossier went over the 10 MiB limit. Paging it worked fine. But one 256-row page was still 3.8 MB. So the row cap does not bound size.

What ran.

  • npm ci and npm run compile passed.
  • The four changed test files passed, 28 of 28.
  • Target: a copy of Fedora's libsqlite3.so 3.51.2 (SQLite, public domain). It is 1,641,368 bytes. Its sha256 starts f5fc84b4.
  • Function: sqlite3VdbeExec at 0x13e980.
  • CLI rea function with Ghidra exited 0 in 78 s.
  • The function record was 28.3 MB as compact JSON.
  • Outgoing references were 25.2 MB of it.
  • The record says 3,000 value-flow ops were kept.
  • It says 3,767 inputs and 3,385 edges were left out.

Over stdio MCP (rea mcp, client SDK 2.3.1):

  • analyze_function gave resource_constraint.
  • It reported at least 10,574,626 bytes.
  • It kept the Evidence and gave its reference.
  • Ping worked after it.

Then inspect_analysis_view on that reference:

facet offset/limit MCP bytes coverage
procedure 0/1 29,352 complete
pseudocode 0/256 15,188 256 of 198,747
assembly 0/256 33,268 256 of 9,451
value_flow_operations 0/256 282,182 256 of 3,000
outgoing_references 0/256 3,827,664 256 of 4,440
outgoing_references 0/8 119,456 8 of 4,440
  • Every view kept the parent ID and the address.
  • Each view got its own digest.
  • The truncated value flow showed up as an unknown.
  • A limit of 257 was refused.
  • Each view took under 1 s.

CLI with inline Evidence. 18 of 20 views exited 0. One was past the end and gave an empty page. Limit 257 was refused. Procedure at offset 1 was refused.

Main (08ec2bf8). The same input was refused. A native view is not known there.

On the P2:

  • 256 assembly rows are about 16 KB. Yet 257 rows are refused.
  • 256 outgoing reference rows are 1.74 MB. On the wire that is 3.8 MB.
  • Each row repeats the full source and target procedure. That is about 3.7 KB each.
  • Nothing in the view code checks bytes.
  • My rough estimate: about 700 such rows would pass 10 MiB.
  • That is under 3x headroom over 256.
  • Small thing: the CLI help still says layout or JavaScript only.

Not run. Hopper. Windows. The full npm run check. Reuse across sessions. Ghidra on main. A view page over 10 MiB.

Test setup
  • Box: Linux x64
  • Node: 24.18.0
  • Head: adb96bda7
  • Other: npm 11.16.0
  • Other: Ghidra 12.1.4 with JDK 21

🤖 Generated with Claude Code (Opus 5.5) 🦊

@CassieFox23

Copy link
Copy Markdown
Contributor

TL;DR: I checked my last note again. The numbers hold. One line was too broad. Here is a sharper picture of the rows.

I ran it again on head adb96bda7. Same Ghidra. Same sqlite copy.

  • I said each row repeats the target procedure.
  • That was too broad.
  • 65 of the first 256 rows have no target.
  • Across all 4,440 rows, 2,167 have none.
  • The source procedure is in every row.
  • It is the same 3,717 bytes each time.
  • It is this function itself.
  • So one shared copy could save a lot.

On the 700 rows:

  • That figure used rows like the first page.
  • Later rows here are smaller.
  • Here, about 805 rows would pass 10 MiB.
  • A script sized each row for that.
  • The biggest single row is about 17 KB.
  • The procedure view is about 29 KB.
  • So this target never tests a huge row.

The row cap still does not bound bytes.

🤖 Generated with Claude Code (Opus 5.5) 🦊

@N0zoM1z0
N0zoM1z0 merged commit a9ee236 into morluto:main Oct 10, 2026
19 checks passed
@morluto morluto added enhancement New feature or request area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Oct 14, 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 enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants