Skip to content

feat(native): select retained batch decompile results through analysis views - #8629

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

kaoru0822-kitauji merged 4 commits into
mainfrom
feat/8498-batch-decompile-view

Conversation

@kaoru0822-kitauji

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

Copy link
Copy Markdown
Collaborator

What broke: a completed batch_decompile could only be read whole. When it exceeded the MCP response budget, inspect_analysis_view refused the retained parent (unsupported_target), so the only recovery was exporting the session, even for one function.
Fix: the batch result gets one domain owner, and a retained view adds a summary, body-free rows with exact filters and opt-in bodies, and UTF-16 pages of one body. The analysis is never repeated.
Risk: additive. batch_decompile output is unchanged, and the shared view contract grows (catalog costs below).

Summary

Fixes #8498 (proposal: #8498 (comment)). A stacked follow-up adds detail: "summary" delivery and overflow continuations; this PR is the retained view it depends on.

Problem and expected behavior

Before: a batch over the 10 MiB response budget completes and is retained, but the record could not be read selectively. inspect_analysis_view returned Parent Evidence operation "batch_decompile" does not support analysis views.

Expected: a client reads a selected completed item and its identity, status, provenance and omissions without repeating analysis or transferring the bundle.

Change and scope

  • src/domain/native/batchDecompile.ts (new owner): the result shape lived in toolOutputSchemaGroups.ts and again as hand-written types in EnhancedTools.ts. The contract, workflow and view now share it. name_error and item limitations use exactOptional, because a JSON value cannot hold undefined; the advertised shape is unchanged.
  • src/domain/analysisView/batchDecompileView.ts, registered for batch_decompile, so MCP and CLI inspect-analysis-view share it:
    • summary: producer counts, provider and profile identity, procedure identity counts, total and largest body size, limitation count.
    • {kind:"batch-decompile", collection:"items", where?, offset, limit, include_pseudocode}: rows in retained order with the original index, so duplicate selectors stay distinct. where takes exact indices, addresses, procedure_addresses and statuses; omitted selects all, [] selects none. Bodies are opt-in; a row otherwise reports pseudocode_code_units, or its exact error and limitations.
    • {kind:"batch-decompile", collection:"pseudocode", index, offset, limit}: UTF-16 pages of one body through the existing analysisTextPage.
    • decompiling_provider comes from the upstream analysis profile, because the Evidence provider is the composing workflow. It is null when the parent records none.
    • Parents must carry the rea.analysis predicate and a valid result, like other native views.
  • Not included: detail: "summary" and overflow continuations (stacked follow-up); input bounds ([Bug] batch_decompile accepts unbounded address arrays #5930); per-item provider provenance ([Bug] Successful batch decompiles lose per-item provider provenance #8350); retention-failure recovery (fix!: preserve results when source publication fails #8444); a CLI batch command.

Follow the contribution scope. This is a read-only view of completed Evidence within existing boundaries, so no maintainer scope decision is required. The API shape was posted on the issue before implementation; there has been no maintainer response yet.

Contract and boundary impact

  • Semantic owner and earliest changed stage: batchDecompileResultSchema owns the producer shape; projectBatchDecompileView owns selection. The superseded contract copy and workflow item types are removed.
  • Contribution scope fit and linked maintainer decision: not applicable, as above.
  • CLI and MCP/tool-catalog contract: inspect_analysis_view accepts a new view kind and result; its description names it. batch_decompile is unchanged.
  • Provider, bridge, target-format, or platform compatibility: none; the view reads retained Evidence only.
  • Evidence, artifact, provenance, or reconstruction contract: the view links its parent and never rewrites it. Page coverage describes the selection only. Batch limitations stay aggregated and are explicitly not attributed to one successful item.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): none.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: the catalog grows with the view contract; nothing else.

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, warm project cache, on Homebrew's unexecuted tmux (arm64 Mach-O, SHA-256 8ab1bd9e…a86d, unchanged). The over-budget batch selects the largest real body of 64 functions 1,000 times (13.4M code units). Bytes are the SDK-serialized reply; tokens are tokenx estimates, not billing.

Step Base 8250bf232 This PR
Complete batch, 64 functions 207,175 B 207,175 B, same
Complete batch, 1,000 selectors resource_constraint, export guidance same, and its retained ID is now readable
Summary of that parent unsupported_target 7,991 B, ~2.3k tokens, 47 ms
8 body-free rows not available 10,739 B, ~3.3k tokens, 2 ms
Last row with its body not available 36,729 B, ~10.5k tokens, 1 ms
That body in 2,048-unit pages not available 7 pages, exact

The last row's body equals the same function's body from the direct 64-function batch. A view adds no provider call in the test harness; the real timings above are consistent with that but do not prove it.

Schema cost, one catalog per session: compact 580,675 to 581,021 B (+346 B, about +97 estimated tokens); full 3,958,851 to 3,968,714 B (+9,863 B, about +2,971 estimated tokens).

  • Tests added or updated: tests/boundary/mcp/batchDecompileViewsMcp.test.ts (public MCP, full and compact input and output profiles, replies validated through createMcpSchemaValidation against output schemas both tools must advertise): duplicates, interior selectors, unknown identity, null and failed entry labels, no-body items, exact and empty filters, page coverage, surrogate-safe text pages, refusals, target-free bundle and Evidence-file sources, wrong view and foreign parents, forged predicate, malformed result, empty batch, and a page mixing another collection's rows. tests/boundary/cli/analysisViewCli.test.ts covers target-free CLI reads from a bundle.
  • Base reproduction or other evidence: the table above.
  • User-visible CLI/MCP output (if applicable):
    {"index":0,"address":"0x100001b48","procedure":{"status":"resolved","address":"0x100001b48","name":"_alerts_check_session"},"status":"ok","pseudocode_code_units":299}
  • Remaining proof gaps: real Ghidra, IDA and Hopper were not available on this host, so those providers are exercised only through the Ghidra MCP harness. The cold path is covered by the follow-up's measurements. No autonomous-agent study was run. Peak memory and CPU for this PR are not reported separately; the follow-up measures the complete workflow.

Applicable boundary regressions: projection fidelity, malformed input, page boundaries and duplicate identity. No lifecycle stage changes.

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 src/application/analysisView/AnalysisViewService.test.ts src/application/WorkflowEvidence.test.ts src/application/EnhancedInputDiagnostics.test.ts src/application/EnhancedToolSelectorOrigin.test.ts — 12 files, 186 tests passed
  • Real Kuna 1.988 stdio MCP workflow on base and this branch — results in the table above
  • After the label_unavailable fix (a575803), npm run test:focused -- tests/boundary/mcp/batchDecompileViewsMcp.test.ts — 6 tests passed. The suites above and the real workflow were not rerun for that one-line count change.
  • After merging main at f95bdbce7, npx tsc --noEmit and npm run test:focused -- tests/boundary/mcp/batchDecompileViewsMcp.test.ts tests/boundary/cli/analysisViewCli.test.ts — 2 files, 35 tests passed. Every required CI check had passed on a57580325 before this merge.
  • After merging main at 0e6943c9d, npx tsc --noEmit and the same 2 focused files passed (35 tests). Every required CI check had passed on f469b5959 before this merge.
  • After the shared-validator test change (f469b59), npm run test:focused -- tests/boundary/mcp/batchDecompileViewsMcp.test.ts — 6 tests passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: real Kuna 1.988 on macOS arm64 only. Ghidra through the MCP harness.
  • Package or release metadata impact: none beyond the generated catalog.
  • Security, privacy, process, or containment review: views read retained Evidence only and start no provider. A retained parent remains unchanged.

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

…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]>
@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-02T07:19:52.242312Z f469b59 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.

kaoru0822-kitauji and others added 2 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]>
@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 reviewed changes appear safe to merge.

Summary

Adds selected views of completed batch_decompile Evidence without repeating analysis.

  • Callers can select retained batch results without repeating decompilation.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Completed batch Evidence] --> B[Check parent and result]
  B --> C[Summary]
  B --> D[Selected rows]
  B --> E[One body page]
  C --> F[View linked to unchanged parent]
  D --> F
  E --> F
Loading

Reviews (3) · Last reviewed commit: "test(native): require advertised batch s..." · Reviewed by Greptile

…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]>
@kaoru0822-kitauji
kaoru0822-kitauji merged commit dec8d2d into main Nov 2, 2026
50 of 52 checks passed
@kaoru0822-kitauji
kaoru0822-kitauji deleted the feat/8498-batch-decompile-view branch November 2, 2026 07:58
coyoteXujie pushed a commit to coyoteXujie/rea that referenced this pull request Nov 2, 2026
…s views (morluto#8629)

* 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]>

* 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]>

* 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]>

---------

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.

[Design] Retrieve selected results from retained batch decompilation

2 participants