[PR #2360] [MERGED] fix(ghidra): warn when callee/caller reads stop at a truncated function body #5186

Closed
opened 2026-10-31 01:04:39 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/2360
Author: @sx4im
Created: 10/12/2026
Status: ✅ Merged
Merged: 10/13/2026
Merged by: @morluto

Base: main ← Head: fix/2326-ghidra-truncated-body-warnings


📝 Commits (1)

  • d9d39ef fix(ghidra): warn when callee/caller reads stop at a truncated function body

📊 Changes

9 files changed (+52 additions, -11 deletions)

View changed files

📝 bridge/ghidra/ReaGhidraBridge.java (+7 -2)
📝 docs/ghidra-provider.md (+4 -3)
📝 src/contracts/officialToolContracts.ts (+2 -2)
📝 src/ghidra/GhidraAnalysisProfile.ts (+2 -2)
📝 src/ghidra/GhidraFunctionValues.test.ts (+25 -0)
📝 src/ghidra/GhidraFunctionValues.ts (+2 -0)
📝 src/ghidra/GhidraProvider.behavior.test.ts (+5 -1)
📝 tests/boundary/mcp/ghidraEvidenceMcp.test.ts (+3 -1)
📝 tests/boundary/mcp/ghidraMcpHarness.ts (+2 -0)

📄 Description

Summary

Fixes #2326. procedure_callees and procedure_callers returned a bare address list. When an inferred no-return call truncates Ghidra's analyzed function body, real call and caller edges outside the body were silently dropped with no warning. Both views now return the function-observation envelope (value + limitations) carrying noReturnCallLimitations notes, the same treatment the five other function views got in 69a8b3a95.

Problem and expected behavior

Smallest trigger: read procedure_callees for a function whose body Ghidra cut short at an inferred no-return call. Before: the response carried the surviving edges only and no caveat, so a caller could not tell edges were missing. The provider design places such caveats in limitations. Expected: terminal-call observations appear in Evidence limitations for these two views, exactly as they already do for procedure_info, procedure_assembly, procedure_pseudo_code, read_function_instructions, and analyze_function.

Change and scope

  • bridge/ghidra/ReaGhidraBridge.java: procedureCalls now returns functionObservation(result, noReturnCallLimitations(...)) over the same instruction listing procedureInfo uses. No new helpers; the existing helper is reused verbatim.
  • src/ghidra/GhidraFunctionValues.ts: procedure_callees and procedure_callers join functionBoundaryObservationOperations, so the TS parser requires the envelope and surfaces its limitations into Evidence.
  • src/ghidra/GhidraAnalysisProfile.ts: boundary-observation contract versioned to ghidra-terminal-call-limitations-v2, so older unqualified snapshots cannot replay.
  • src/contracts/officialToolContracts.ts and docs/ghidra-provider.md: document the limitation for these views.

Contribution scope fit: ordinary fix within existing boundaries; no new capability, no execution or mutation behavior. Maintainer scope decision: not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: Ghidra Java bridge response shape for two operations; TS envelope parser owns the parse.
  • Contribution scope fit and linked maintainer decision: in-scope bug fix; not applicable.
  • CLI and MCP/tool-catalog contract: tool descriptions gain one sentence each; value schemas unchanged (still address lists).
  • Provider, bridge, target-format, or platform compatibility: bridge output shape changes for procedure_callees/procedure_callers (bare array to {value, limitations}); TS parser is the only consumer and expects the new shape. Other providers untouched.
  • Evidence, artifact, provenance, or reconstruction contract: limitations now carry terminal-call observations for these views; raw result shape follows the envelope convention.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable; read-only bridge.
  • Generated metadata: none committed; CI generates catalogs.

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated:
    • src/ghidra/GhidraFunctionValues.test.ts: new red-green test requiring the envelope for both operations (bare array rejected; envelope with limitations preserved). Test-local operation set updated.
    • tests/boundary/mcp/ghidraEvidenceMcp.test.ts: terminal-call qualification test extended to procedure_callees/procedure_callers, proving limitations flow through Evidence and snapshot replay.
    • tests/boundary/mcp/ghidraMcpHarness.ts and src/ghidra/GhidraProvider.behavior.test.ts: bridge fixtures updated to the envelope shape.
  • Base reproduction or other evidence: the new unit test failed before the fix (bare array accepted, ok: true) and passes after. No Ghidra host available here, so no real-provider reproduction of a truncated body; the Java change is a mechanical wrap identical to the existing procedureInfo call pattern.
  • User-visible CLI/MCP output: unchanged value shape; limitations now include terminal-call notes, e.g. "Ghidra Listing reports a terminal call at 0x... to 0x...; fallthrough is excluded by Ghidra's flow model."
  • Remaining proof gaps: real Ghidra host lane (verify-real-ghidra-function) not run locally; the Java-side wrap is unverified against a live bridge beyond matching the established pattern.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npm run test:focused -- src/ghidra/GhidraFunctionValues.test.ts — 43 passed (new envelope test red before, green after)
  • npm run test:focused -- tests/boundary/mcp/ghidraEvidenceMcp.test.ts src/ghidra/GhidraProvider.behavior.test.ts — 53 passed
  • 8 MCP boundary test files using the Ghidra harness (analysisViewMcp, ghidraCompactReferencesMcp, ghidraFailureDiagnostics, ghidraInventoryMcp, ghidraNativeApiMcp, ghidraRoutingMcp, inlineEvidenceCompositionMcp, ghidraEvidenceMcp) — 25 passed
  • npm run check:fast — typecheck + lint successful
  • npm run docs:check — passed
  • npm run verify:test-discovery — 982 test files discovered exactly once
  • Remote head/tree verified: fork branch fix/2326-ghidra-truncated-body-warnings at 926bd5bba0bf2bd9808426887d02027655edd6bd, tree 378c4f4 identical to local commit, parent fd9588089 (upstream main).

Compatibility, safety, and release

  • Breaking changes or migration steps: bridge wire shape for the two operations changes from bare array to {value, limitations}; the in-repo TS parser is updated in the same change. No migration for callers of the MCP/CLI surface, where the value schema is unchanged.
  • Real Hopper/Ghidra, browser, or OS coverage: real Ghidra host lane unavailable in this environment (no Ghidra installed); simulated-provider harness and source tests cover the parsing and evidence flow.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: read-only change; no new authority.

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.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/2360 **Author:** [@sx4im](https://github.com/sx4im) **Created:** 10/12/2026 **Status:** ✅ Merged **Merged:** 10/13/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/2326-ghidra-truncated-body-warnings` --- ### 📝 Commits (1) - [`d9d39ef`](https://github.com/morluto/rea/commit/d9d39ef721ffa944ea4b3542e89ec092a2bc7f5e) fix(ghidra): warn when callee/caller reads stop at a truncated function body ### 📊 Changes **9 files changed** (+52 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `bridge/ghidra/ReaGhidraBridge.java` (+7 -2) 📝 `docs/ghidra-provider.md` (+4 -3) 📝 `src/contracts/officialToolContracts.ts` (+2 -2) 📝 `src/ghidra/GhidraAnalysisProfile.ts` (+2 -2) 📝 `src/ghidra/GhidraFunctionValues.test.ts` (+25 -0) 📝 `src/ghidra/GhidraFunctionValues.ts` (+2 -0) 📝 `src/ghidra/GhidraProvider.behavior.test.ts` (+5 -1) 📝 `tests/boundary/mcp/ghidraEvidenceMcp.test.ts` (+3 -1) 📝 `tests/boundary/mcp/ghidraMcpHarness.ts` (+2 -0) </details> ### 📄 Description ## Summary Fixes #2326. `procedure_callees` and `procedure_callers` returned a bare address list. When an inferred no-return call truncates Ghidra's analyzed function body, real call and caller edges outside the body were silently dropped with no warning. Both views now return the function-observation envelope (`value` + `limitations`) carrying `noReturnCallLimitations` notes, the same treatment the five other function views got in 69a8b3a95. ## Problem and expected behavior Smallest trigger: read `procedure_callees` for a function whose body Ghidra cut short at an inferred no-return call. Before: the response carried the surviving edges only and no caveat, so a caller could not tell edges were missing. The provider design places such caveats in `limitations`. Expected: terminal-call observations appear in Evidence limitations for these two views, exactly as they already do for `procedure_info`, `procedure_assembly`, `procedure_pseudo_code`, `read_function_instructions`, and `analyze_function`. ## Change and scope - `bridge/ghidra/ReaGhidraBridge.java`: `procedureCalls` now returns `functionObservation(result, noReturnCallLimitations(...))` over the same instruction listing `procedureInfo` uses. No new helpers; the existing helper is reused verbatim. - `src/ghidra/GhidraFunctionValues.ts`: `procedure_callees` and `procedure_callers` join `functionBoundaryObservationOperations`, so the TS parser requires the envelope and surfaces its limitations into Evidence. - `src/ghidra/GhidraAnalysisProfile.ts`: boundary-observation contract versioned to `ghidra-terminal-call-limitations-v2`, so older unqualified snapshots cannot replay. - `src/contracts/officialToolContracts.ts` and `docs/ghidra-provider.md`: document the limitation for these views. Contribution scope fit: ordinary fix within existing boundaries; no new capability, no execution or mutation behavior. Maintainer scope decision: not applicable. ## Contract and boundary impact - Semantic owner and earliest changed stage: Ghidra Java bridge response shape for two operations; TS envelope parser owns the parse. - Contribution scope fit and linked maintainer decision: in-scope bug fix; not applicable. - CLI and MCP/tool-catalog contract: tool descriptions gain one sentence each; value schemas unchanged (still address lists). - Provider, bridge, target-format, or platform compatibility: bridge output shape changes for `procedure_callees`/`procedure_callers` (bare array to `{value, limitations}`); TS parser is the only consumer and expects the new shape. Other providers untouched. - Evidence, artifact, provenance, or reconstruction contract: limitations now carry terminal-call observations for these views; raw result shape follows the envelope convention. - Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable; read-only bridge. - Generated metadata: none committed; CI generates catalogs. Expected effects: - [x] Read existing files or captured data. - [ ] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [ ] Change process memory, registers, files, or configuration. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [ ] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage - Tests added or updated: - `src/ghidra/GhidraFunctionValues.test.ts`: new red-green test requiring the envelope for both operations (bare array rejected; envelope with limitations preserved). Test-local operation set updated. - `tests/boundary/mcp/ghidraEvidenceMcp.test.ts`: terminal-call qualification test extended to `procedure_callees`/`procedure_callers`, proving limitations flow through Evidence and snapshot replay. - `tests/boundary/mcp/ghidraMcpHarness.ts` and `src/ghidra/GhidraProvider.behavior.test.ts`: bridge fixtures updated to the envelope shape. - Base reproduction or other evidence: the new unit test failed before the fix (bare array accepted, `ok: true`) and passes after. No Ghidra host available here, so no real-provider reproduction of a truncated body; the Java change is a mechanical wrap identical to the existing `procedureInfo` call pattern. - User-visible CLI/MCP output: unchanged value shape; limitations now include terminal-call notes, e.g. "Ghidra Listing reports a terminal call at 0x... to 0x...; fallthrough is excluded by Ghidra's flow model." - Remaining proof gaps: real Ghidra host lane (`verify-real-ghidra-function`) not run locally; the Java-side wrap is unverified against a live bridge beyond matching the established pattern. For evidence-bearing changes: - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed - `npm run test:focused -- src/ghidra/GhidraFunctionValues.test.ts` — 43 passed (new envelope test red before, green after) - `npm run test:focused -- tests/boundary/mcp/ghidraEvidenceMcp.test.ts src/ghidra/GhidraProvider.behavior.test.ts` — 53 passed - 8 MCP boundary test files using the Ghidra harness (`analysisViewMcp`, `ghidraCompactReferencesMcp`, `ghidraFailureDiagnostics`, `ghidraInventoryMcp`, `ghidraNativeApiMcp`, `ghidraRoutingMcp`, `inlineEvidenceCompositionMcp`, `ghidraEvidenceMcp`) — 25 passed - `npm run check:fast` — typecheck + lint successful - `npm run docs:check` — passed - `npm run verify:test-discovery` — 982 test files discovered exactly once - Remote head/tree verified: fork branch `fix/2326-ghidra-truncated-body-warnings` at 926bd5bba0bf2bd9808426887d02027655edd6bd, tree 378c4f4 identical to local commit, parent fd9588089 (upstream main). ## Compatibility, safety, and release - Breaking changes or migration steps: bridge wire shape for the two operations changes from bare array to `{value, limitations}`; the in-repo TS parser is updated in the same change. No migration for callers of the MCP/CLI surface, where the value schema is unchanged. - Real Hopper/Ghidra, browser, or OS coverage: real Ghidra host lane unavailable in this environment (no Ghidra installed); simulated-provider harness and source tests cover the parsing and evidence flow. - Package or release metadata impact: none. - Security, privacy, process, or containment review: read-only change; no new authority. ## Before merge - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [x] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:04:39 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#5186
No description provided.