Skip to content

test(ghidra): verify PSP Allegrex unresolved indirect branches - #6931

Open
jaelliot wants to merge 5 commits into
morluto:mainfrom
jaelliot:codex/rea-psp-indirect-conformance-upstream-20261023
Open

jaelliot wants to merge 5 commits into
morluto:mainfrom
jaelliot:codex/rea-psp-indirect-conformance-upstream-20261023

Conversation

@jaelliot

@jaelliot jaelliot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add an opt-in, source-owned PSP/Allegrex control-flow verifier, as a separate follow-up requested by the author of #2977. Related: #1330.

Dependency: #2977 → #6931. The verifier requires the unresolved computed-branch inventory from canonical #2977. That implementation stays with its author; #5137 was incorporated there and closed as superseded. This PR remains six conformance/fixture/documentation files and does not copy production bridge or schema changes.

Problem and expected behavior

Once #2977 is present, two synthetic parameter-derived jr $t9 sites must remain explicitly unresolved, with no invented listing destinations and with retained reachability unknowns. An ordinary jr $ra return and direct j must be inspected and excluded from that inventory. Snapshot reuse must retain the observation and identify its replay provenance.

Review fixes

Commits d7360ed and 1dc5521 address the four review findings in the existing verifier only: 30 additions, 14 deletions.

  • Reuse createVerifierCommands and await commands.close() before completing the verifier, so timeout cleanup retains ownership of compiler descendants.
  • Require unresolved_indirect_branches to be an array; omission or null cannot establish an inspected empty result.
  • Require empty listing_targets for both synthetic computed jumps.
  • Retain replayed Evidence and require the owner's SNAPSHOT_REPLAY_LIMITATION before comparing values. Recognize the provider/operation attribution added by REA's composed-Evidence formatter, following the existing Ghidra MCP replay test.

Change and scope

The existing source-owned ELF32/Allegrex fixture is compiled and statically analyzed through public REA MCP operations. The verifier checks independent ELF/ABI facts, listing observations, Evidence, residual unknowns, snapshot identity/replay, unchanged target bytes, and owned cleanup. Its entry is registered in knip.json; invocation and prerequisites are documented in docs/ghidra-psp.md.

  • Semantic owner: PSP conformance verifier. Process ownership and snapshot provenance reuse the existing owners.
  • Scope decision: routine test-only static analysis within existing PSP admission; the author requested this separate follow-up.
  • Contracts/package: no production provider, bridge, schema, CLI/MCP, dependency, installation, or release changes.
  • Host/provider scope: Linux x64, Ghidra 12.1.3 with compatible Allegrex v21.4, PSPDEV v20261001, and JDK 21 for the pinned qualification lane.
  • Authority: the verifier invokes local build tools and an isolated Ghidra analyzer, writing disposable fixture/project files. It does not execute the synthesized PSP target or use game assets. No toolchain installation or network operation is performed by the verifier.

Expected effects on the test host:

  • 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 effects describe host compilation, analyzer execution, and temporary files; target code is never executed.

Evidence and validation

Current verifier revision

  • Node 24.22.1 / npm 11.16.0, locked npm ci: passed.
  • npm run test:focused -- tests/boundary/process/nativeVerifierCommandOwnership.test.ts tests/boundary/process/verifierCommandSemantics.test.ts tests/boundary/process/verifierSourceLoading.test.ts tests/conformance/ghidra/psp-checks.test.ts tests/boundary/mcp/ghidraNativeApiMcp.test.ts: 55 tests passed in five files. This includes real timed-out leader/descendant cleanup with zero survivors, retained artifacts, command cleanup retry, and simulated Ghidra MCP snapshot behavior.
  • Controlled execution of the actual original, intermediate, and final assertion blocks: 9 scenarios / 27 executions. The final source accepts all four valid controls, including a replay limitation produced by REA's actual source formatter, and rejects all five bad observations: omitted/null inspection, missing/fabricated listing targets, and an identical recomputed value without replay provenance. The original accepts those bad cases; the intermediate exact-array check incorrectly rejects the qualified positive control. This is source-assertion evidence, not a real-provider run.
  • After the final marker-format correction, npm run test:focused -- tests/boundary/mcp/ghidraNativeApiMcp.test.ts: 11/11 passed again.
  • node --check, focused formatter check, and git diff --check: passed.
  • npm run check: passed, including typecheck, ordinary/typed lint, formatting, Knip, metadata, module boundaries, and architecture guards. Typed lint reported zero errors with repository advisories. The final two-line assertion adjustment additionally passed focused syntax, formatting, and lint checks.

Dependent real-provider qualification

Current fork run 41854251564 passed at 173c85a. It retains the existing #2977 integration and pinned workflow, using the exact final PR verifier blob 9e335c7f71e795f14b3b7ac7d154c9b47dd91fdd. Its parents are the previous qualification f093496 and current PR commit 1dc5521.

The pinned Linux Ghidra 12.1.3 / Allegrex v21.4 / PSPDEV v20261001 / JDK 21 lane passed 153 focused contract tests, missing-extension refusal, the unchanged PSP acceptance baseline, and the final indirect-branch verifier. Both computed jr $t9 sites remained unresolved with empty listing targets; return/direct controls had inspected empty inventories. The replay assertion passed, the snapshot retained 26 Evidence records, ELF bytes stayed unchanged, and cleanup was verified with zero surviving descendants. Source/working-tree hygiene also passed. This qualifies the final verifier against the retained #2977 integration; it does not establish standalone success against plain main.

The first review-fix qualification, 41852710078, passed the branch checks but failed the new replay assertion: exact array membership did not recognize REA's provider/operation-qualified replay marker. The follow-up corrects that verifier mismatch; the canonical marker remains mandatory. This failed run is retained as evidence.

Current upstream CI 41854491389 completed successfully on 1dc5521: 17 successful jobs, 23 intentionally skipped jobs, and no failures or cancellations. All eight built-test shards, source tests, static checks, documentation, package build, bundled Windows-controls build, Linux native package verification, Portable tests, and CI required passed. Skipped provider/platform lanes remain unexecuted. This standard CI result is separate from the successful dependent real-provider qualification above.

Historical evidence — earlier verifier revisions

Standard upstream CI 41757456999 passed at b71a0c6. Dependent real-Ghidra run 41766913011 passed at 191d759 with Ghidra 12.1.3 / Allegrex v21.4 / PSPDEV v20261001 / JDK 21: 153 focused tests, two unresolved computed branches, ordinary controls excluded, 26 snapshot Evidence records, unchanged ELF bytes, and complete cleanup. These runs predate the new assertions and do not validate the current 1dc5521 revision.

The earlier main-only negative control observed listing-computed branches without #2977's unresolved inventory. Earlier pcap worker-OOM observations and retries concern historical runs; they are not evidence about this revision.

Remaining limits

The dependent provider run and current-head upstream CI both passed. The optional verifier still requires #2977. No runtime game behavior, VFPU semantics, PRX/PBP/ISO/CSO, arbitrary PSP binary support, or cross-platform qualification is claimed.

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.

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 feat(ghidra): report computed branches without a recovered jump table #2977 and issue [Feature] Add PSP/Allegrex native analysis through Ghidra #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.

@greptile-apps

greptile-apps Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The reviewed changes appear safe to merge, with no outstanding findings.

Summary

Adds an optional PSP/Allegrex verifier with source-owned fixtures for two unresolved computed jumps, a return, and a direct jump.

  • The PSP verifier checks computed branches without treating ordinary jumps as unresolved.

Reviews (13) · Last reviewed commit: "test(ghidra): clean up interrupted PSP v..." · Reviewed by Greptile

jaelliot added a commit to jaelliot/rea that referenced this pull request Nov 4, 2026
@jaelliot
jaelliot marked this pull request as ready for review November 4, 2026 05:37
Copilot AI balanced review requested due to automatic review settings November 4, 2026 05:37
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

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

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

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.

Copilot AI 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.

🟡 Changes recommended

The verifier can accept missing branch-inspection data, fabricated targets, and recomputed results instead of snapshot replay, while timed-out builds can leave compiler descendants running.

4 open issues
What changed in this PR

Adds an opt-in PSP/Allegrex conformance verifier for the unresolved indirect-branch reporting introduced by #2977. This is test-only coverage within REA’s existing static-analysis workflow; it does not change production behavior or execute target code.

Changes:

  • Adds synthetic computed-branch fixtures with ordinary return and direct-jump controls.
  • Exercises real Ghidra through public MCP operations, checking Evidence, residual unknowns, snapshot replay, unchanged ELF bytes, and cleanup.
  • Documents prerequisites and the #2977 dependency, and registers the verifier with Knip.
File Description
tests/​conformance/​psp/​control-flow/​Makefile Builds the isolated PSP ELF fixture.
tests/​conformance/​psp/​control-flow/​main.c References the four static control-flow probes.
tests/​conformance/​psp/​control-flow/​control-flow.S Defines computed jumps and ordinary branch controls.
scripts/​verify-real-ghidra-psp-indirect.mjs Adds the real-provider conformance verifier.
knip.json Registers the verifier as an entry point.
docs/​ghidra-psp.md Documents invocation, dependency, and coverage limits.

Review effort: Balanced

morluto commented Nov 7, 2026

Copy link
Copy Markdown
Owner

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.

@CassieFox23

Copy link
Copy Markdown
Contributor

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 🦊

@morluto morluto added area: tests Test suite and verification provider: ghidra Analysis provider / engine: ghidra labels Nov 23, 2026
@morluto

morluto commented Nov 24, 2026

Copy link
Copy Markdown
Owner

@jaelliot thanks for the PR — this branch has merge conflicts with main. Could you merge or rebase onto the latest main and resolve them? Once it's clean and CI is green we can take another look.
cc @gensokyo-dev @dandgabr

Use the replayable procedure inventory to check snapshot provenance. Verify native API results separately because Ghidra reobserves that workflow. The focused replay control passed on a source-owned PSP ELF.
@jaelliot
jaelliot force-pushed the codex/rea-psp-indirect-conformance-upstream-20261023 branch from 2468329 to 13ac3fa Compare November 25, 2026 00:46

This branch has not been deployed

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

Labels

area: tests Test suite and verification provider: ghidra Analysis provider / engine: ghidra

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants