Skip to content

fix(mcp): report references a provider truncated in trace_feature - #2348

Merged
morluto merged 15 commits into
morluto:mainfrom
nikolay-dementiev:feat/trace-feature-xref-coverage
Oct 13, 2026
Merged

morluto merged 15 commits into
morluto:mainfrom
nikolay-dementiev:feat/trace-feature-xref-coverage

Conversation

@nikolay-dementiev

Copy link
Copy Markdown
Contributor

Summary

trace_feature always reported truncated: false with no residual unknowns, even when a provider capped the references it returned for a match. A provider can now report that an xrefs read was truncated, and the trace marks that target as a residual unknown. A provider that reports nothing produces the same trace as before.

Prerequisite for #2335 (headless IDA containing procedures); this change alone does not close it.

Problem and expected behavior

The IDA adapter reads references with upstream xrefs_to (limit 1000) and records more: true only as a diagnostic limitation string. EnhancedTools.#call keeps just the result, and traceLiteralFeature returns truncated: false, residual_unknowns: [] unconditionally, so a trace over a capped read looks complete.

Expected: when the provider explicitly reports that the references to a matched address were truncated, the trace keeps the references it received, sets truncated: true, and adds a residual unknown naming that address. An explicit "not capped" report and a provider that reports nothing leave the trace unchanged. No completeness is inferred from limitation text.

Change and scope

  • src/application/AnalysisProvider.ts: AnalysisExecution and createAnalysisExecution gain an optional referencesTruncated (true: the provider capped the xrefs read; false: it explicitly reported no cap; absent: it reports nothing). It is internal: it is not part of Evidence, tool output or the snapshot format.
  • src/ida/IdaOperationRunner.ts, src/ida/IdaSessionClient.ts: the IDA adapter sets it from the upstream more flag of xrefs_to; the existing limitation text is unchanged.
  • src/application/EnhancedLiteralTracing.ts, src/application/EnhancedTools.ts: trace_feature reads xrefs through #observe and, only when referencesTruncated is true, sets truncated: true and adds "References to were truncated by the provider; additional references may exist." once per address.
  • src/application/InvestigationProviders.ts: the trace_feature workflow profile revision is bumped, so earlier results are not replayed under the new semantics (same pattern as the graph and batch workflows).
  • src/application/binary/AnalysisSnapshotCache.ts: record does not store an execution whose referencesTruncated is true, because the snapshot format cannot carry the field and a replay would present a capped read as complete. Only IDA sets the field today and its operations are never cached.
  • Hopper, Ghidra and every other provider are unchanged and do not set the field, so their traces are identical to before (asserted).

Intentionally not included:

  • Supporting Evidence and evidence_links for the primitive reads behind a composed workflow.
  • Containing-procedure support for headless IDA, which makes trace_feature usable there (separate change).
  • No tool schema, CLI output or error code changes; truncated and residual_unknowns already exist in the output.

Contract and boundary impact

  • Semantic owner and earliest changed stage: the provider execution contract in src/application, set by the IDA adapter; consumed by the trace_feature workflow.
  • CLI and MCP/tool-catalog contract: none. Existing output fields carry the new values; the new execution field never appears in output (asserted).
  • Provider, bridge, target-format, or platform compatibility: IDA headless, attached and native profiles that report more; legacy get_xrefs_to reports no flag and stays silent.
  • Evidence, artifact, provenance, or reconstruction contract: unchanged for primitive Evidence. The composed workflow result differs only when a provider reports truncation.
  • Process execution, authorization, cleanup, or containment impact: none.
  • Generated metadata/package/installation impact: none.

Evidence and regression coverage

  • Tests added or updated: tests/boundary/mcp/enhancedTools.traceFeatureCoverage.test.ts (production MCP server over an in-memory transport, exact toEqual on the whole trace): a capped target is a residual unknown while an uncapped sibling is not and all references are kept; a truncation is not carried over to the next target that reports nothing; a target matched twice is reported once; an explicit "not capped" report leaves the trace complete; a provider that reports nothing, even with limitation text mentioning a cap, returns exactly the trace it returned before; neither spelling of the field appears in the output; a failed references read stops the trace without reading further targets; a cancelled trace reads no references. tests/composition/analysis-sessions/binarySession.test.ts: the session forwards the field on both execution paths and a truncated read is never replayed, while an explicit complete report is. src/ida/IdaReferenceCoverage.test.ts (real headless session client over the recording fake): more: true gives true and keeps the limitation, more: false gives false, no flag gives nothing, the legacy profile and other operations report nothing; src/ida/IdaNativeProtocol.test.ts asserts the native profile forwards the explicit flag. src/application/binary/AnalysisSnapshotCache.test.ts: a truncated execution is not replayed while a complete or silent one is, and the trace_feature profile is revised while other workflows keep theirs.
  • Base reproduction or other evidence: the new tests fail on a97b713f7 (RED commit d8b802b3a: 5 failed in the three files; the unchanged-trace test passes there by design).
  • Real IDA Professional 9.1 (headless idalib, ida-pro-mcp c133c38, macOS arm64): a fixed 37-step sweep over five fixtures (callees, call graphs, traces, build_call_path, error cases, universal and stripped binaries) gives results identical to a97b713f7, and npm run verify:ida passes.
  • Remaining proof gaps: Hopper and Ghidra were not run (no engines on this machine); real IDA cannot run trace_feature until containing procedures are supported for headless IDA.
  • 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, npm run check, npm run docs:check, npm run verify:test-discovery (966 files) - green
  • npm run test:focused over the five affected test files - 87 passed
  • npm run test:fast - 408 files, 5310 passed, 7 skipped, 0 failed; npm run test:mcp - 103 files passed, 2 skipped, 447 passed, 3 skipped; npm run test:boundary -- tests/boundary/providers/ida after npm run build:cached - 14 passed
  • Mutation checks, each reverted: the IDA adapter never reporting fails 2; counting an absent field as truncated fails 1; removing the revision fails 1; removing the snapshot guard fails 1; deriving truncation from limitation text fails 2; a session that drops the field fails 2; reporting a capped target twice fails 1; leaking a differently spelled field into the output fails 6

macOS arm64 only; Linux and Windows were not executed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. A trace_feature result for a provider that reports a truncated read now has truncated: true and a residual unknown.
  • Real Hopper/Ghidra, browser, or OS coverage: none; not applicable to the reported flag, which only the IDA adapter sets.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no new capability, input or write path; no limitation text is parsed.

Review checklist

  • The change addresses a concrete problem, not an unscoped refactor.
  • The PR has one focused outcome, and the title follows type(scope): outcome.
  • Related issue is linked.
  • Tests cover changed behavior and failure paths.
  • Owning docs, contracts, and generated metadata are updated.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

…ncated

A provider that reports a capped xrefs read makes the trace truncated with a residual unknown for that target. An explicit complete report and a provider that reports nothing leave the trace as before.
Executions gain an optional flag for a capped xrefs read, set by the IDA adapter from the upstream cap. trace_feature marks the trace truncated with a residual unknown for that target only when the provider reports a truncation; a provider that reports nothing keeps its previous result. The trace_feature workflow profile is revised so earlier results are not replayed.
@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 13, 2026

Copy link
Copy Markdown
Owner

@greptileai review

@greptile-apps

greptile-apps Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

This PR is set for a Plus review. TREX isn't supported with Plus or Apex reviews yet, so Greptile reviews this PR at Base while TREX is on.

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Low impact] This test-only change appears safe to merge.

Summary

The actual PR diff adds one assertion in src/ida/IdaNativeProtocol.test.ts. It checks that native xrefs forwards an explicit referencesTruncated: false.

  • The native IDA test checks that uncapped reference reads stay explicit.

Reviews (6) · Last reviewed commit: "fix(process): keep monotonic deadline ow..." · Reviewed by Greptile

nikolay-dementiev and others added 8 commits October 13, 2026 09:24
…xref-coverage

# Conflicts:
#	src/application/AnalysisProvider.ts
…xref-coverage

# Conflicts:
#	src/ida/IdaWorkspaceThinning.test.ts
Node timers can fire while performance.now() is still a fraction of a
millisecond short of the monotonic deadline. ProviderStartupDeadline then
reported interruption "timeout" and an aborted signal while remainingMs()
returned ceil(0.x) = 1, so polling loops guarded by remainingMs() > 0
(Hopper and Ghidra startup) could run past an elapsed deadline, and the
real-timer test "aborts a bounded wait when its real monotonic deadline
expires" failed intermittently in CI (expected 1 to be 0).

Once the deadline's own timer has classified a timeout, report zero
remaining time. A deterministic regression test fires the timer with the
monotonic clock 0.4 ms short of the deadline.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit dfdaa0c)
@morluto morluto added bug Something isn't working area: mcp MCP server, transport, and tool registration area: runtime Process capture and runtime observation area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior P2: medium Medium priority issue labels Oct 13, 2026
@morluto
morluto merged commit af142f6 into morluto:main Oct 13, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: mcp MCP server, transport, and tool registration area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior area: runtime Process capture and runtime observation bug Something isn't working P2: medium Medium priority issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants