Repository navigation
fix(ghidra): declare observed function facets and call coverage - #3025
RishTheFish21 wants to merge 2 commits 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: 8e3a0975e8
ℹ️ 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".
| operation === "analyze_function" | ||
| ? { | ||
| status: "complete", | ||
| diagnostics: [resolvedCallReferenceLimitation], |
There was a problem hiding this comment.
Do not mark incomplete analyzed call sets complete
When the analyzed function contains a targetless indirect/computed call, this new branch emits status: "complete" even though analyzeFunctionObservation only serializes the resolved getCallingFunctions/getCalledFunctions sets and never fills unresolved_calls. Because functionCallCoverageLimitations ignores diagnostics on complete coverage, compare_functions can label that incomplete call set unchanged (and call-path consumers can treat it as exhaustive); emit the unresolved sites or downgrade this coverage instead.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
|
| operation === "procedure_callers" || operation === "procedure_callees" | ||
| operation === "procedure_callers" || | ||
| operation === "procedure_callees" || | ||
| operation === "analyze_function" |
There was a problem hiding this comment.
Unresolved calls look unchanged
With complete coverage for analyze_function, functions with unresolved indirect calls compare as unchanged in the calls dimension when their resolved callers and callees match. analyzeFunctionObservation never adds unresolved_calls, and functionCallCoverageLimitations ignores diagnostics for complete coverage.
Share the unresolved-call collector from procedureReferences with analyze_function and include those sites in the dossier. This keeps unresolved calls unknown while allowing fully observed functions to compare normally.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/ghidra/GhidraProviderCapabilities.ts
Line: 60
Comment:
**Unresolved calls look unchanged**
With complete coverage for `analyze_function`, functions with unresolved indirect calls compare as `unchanged` in the `calls` dimension when their resolved callers and callees match. `analyzeFunctionObservation` never adds `unresolved_calls`, and `functionCallCoverageLimitations` ignores diagnostics for complete coverage.
Share the unresolved-call collector from `procedureReferences` with `analyze_function` and include those sites in the dossier. This keeps unresolved calls `unknown` while allowing fully observed functions to compare normally.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| Promise.resolve( | ||
| ok({ | ||
| value: { ...dossier, comments: [], facet_availability: facets }, | ||
| limitations: [], | ||
| }), | ||
| ), | ||
| close: () => Promise.resolve(ok(null)), |
There was a problem hiding this comment.
Bridge changes escape the test
The mock supplies facet_availability, so this test only checks that the provider preserves it. Removing the Java declaration would leave the test passing.
Add bridge-level coverage for an ordinary function and an external or bodyless function, including the unavailable pseudocode branch. That would catch regressions in the producer this PR changes.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/ghidra/GhidraProvider.behavior.test.ts
Line: 698-704
Comment:
**Bridge changes escape the test**
The mock supplies `facet_availability`, so this test only checks that the provider preserves it. Removing the Java declaration would leave the test passing.
Add bridge-level coverage for an ordinary function and an external or bodyless function, including the unavailable `pseudocode` branch. That would catch regressions in the producer this PR changes.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
CI-fix track: main already has a different implementation of this, so I didn't push a merge. #3002 (242e2b0, "preserve function facet and call coverage", closes #2951) makes the Ghidra bridge emit |
|
Thanks @kaoru0822-kitauji. #3002 already covers this, and more completely, since it also keeps unresolved indirect calls out of "complete" coverage, which addresses the P1 both reviewers raised here. There's no remaining delta worth a rebase, so I'm closing this in favour of #3002. |
|
Thanks @RishTheFish21 for spotting that undeclared Ghidra facets made even a self-comparison look unknown. Main now carries explicit facet and call-coverage declarations through the provider result (main). |
Summary
Fixes #2980. Since #2450 (
b17487f4),compare_functionstreats an empty facet without a coverage declaration asunknown, and the calls dimension also needs Evidence relationship coverage. The Ghidra bridge declared neither, so comparing a Ghidraanalyze_functionresult with itself returnedunknowninstead ofunchanged. That stopped every real-Ghidra lane at the native-value check (scripts/lib/native-value-e2e.mjs:238), before it reached the lane's own fixtures.Problem and expected behavior
Before, on
main: a Ghidra dossier compared with itself →status: "unknown", withcomments("Provider did not declare coverage for this empty facet") andcalls("Provider did not report relationship coverage") unresolved.After: the same comparison is
unchanged, because Ghidra declares the facets it actually observed and reports call coverage foranalyze_function.Change and scope
ReaGhidraBridge.java: function dossiers includefacet_availability. Every facet is read from the complete function body (all instructions and comment types, reference-manager edges, call references, basic blocks), so each is declared available.pseudocodeis declared unavailable when there's no decompiled body (external or bodyless procedures).GhidraProviderCapabilities.ts:relationshipCoverageFor("analyze_function")returns the same complete coverage and diagnostic asprocedure_callers/procedure_callees. The dossier's callers and callees come from the samegetCallingFunctions/getCalledFunctionscalls.GhidraAnalysisProfile.ts:call_relationship_coveragebumped to-v2andfunction_facet_availability: "declared-observed-facets-v1"added, so cached representations from before this change can't replay under the new contract (same approach as5dfb9d05).docs/mcp-contracts.md: documents Ghidra's declarations next to the existing IDA note.Not changed: the comparison rules from #2450.
Contract and boundary impact
facet_availabilityfield, andanalyze_functionEvidence carriesrelationship_coverage.analyze_functioncall relationships are now reported complete with the existing resolved-call-reference diagnostic, matchingprocedure_callers/procedure_callees. The profile version changes so older cached Evidence doesn't replay.docs/public/product-catalog.json), package, or installation impact: none.Evidence and regression coverage
GhidraProvider.behavior.test.ts. A new test checks thatanalyze_functionEvidence carries the complete call coverage with its diagnostic and keeps the declared facets; the profile assertion is updated for the new versions.main,npm run verify:ghidra:aarch64-jump-tablefails atnative-value-e2e.mjs:238with the two unknown dimensions above (details in #ISSUE).compare_functionson two identical Ghidra dossiers returnsunchanged.For evidence-bearing changes:
Validation performed
npm run test:focused -- src/ghidra/GhidraProvider.behavior.test.ts: passednpm run check:fast: passednpm run knip: passednpm run docs:check: passednpm run verify:ghidra:aarch64-jump-tableon an Apple Silicon Mac (Ghidra 12.1.4, JDK 21), with no local skips: passed. Onmainit fails at the native-value self-comparison.Compatibility, safety, and release
Review checklist
type(scope): outcome.