[PR #3728] [MERGED] fix(ghidra): invalidate synthetic entry reference snapshots #5872

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

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/3728
Author: @N0zoM1z0
Created: 10/14/2026
Status: ✅ Merged
Merged: 10/14/2026
Merged by: @N0zoM1z0

Base: main ← Head: fix/ghidra-snapshot-entry-references-3664


📝 Commits (3)

  • 6846a71 fix(ghidra): exclude synthetic entry references
  • a1337e4 Merge remote-tracking branch 'origin/main' into fix/ghidra-snapshot-entry-references-3664
  • 17c9efd Merge remote-tracking branch 'origin/main' into fix/ghidra-snapshot-entry-references-3664

📊 Changes

3 files changed (+36 additions, -30 deletions)

View changed files

📝 bridge/ghidra/ReaGhidraBridge.java (+26 -27)
📝 src/ghidra/GhidraAnalysisProfile.ts (+4 -2)
📝 src/ghidra/GhidraSnapshotCache.test.ts (+6 -1)

📄 Description

Summary

Fixes #3664 as a follow-up to #3204. Fresh Ghidra analysis now excludes synthetic entry-point references, but persisted snapshots still use the pre-fix exact-address-incoming-v1 identity and can be admitted with stale Entry Point:0x0 metadata. This change gives the corrected semantics a v2 identity and centralizes reference eligibility at the Ghidra bridge boundary.

Problem and expected behavior

A snapshot created before #3204 can retain a synthetic incoming entry reference. Because current main still declares v1, importing that snapshot after upgrading does not force reanalysis. Reference eligibility is also implemented separately in the exact-address, xref, and function-level collectors, which is the structural divergence that caused #3204.

Corrected builds must reject v1 or missing instruction-reference coverage, reanalyze once, and expose only observable Ghidra references consistently across those consumers.

Change and scope

  • Route incoming/outgoing reference iteration through one bridge helper that owns cancellation and excludes isEntryPointReference() before formatting or deduplication.
  • Use exact-address-incoming-without-synthetic-entry-v2 in raw and regular Ghidra analysis profiles.
  • Extend snapshot-admission coverage to reject both v1 and missing instruction-reference markers.

The public output schema already promises that synthetic references are excluded, so no CLI/MCP schema or output expansion is needed. The change is within the existing read-only Ghidra provider boundary and adds no authority.

Contract and boundary impact

  • Semantic owner and earliest changed stage: Ghidra bridge reference observation; Ghidra analysis-profile snapshot identity.
  • Contribution scope fit and linked maintainer decision: ordinary correctness fix within the existing Ghidra provider; no additional maintainer scope decision required.
  • CLI and MCP/tool-catalog contract: unchanged; both adapters continue to consume the same corrected provider evidence.
  • Provider, bridge, target-format, or platform compatibility: Ghidra snapshots with v1 or a missing instruction-reference marker are reanalyzed once; current snapshots remain reusable.
  • Evidence, artifact, provenance, or reconstruction contract: synthetic entry metadata is excluded before Evidence formatting; snapshot provenance now identifies that semantic revision.
  • Target selection, authority, upstream behavior, and cleanup details: caller target and read-only authority are unchanged; Ghidra's synthetic entry metadata is not treated as a target reference.
  • Generated metadata, package, or installation impact: none.

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: snapshot admission rejects both exact-address-incoming-v1 and a missing marker while accepting v2.
  • Base reproduction: #3204 records real Windows x64/x86 PE EXE failures where compact incoming references included Entry Point:0x0 but xrefs did not. Current main fixes fresh collection while retaining the old snapshot marker.
  • User-visible CLI/MCP output: schema unchanged; corrected fresh and reanalyzed results omit the synthetic reference.
  • Remaining proof gaps: complete agent-token cost is unmeasured; no equivalent cold/warm before-and-after timing supports a speedup claim.

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:changed -- --base origin/main — 7 files and 218 tests passed after merging current main.
  • npm run build:cached — compile and packaged skill artifacts passed; compile was fresh.
  • npm run check:fast — non-cached typecheck and lint passed.
  • Real Windows candidate 6846a71e8: ordinary-user Ghidra 12.1.4/JDK 21 workflows passed for x64/x86 EXE and DLL targets, 26 provider operations per lane, empty stderr, complete cleanup, and zero owned processes. EXE synthetic exclusion and incoming/xrefs parity passed. Runs were serialized with 2 logical CPUs, BelowNormal priority, Node/Java 768 MiB, and a 3 GiB Job limit:
    • x64 EXE: 999.75 s wall, 312.48 s sampled CPU, 2028.50 MiB Job peak, 1128.50 MiB sampled working-set peak.
    • x86 EXE: 897.48 s wall, 312.13 s CPU, 2024.61 MiB Job, 1257.02 MiB working set.
    • x64 DLL: 740.56 s wall, 237.34 s CPU, 2029.41 MiB Job, 1083.10 MiB working set.
    • x86 DLL: 735.70 s wall, 249.27 s CPU, 2022.66 MiB Job, 1122.23 MiB working set.
  • Exact head a1337e4c after merging current main fffb07419: the bridge hash is identical to the four-lane candidate, while the compiled profile/runtime includes current main and the v2 identity. Complete x64/x86 EXE workflows passed the same 26 operations and all reference, source-integrity, and cleanup assertions:
    • x64: 1018.98 s wall, 632.28 s sampled CPU, 2033.13 MiB Job peak, 1281.49 MiB sampled working-set peak, minimum host free memory 11.28 GiB, Job0.
    • x86: 968.48 s wall, 317.73 s sampled CPU, 2030.87 MiB Job peak, 1105.19 MiB sampled working-set peak, minimum host free memory 13.83 GiB, Job0.
  • CI run 38641838255 on a1337e4c passed source/static/build/native/Greptile and all five test shards after a failed-only retry. The first shard 3 attempt had one unrelated fixed-10-second timeout in serverIdentity.test.ts; the same 3-file PR does not touch that boundary, and the focused file passed locally 11/11 with the affected test completing in 5.51 s. Shards 1/4/5 were initially cancelled by fail-fast and passed on the retry; no code changed.
  • Latest main bb4925252 was then merged normally. Its nine commits change setup, IDA/JEB deadline configuration, MCP guidance, and tests; they do not change the Ghidra bridge/profile/test inputs in this PR. On final head 17c9efd27, changed tests again pass 218/218, compile is fresh, and typecheck/lint are non-cached. The real Ghidra bridge/profile hashes remain those validated above.

Two-second process-family sampling can miss short-lived children. Byte-search correctly continues to report cli_mcp_parity:false; file-offset parity passed. Exact-head output was 2623 bytes for x64 and 2620 bytes for x86. These measurements establish bounded completed tasks, not a speedup. Receipts and SHA256 manifests are retained under /tmp/rea-windows-e2e-20261013/results/issue3204-candidate6846 and results/issue3664-exact-a1337e4c. After exact-head success and an independent zero-process check, 23,641,513 bytes of rollback and runner staging were removed.

Compatibility, safety, and release

  • Breaking changes or migration steps: persisted Ghidra snapshots with pre-filter instruction-reference semantics are intentionally rejected and reanalyzed; callers do not need to change requests or configuration.
  • Real Hopper/Ghidra, browser, or OS coverage: real Windows Ghidra coverage is listed above; Hopper, browser, and non-Windows providers are unaffected and not claimed.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: read-only Ghidra authority is unchanged; source fixtures stayed byte-identical and all owned process families settled.

Author readiness

Human owner: @N0zoM1z0

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

🔄 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/3728 **Author:** [@N0zoM1z0](https://github.com/N0zoM1z0) **Created:** 10/14/2026 **Status:** ✅ Merged **Merged:** 10/14/2026 **Merged by:** [@N0zoM1z0](https://github.com/N0zoM1z0) **Base:** `main` ← **Head:** `fix/ghidra-snapshot-entry-references-3664` --- ### 📝 Commits (3) - [`6846a71`](https://github.com/morluto/rea/commit/6846a71e8f08c0e603a70a7f3691406912ba5007) fix(ghidra): exclude synthetic entry references - [`a1337e4`](https://github.com/morluto/rea/commit/a1337e4c70f262d6ec027091480a2b9a0d7bcdfc) Merge remote-tracking branch 'origin/main' into fix/ghidra-snapshot-entry-references-3664 - [`17c9efd`](https://github.com/morluto/rea/commit/17c9efd274e35056031ce2076dd44097d5d64569) Merge remote-tracking branch 'origin/main' into fix/ghidra-snapshot-entry-references-3664 ### 📊 Changes **3 files changed** (+36 additions, -30 deletions) <details> <summary>View changed files</summary> 📝 `bridge/ghidra/ReaGhidraBridge.java` (+26 -27) 📝 `src/ghidra/GhidraAnalysisProfile.ts` (+4 -2) 📝 `src/ghidra/GhidraSnapshotCache.test.ts` (+6 -1) </details> ### 📄 Description ## Summary Fixes #3664 as a follow-up to #3204. Fresh Ghidra analysis now excludes synthetic entry-point references, but persisted snapshots still use the pre-fix `exact-address-incoming-v1` identity and can be admitted with stale `Entry Point:0x0` metadata. This change gives the corrected semantics a v2 identity and centralizes reference eligibility at the Ghidra bridge boundary. ## Problem and expected behavior A snapshot created before #3204 can retain a synthetic incoming entry reference. Because current main still declares v1, importing that snapshot after upgrading does not force reanalysis. Reference eligibility is also implemented separately in the exact-address, xref, and function-level collectors, which is the structural divergence that caused #3204. Corrected builds must reject v1 or missing instruction-reference coverage, reanalyze once, and expose only observable Ghidra references consistently across those consumers. ## Change and scope - Route incoming/outgoing reference iteration through one bridge helper that owns cancellation and excludes `isEntryPointReference()` before formatting or deduplication. - Use `exact-address-incoming-without-synthetic-entry-v2` in raw and regular Ghidra analysis profiles. - Extend snapshot-admission coverage to reject both v1 and missing instruction-reference markers. The public output schema already promises that synthetic references are excluded, so no CLI/MCP schema or output expansion is needed. The change is within the existing read-only Ghidra provider boundary and adds no authority. ## Contract and boundary impact - Semantic owner and earliest changed stage: Ghidra bridge reference observation; Ghidra analysis-profile snapshot identity. - Contribution scope fit and linked maintainer decision: ordinary correctness fix within the existing Ghidra provider; no additional maintainer scope decision required. - CLI and MCP/tool-catalog contract: unchanged; both adapters continue to consume the same corrected provider evidence. - Provider, bridge, target-format, or platform compatibility: Ghidra snapshots with v1 or a missing instruction-reference marker are reanalyzed once; current snapshots remain reusable. - Evidence, artifact, provenance, or reconstruction contract: synthetic entry metadata is excluded before Evidence formatting; snapshot provenance now identifies that semantic revision. - Target selection, authority, upstream behavior, and cleanup details: caller target and read-only authority are unchanged; Ghidra's synthetic entry metadata is not treated as a target reference. - Generated metadata, package, or installation impact: none. Expected effects: - [x] Read existing files or captured data. - [x] 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: snapshot admission rejects both `exact-address-incoming-v1` and a missing marker while accepting v2. - Base reproduction: #3204 records real Windows x64/x86 PE EXE failures where compact incoming references included `Entry Point:0x0` but xrefs did not. Current main fixes fresh collection while retaining the old snapshot marker. - User-visible CLI/MCP output: schema unchanged; corrected fresh and reanalyzed results omit the synthetic reference. - Remaining proof gaps: complete agent-token cost is unmeasured; no equivalent cold/warm before-and-after timing supports a speedup claim. 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:changed -- --base origin/main` — 7 files and 218 tests passed after merging current main. - `npm run build:cached` — compile and packaged skill artifacts passed; compile was fresh. - `npm run check:fast` — non-cached typecheck and lint passed. - Real Windows candidate `6846a71e8`: ordinary-user Ghidra 12.1.4/JDK 21 workflows passed for x64/x86 EXE and DLL targets, 26 provider operations per lane, empty stderr, complete cleanup, and zero owned processes. EXE synthetic exclusion and incoming/xrefs parity passed. Runs were serialized with 2 logical CPUs, BelowNormal priority, Node/Java 768 MiB, and a 3 GiB Job limit: - x64 EXE: 999.75 s wall, 312.48 s sampled CPU, 2028.50 MiB Job peak, 1128.50 MiB sampled working-set peak. - x86 EXE: 897.48 s wall, 312.13 s CPU, 2024.61 MiB Job, 1257.02 MiB working set. - x64 DLL: 740.56 s wall, 237.34 s CPU, 2029.41 MiB Job, 1083.10 MiB working set. - x86 DLL: 735.70 s wall, 249.27 s CPU, 2022.66 MiB Job, 1122.23 MiB working set. - Exact head `a1337e4c` after merging current `main` `fffb07419`: the bridge hash is identical to the four-lane candidate, while the compiled profile/runtime includes current main and the v2 identity. Complete x64/x86 EXE workflows passed the same 26 operations and all reference, source-integrity, and cleanup assertions: - x64: 1018.98 s wall, 632.28 s sampled CPU, 2033.13 MiB Job peak, 1281.49 MiB sampled working-set peak, minimum host free memory 11.28 GiB, Job0. - x86: 968.48 s wall, 317.73 s sampled CPU, 2030.87 MiB Job peak, 1105.19 MiB sampled working-set peak, minimum host free memory 13.83 GiB, Job0. - CI run `38641838255` on `a1337e4c` passed source/static/build/native/Greptile and all five test shards after a failed-only retry. The first shard 3 attempt had one unrelated fixed-10-second timeout in `serverIdentity.test.ts`; the same 3-file PR does not touch that boundary, and the focused file passed locally 11/11 with the affected test completing in 5.51 s. Shards 1/4/5 were initially cancelled by fail-fast and passed on the retry; no code changed. - Latest main `bb4925252` was then merged normally. Its nine commits change setup, IDA/JEB deadline configuration, MCP guidance, and tests; they do not change the Ghidra bridge/profile/test inputs in this PR. On final head `17c9efd27`, changed tests again pass 218/218, compile is fresh, and typecheck/lint are non-cached. The real Ghidra bridge/profile hashes remain those validated above. Two-second process-family sampling can miss short-lived children. Byte-search correctly continues to report `cli_mcp_parity:false`; file-offset parity passed. Exact-head output was 2623 bytes for x64 and 2620 bytes for x86. These measurements establish bounded completed tasks, not a speedup. Receipts and SHA256 manifests are retained under `/tmp/rea-windows-e2e-20261013/results/issue3204-candidate6846` and `results/issue3664-exact-a1337e4c`. After exact-head success and an independent zero-process check, 23,641,513 bytes of rollback and runner staging were removed. ## Compatibility, safety, and release - Breaking changes or migration steps: persisted Ghidra snapshots with pre-filter instruction-reference semantics are intentionally rejected and reanalyzed; callers do not need to change requests or configuration. - Real Hopper/Ghidra, browser, or OS coverage: real Windows Ghidra coverage is listed above; Hopper, browser, and non-Windows providers are unaffected and not claimed. - Package or release metadata impact: none. - Security, privacy, process, or containment review: read-only Ghidra authority is unchanged; source fixtures stayed byte-identical and all owned process families settled. ## Author readiness Human owner: @N0zoM1z0 - [x] 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. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## 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:10:05 +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#5872
No description provided.