Skip to content

fix(mcp): provide native evidence paging continuation - #1910

Merged
N0zoM1z0 merged 5 commits into
morluto:mainfrom
cold-atom:fix/1849-native-evidence-continuation
Oct 11, 2026
Merged

N0zoM1z0 merged 5 commits into
morluto:mainfrom
cold-atom:fix/1849-native-evidence-continuation

Conversation

@cold-atom

@cold-atom cold-atom commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Give callers a ready-to-call pseudocode page when completed native function Evidence exceeds MCP delivery capacity. Preserve the complete canonical record and only offer continuation after session recording is acknowledged.

Fixes #1849.

Problem and expected behavior

An oversized analyze_function result already retains useful Evidence, but generic export advice leaves callers to reconstruct the supported view request. The error should supply exact arguments for the existing bounded source view, without silently replacing or truncating the requested full result.

Change and scope

Attach a named, schema-validated inspect_analysis_view continuation to the completed-result transport error. Start at offset zero with the existing 64-unit default, then follow coverage.next_offset. Keep export advice and explain that arbitrary source or metadata can still require a smaller limit or export. The follow-up regression checks the pinned SDK receive-buffer bound rather than a fixed 12,000-byte envelope; preserved caller paths make envelope size depend on the local directory.

Contract and boundary impact

  • Semantic owner and earliest changed stage: MCP result delivery, after explicit Evidence recording acknowledgment.
  • CLI and MCP/tool-catalog contract: additive details.reported_limits.continuation and actionable remediation; reuse the existing named input contract. CLI behavior and advertised operation schemas are unchanged.
  • Provider, bridge, target-format, or platform compatibility: native function results from existing providers; no engine, import or bridge changes.
  • Evidence, artifact, provenance, or reconstruction contract: preserve full canonical result, exact procedure parameters, target digest and retained reference. No new recording claim for unacknowledged or failed retention.
  • Process execution, authorization, cleanup, or containment impact: no expanded authority or process changes; view retrieval does not invoke the provider again.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: owning MCP documentation updated; no dependency, installer or authored catalog-schema change.

Evidence and regression coverage

  • Tests added or updated: obtain a completed-result transport failure through the registered Ghidra adapter and MCP client, use its continuation directly, retrieve exact first/second source slices, preserve complete parent Evidence, and ping successfully. Existing delivery, unacknowledged retention, failed retention and oversized-view regressions retained.
  • Base reproduction or other evidence: the parent implementation only supplies the retained reference and generic export guidance. Review of head 92817465f also reproduced a path-dependent assertion: a correct 64-unit page serialized to 12,017 bytes, exceeding an arbitrary 12,000-byte test threshold. Follow-up d0aedf63e uses the actual protocol bound.
  • User-visible CLI/MCP output: reported_limits.continuation.name is inspect_analysis_view; its arguments contain the reported retained reference and {kind: "native", facet: "pseudocode", offset: 0, limit: 64}. The next page uses the returned offset.
  • Remaining proof gaps: paging improves delivery and continuation, not native analysis cost or general directory projection. Real Hopper/IDA and local Windows/macOS provider runs were not performed. Simulated Ghidra results establish transport semantics, not engine correctness.

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 test:focused -- tests/boundary/mcp/analysisViewMcp.test.ts tests/boundary/mcp/toolResult.test.ts src/server/toolResultEncoding.test.ts — 28 passed across 3 files, including the follow-up on an isolated long-path worktree.
  • npm run check — passed, including typecheck, lint, formatting, metadata/unused-code checks and architecture guards.
  • npm run docs:check — passed.
  • Fresh stdio MCP with real Ghidra 12.1.4, unchanged stripped x86-64 ELF and procedure 0x41bf30: full result exceeded the 10,485,760-byte receive buffer (at least 10,512,118 bytes). Used the supplied continuation directly: first/second responses each 28,863 bytes, exact 64-unit source slices, next offsets 64/128. Export verified the complete 39,225 UTF-16-unit pseudocode and original selected procedure/digest. Ping, explicit close and unchanged target bytes passed.
  • The real-provider workflow completed in 275.20 s, including startup, export and close, under one CPU, 768-MiB Java heap and a 3-GiB scope. Peak memory 1,268,264,960 bytes; all scope OOM/max events zero.

Compatibility, safety, and release

  • Breaking changes or migration steps: none; complete-result requests retain their contract and transport guard. A continuation is an optional recovery request, not an automatic fallback or completeness guarantee.
  • Real Hopper/Ghidra, browser, or OS coverage: real Linux Ghidra through stdio MCP verified above; remaining local provider/platform scope explicitly unverified.
  • Package or release metadata impact: no dependency/version edits; owning delivery documentation updated.
  • Security, privacy, process, or containment review: no source execution, executable mutation, GUI control, native database save or added installation. Canonical provenance and caller-selected inputs remain intact; local artifacts and verification files are not committed.

Review checklist

  • This PR addresses a concrete problem or an agreed enhancement.
  • 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.

Include schema-validated inspect_analysis_view arguments when retained analyze_function Evidence exceeds the response budget. Preserve complete Evidence and require acknowledged retention.

Refs morluto#1849. Verified with 28 focused MCP tests, npm run check, and npm run docs:check; real native providers were not run.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 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-11T17:58:37.954539Z 9281746 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: 830eee209e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

.parse(parseMcpToolError(detached)).error.details.reported_limits;
expect(detachedLimits).not.toHaveProperty("continuation");
expect(detachedLimits).not.toHaveProperty("evidence_reference");
const failed = delivery.toEvidenceToolResult(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Drive the initial failure through the MCP transport

In this MCP-boundary case, the initial oversized analyze_function failure is manufactured by calling ToolResultDelivery.toEvidenceToolResult directly, so it never traverses the registered producer handler, session-recording wiring, SDK error handling, or ErrorEvidenceTransport; only the later continuation calls use client.callTool. A regression that removes or rewrites details.reported_limits.continuation before it reaches an MCP client would therefore leave this test green. Return the large dossier from the test provider and obtain this first failure via a public analyze_function call instead.

AGENTS.md reference: AGENTS.md:L44-L44

Useful? React with 👍 / 👎.

cold-atom and others added 4 commits October 12, 2026 01:24
Obtain oversized analyze_function failures through the registered Ghidra adapter and MCP client, then page acknowledged session Evidence without further provider calls.

Repair upstream tool-effect wording audit exceptions for static WASM and Harmony inventory tools. Validation: 28 MCP boundary tests, 5 tool-effects tests, check:fast and docs:check passed. Real Ghidra was not run.
Preserved caller paths make page envelopes depend on checkout and temporary
directory length. Replace an arbitrary 12000-byte assertion with the pinned
stdio receive-buffer bound, retaining exact source, offset and retention
checks. The unchanged 64-unit page is 12017 bytes in an isolated worktree.

Refs morluto#1849

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

Copy link
Copy Markdown
Collaborator

Local review found a directory-dependent test failure on head 92817465f3302ea91119c851b0db7d89b2e4b6e9: the first 64-unit pseudocode page is 12,017 bytes including its MCP envelope and preserved caller paths, exceeding the fixed 12,000-byte assertion. The page contents, retention reference and continuation behavior are correct.

Follow-up commit d0aedf63e checks the pinned SDK stdio receive-buffer budget instead, keeping the exact first/second source slices, offsets, complete parent retention and ping assertions. All 28 relevant MCP/encoding tests, npm run check and npm run docs:check now pass in the isolated worktree. Real Ghidra verification is in progress; this note does not claim a real-provider result yet.

@N0zoM1z0
N0zoM1z0 merged commit 1449e8e into morluto:main Oct 11, 2026
31 checks passed
@morluto morluto mentioned this pull request Oct 13, 2026
3 tasks done
@morluto morluto added bug Something isn't working 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 bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Provide bounded native function delivery with actionable retained-evidence continuation

3 participants