Skip to content

feat(native): deliver batch decompile as a retained summary - #8631

Merged
kaoru0822-kitauji merged 14 commits into
mainfrom
feat/8498-batch-decompile-detail
Nov 2, 2026
Merged

kaoru0822-kitauji merged 14 commits into
mainfrom
feat/8498-batch-decompile-detail

Conversation

@kaoru0822-kitauji

@kaoru0822-kitauji kaoru0822-kitauji commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

What broke: a batch that fits still puts every pseudocode body in the caller's context, and one that doesn't fit only offered an export. A selected page that didn't fit also only named an export, even when its text pages would work.
Fix: batch_decompile accepts detail: "summary", which retains the batch and returns counts and sizes. Overflows now carry a ready-to-call smaller selection of the same retained parent.
Risk: additive. detail defaults to complete, and a complete reply had the same size and wanted-body hashes as base on the measured workflow. The advertised batch_decompile output becomes a union with the summary, as on the other detail tools.

Summary

Follow-up to #8498, built on the retained view from #8629, which has merged. This PR now shows only its own change. Design: #8498 (comment).

Problem and expected behavior

An agent reading two of 64 functions received all 64 bodies: about 207 KB and 67k estimated tokens on the real workflow below. The retained view from #8629 only helps after that cost is paid. Over budget, the reply named an export rather than the view.

Expected: the caller chooses delivery up front, and an overflow names a call that can succeed.

Change and scope

  • batch_decompile detail: uses the existing enhanced-tool summary delivery, as get_call_graph does. It refuses before analysis when the server retains no Evidence. detail is stripped before the workflow, so the parent's parameters and Evidence ID match a complete call.
  • Overflow continuation: an oversized complete batch offers {kind:"batch-decompile", collection:"items", offset:0, limit:64}.
  • smallerBatchDecompileSelection: an oversized selected page continues from the caller's own source, so a parent read from an Evidence file is never named as retained. Several rows halve; one row with a body moves to its pseudocode pages; a text page halves its limit. An error row that alone cannot fit keeps the export guidance. An inline source offers no continuation, because the record cannot be repeated within the reply it overflowed. A view's continuation doesn't depend on session recording, so a fixed-target server reading an Evidence file offers one too.
  • Delivery plumbing: continuationOf is extracted so both paths share one schema-validated call builder, and inspect_analysis_view passes its caller's source through runEvidenceToolOperation to delivery.
  • Not included: continuations for other view kinds, and changes to the default delivery.

Follow the contribution scope. Read-only delivery of completed Evidence within existing boundaries; no maintainer scope decision is required.

Contract and boundary impact

  • Semantic owner and earliest changed stage: projectBatchDecompileView (feat(native): select retained batch decompile results through analysis views #8629) still owns selection; smallerBatchDecompileSelection lives beside it and reads only the page's view and row identities.
  • Contribution scope fit and linked maintainer decision: not applicable.
  • CLI and MCP/tool-catalog contract: MCP-only detail on batch_decompile; output is complete Evidence or its summary view. The CLI has no batch command and reads saved Evidence as in feat(native): select retained batch decompile results through analysis views #8629.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: the parent is retained before its summary is delivered; the summary view links it.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): none.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: catalog only.

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

Before and after, executed. Real Kuna 1.988 (release digest verified), stdio MCP compact profile, macOS arm64, on Homebrew's unexecuted tmux (arm64 Mach-O, SHA-256 8ab1bd9e…a86d, unchanged in every run). The task is to read two of 64 functions. Task columns cover the batch and view calls, including request text, and exclude open_binary and list_procedures (identical in every run). Bytes are the SDK-serialized reply; tokens are tokenx estimates, not billing. CPU and peak memory cover the whole session's process family, sampled with ps. One run each on a machine shared with other jobs, so small timing and memory differences are noise.

Workflow Cache Calls Reply bytes Est. tokens Tool time Peak RSS CPU
Base 8250bf232, complete cold 1 207,333 66,723 13,969 ms 725 MiB 26.3 s
This PR, summary + 8 rows + 2 bodies cold 3 31,871 9,826 13,182 ms 757 MiB 25.4 s
Base 8250bf232, complete warm 1 207,175 66,822 53 ms 432 MiB 2.0 s
This PR, complete warm 1 207,175 66,822 52 ms 434 MiB 2.0 s
This PR, summary + 8 rows + 2 bodies warm 3 28,599 8,984 282 ms 434 MiB 2.1 s

That is about 85–87% fewer estimated tokens for this task, with no measurable analysis saving: decompilation still runs for all 64 functions. A task that reads most bodies gains little or nothing from selected delivery, and the default stays complete.

The two wanted bodies hash identically between complete and selected delivery in the same cache state. The first function's text differs between cold and warm on both base and this branch, which matches Kuna's documented single-function run versus project export; this PR doesn't change it.

Schema cost, one catalog per session: compact 580,675 to 581,159 B (+484 B, about +133 estimated tokens); full 3,958,851 to 3,972,219 B (+13,368 B, about +3,961 estimated tokens). Both are against base 8250bf232, so they include #8629.

Over budget, executed on the same provider: the largest real body selected 1,000 times (13.4M code units, default 10 MiB budget).

Step Result
Complete batch 3,283 B resource_constraint with a ready-to-call continuation
Follow the continuation 30,231 B, 64 body-free rows of 1,000
64 rows with bodies 1,844,371 B, fits
detail: "summary" of the same selectors 7,991 B, same parent Evidence ID
Largest body in 2,048-unit pages 7 pages, 13,397 code units, largest page 12,678 B
  • Tests added or updated: tests/boundary/mcp/batchDecompileViewsMcp.test.ts: summary delivery in full and compact input and output profiles validated against advertised schemas, parameters excluding detail, no provider call after the batch, the overflow chain (complete, fewer rows, one body's text, oversized text page), an unretained Evidence-file parent that continues from its file (including on a fixed-target server that retains nothing), an inline parent that offers no continuation, no retention, ledger failure, and cancellation retaining nothing. Three existing batch tests now narrow the wider output union through the owner schema.
  • Base reproduction or other evidence: the tables above.
  • User-visible CLI/MCP output (if applicable):
    {"batch":{"total":64,"succeeded":64,"failed":0},"decompiling_provider":{"id":"kuna","name":"Kuna","version":"1.988"},"procedures":{"distinct_resolved":64,"unknown_identity":0,"label_unavailable":0},"pseudocode":{"code_units":81682,"largest":{"index":57,"code_units":13397}},"limitation_count":5}
  • Remaining proof gaps: real Ghidra, IDA and Hopper were unavailable on this host, so they are exercised only through the Ghidra MCP harness. The overflow chain's single-row and oversized-text steps ran only in that harness, because real Kuna bodies here are far below the 10 MiB floor. One target and one run per workflow; no autonomous-agent study.

Applicable lifecycle regressions: cancellation during the batch retains nothing. Retention-failure recovery beyond the existing typed error is #8444.

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

  • npm run check:fast — passed
  • npm run format:check — passed
  • npm run knip — passed
  • npm run docs:check — passed
  • npm run metadata:check — passed
  • npm run test:focused -- tests/boundary/mcp/batchDecompileViewsMcp.test.ts tests/boundary/mcp/enhancedTools.callPathsAndBatches.test.ts tests/boundary/mcp/ghidraRoutingMcp.test.ts tests/boundary/providers/kuna/kunaBatchDecompileMcp.test.ts tests/boundary/mcp/nativeViewPredicateMcp.test.ts tests/boundary/cli/analysisViewCli.test.ts tests/boundary/cli/cliToolCoverage.test.ts tests/conformance/contracts/targetContentProvenance.test.ts tests/boundary/mcp/featureTraceViewsMcp.test.ts tests/boundary/mcp/nativeInventoryViewsMcp.test.ts tests/boundary/mcp/largeToolResult.test.ts src/application/analysisView/AnalysisViewService.test.ts src/application/WorkflowEvidence.test.ts src/application/EnhancedInputDiagnostics.test.ts src/application/EnhancedToolSelectorOrigin.test.ts — 15 files, 207 tests passed
  • Real Kuna 1.988 stdio MCP workflows on base and this tree — results in the tables above
  • After merging the label_unavailable fix from feat(native): select retained batch decompile results through analysis views #8629, npm run test:focused -- tests/boundary/mcp/batchDecompileViewsMcp.test.ts — 8 tests passed. The suites above and the real workflows were not rerun for that one-line count change.
  • After the source-preserving continuation fix: npm run check:fast, format:check, knip, docs:check and metadata:check passed; npm run test:focused -- tests/boundary/mcp/batchDecompileViewsMcp.test.ts tests/boundary/mcp/enhancedTools.callPathsAndBatches.test.ts tests/boundary/mcp/ghidraRoutingMcp.test.ts tests/boundary/providers/kuna/kunaBatchDecompileMcp.test.ts tests/boundary/mcp/nativeViewPredicateMcp.test.ts tests/boundary/mcp/analysisViewMcp.test.ts tests/boundary/mcp/featureTraceViewsMcp.test.ts tests/boundary/mcp/nativeInventoryViewsMcp.test.ts tests/boundary/mcp/largeToolResult.test.ts tests/boundary/mcp/contractToolHandlerTargetContent.test.ts tests/boundary/cli/analysisViewCli.test.ts src/application/analysisView/AnalysisViewService.test.ts — 12 files, 183 tests passed; and the over-budget real Kuna workflow was rerun with the same results as the table. The cold and warm comparison was not rerun; this fix only changes overflow recovery.
  • After the no-recorder continuation fix (7bfbf3a): the same five static checks passed, and the same 12 focused files passed (183 tests).
  • After merging main at f95bdbce7, npx tsc --noEmit and npm run test:focused -- tests/boundary/mcp/batchDecompileViewsMcp.test.ts tests/boundary/mcp/enhancedTools.callPathsAndBatches.test.ts — 2 files, 27 tests passed. Every required CI check had passed on 96d794166 before this merge.
  • After merging main at aba56df68, which includes feat(native): select retained batch decompile results through analysis views #8629: the conflicted files were verified identical on main and feat(native): select retained batch decompile results through analysis views #8629's final tree before keeping this branch's versions, and the resulting diff against main is byte-identical to this PR's change against feat(native): select retained batch decompile results through analysis views #8629. npx tsc --noEmit and npm run test:focused -- tests/boundary/mcp/batchDecompileViewsMcp.test.ts tests/boundary/mcp/enhancedTools.callPathsAndBatches.test.ts tests/boundary/cli/analysisViewCli.test.ts passed (3 files, 57 tests).
  • After merging main at 0e6943c9d, npx tsc --noEmit and npm run test:focused -- tests/boundary/mcp/batchDecompileViewsMcp.test.ts tests/boundary/mcp/enhancedTools.callPathsAndBatches.test.ts passed (2 files, 28 tests).
  • After merging the shared-validator test change from feat(native): select retained batch decompile results through analysis views #8629, npm run test:focused -- tests/boundary/mcp/batchDecompileViewsMcp.test.ts tests/boundary/mcp/ghidraRoutingMcp.test.ts — 2 files, 11 tests passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. A client strictly parsing batch_decompile output sees the union only when it selects detail: "summary".
  • Real Hopper/Ghidra, browser, or OS coverage: real Kuna 1.988 on macOS arm64 only.
  • Package or release metadata impact: none beyond the generated catalog.
  • Security, privacy, process, or containment review: no new process, file or network effect. Summary delivery retains the same record a complete call retains.

Author readiness

Human owner: @kaoru0822-kitauji

  • 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

kaoru0822-kitauji and others added 2 commits November 2, 2026 05:48
…s views

A completed batch_decompile could only be read whole. When it did not fit the
MCP response budget, or an agent wanted one function, inspect_analysis_view
refused the parent as unsupported and the only recovery was exporting the
session.

- Own the batch result schema in the domain, replacing the contract's copy and
  the workflow's hand-written item types.
- Add summary and batch-decompile views: body-free rows keyed by original index
  with exact filters and opt-in bodies, and UTF-16 pages of one body.
- Report the decompiling provider from the upstream analysis profile, since the
  Evidence provider is the composing workflow.
- Keep batch limitations visibly aggregated rather than attributing them to one
  successful item.

Fixes #8498

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A batch that fits still floods the caller's context with every body, and one
that does not fit only named an export. Selecting a body that cannot fit named
an export too, even though its text pages can.

- Accept detail: summary on batch_decompile: retain the complete batch first and
  return its counts, identities and sizes. The default stays complete, and the
  selection never reaches the Evidence parameters.
- Offer a ready-to-call body-free first page when a complete batch overflows.
- When a selected batch page overflows, continue from the same retained parent
  with fewer rows, then with one body's text pages.

Refs #8498

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kaoru0822-kitauji kaoru0822-kitauji added enhancement New feature or request track:feature Feature/enhancement automation track labels Nov 2, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 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-11-02T08:09:13.628002Z a1a8e17 New commits
ℹ️ 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c2fdb6f3bb

ℹ️ 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".

kaoru0822-kitauji and others added 4 commits November 2, 2026 06:05
label_unavailable only counted failed lookups, so a batch whose provider
answered null for every label reported zero. The identity contract defines a
null name as an unavailable label in both cases.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b78c6c553a

ℹ️ 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".

Comment thread src/server/toolResult.ts Resolved
kaoru0822-kitauji and others added 3 commits November 2, 2026 07:11
…ource

A batch view read from an Evidence file or inline record advertised a
retained-evidence continuation for a parent the session never retained, so
following it failed. A view's continuation now repeats the caller's source and
only narrows the selection. An inline record offers none, because it cannot be
repeated within the reply it overflowed. Non-batch views skip the selection
parse, since delivery asks about every view it returns.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…idator

A local validator map dropped any tool without an output schema, so removing an
advertised schema would have left these contract tests green. Require both named
schemas and validate through createMcpSchemaValidation, as docs/testing.md asks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…compile-detail

# Conflicts:
#	tests/boundary/mcp/batchDecompileViewsMcp.test.ts
@greptile-apps

greptile-apps Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

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

Summary

Adds detail: "summary" to batch_decompile and smaller follow-up calls for oversized batch replies.

  • Callers can get a batch summary and choose which results to read.
  • Oversized batch replies offer a smaller selection to read next.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A["batch_decompile"] --> B{"Summary requested?"}
  B -->|Yes| C{"Can retain the parent?"}
  C -->|No| D["Refuse before analysis"]
  C -->|Yes| E["Run batch and retain full Evidence"]
  E --> F["Return summary with parent ID"]
  B -->|No| G["Run batch and return complete Evidence"]
  G -->|Over budget and retained| H["Offer body-free items page"]
  F --> I["inspect_analysis_view"]
  H --> I
  I --> J{"Page fits?"}
  J -->|Yes| K["Deliver page"]
  J -->|No, repeatable source| L["Offer fewer rows or shorter text"]
  L --> I
Loading

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

Comment thread src/server/ToolResultDelivery.ts Resolved
kaoru0822-kitauji and others added 5 commits November 2, 2026 07:34
…hing

A fixed-target server reads an Evidence file through inspect_analysis_view but
records nothing, so its overflow skipped the continuation and returned generic
CLI guidance. A view's continuation names the caller's source and needs no
session, so it no longer depends on recording. Retained references still do.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…pile-detail

# Conflicts:
#	.agents/skills/reverse-engineer-anything/references/evidence-workflows.md
#	docs/mcp-contracts.md
#	docs/native-investigation.md
#	src/contracts/toolOutputSchemaGroups.ts
#	src/domain/analysisView/analysisViewResult.ts
#	src/domain/analysisView/batchDecompileView.ts
#	tests/boundary/mcp/batchDecompileViewsMcp.test.ts
#	tests/boundary/mcp/ghidraMcpHarness.ts
@kaoru0822-kitauji
kaoru0822-kitauji merged commit 93b8b82 into main Nov 2, 2026
53 checks passed
@kaoru0822-kitauji
kaoru0822-kitauji deleted the feat/8498-batch-decompile-detail branch November 2, 2026 08:50
coyoteXujie pushed a commit to coyoteXujie/rea that referenced this pull request Nov 2, 2026
…8631)

* feat(native): select retained batch decompile results through analysis views

A completed batch_decompile could only be read whole. When it did not fit the
MCP response budget, or an agent wanted one function, inspect_analysis_view
refused the parent as unsupported and the only recovery was exporting the
session.

- Own the batch result schema in the domain, replacing the contract's copy and
  the workflow's hand-written item types.
- Add summary and batch-decompile views: body-free rows keyed by original index
  with exact filters and opt-in bodies, and UTF-16 pages of one body.
- Report the decompiling provider from the upstream analysis profile, since the
  Evidence provider is the composing workflow.
- Keep batch limitations visibly aggregated rather than attributing them to one
  successful item.

Fixes morluto#8498

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(native): deliver batch decompile as a retained summary

A batch that fits still floods the caller's context with every body, and one
that does not fit only named an export. Selecting a body that cannot fit named
an export too, even though its text pages can.

- Accept detail: summary on batch_decompile: retain the complete batch first and
  return its counts, identities and sizes. The default stays complete, and the
  selection never reaches the Evidence parameters.
- Offer a ready-to-call body-free first page when a complete batch overflows.
- When a selected batch page overflows, continue from the same retained parent
  with fewer rows, then with one body's text pages.

Refs morluto#8498

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(native): count every unavailable entry label in a batch summary

label_unavailable only counted failed lookups, so a batch whose provider
answered null for every label reported zero. The identity contract defines a
null name as an unavailable label in both cases.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(native): continue an oversized batch view from the caller's own source

A batch view read from an Evidence file or inline record advertised a
retained-evidence continuation for a parent the session never retained, so
following it failed. A view's continuation now repeats the caller's source and
only narrows the selection. An inline record offers none, because it cannot be
repeated within the reply it overflowed. Non-batch views skip the selection
parse, since delivery asks about every view it returns.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(native): require advertised batch schemas through the shared validator

A local validator map dropped any tool without an output schema, so removing an
advertised schema would have left these contract tests green. Require both named
schemas and validate through createMcpSchemaValidation, as docs/testing.md asks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(native): offer file view continuations on servers that retain nothing

A fixed-target server reads an Evidence file through inspect_analysis_view but
records nothing, so its overflow skipped the continuation and returned generic
CLI guidance. A view's continuation names the caller's source and needs no
session, so it no longer depends on recording. Retained references still do.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
@morluto morluto mentioned this pull request Nov 11, 2026
3 tasks done
@morluto morluto added the area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior label Nov 22, 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 track:feature Feature/enhancement automation track

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants