Skip to content

feat(ghidra): report computed branches without a recovered jump table - #2977

Closed
RishTheFish21 wants to merge 51 commits into
morluto:mainfrom
RishTheFish21:feat/487-unresolved-indirect-branches
Closed

RishTheFish21 wants to merge 51 commits into
morluto:mainfrom
RishTheFish21:feat/487-unresolved-indirect-branches

Conversation

@RishTheFish21

@RishTheFish21 RishTheFish21 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Part of #487 (second of the steps proposed there; the first was #1592). When Ghidra cannot recover a jump table for a computed br, its decompiler rewrites the branch as a call or return (FlowInfo::truncateIndirectJump), so nothing reached REA's output: jump_tables and unsupported_branches stayed empty and the dossier read as complete. This is the gap @CassieFox23 reported for the RenderScript blur kernels.

This PR reports those sites in a new optional field, native_api.unresolved_indirect_branches, and surfaces each one as a residual unknown in inspect_native_api.

Problem and expected behavior

Before: a function whose only dispatch is an unbounded computed jump (adr x8, …; add x8, x8, x0, lsl #3; br x8) produces jump_tables: [], unsupported_branches: [], and no residual unknown.

After, for the same function:

  • unresolved_indirect_branches: [{ branch_address, decompiler_outcome: "jump_table_recovery_failed", listing_targets: [], evidence: [...] }], with Ghidra's warning ("Could not recover jumptable at … Too many branches") retained as evidence
  • unsupported_branches: ["indirect-branch-target-recovery"]
  • residual unknown: "Which targets can the indirect branch at 0x… reach? The decompiler could not recover a jump table there and treated it as a call; it may be a dispatch inside this function or an indirect tail call."

Change and scope

  • Bridge (ReaGhidraBridge.java): every listing instruction in the function body whose flow type is a computed jump (not a call or terminator), and whose address is not a recovered JumpTable switch, is reported. decompiler_outcome is jump_table_recovery_failed when the decompiler's pseudocode contains "Could not recover jumptable at ", otherwise no_jump_table_warning. listing_targets are the listing's flow references (no case values implied).
  • Schema (nativeApiBoundary.ts): new unresolved_indirect_branches field using exactOptional(): absent means the provider did not inspect indirect branches, so Hopper/IDA output and older snapshots parse unchanged. New evidence kind indirect-branch.
  • Projection (NativeApiInspection.ts): one residual unknown per site and indirect-branch-target-recovery in unsupported_branches.
  • Ghidra address validation also covers the new addresses.

Deliberately not attempted: telling a dispatch apart from an indirect tail call. On real Ghidra 12.1.4 both produce the same recovery failure (see Validation), so REA reports the uncertainty instead of guessing. Not included: the decompiler-failure handling from #487 (a separate follow-up), and sites in regions where Ghidra created no function.

Contract and boundary impact

  • Semantic owner and earliest changed stage: Ghidra bridge native API boundary.
  • CLI and MCP/tool-catalog contract: additive. analyze_function/inspect_native_api output gains the optional unresolved_indirect_branches field, the evidence kind indirect-branch, and the unsupported_branches value indirect-branch-target-recovery. Existing fields are unchanged.
  • Provider, bridge, target-format, or platform compatibility: Ghidra only; other providers omit the field.
  • Evidence, artifact, provenance, or reconstruction contract: new facts are listing and decompiler-warning observations with their source recorded; no targets or case values are inferred.
  • Process execution, authorization, cleanup, or containment impact: none.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: output schemas regenerate in CI; no tracked metadata changes.

Evidence and regression coverage

  • Tests added or updated:
    • NativeApiInspection.test.ts: residual unknowns and unsupported_branches for both outcomes; empty or absent inventory adds nothing; a branch without evidence is rejected.
    • GhidraFunctionValues.test.ts: a non-canonical branch address is rejected.
    • New real-Ghidra fixture tests/conformance/ghidra/indirect-branches.S (unbounded computed jump plus an indirect tail call) in the aarch64-jump-table lane, as ELF and, on arm64 hosts, Mach-O. The lane asserts the computed jump is reported and not mistaken for a jump table, and records the tail call's classification.
    • The existing relative-switch fixtures now assert that recovered switches are not reported as unresolved.
  • Base reproduction or other evidence: on main the field doesn't exist, so the fixture's computed jump leaves no trace in the dossier.
  • User-visible CLI/MCP output: see "Problem and expected behavior".
  • Remaining proof gaps: not run against the real librenderscript-toolkit.so from the issue thread; no Linux run.

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/application/native/NativeApiInspection.test.ts src/ghidra/GhidraFunctionValues.test.ts: passed
  • npm run check:fast: passed
  • npm run lint, npm run knip: passed
  • npm run docs:check: passed
  • npm run verify:ghidra:aarch64-jump-table on an Apple Silicon Mac (Ghidra 12.1.4, JDK 21): ok: true.
    • Computed jump: reported as jump_table_recovery_failed with the decompiler warning, on ELF (0x10000c) and Mach-O (0xc).
    • Indirect tail call: also reported as jump_table_recovery_failed ("Could not recover jumptable at … Too many branches") on both formats.
    • All relative-* switch fixtures passed, including the new "not unresolved" check.

Note on that run: on current main the lane stops early in the host-native native-value check, where compare_functions of a function against itself returns unknown instead of unchanged. Reproduced on main without this PR. The comments facet is empty with no declared coverage, and calls lacks relationship coverage, which looks related to #2450 (b17487f4). I skipped that one assertion locally to reach the fixtures this PR adds, and will report it separately.

Compatibility, safety, and release

  • Breaking changes or migration steps: none; the field is optional and additive.
  • Real Hopper/Ghidra, browser, or OS coverage: real Ghidra on macOS arm64 only.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: static analysis only; reads the existing listing and decompiler output.

Review checklist

  • This PR addresses a concrete problem or an agreed enhancement.
  • 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.

Author readiness

Human owner: @RishTheFish21

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-10T22:19:03.460699Z 1b4107c New commits
ℹ️ 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.

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The reviewed changes appear safe to merge, with no new actionable issues found.

Summary

Adds Ghidra observations for computed jumps without recovered jump tables.

  • Ghidra records computed branches that have no recovered jump table.
  • Native API inspection shows which indirect branch targets remain unknown.

Validation was source-only; no tests were run. Supersession could not be checked because GitHub access required authentication.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  Listing[Ghidra function instructions] --> Filter[Keep computed jumps without recovered tables]
  Comments[Typed decompiler comments] --> Attribution[Match warning sources and discount saved copies]
  Filter --> Inventory[Bounded branch inventory with evidence]
  Attribution --> Inventory
  Inventory --> Schemas[Validate addresses and preserve optional fields]
  Schemas --> Inspection[Report per-site unknowns]
  Schemas --> Page[Page retained sites and report omissions]
Loading

Reviews (15) · Last reviewed commit: "merge(main): refresh computed-branch int..." · Reviewed by Greptile

Comment thread scripts/verify-real-ghidra-function.mjs Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 26fd63c396

ℹ️ 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".

Comment thread bridge/ghidra/ReaGhidraBridge.java Resolved
: ["structured-boundary-types", "jump-table-data-mapping"];
const unsupportedBranches = !boundary.available
? ["structured-boundary-types", "jump-table-data-mapping"]
: (boundary.unresolved_indirect_branches ?? []).length > 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve omission as an uninspected branch facet

When an available boundary comes from an older cached dossier or another provider that omits the new exact-optional field, this ?? [] reports no indirect-branch-target-recovery, and availableResidualUnknowns similarly emits no branch unknown. The schema explicitly defines omission as meaning that the provider did not inspect indirect branches, so this conflates “uninspected” with an inspected empty inventory and presents incomplete analysis as complete; handle omission separately from [].

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: an absent unresolved_indirect_branches now reports indirect-branch-inventory in unsupported_branches plus a residual unknown; only an explicit empty array means none were found. Covered by new tests.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 523cad54fc

ℹ️ 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".

Comment thread bridge/ghidra/ReaGhidraBridge.java Resolved
@RishTheFish21

Copy link
Copy Markdown
Contributor Author

Follow-up on the skipped assertion mentioned in the description: the self-comparison failure on main is now reported in #2980 and fixed in #3025 . With that fix applied, the aarch64-jump-table lane passes on real Ghidra with no local skips.

@CassieFox23

CassieFox23 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR: I ran this PR on Linux x64 with real Ghidra 12.1.4, and it works. The computed jump now shows up with the decompiler warning, and the base says nothing. Both named unit files pass on Node 22, 24 and 26.

Results

I tested head 523cad5 against its base 2895a18, on the PR's AArch64 fixture. The base is the head with the four changed source files put back.

Function Base Head
Computed jump No entry One entry
Indirect tail call No entry One entry

The functions are rea_computed_branch and rea_indirect_tail_call. The entries sit at 0x10000c and 0x100040. Each has the outcome jump_table_recovery_failed and ghidra-decompiler-warning evidence. Each also adds one residual unknown and indirect-branch-target-recovery in unsupported_branches. The stricter check from morluto holds on this run. I replayed it by script on the saved output.

Unit file Base, Node 24 Head, Node 22 Head, Node 24 Head, Node 26
NativeApiInspection.test.ts 2 of 8 fail 8 pass 8 pass 8 pass
GhidraFunctionValues.test.ts 51 pass 51 pass 51 pass 51 pass

The 2 base failures are expected, because the old schema rejects the new field. The GhidraFunctionValues case likely passes on base for that same reason, so it may not tell old from new. I did not check that one.

Ghidra said "Treating indirect jump as call" for both functions. I saw no return case. The analysis profile digest is the same on base and head, as the open Codex note says.

Not run

Edit (2026-10-13): The retest on fb7764564 covers the snapshot item below. The rest is still not run.

  • The real RenderScript library from [Feature] Improve Ghidra AArch64 jump-table recovery #487. I did not fetch it this time.
  • The npm run verify:* lanes, and so the recovered-switch checks.
  • Snapshot replay. Done in the retest. Old snapshots are now refused.
  • The Mach-O fixture, CI and the full suite.
  • Anything on macOS or Windows.

Thanks, RishTheFish21, for the fix. Thanks, morluto, for the stricter check. This is the gap I reported on #487.

Test setup
  • Box: Nobara 44 (Fedora 44 base), Linux 7.2.9
  • CPU: AMD Ryzen 9 5900X, 12 cores / 24 threads
  • RAM: 32 GB DDR4-3600
  • Node: 22.23.1, 24.18.0, 26.11.1
  • Head: 523cad5
  • Base: 2895a18
  • Other: Ghidra 12.1.4 (Apache-2.0)
  • Other: JDK 21.0.12.1
  • Other: clang 22.1.8 (Apache-2.0 WITH LLVM-exception)
  • The box ran another test at the same time, so I give no timings.
Commands
clang --target=aarch64-linux-gnu -c tests/conformance/ghidra/indirect-branches.S -o indirect-branches-elf.o
rea function indirect-branches-elf.o rea_computed_branch --provider ghidra --json
rea inspect-native-api indirect-branches-elf.o 0x100000 --provider ghidra --json
rea function indirect-branches-elf.o rea_indirect_tail_call --provider ghidra --json
rea inspect-native-api indirect-branches-elf.o 0x100038 --provider ghidra --json
node scripts/run-development-tests.mjs focused src/application/native/NativeApiInspection.test.ts
node scripts/run-development-tests.mjs focused src/ghidra/GhidraFunctionValues.test.ts

Every command exited 0. Only the base run of the NativeApiInspection file exited 1. The test script is the one behind npm run test:focused, run with each Node binary by full path. The base tree is the head tree with bridge/ghidra/ReaGhidraBridge.java, src/application/native/NativeApiInspection.ts, src/domain/native/nativeApiBoundary.ts and src/ghidra/GhidraFunctionValues.ts taken back from 2895a18.

Decompiler output on both trees
/* WARNING: Could not recover jumptable at 0x0010000c. Too many branches */
/* WARNING: Treating indirect jump as call */
(*(code *)(&Lunrolled + param_1 * 8))(param_1,0);

Ghidra printed this before the PR too. The PR carries the warning into the REA output.

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊

@RishTheFish21

Copy link
Copy Markdown
Contributor Author

@CassieFox23 Thanks for running it on Linux. Two of your notes led to changes in the latest push:

  • Profile digest unchanged: that confirmed the Codex snapshot concern, so the Ghidra profile now has indirect_branch_inventory: "listing-computed-jumps-decompiler-outcome-v1" and cached analyze_function results without the field won't replay.
  • The GhidraFunctionValues case not distinguishing old from new: you're right, the old strict schema rejected the whole field, so a rejection test passes on base. I added an acceptance test, where a canonical entry must parse and round-trip, which fails on base.

Also from review: an absent inventory now reports indirect-branch-inventory as unsupported instead of looking like "none found", the wording says "call or return", and warnings are matched by address space as well as offset. Your "Treating indirect jump as call" observation matches Ghidra's source: a "Could not recover jumptable" failure is always rewritten as a call, so the return case only applies without that warning.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fb77645644

ℹ️ 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".

Comment thread bridge/ghidra/ReaGhidraBridge.java Outdated
}

private static final Pattern DECOMPILER_JUMP_TABLE_FAILURE = Pattern.compile(
"Could not recover jumptable at (?:([A-Za-z_][A-Za-z0-9_]*):+)?(?:0x)?([0-9A-Fa-f]+)[^\\r\\n*]*"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Parse segmented warning addresses before branch matching

The new space-aware key still parses only one hexadecimal run, so when a supported DOS COM/MZ function gets a warning rendered with Ghidra's segmented coordinate (for example 1000:010c), group 2 is only 1000 and :010c is consumed as suffix text. warningSpaceKey then stores offset 0x1000, while the listing address uses the linear SegmentedAddress.getOffset() (ReaGhidraPrepareCom.java:14 constructs 1000:0100, which docs/ghidra-dos.md:69 maps to 0x10100), so the warning never attaches and the branch is falsely labeled no_jump_table_warning without its warning evidence; parse and canonicalize the full coordinate with Ghidra's address factory instead.

AGENTS.md reference: AGENTS.md:L23-L23

Useful? React with 👍 / 👎.

? []
: ["structured-boundary-types", "jump-table-data-mapping"];
const unsupportedBranches = !boundary.available
? ["structured-boundary-types", "jump-table-data-mapping"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Report inventory gaps when the boundary is unavailable

When dossier.native_api is null, as emitted by Hopper (bridge/hopper_bridge.py:719) and IDA (src/ida/IdaOperationRunner.ts:714), unavailableBoundary() means the provider exposed no branch inventory, but this arm still returns only the two legacy unsupported facets and later copies the legacy residuals unchanged. The new undefined check runs only for an available boundary, so inspect_native_api emits neither indirect-branch-inventory nor an indirect-branch residual for these uninspected providers; include that uncertainty in the null/unavailable projection too.

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

@CassieFox23

CassieFox23 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR: I re-tested this PR at fb77645 on Linux x64 with real Ghidra 12.1.4. Old saved snapshots are now refused instead of replayed. The earlier CLI results and both named unit files still hold.

Edit: I retested at b4fd1de. The results are here.

Results

Base is 2895a18 (#2943), the old head is 523cad5, and the new head is fb77645. I saved rea_computed_branch snapshots with the base and the old head. Then I loaded each on a fresh copy.

Snapshot made by Loaded by Result
Base Old head Replayed, with no branch entry
Base New head Refused, exit 1
Old head New head Refused, exit 1
New head New head Replayed, with the branch entry

The first row is the gap this push closes. The old head finds the branch on a fresh run, but its replay of a base snapshot hid it. The profile digest began adc662b9 on the base and the old head. It is 76928862 on the new head.

The CLI results hold. Both functions still get one entry, at 0x10000c and 0x100040. Only the profile, the evidence IDs and two phrases changed. They now say "rewrote" where they said "treated".

Unit file Node 22 Node 24 Node 26
NativeApiInspection.test.ts 9 of 9 pass 9 of 9 pass 9 of 9 pass
GhidraFunctionValues.test.ts 52 of 52 pass 52 of 52 pass 52 of 52 pass

The push adds one test to each file. My first run had 8 and 51 tests.

Still not run

  • The real RenderScript library from [Feature] Improve Ghidra AArch64 jump-table recovery #487.
  • The npm run verify:* lanes, the Mach-O fixture, CI and the full suite.
  • Snapshot loads through MCP. I used the CLI only.
  • The new tests against the base source. I did not check that they fail there. Ran at b4fd1de; see the new results.
  • Other tests that use the changed fixture file.
  • Anything on macOS or Windows.

Thanks, RishTheFish21, for the quick fix.

Test setup
  • Box: Nobara 44 (Fedora 44 base), Linux 7.2.9
  • CPU: AMD Ryzen 9 5900X, 12 cores / 24 threads
  • RAM: 32 GB DDR4-3600
  • Node: 22.23.1, 24.18.0, 26.11.1
  • Head: fb77645
  • Base: 2895a18
  • Other: the old head 523cad5, used for the snapshot contrast
  • Other: Ghidra 12.1.4 (Apache-2.0)
  • Other: JDK 21.0.12.1
  • Other: the AArch64 object from my first run, reused. Its sha256 is ae8b6c82596d1eb7dcfef5a068f1d3b04edbd3423947bb50b8d6d8d4a25916fd, and the .S source did not change in this push. I built it then with clang 22.1.8 (Apache-2.0 WITH LLVM-exception).
  • The box ran another test at the same time. A fresh run took about 7 seconds. A replay or a refusal took under 2 seconds. Treat these times as rough.
Profile digests
Tree Ghidra profile inspect-native-api workflow profile
base 2895a18 adc662b92264458a7c0bbb945c3a4028ef9668de9d6919edaad4335d927ba465 2e048032cc0f3e68234c1fade30e4af5bc6dade184b45ea123a212ae56faf475
523cad5 adc662b92264458a7c0bbb945c3a4028ef9668de9d6919edaad4335d927ba465 2e048032cc0f3e68234c1fade30e4af5bc6dade184b45ea123a212ae56faf475
fb77645 76928862bb08cedecb8f47dbe7fd42a3f136acc12e018c63ce3a5017e3a9cec4 308bb587cb87258078fbb2d211e79f0db44a25453ab7322ae6ad76ba54f1a0b5

The new profile carries indirect_branch_inventory: "listing-computed-jumps-decompiler-outcome-v1". The saved snapshots of rea function, rea inspect-native-api and rea decompile all bind to the Ghidra profile. So a base snapshot of rea decompile is refused on fb77645 too, even though it holds no saved results.

rea function and rea inspect-native-api snapshots acted the same way. The refusal says profile_mismatch and tells you to run without the snapshot and save a new one. The refused loads left each snapshot file unchanged. The checksums matched before and after.

Raw output of a refused load
{"error":"Analysis failed","code":"evidence_integrity_mismatch","category":"integrity_mismatch","message":"Analysis snapshot profile_mismatch: target, provider, or analysis profile does not match the requested binary","retryable":false,"remediation":{"action":"Run analysis without this snapshot, then save a fresh snapshot using the intended artifact, provider, and analysis profile."},"details":{"reason":"Analysis snapshot profile_mismatch: target, provider, or analysis profile does not match the requested binary"}}
Commands
rea function indirect-branches-elf.o rea_computed_branch --provider ghidra --json --snapshot base.json
rea inspect-native-api indirect-branches-elf.o 0x100000 --provider ghidra --json --snapshot base.json
rea decompile indirect-branches-elf.o rea_computed_branch --provider ghidra --json --snapshot base.json
cp base.json copy.json
rea function indirect-branches-elf.o rea_computed_branch --provider ghidra --json --snapshot copy.json
rea function indirect-branches-elf.o rea_indirect_tail_call --provider ghidra --json
rea inspect-native-api indirect-branches-elf.o 0x100038 --provider ghidra --json
node scripts/run-development-tests.mjs focused src/application/native/NativeApiInspection.test.ts
node scripts/run-development-tests.mjs focused src/ghidra/GhidraFunctionValues.test.ts

I made a fresh copy of the snapshot before each load, because --snapshot also updates the file. I made the base snapshots with the base tree and the 523cad5 snapshots with that tree. Each load ran under the Node 24 build of its own tree. Every load of a copy made by the same tree exited 0 and replayed. The refusals exited 1. All other commands exited 0. The test script is the one behind npm run test:focused, run with each Node binary by full path.

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊

@morluto morluto added area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior enhancement New feature or request labels Oct 14, 2026

jaelliot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Hey @RishTheFish21, I wanted to reach out about contributing to your indirect-branch recovery work.

I previously contributed REA's generic MIPS and PSP/Allegrex support through #1362 and #1599. I'm working toward more robust PSP reverse engineering, and your changes address an important problem: preserving control-flow uncertainty when Ghidra can't recover the original dispatch.

I saw the existing AArch64 verification and the independent Linux testing from @CassieFox23, as well as the newer review findings. I don't want to duplicate work you're already handling.

One thing I could contribute is a source-owned Allegrex fixture covering a computed jr dispatch and an indirect tail-call control. I'd like to verify the Ghidra listing, decompiler output, unresolved-branch Evidence, retained unknowns, and snapshot behavior without assuming that pseudocode represents complete control flow.

I still need to restore the appropriate PSP testing environment, so this is a proposed regression rather than a completed result.

Would that be helpful within #2977, or would you prefer a separate PSP-specific follow-up? I'm interested in collaborating on your existing implementation rather than developing a competing one.

Status update (October 23, 2026): The PSP/Allegrex fixture was subsequently validated against real Ghidra and remains a separate follow-up, as requested. For this PR's own saved-warning attribution issue, I have now shared a focused regression commit. That new regression has not yet had a real-Ghidra run; the original collaboration offer and earlier status above are preserved for context.

Copy link
Copy Markdown
Contributor

Following my collaboration offer and the reported unavailable-boundary inventory gap, I’ve prepared a focused correction for PR #2977.

The earlier fix made Hopper/IDA’s unavailable boundary report the missing indirect-branch inventory. A persisted CLI workflow snapshot could still return an older inspect_native_api result before running the corrected projection. The PR’s Ghidra provider-profile change addresses cached analyze_function results; this separate application workflow now commits workflow_revision: 1 for inspect_native_api only.

The regression used a persisted, authenticated old-profile snapshot. Before the revision, it returned the legacy result without the inventory unknown. Afterward, the CLI runs the workflow, preserves the historical Evidence, emits the unknown, and can replay a fresh result. A linked source-Evidence control also passed. The profile controls for binary_overview, trace_feature, get_call_graph, batch_decompile, and inspect_native_dispatch_metadata passed unchanged.

The contribution is on my fork at e191d9d, following the existing 02acfef unavailable-boundary fix. Before the change, the new profile regression failed because the digests were equal; the persisted CLI regression returned the stale result (1 failure, 16 passes, 2 Windows-only skips). After the change, 43 focused source tests and 25 filesystem/MCP boundary tests passed (2 Windows-only skips), and npm run check:fast -- --force passed.

Validation used Node 22.23.1 and npm 10.9.8; the package pins npm 11.16.0. The persisted CLI test uses REA’s fixture provider. I did not run real Ghidra or PSP tests.

Please feel free to incorporate both commits into your existing PR. I’d also welcome your guidance on whether a later source-owned Allegrex regression should live in #2977 or a separate follow-up.

@kaoru0822-kitauji kaoru0822-kitauji added the ci-fix-wip Claimed by the CI-fix track label Oct 14, 2026
@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator

CI-fix track: none of the failures came from this PR. The Source tests job failed in GhidraPowerPcProfile.test.ts, and shard 3 in ciTestReports and javascriptSourceAnalysisWorker, all files this PR doesn't touch; they were main's state at the time. I merged current main (9a4866d, no conflicts). On the merged tree, src/ghidra, src/application/native, src/domain/native and those three previously failing files all pass (697 tests). check:fast and docs:check are clean. Main's own CI is green again after #3080. The real-Ghidra verifier script changes weren't run locally.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@kaoru0822-kitauji kaoru0822-kitauji removed the ci-fix-wip Claimed by the CI-fix track label Oct 14, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@RishTheFish21

Copy link
Copy Markdown
Contributor Author

Thanks @jaelliot, both commits are in. cherry-picked onto the current head with your authorship. Good catch on the second cache layer. On the Allegrex fixture, I'd prefer a separate PSP-specific follow-up. That keeps this PR focused on the AArch64 evidence it already has, and lets your fixture land with its own real-Ghidra results once your PSP environment is back. It would be a useful second architecture for this, since a computed jr plus a tail-call control would show whether the decompiler-outcome labels hold outside AArch64.

Copy link
Copy Markdown
Contributor

Hey @RishTheFish21, following your request to keep the Allegrex regression separate from #2977, I've now verified the source-owned PSP control-flow fixture against real Ghidra 12.1.3 + ghidra-allegrex v21.4 + PSPDEV v20261001 on Linux.

Fixture/verifier branch in my fork | successful real-Ghidra CI run

The run is based on REA main 8ab5024397ddbd3b37ab68a13cabedc2eb7ce7dd, with the newer PSP GNU/ABI declaration checks. An unchanged PSP baseline and missing-extension refusal both passed. The new wholly synthetic ELF32/Allegrex fixture contains a register-derived jr $t9 dispatch, a separate jr $t9 indirect-tail control, jr $ra return, and a direct jump. It never executes the PSP binary.

Observed in real Ghidra: both register-based jr sites were classified COMPUTED_JUMP with no direct destinations; jr $ra was classified as a return. On current main, inspect_native_api for those two computed sites reported neither unresolved-branch entries nor recovered jump tables, illustrating the uncertainty gap #2977 addresses. The verifier also checked source identity, Allegrex language, authenticated Evidence, snapshot replay, and cleanup. It passed along with 104 focused source tests.

This is not a test of #2977's unmerged branch or proof that its new decompiler-outcome labels work for Allegrex. The older #2977 head still predates main's complete GNU MIPS ABI inspection and refused the present PSP baseline before its extension path ran, so I did not bypass admission or force-merge the branches. I'll keep the PSP follow-up independent as you requested.

Would you prefer that I wait for #2977 to merge before proposing the separate PSP regression PR? I can then make the test assert actual unresolved-branch Evidence and its snapshot semantics against the integrated source, rather than rely on assumed output.

jaelliot added a commit to jaelliot/rea that referenced this pull request Nov 4, 2026
jaelliot added a commit to jaelliot/rea that referenced this pull request Nov 4, 2026
…ature overlay

Retain the existing morluto#2977 integration and pinned fork workflow. Update only the PSP indirect-branch verifier to the exact d7360ed source for cleanup, missing-inspection, listing-target, and replay-provenance checks.
jaelliot added a commit to jaelliot/rea that referenced this pull request Nov 4, 2026
Use the exact 1dc5521 verifier with the existing morluto#2977 integration and pinned PSP/Ghidra workflow. Preserve the prior failed qualification as evidence of the raw-versus-qualified marker mismatch.
jaelliot added a commit to jaelliot/rea that referenced this pull request Nov 5, 2026
jaelliot added a commit to jaelliot/rea that referenced this pull request Nov 5, 2026

jaelliot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

@RishTheFish21 — following up with a concrete handoff/decision for the canonical #2977 (not a competing PR). I rechecked upstream main at 71f680d and your unchanged source head 063df50: GitHub still reports a merge conflict.

The existing fork-only candidate c98cd2d is a non-force fast-forward descendant of your head and contains current main; its tree changes exactly your same 27 feature files relative to 71f680d (no unrelated files). Exact-tree Linux/Ghidra qualification passed build/static/docs plus 441 focused tests and the real warning-provenance checks.

One remaining independent gate: your original upstream CI failed a 30-second macOS nativeMachoSummaryMcp.test.ts timeout; the fork isolated macOS recheck is still queued, not a pass or root-cause determination. I haven't touched your branch. Could you review the candidate and decide whether to fast-forward it into #2977 for fresh upstream qualification? If you prefer to wait for the macOS recheck, that is reasonable too. I will keep #6931 separate and dependent until the feature actually lands.

@morluto

morluto commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Hey @RishTheFish21, thanks for the PR! This addition looks good to me. What's left: it has merge conflicts with main in src/application/WorkflowAnalysisProfile.ts, src/application/binary/AnalysisSnapshotCache.test.ts, src/ghidra/GhidraRawProfileDigest.test.ts and 1 other file (merging main into the branch is fine) and the CI required check is failing (failing job: Real Apple artifact CLI/MCP E2E). There are 7 unresolved review threads from Codex (1 still on current code), e.g. "Bound and page the unresolved-branch inventory"; the 6 on outdated lines may just need resolving if they're already handled. Once that's done I'm happy to merge it.

Expose native_api.unresolved_indirect_branches as a bounded native view
facet, so the retained inventory can be read a page at a time instead of
only inside the native_api singleton. Sites beyond the provider's
inventory bound stay unknown on every page, an uninspected inventory
reports "not recorded", and an unavailable native_api keeps its reason.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@RishTheFish21

Copy link
Copy Markdown
Contributor Author

Thanks @morluto. Here's where each item stands:

  • Conflicts: fast-forwarded to @jaelliot's merge candidate c98cd2d (main merged in, your four conflicting files resolved, his commits under his authorship). It merges cleanly with current main (0beedcd), and the net diff against main is still the PR's own 27 files.
  • "Bound and page the unresolved-branch inventory": the bound was already there (256 sites, 64 listing targets per site, with *_omitted counts and a residual unknown). 1b5df26 adds the paging: inspect_analysis_view now accepts view: {kind: "native", facet: "unresolved_indirect_branches", offset, limit}, so the retained inventory no longer has to be read inside the native_api singleton. Every page repeats the bridge-omitted count as an unknown, an uninspected inventory reports "not recorded", and an unavailable native_api keeps its own reason. Tested in analysisView.test.ts, and documented next to the inventory in docs/native-investigation.md.
  • The 6 outdated Codex threads: each one is handled at this head (omitted vs empty inventory, unavailable boundaries, segmented addresses, string literals, and the two saved-comment threads), so I've resolved them.
  • Real Apple artifact CLI/MCP E2E: the earlier failure was the 30-second timeout in tests/boundary/mcp/nativeMachoSummaryMcp.test.ts, which this PR doesn't touch. It passes locally on macOS arm64 at this head. The fresh CI run will show whether it recurs.

Local validation at 1b5df26 (macOS arm64, Node 24.22.1): check:fast and format:check passed, and the focused tests passed (analysisView, NativeApiInspection, GhidraFunctionValues, GhidraRawProfileDigest, and nativeMachoSummaryMcp).

… fails

Report incomplete supervisor cleanup and a failed workspace removal
alongside the probe's own failure instead of replacing it, as verifyTarget
already does, so the original Ghidra assertion and output survive.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

Keeps both sides in knip, the conformance README, the Ghidra and workflow profiles, and snapshot admission; morluto#2977's inspect_native_api revision now sits in main's workflowAnalysisProfileParameters. The raw profile digests are repinned.
@RishTheFish21

Copy link
Copy Markdown
Contributor Author

Merged current main (c78c8aed4) into this branch to clear the conflicts; normal push, no rebase or force. The six conflicts were all new profile keys next to this PR's, and I kept both sides: the inspect_native_api workflow revision now sits in main's workflowAnalysisProfileParameters. The raw profile digests are repinned, and this PR's snapshot test now expects main's trace_feature revision 9. check:fast passed, and the AArch64 jump-table lane and warning-attribution lane passed on real Ghidra 12.1.4 on macOS arm64.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f7f2ba2815

ℹ️ 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".

Comment on lines +88 to +90
unresolved_indirect_branches: dossier.native_api?.available
? dossier.native_api.unresolved_indirect_branches
: undefined,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve branch coverage in the default summary

When analyze_function uses its default detail: summary, this new collection is only wired into nativeRows: neither parentFields nor summarizeDossier reports an available boundary whose inventory is absent or whose unresolved_indirect_branches_omitted count is positive. Consequently an uninspected inventory and a Ghidra function that hit the 256-site cap both produce a compact result without the corresponding coverage unknown/count (it appears only if the caller already knows to request this facet), so propagate the nested inventory coverage state into the summary's counts or unknowns.

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

@CassieFox23

Copy link
Copy Markdown
Contributor

TL;DR: On head f7f2ba2, the PR's 11 test files passed on all three Node versions. The CI run on head f7f2ba2 ended completed/failure, with three failed check runs. The one failing test I found in its log is in a file I did not run.

Results

Check Node 22.23.4 Node 24.22.1 Node 26.12.1
npm run test:focused on the 11 changed test files pass: Test Files 11 passed (11); Tests 608 passed, 2 skipped (610) pass: Test Files 11 passed (11); Tests 608 passed, 2 skipped (610) pass: Test Files 11 passed (11); Tests 608 passed, 2 skipped (610)
  • The PR changes 30 files against the merge base: 11 test files and 19 others.
  • I last tested b4fd1de. Head f7f2ba2 is 2 commits behind main b46f4fc.
  • GitHub shows mergeable true, state blocked, and not a draft.
  • Workflow runs: CI is completed/failure, CodeQL production is completed/skipped, PR readiness and PR title are completed/success.
  • Check runs: 43 success, 3 skipped, 3 failure.
  • The failures are CI required, Portable tests and Test shard (6/6).
  • The skips are Analyze production (${{ matrix.language }}), Python producer tests and Source tests.
  • Real Apple artifact CLI/MCP E2E and Test shard (1/6) through Test shard (5/6) are success.
  • In the log of CI run 42553749822, the failing test is preserves the source when an inline result with unknown retention exceeds delivery.
  • The test lives in tests/boundary/mcp/sourcePublicationComposed.test.ts, in the mcp-boundary vitest project.
  • The error is an AssertionError on a resource_constraint result. The received object had 5 more fields, and the expected object had 1.
  • The CI required job log says Error: CI lanes did not pass: test, test-shard.
  • sourcePublicationComposed.test.ts is not one of the 11 files I ran. That file came in with 88cf498 (fix!: preserve results when source publication fails #8444), which is in this head's history. Main's newer commit 78a84d7 (test(mcp): size source recovery budget from delivered evidence #9566) changes it. That PR says it fixes this failure.

Not run

  • A real-Ghidra probe is not run. It would use a function with only a stored comment. The comment is long, wrapped, and starts with WARNING:. It should report no_jump_table_warning.
  • A real Ghidra target with a string literal in its pseudocode, covering the warning_string_literal token in ReaIndirectBranchEvidenceProbe.java.
Test setup
  • Box: Fedora 44 VM (4 vCPUs, 8 GB) on my Nobara 44 PC, Linux 7.2.11
  • Node: 22.23.4, 24.22.1, 26.12.1
  • Head / base: f7f2ba2 / c78c8ae (merge base with main)
  • Install: npm ci --offline and npm run test:prepare on Node 24.22.1
Commands
npm ci --offline
npm run test:prepare
xvfb-run -a npm run test:focused -- src/application/WorkflowEvidence.test.ts src/application/binary/AnalysisSnapshotCache.test.ts src/application/native/NativeApiInspection.test.ts src/domain/analysisView/analysisView.test.ts src/ghidra/GhidraFunctionValues.test.ts src/ghidra/GhidraProvider.behavior.test.ts src/ghidra/GhidraRawProfileDigest.test.ts src/ghidra/GhidraSnapshotCache.test.ts tests/boundary/filesystem/directAnalysisSnapshotReplay.test.ts tests/boundary/mcp/enhancedTools.01-lists-the-complete-target-open.test.ts tests/boundary/mcp/ghidraNativeApiMcp.test.ts

🤖 Written and tested with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊

…gests

Main's morluto#9566 fixes the sourcePublicationComposed failure in test shard 6. The raw profile digests changed again; both are repinned, and this PR's indirect_branch_inventory assertion is kept.
Main's morluto#9706 makes this MCP test create two Evidence records instead of three, so the automatic unknown counts drop from 6 to 4 (two per record). The raw profile digests changed again and are repinned; the profile assertion keeps both main's native_value_flow_projection and this PR's indirect_branch_inventory.
Resolves one import conflict in the direct snapshot replay test: keeps main's verifier cleanup import and this PR's createEvidenceBundle import.
@RishTheFish21

Copy link
Copy Markdown
Contributor Author

@morluto This has been open since Oct 13, so a quick nudge. Per your Oct 18 backlog note, the conflicts are resolved and the head (1b4107c55) is mergeable. CI's only failures are main's: shards 1 and 6 fail the same five tests (agentEvaluationCommands, releaseArtifactCanary, cutterVerifierPlatform) as main's scheduled run at 4082375e7, and the Apple E2E job hit its 15-minute limit with every test passing. All review threads are addressed, including Greptile's cleanup finding (74a18535b), and the real-Ghidra lanes pass on macOS arm64. #4237's combined #2735 work with @Bobtoshi is stacked on this, so merging it would unblock that too. Is anything else needed from my side?

@Bobtoshi

Bobtoshi commented Nov 11, 2026 •

Copy link
Copy Markdown

@RishTheFish21, I prepared a merge candidate for 1b4107c5 against upstream main 0909d89c. The conflict was in WorkflowAnalysisProfile.ts. The resolution keeps inspect_native_api at revision 2 and main’s trace_native_values at revision 3 and trace_call_path at revision 2. The merge preserves the existing commits. Merge candidate

Typecheck, lint, formatting and the workflow revision checks passed. Focused suites had 207 passes and two skips. One Swift literal pagination fixture failed identically on a pristine copy of main 0909d89c. That fixture provides the literals without the paired omission array required by the current schema. The default-summary coverage review remains open. Review thread

Update for review at 3d4d01e83. The candidate now includes a focused fix for the default summary. It reports an uninspected branch inventory and the provider’s omitted count through the existing unknowns field. An explicitly empty inventory remains clear. The paged facet uses the same wording. I added a regression covering all three cases and merged main 6878a847, which includes the Swift fixture repair. Nine focused suites passed with 288 tests and two skips. Typecheck, lint and formatting passed. The original author commits remain in the candidate history. Updated candidate

@morluto morluto added the provider: ghidra Analysis provider / engine: ghidra label Nov 23, 2026
@morluto

morluto commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Thank you for this contribution! The computed-branch reporting work has already landed on main in commit 26fd63c396 (feat(ghidra): report computed branches without a recovered jump table), and the linked tracking issue #487 was closed as completed. Closing this PR as already landed.

@morluto morluto closed this Nov 24, 2026
@RishTheFish21

Copy link
Copy Markdown
Contributor Author

Thanks @morluto. I think this was closed by mistake: 26fd63c396 is this PR's own first commit, and it isn't on main. git merge-base --is-ancestor 26fd63c396 upstream/main fails, and current main (7e88503e5a) has no unresolved_indirect_branches, indirect_branch_inventory or tests/conformance/ghidra/indirect-branches.S. So #487's computed-branch reporting hasn't landed yet.

Could you reopen this? If you'd rather have a fresh PR rebased onto current main, I can do that instead. Either way, #4237 no longer depends on it: I've rebuilt that one as a standalone change on main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior ci:full enhancement New feature or request provider: ghidra Analysis provider / engine: ghidra

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants