Skip to content

fix(mcp): guide address context recovery - #8766

Merged
morluto merged 11 commits into
mainfrom
codex/address-comment-dossier-guidance
Nov 4, 2026
Merged

morluto merged 11 commits into
mainfrom
codex/address-comment-dossier-guidance

Conversation

@morluto

@morluto morluto commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

Summary

Addresses #8363. inspect_address_context no longer tells callers to repeat an unsupported facet operation. For unavailable comments with a known containing function, it suggests a conditional route through the function's retained dossier.

Problem and expected behavior

For a Ghidra function, address context could resolve the containing function while telling callers to invoke unsupported comment and inline_comment. The complete function dossier already carries address-tagged comments. The result must retain the unavailable state and avoid assigning an entry comment to an interior address.

This PR supersedes #8414 for #8363. It includes the real Ghidra COM verifier and covers containment, unsupported operations, retryable failures and provider-specific recovery.

Change and scope

For non-retryable comment capability refusals with no provider-specific remediation, use the resolved entry to suggest analyze_function summary followed by its parent Evidence's paged native comments view. The message conditions this on provider support and the same document, and tells callers to check availability, pagination and the exact address. If no function is known, it points to complete binary_session provider availability and conditionally suggests searching a known name and verifying identity and coordinates after a provider switch. Retryable or provider-specific facet refusals retain their user-facing reason and remediation; unsupported facets point to provider availability; other errors, cancellation and cleanup handling remain unchanged. This is navigation guidance; it neither invokes an extra analysis nor reports comments as available. The analyze_function catalog description also names comments among the pageable facets.

Contract and boundary impact

  • Semantic owner: the shared address-context workflow owns facet recovery, using its already parsed containing-function result.
  • Contribution scope: ordinary recovery guidance; no maintainer scope decision required.
  • CLI and MCP contract: changes facet remediation text and the analyze_function description; no schema changes.
  • Provider compatibility: conditional across providers; comment retrieval verified with Ghidra and unavailable-facet behavior checked with Kuna.
  • Evidence and lifecycle: no new Evidence or provider calls; existing errors and cleanup outcomes remain owned by their producers.
  • Generated metadata and package: no generated outputs changed.

Evidence and regression coverage

  • Public MCP boundary coverage checks both output profiles, the resolved entry, same-document and exact-address caveats, the case with no containing function, a retryable refusal with provider-specific remediation, continuing-session versus one-shot guidance, and an unavailable containing-procedure operation. These recovery variants use controlled provider failures. The no-function fixture uses the complete producer reply shape and rejects unmodeled operations; assertions check recovery facts rather than full prose. Existing tests exercise input errors, cancellation and cleanup.
  • Real Ghidra 12.1.4 on macOS arm64: with a known EOL comment at interior address 0x201171 in a disposable copy of an existing project, all four compact/full input and output profile combinations produced the new guidance. Following the summary's parent_evidence_id through inspect_analysis_view returned the exact interior comment and the separate entry comment. With a one-item page limit, the first page pointed to offset 1 and the interior comment appeared on the exhausted second page. A separate query at 0x201185, outside known functions, returned no containing function and provider-availability guidance rather than the dossier route in both output profiles. The original unexecuted ELF SHA-256 remained 0cee46f9e95af174dec7f281c179cbe5233348520302c69fdc9eafc7fcebff1d.
  • In a separate real Kuna 1.989 control in both profiles, containing-procedure resolution was unavailable, so the context offered provider-availability guidance for that facet rather than asking the caller to repeat the unsupported operation, and did not suggest the dossier route. With Ghidra and a JDK configured, complete session status identified Ghidra as an available, target-supported candidate declaring containing-procedure resolution. After explicitly closing and reopening the same ELF with Ghidra, the same coordinate resolved a function in both output profiles; this fixture does not establish coordinate equivalence in general. A separate Kuna dossier reported its comments facet unavailable; paging its retained comments returned an explicit unavailable item and reason, rather than an empty comment list. The same unexecuted ELF digest remained unchanged.
  • A real Ghidra malformed-address control (0xZZ) kept address_name and containing-procedure failures as structured invalid_request facets with address-format details in both output profiles; no containing-function dossier route was suggested. Unsupported comment facets still reported provider availability.
  • With a deliberately wrong explicit document, real Ghidra in both output profiles retained the supplied identity and reported the actual active Program in structured invalid-request details; it did not suggest a containing-function dossier. The target remained unchanged. This does not test a multi-document provider.
  • A second real ELF switch used Kuna coordinate 0x1340 and Ghidra search_procedures returned the named candidate at 0x101340; Ghidra context resolved that candidate in both output profiles. The unexecuted target SHA-256 stayed 5b8bb1398a664530924f4cc47d0eb84927c67e1f6ed634cdd6ec7cf3b769cd09. This is a fixture-specific candidate, not an automatic mapping or general identity guarantee.
  • On a separate unexecuted Mach-O containing two local functions named _shared_func, real Kuna and Ghidra search_procedures each returned both distinct addresses with default detail and with complete detail, in compact and full output profiles. This supports treating search results as candidates, not choosing by name alone; the target digest remained ae0f2a349b22332113ab60ab4c78024eb18153c76bdeefb01c4b1d89a26c0003.
  • The application port does not independently prove that a dossier targets the same document or is available; the guidance makes both conditions explicit. It does not establish comment absence, arbitrary-provider support, natural agent selection, or bounded underlying Ghidra analysis cost. The facet schema does not expose structured capability errors; this change preserves their reason and remediation as text.

Validation performed

  • npm run verify:ghidra:com — passed after incorporating the fix: guide address-context comment recovery #8414 real-provider recovery control, using Ghidra 12.1.4 and JDK 21 on macOS arm64. The public MCP workflow retrieved exact regular and inline comments through the retained dossier and checked outside-function guidance; the fixture remained unchanged and cleanup completed.

  • npm run test:focused -- tests/boundary/mcp/addressContextInputErrors.test.ts src/application/AnalysisContextQueries.test.ts — 36 passed.

  • npm run test:focused -- tests/boundary/mcp/addressContextInputErrors.test.ts — 8 passed after the continuing-session assertion.

  • npm run check:ci:fast — passed after the fixture and assertion corrections.

  • npm run test:focused -- tests/boundary/mcp/addressContextInputErrors.test.ts — 8 passed after those corrections. npm run docs:check passed before the test-only refactor.

  • Real Ghidra stdio MCP catalog description, summary, retained comments page, and address-context guidance — passed in all four compact/full input and output profile combinations.

Compatibility, safety, and release

  • No migration or schema change; facet recovery text and catalog description change.
  • Other Ghidra hosts and real providers beyond Ghidra and Kuna were not exercised for this change.
  • The original selected project is not modified by REA; the interior marker was prepared only in a disposable project copy.

Author readiness

Human owner:

  • 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.
  • This PR has one focused outcome and a conventional title.
  • Tests cover changed observable behavior and meaningful failure paths.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

@morluto morluto changed the title fix(mcp): guide function comment recovery from address context fix(mcp): guide address context recovery Nov 3, 2026
@greptile-apps

greptile-apps Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

[Low impact] No actionable issue was found that blocks merging this revision.

Summary

Updates inspect_address_context recovery guidance and adds a real Ghidra check that follows the suggested route to retained comments.

  • Address context points unsupported comment lookups to a known function’s retained comments.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A["inspect_address_context"] --> B{"Comment capability refused?"}
  B -->|No| C["Keep the facet result or error"]
  B -->|Yes| D{"Retryable or provider recovery supplied?"}
  D -->|Yes| E["Keep provider recovery"]
  D -->|No| F{"Containing function found?"}
  F -->|No| G["Suggest binary_session complete availability"]
  F -->|Yes| H["Suggest analyze_function for the same document"]
  H -. "Caller follows guidance if supported" .-> I["Page native comments using parent_evidence_id"]
  I --> J["Check availability, pages and exact address"]
Loading

Reviews (3) · Last reviewed commit: "test(ghidra): verify address comment rec..." · Reviewed by Greptile

@morluto
morluto marked this pull request as ready for review November 4, 2026 16:53
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 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-04T16:56:08.021009Z baed452 Draft marked ready
ℹ️ 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.

@morluto
morluto merged commit 5a1f754 into main Nov 4, 2026
52 of 54 checks passed
@morluto
morluto deleted the codex/address-comment-dossier-guidance branch November 4, 2026 17:48
@morluto morluto added area: mcp MCP server, transport, and tool registration bug Something isn't working labels Nov 22, 2026
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 bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant