Skip to content

fix: guide address-context comment recovery - #8414

Closed
morluto wants to merge 4 commits into
mainfrom
codex/address-context-recovery
Closed

morluto wants to merge 4 commits into
mainfrom
codex/address-context-recovery

Conversation

@morluto

@morluto morluto commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Superseded by #8766, which covers the same recovery problem and includes the real Ghidra COM verifier.

Summary

inspect_address_context tells agents to call comment or inline_comment even after the active provider has reported those operations unavailable. When a containing function is known, guide them to the existing function-dossier comments view; otherwise preserve the facet as unknown and point to session availability.

Addresses #8363. The aggregate result and its Evidence handoff remain separate design questions in #8364. Structured invalid-address/document diagnostics and incomplete facet cleanup were merged separately; this branch incorporates main and retains both behaviors.

Both this PR and #8766 address #8363 and overlap in AnalysisContextQueries.ts; #8766 adds a catalog description and further recovery controls. Review them together and reconcile the final implementation and validation before merging either.

Change and scope

The context workflow selects recovery from the actual error and containment result. A non-retryable capability refusal uses provider-supplied recovery when present. For comments with known containment, it conditionally explains the summary-to-comments-view route, same-document requirement, address/kind matching, paging and coverage. Other capability refusals no longer recommend repeating an operation already known to be unavailable. Retryable and other failure guidance remains unchanged.

This changes guidance only: it adds no provider operation, automatic dossier query, cross-document selection, new mutation, or claim that unknown comments are absent. The existing context result shape, facet observations and reasons are retained. Ordinary usability fix within existing scope; no new-capability maintainer decision is required.

Evidence and regression coverage

On base 6e9ee97a, real Ghidra 12.1.4 returned a containing function but told the caller to invoke unavailable direct comment operations. Real Kuna 1.986 did not expose containment on the same Mach-O and its function dossier explicitly reported analyst comments unavailable. The candidate preserved these observations and reasons, offered the conditional dossier route for Ghidra's known function, and left Kuna and Ghidra addresses outside a function unknown.

The maintained real-Ghidra COM verifier now writes a regular and an inline session annotation, calls inspect_address_context with the TypeScript MCP SDK using fetched tool definitions, follows the returned summary-to-retained-comments path, verifies both exact comment kinds and address, and checks an outside-function control. The fixture bytes remain unchanged and owned processes clean up. The in-memory MCP boundary cases compare delivered recovery with its owning constants and additionally cover containment unavailable, retryable capability errors and provider-owned recovery. These are not autonomous-agent behavior measurements.

Validation performed

  • npm run verify:ghidra:com — passed with real Ghidra 12.1.4 / JDK 21 on macOS arm64; unexecuted DOS COM fixture, SDK MCP and CLI, original bytes unchanged and process cleanup verified.
  • Real stdio MCP baseline/8b715f255 candidate controls on an unexecuted source-owned arm64 Mach-O (the later follow-up extracts identical guidance into named constants) — Ghidra 12.1.4 with full and Kuna 1.986 with compact advertised output schemas; source digest unchanged. Ghidra and Kuna covered function, non-function and unmapped addresses.
  • npm run test:focused -- tests/boundary/mcp/addressContextBookmarks.test.ts — 15 passed after integrating main, including generic versus provider-specific recovery precedence.
  • npm run test:local -- src/application/AnalysisContextQueries.test.ts — 28 passed after integrating main.
  • A detached combination with fix(session): guide unsupported provider recovery #8567 was exercised through real compact MCP on an owned arm64 Mach-O: specific function-comment recovery remains visible despite generic provider-discovery guidance. Following its summary-to-retained-comments-view route returned both exact annotated comments with page coverage. The target stayed unchanged and unexecuted.
  • On an owned existing Ghidra project, independently set regular and inline comments at an instruction inside a function using a headless script. Real compact MCP context returned the interior query address and containing entry; following the summary-to-comments-view route returned both exact interior-address comments. The target and the caller-owned project files were unchanged by REA. One Mach-O, Ghidra 12.1.4, macOS arm64; no broader coverage is implied.
  • A headless Ghidra control also placed a PRE comment at a mapped data address outside any function. In existing-project mode, REA reported no containing function and an unavailable/unknown comment rather than directing the caller to a function dossier. REA left the project and target unchanged. The address-level retrieval gap is tracked in [Feature] Ghidra: admit comment / inline_comment / set_comment / set_inline_comment at any mapped address #6404.
  • npm run check:fast, git diff --check, and changed-file oxfmt --check — passed.

Compatibility, safety, and release

No schema or migration change. Comments remain unavailable in the context result; this change exposes a conditional route to separately retained function Evidence. Other providers, Windows, cross-document applicability and autonomous agent decisions were not tested. A complete page does not by itself establish complete provider coverage.

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.
  • 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.

@greptile-apps

greptile-apps Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The reviewed changes appear safe to merge.

Summary

Updates inspect_address_context recovery without changing its result shape or making extra provider calls.

  • Address checks point callers to retained comments when a function is known.

The previous unnumbered wording finding is addressed by the shared constants and separate behavior checks. No security issues were identified in the changed code.

Tests were not run during this review. Whether another PR supersedes this one could not be checked because GitHub access was unavailable.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Facet read fails] --> B{Non-retryable capability refusal?}
  B -->|No| C[Keep existing failure guidance]
  B -->|Yes| D{Provider supplies recovery?}
  D -->|Yes| E[Return provider recovery]
  D -->|No| F{Comment with known containing function?}
  F -->|Yes| G[Suggest same-document summary and retained comments view]
  F -->|No| H[Point to binary_session; facet remains unknown]
Loading

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 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-01T16:56:43.565440Z 89bf190 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.

…-recovery

# Conflicts:
#	src/application/AnalysisContextQueries.ts
#	tests/boundary/mcp/addressContextBookmarks.test.ts
…-recovery

# Conflicts:
#	src/application/AnalysisContextQueries.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant