#6931

test(ghidra): verify PSP Allegrex unresolved indirect branches

Draftjaelliotwants to merge intofrom

Summary

Add an opt-in, source-owned PSP/Allegrex control-flow conformance verifier, as a separate follow-up requested by the author of #2977 (coordination). This is a draft dependent on #2977, not a second implementation of unresolved-branch recovery. Related: #1330.

Problem and expected behavior

Before #2977, static PSP Ghidra analysis preserves listing-computed jr $t9 instructions but can omit their unresolved target uncertainty from native API output. Once #2977 is present, a real-provider regression should show both sites and their unknowns without mistaking an ordinary return or direct branch for a computed dispatch.

Change and scope

  • Add a synthetic ELF32/Allegrex fixture with computed jr $t9 dispatch, independent indirect-tail jr $t9, ordinary jr $ra return, and direct j control. Target bytes are never executed.
  • Add an opt-in real-Ghidra verifier using the existing REA public CLI/MCP, ELF/ABI verification, evidence and snapshot contracts, verifier-run identity, and owned cleanup utilities.
  • Register the verifier in knip.json and document the invocation and the #2977 dependency in docs/ghidra-psp.md.

No production bridge, provider admission, schema, CLI/MCP surface, dependencies, or binary execution capabilities change. No toolchain is downloaded or installed by the verifier.

Contract and boundary impact

  • Semantic owner and earliest changed stage: source-owned PSP conformance fixture and verification harness.
  • Contribution scope fit and linked maintainer decision: test-only static analysis within existing PSP admission; no new execution/injection/mutation/protection-recovery capability. The #2977 author explicitly requested a separate follow-up.
  • CLI and MCP/tool-catalog contract: unchanged. The test exercises existing operations.
  • Provider, bridge, target-format, or platform compatibility: Linux x64, Ghidra 12.1.3 with ghidra-allegrex v21.4, PSPDEV v20261001 and JDK 21; #2977 unresolved-branch inventory must be present.
  • Evidence, artifact, provenance, or reconstruction contract: verifies authentic Ghidra listing/evidence, residual unknowns, original-byte SHA-256 preservation, and authenticated snapshot replay; does not infer runtime reachability.
  • Target selection, authority, upstream behavior, and cleanup: static synthetic target only; invokes local build tools and an isolated Ghidra analyzer process; temporary outputs are owned and cleaned. No PSP execution or commercial game files.
  • Generated metadata/package/install impact: one knip.json entry; no package or dependency changes; no generated artifacts committed.

Expected effects (test host, not analyzed target):

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

The checked process/script/file effects are local host test execution and temporary fixture/project writes, not target-code execution, injection, memory modification or persistent configuration changes.

Evidence and regression coverage

  • Tests added: scripts/verify-real-ghidra-psp-indirect.mjs with source-owned tests/conformance/psp/control-flow/ inputs.
  • Baseline and historical evidence: real-Ghidra feature overlay run previously passed with Ghidra 12.1.3 + Allegrex v21.4 + PSPDEV v20261001, observing both jr $t9 sites as unresolved and excluding the controls. Main-only negative control reported the computed listing jumps without the new unresolved inventory. These runs predate the refreshed main-based PR; a new overlay validation is reported below.
  • User-visible CLI/MCP output (historically observed): computed branches reported with jump_table_recovery_failed, no fabricated listing targets, explicit reachability unknowns, and snapshot replay. Source-level assertions preserve both computed controls.
  • Remaining proof gaps: current main lacks #2977, so this verifier cannot pass against the draft's base until the dependency is integrated. The current verifier was replayed on a disposable overlay of #2977 at the matching script blob, with passing real PSP tests (see Validation). The main-based PR cannot pass its dependent branch assertions until #2977 lands. Upstream CI is not green: built-test shard 3/8 suffered a Vitest worker heap exhaustion and SIGABRT while running an unchanged pcapCli.test.ts, causing the other shards to be cancelled by fail-fast. A separate PR-readiness workflow run hit a GitHub installation API rate limit (HTTP 403), not a code or readiness-declaration failure. The independent fork-only shard replay is documented under Validation. No VFPU semantics, PRX/PBP/ISO/CSO, commercial game binary or runtime emulation claims.

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

  • Refreshed PR branch based on upstream main at 044c9705: three focused commits (fixture/docs, repository formatting, awaited resource-owned Ghidra prerequisite inspection), six changed files. Only test/doc/Knip paths changed.
  • Historical overlay validation: passing Linux real Ghidra acceptance and main-only control. See caveat above.
  • Real-Ghidra overlay of #2977: passed with Ghidra 12.1.3, Allegrex v21.4, PSPDEV v20261001, JDK 21, Linux x64; both computed jr $t9 sites retained as unresolved; ordinary return/direct controls excluded; 22 snapshot Evidence records, original bytes unchanged, cleanup complete. It reused the exact verifier blob in the refreshed PR branch, but exercised it against #2977's producer implementation rather than plain main.
  • Same run: existing PSP missing-extension refusal and unchanged PSP baseline passed; 119 source tests in three files, node --check, build, and npm run check:fast passed.
  • Upstream CI for the refreshed PR commit: package build, static checks, documentation and source tests passed. One out-of-scope built-test shard (3/8) failed after 1,600 passing tests / 12 skips with a Node.js worker heap OOM and SIGABRT during unchanged tests/boundary/cli/pcapCli.test.ts; the other seven shards were cancelled by fail-fast. The same file has the same blob on current upstream main. The configured CLI-boundary test heap is 384 MiB. This is a source-independent failure observation, not proof of flakiness or correctness of the entire CI suite.
  • Independent fork-only replay: passed against this PR's exact source, with 168 test files passed and 2 skipped (1,553 tests passed, 37 skipped), no worker OOM, and 5/5 pcapCli.test.ts checks passing within the shard. Its explicit second run of the same test also passed 5/5. A separate clean-runner focused check independently passed all 5 cases. These runs preserve REA's standard Vitest/heap settings but do not import upstream's historical CI test-ordering data or replace the upstream red status check. A direct upstream retry returned 403 Resource not accessible by integration. A separate PR-readiness API call failed because of the upstream installation rate limit; no human readiness declarations were checked.

Compatibility, safety, and release

  • Breaking changes/migrations: none; verifier opt-in.
  • Real Ghidra/OS coverage: Ghidra 12.1.3, Allegrex v21.4, PSPDEV v20261001 and JDK 21 on Linux x64 for the verifier paired with #2977; not full cross-platform qualification.
  • Package/release impact: none beyond verifier discovery.
  • Containment: no target execution, no PSP/game assets, no network actions from verifier. Host compilation and Ghidra process/database writes are isolated temporary test activity.

Author readiness

Human owner: @jaelliot

  • 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 PR #2977 and issue #1330 are linked.
  • Tests cover changed observable behavior and meaningful failure paths on the current source revision.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative historical output (no new contract).
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

Activity

18
greptile-apps[bot]25d ago

Confidence Score: 5/5

[Low impact] No blocking code issue was found in the reviewed changes.

Summary

Adds an optional PSP/Allegrex verifier with source-owned fixtures. It checks unresolved computed jumps, ordinary controls, saved snapshots, unchanged target bytes, and cleanup.

  • PSP control-flow checks now distinguish computed jumps from ordinary branches.

Reviews (9) · Last reviewed commit: "test(ghidra): recognize qualified snapsh..." · Reviewed by Greptile

greptile-apps[bot]reviewed25d ago
chatgpt-codex-connector[bot]22d ago

Codex Review Summary

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

ReviewStatusCommitReview trigger
📝 Code Review⚠️ Failed 2026-11-04T05:38:01.443002Z
We couldn’t complete this review. Comment @codex review to try again.
b71a0c6Draft marked ready
ℹ️ 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.

chatgpt-codex-connector[bot]22d ago

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.

morluto18d ago

The PSP verifier requires unresolved_indirect_branches, which is added by still-open #2977, not this diff. Please hold the verifier until that dependency lands, or separate it from this PR. The structured flow assertions look suitable once the inventory exists.

CassieFox2312d ago

Hi! This PR's checks pass, but GitHub shows a merge conflict with main. A rebase on main should clear it, and then it's ready for a maintainer to review. No rush.

🤖 Written with Claude Code (Opus 5.5), posted with my OK 🦊

This pull request is a draft

Merging is unavailable until it is marked ready for review.