Repository navigation
fix(ghidra): tell callers to reopen after the provider exits - #2945
RishTheFish21 wants to merge 1 commit into
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e960a64d82
ℹ️ 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".
| ? {} | ||
| : { progress: options.progress }), | ||
| }); | ||
| if (called.ok) providerStarted = true; |
There was a problem hiding this comment.
Treat bridge replies as proof of startup
providerStarted is set only when callTool returns ok, but a remote error is also a validated response from an already-started bridge (GhidraClient.callTool completes startup before entering the request queue). If the first Ghidra query returns, for example, not_found or ambiguous and the JVM exits afterward, the next process failure still sees providerStarted === false, so lostProviderHealth() suppresses the observed exit and falls back to the misleading rea doctor guidance. Record completion of the startup handshake at the owning client boundary (and make ready-only dispatches use the same fact) instead of inferring it from a successful operation.
AGENTS.md reference: AGENTS.md:L23-L23
Useful? React with 👍 / 👎.
|
| ? {} | ||
| : { progress: options.progress }), | ||
| }); | ||
| if (called.ok) providerStarted = true; |
There was a problem hiding this comment.
First errors hide reopen advice
On a plain ELF target, callTool can complete startup and return a bridge error, but providerStarted stays false. For example, call procedure_pseudo_code for a missing procedure, then kill Ghidra and call list_documents. The new gate hides the exited health, so the caller still gets rea doctor advice instead of being told to reopen.
Track successful startup independently of successful tool results, and add a test for a bridge error followed by provider loss.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/ghidra/GhidraProviderClient.ts
Line: 837
Comment:
**First errors hide reopen advice**
On a plain ELF target, `callTool` can complete startup and return a bridge error, but `providerStarted` stays false. For example, call `procedure_pseudo_code` for a missing procedure, then kill Ghidra and call `list_documents`. The new gate hides the exited health, so the caller still gets `rea doctor` advice instead of being told to reopen.
Track successful startup independently of successful tool results, and add a test for a bridge error followed by provider loss.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.e960a64 to
543b14d
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 543b14d52f
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return undefined; | ||
| if ( | ||
| health === undefined || | ||
| providerRetryAction(health.state) !== "restart_provider" |
There was a problem hiding this comment.
Honor the health snapshot's retry action
ProviderOperationHealth already carries the recovery decision chosen by its owner. If an exited or unreachable snapshot reports retryAction: "retry" or "unknown"—for example when the owner applies the startup-sensitive mapping supported by providerRetryAction(state, true)—this recomputation silently changes it to restart_provider, so the error tells callers to open_binary while binary_session.provider_operation_health exposes a different action. Gate on health.retryAction rather than deriving it again.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
543b14d to
a106581
Compare
a106581 to
e1e6a2c
Compare
Share tagged readiness observations, retain partial provider facts, authenticate bridge identity, bound diagnostics, and preserve cancellation and lost-session reasons. Fail closed for unparsed MIPS ABI attributes and macOS saved Hopper databases without a script-capable bridge route. Reviewed fixes: #2010, #2108, #2513, #2695, #2731, #2771, #2828, #2867, #2868, #2870, #2880, #2919, #2945, #2961, #2981, #2998, #3000, #3002. Validation: 285 focused source/boundary tests passed. Real Ghidra, IDA, Linux Hopper, and Windows provider runs were not repeated. BREAKING CHANGE: MIPS targets with unresolved GNU ABI attributes and saved Hopper databases on macOS are refused rather than advertised as supported.
|
Heads up: main already has this change in d4bd65c. The code is in 🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊 |
|
Superseded by the lost-Ghidra-session guidance delivered on main in d4bd65c53 and current session/projection regressions. The failure retains the provider-specific reason and tells callers to reopen after provider exit rather than implying the lost session can continue. Closing this earlier proposal; #1719 is already resolved. |
|
Thank you @RishTheFish21 for highlighting the recovery path after a Ghidra session is lost. Main provides reopen guidance for that failure. |
Summary
Fixes #1719. The reopen and
snapshot_pathpaths from the original report were already fixed bye59db2fand #2014; I verified them on real Ghidra (see Validation). The one remaining case: after the Ghidra process dies, a query without a reopen returned a genericexecution_failuretelling the caller to runrea doctorand that repeating would not help. Nothing is wrong with the installation, and a plainopen_binaryon the same target recovers.Problem and expected behavior
Kill the Ghidra JVM after a successful query, then call
list_documentswithout reopening:rea doctorand review the reported details; repeating the unchanged request is not expected to succeed."Change and scope
projectSessionErrorinGhidraProviderClient.tsnow receives the client'soperationHealthSnapshot(). When aprocess/protocolfailure coincides with healthexitedorunreachable(providerRetryAction=restart_provider), theProviderAdapterErrorcarries a user message pointing atopen_binary. This follows the existing HopperRESTART_OWNED_PROVIDERpath.remote) failures and failures with unknown health are unchanged.Not included: restarting Ghidra automatically on the next query. A silent restart would discard session annotations, so the caller reopens explicitly.
Contract and boundary impact
execution_failure), category,retryable: falseand details; only the message and remediation text change in this case.docs/public/product-catalog.json), package, or installation impact: none.Evidence and regression coverage
src/ghidra/GhidraProvider.behavior.test.ts: exited → reopen message; unreachable → reopen message; death before the first reply → keepsrea doctor; unknown health → unchanged;remotefailure → unchanged.main(ebaaa79ca) posted on [Bug] open_binary silently short-circuits without starting a real provider client #1719 shows the old message.unreachablecase (socket closed, process alive) is covered by the fake-client test, not reproduced with real Ghidra.For evidence-bearing changes:
Validation performed
npm run test:focused -- src/ghidra/GhidraProvider.behavior.test.ts: passednpm run check:fast: passednpm run check: typecheck, compile and metadata passed;format:checkfails ondocs/readme/README_tr.mdandscripts/lib/clean-linux-hopper-runtime.mjs, which this PR doesn't touch (pre-existing onmain)npm run lintandnpm run knip: passedrea mcpover stdio and SIGKILLing the Ghidra JVM at set points:open_binarysame target → query: okopen_binary+ query: okclose_binarywithsnapshot_path→open_binarywithsnapshot_path→ query → second open → query: okopen_binarywithsnapshot_path→ query: okCompatibility, safety, and release
Review checklist
type(scope): outcome.