Skip to content

fix(ghidra): explain read-only project recovery - #8581

Closed
morluto wants to merge 3 commits into
mainfrom
codex/ghidra-readonly-recovery
Closed

morluto wants to merge 3 commits into
mainfrom
codex/ghidra-readonly-recovery

Conversation

@morluto

@morluto morluto commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fixes #8580. Annotating a selected read-only Ghidra project correctly fails, but the error previously advised only choosing another analysis or target. It now states the read-only policy and explains that a fresh editable import is a separate ephemeral analysis without the saved project's annotations.

Change and scope

The Ghidra capability owner supplies the policy and recovery for unavailable mutation operations. The shared session execution boundary preserves an unavailable descriptor's explicit reason and remediation in the typed error. Declared capabilities without remediation retain their existing projection. No provider is switched and the existing project remains read-only.

Contract and boundary impact

  • Semantic owner: Ghidra existing-project capability descriptor; the shared session layer delivers its reason and recovery without reinterpreting it. Other provider descriptors that already declare remediation also receive their own guidance.
  • CLI/MCP: capability_unavailable and structured reason are retained; message and action are now specific when an unavailable descriptor provides remediation. No request or result shape changes.
  • Existing projects and target bytes are never modified; the fresh-import option is explicit, separate and ephemeral. No new capability or maintainer scope decision applies.
  • Related fix(session): guide unsupported provider recovery #8567 changes the adjacent undeclared-operation fallback; the declared policy recovery here should take precedence when the changes are combined.

Evidence and regression coverage

  • Public MCP boundary regressions use the actual Ghidra existing-project capability descriptor to check delivered guidance, setting names, unchanged active run and that the refused operation is not dispatched. Removing the descriptor remediation made this regression fail; restoring it passed. A second fixture with unrelated reason and remediation checks generic descriptor delivery without Ghidra-specific text.
  • Real Ghidra 12.1.4 stdio MCP with compact and full profiles: an owned existing project with a saved function name refused annotation with the specific reason and action. A separate fresh import exposed the original name and allowed an ephemeral edit. Target and original project hashes remained unchanged.
  • Real CLI returned the same typed refusal and guidance on the owned root project. Nested project selection is unmerged (feat(ghidra): select an existing-project program inside a project folder #3817) and was not tested with this branch; if it lands, its additional folder setting must be included in recovery.

Validation performed

  • npm run test:focused -- tests/boundary/mcp/sessionAvailabilityRecovery.test.ts tests/boundary/mcp/providerSelectionMcp.test.ts — 20 passed; the changed session file was rerun after the final generic-provider regression, 10 passed.
  • npm run check:fast — passed.
  • npm run docs:check — passed.
  • Real Ghidra 12.1.4 / JDK 21, macOS arm64 MCP and CLI controls described above — passed.
  • git diff --check — passed.

A temporary merge of this head 41472c933 and #8567 96ba4225 required resolving their shared session-execution hunk. With undeclared-operation guidance used only for absent descriptors and explicit descriptor remediation taking precedence, the two MCP boundary suites passed 20 tests and the real Ghidra existing/fresh handoff passed in both schema profiles. This validates that specific local resolution, not an automatic merge or either PR alone.

An additional real Ghidra control omitted REA_GHIDRA_PROGRAM_NAME, letting the name default from the target. Both MCP profiles returned the same read-only recovery and preserved source hashes. binary_session complete detail also exposed the same remediation for the unavailable annotation tools; this is a catalog observation, not a controlled agent-selection study.

A further real Ghidra control exercised seven annotation-related operations on the read-only root project in both MCP profiles. set_address_name, set_addresses_names and annotate_native_function received the read-only recovery; set_comment, set_inline_comment, set_bookmark and unset_bookmark remained undeclared and received the generic unavailable error. In a fresh Ghidra import, direct set_comment was still unavailable, while annotate_native_function successfully wrote a function-entry comment. This PR does not claim that every annotation operation becomes available after reopening; arbitrary-address comments are tracked separately in #6404. The selected project, target and session state stayed unchanged during the refusal control.

Compatibility, safety, and release

Existing successful calls and result shapes are unchanged. Unavailable capability descriptors with explicit remediation now expose it to callers. Real-provider coverage is limited to the stated host and fixtures; no model-choice or other-platform claim is made.

A temporary conflict-resolved combination of #8567 757f2646 and #8581 d1f5b3ea passed 23 MCP boundary tests and real Ghidra 12.1.4 controls in both schema profiles. Fresh sessions offered and successfully followed the regular/inline function-entry handoff; existing-project sessions did not suggest that unavailable edit and retained their specific read-only recovery. The target and original project hashes were unchanged. This validates the stated local resolution, not an automatic merge.

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.

@greptile-apps

greptile-apps Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

[Medium impact] The PR appears safe to merge; the earlier test gap is fixed and no new blocking issue was found.

Summary

Ghidra's read-only refusal now explains how to start a separate editable import without the saved project's annotations. The shared session layer preserves provider-owned recovery guidance.

  • Read-only Ghidra refusals explain how to start a separate fresh import.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Ghidra read-only capability] --> B[Session refuses operation]
  B --> C[Typed error preserves reason and recovery]
  C --> D[CLI or MCP caller]
Loading

Reviews (2) · Last reviewed commit: "test(ghidra): exercise read-only capabil..." · Reviewed by Greptile

@morluto
morluto marked this pull request as ready for review November 1, 2026 18:23
@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-01T18:25:10.219103Z d1f5b3e 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 closed this Nov 7, 2026
@morluto morluto added bug Something isn't working provider: ghidra Analysis provider / engine: ghidra labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working provider: ghidra Analysis provider / engine: ghidra

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(ghidra): explain read-only project annotation refusal

1 participant