Skip to content

feat(psp): correlate caller-selected symbol maps with Ghidra inventories - #8615

Open
jaelliot wants to merge 5 commits into
morluto:mainfrom
jaelliot:codex/rea-psp-symbol-correlation-20261101
Open

jaelliot wants to merge 5 commits into
morluto:mainfrom
jaelliot:codex/rea-psp-symbol-correlation-20261101

Conversation

@jaelliot

@jaelliot jaelliot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Provide an opt-in, read-only developer script to correlate caller-selected PPSSPP-style function labels with an existing REA list_procedures inventory, preserving original addresses, explicit source/analysis bases, selected file paths and hashes, and uncertainty. No Ghidra rename, binary mutation, new MCP/CLI tool, or additional provider.

Problem and expected behavior

Analyzing PSP game functions benefits from PPSSPP's labels, but a name or 32-bit address does not prove which PSP module or load base it belongs to. The legacy .sym exported by ghidra-allegrex and modern .ppsym saved by PPSSPP have different layouts: modern module symbols are module-relative, while module-index-zero game/RAM symbols are absolute. Silent zero-offset matching can invent function identities.

Change and scope

  • scripts/psp-symbol-correlation.mjs: bounded .sym / .ppsym 1 function-label parser, explicit base selection, optional externally-known CRC comparison, read-only comparison with already captured REA list_procedures JSON array or Evidence normalized_result.
  • Produce distinct outcomes for address/name agreement, address-only, missing observation, duplicate ambiguity, autogenerated placeholders and out-of-range mapping; include source SHA-256, selected target SHA-256, caller paths, optional input Evidence target digest, provenance limitations and selected bases. Agreement does not establish module/binary identity.
  • scripts/verify-psp-symbol-correlation.mjs: focused source-only positive and negative controls.
  • Reuse existing source-owned PSP --psp real Ghidra verifier to compare three independently readelf-derived, legacy export-shaped labels with actual MCP list_procedures observations; deliberately wrong-base mapping fails.
  • Register the two opt-in scripts in knip.json and document usage in docs/ghidra-psp.md. No schema, external package, bridge, provider, installer or public REA surface changes.

Contract and boundary impact

  • Semantic owner: offline developer-only import comparison and existing PSP verification script, not a new runtime analysis service.
  • Contribution scope and required decision: read-only static analysis and evidence/reporting; no target execution or protection recovery. No new authority requiring a separate integration scope decision.
  • CLI/MCP/tool catalog: unchanged; this is a source-tree opt-in script and not a new published REA CLI/MCP operation.
  • Evidence: the tool checks the claimed target digest if supplied but does not cryptographically authenticate a raw Evidence JSON file; use REA's existing authenticated Evidence workflows to establish provenance before handing it to the script.
  • Effects: [x] read caller-selected symbol/inventory files, [x] write result only to stdout; [x] existing CI creates ephemeral PSP/Ghidra project and launches Ghidra. [ ] target binary execution; [ ] user executable modification; [ ] protection-recovery automation. The CI job downloads checksum-verified tools to an ephemeral runner.
  • No package/install or generated-contract changes.

Evidence and regression coverage

  • Symbol-correlation implementation commit 3b64bca0380ab2f7e37981166795beea22bd2ba2 (preserved in earlier merge head 4969685685f41376ee356a316f542756976cf435; prior pre-review head 008cd17a).
  • Prior pre-review source tests and Ghidra 12.1.3/Allegrex v21.4/PSPDEV real-provider run. Source check covers legacy/modern formats, duplicate rows, generated placeholders, outside-mapping, CRC mismatch, malformed input and wrong base. Real PSP ELF verification observed three agreed source-owned function labels and a mismatched rebase negative control through REA's real CLI/MCP.
  • No genuine PPSSPP runtime export or MHFU executable was used. Additional unsupported formats: legacy .map, gzipped exports, arbitrary PSP binaries/PRX/PBP/ISO/CSO, live overlays. Does not establish module CRC/provenance on its own.

Validation performed

  • node scripts/verify-psp-symbol-correlation.mjs — passed.
  • node --check scripts/psp-symbol-correlation.mjs and existing PSP verifier — passed.
  • Targeted oxfmt --check, npm ci, npm run build:cached, npm run check:fast, npm run docs:check — passed at the prior pre-review source head; updated current-head fixes are verified below.
  • node scripts/verify-real-ghidra-mips.mjs --psp — passed on Linux x64 using independently checksum-verified Ghidra, Allegrex and PSPDEV, including existing ELF/ABI/Evidence, snapshot A→B→A and owned-process cleanup.

Upstream CI repair and branch refresh (November 1, 2026)

Initial upstream CI on the earlier branch failed on the same 16 formatting errors and independent JavaScript/Frida test fixtures as old main d3ab0fa. Fork-only integration of #8592 and #8596 with the pre-review symbol branch passed.

Canonical upstream main has since repaired those failures directly in 00c4f44 (fix(ci): repair verifier fixtures and formatting failures), with passing main CI. #8592 was closed without merging and #8596 remains draft; the original fixes are present on main notwithstanding those separate PR statuses.

This PR was refreshed without history rewriting: a two-parent merge of main 00c4f44 onto the existing symbol branch produced 49696856. Against repaired main, the diff contains exactly the same five PSP-specific files, including all four Greptile review corrections. Updated upstream PR CI and fork-only real PSP/Ghidra qualification are separate checks. The fork validation completed successfully on this exact merge head, including repository-wide formatting, 11 focused JavaScript/Frida fixture tests, source/CLI checks, build/type/lint/docs, and real PSP/Ghidra verification. The current source head and its completed upstream/fork validation are recorded below.

Review follow-up and current-head verification (November 1, 2026)

Addressed four actionable Greptile review threads in the original PR branch, without modifying REA's public CLI/MCP tools or adding a provider:

  • P1, qualified addresses: Validate Ghidra address-space-qualified coordinates (including EXTERNAL:0x1) and exclude them from the explicitly unqualified PSP mapping rather than rejecting the whole inventory. Count excluded rows; preserve source selection.
  • P1, duplicate expansion: Store observed labels once per selected coordinate in observed_labels_by_address, not on every source record. The regression exercises 8,192 duplicate source rows with 50,000 observed function rows and bounds the serialized report.
  • P2, source digest: Hash the original symbol-file bytes and use fatal UTF-8 decoding. Invalid 0xff bytes are refused, rather than silently substituted.
  • P2, CLI coverage: Node subprocess checks cover raw-array and Evidence-shaped inventories, caller-selected paths, target-digest mismatch refusal, duplicate flags and nonzero exit status.

Prior review-fix source head: 3b64bca0380ab2f7e37981166795beea22bd2ba2 (later commits add further boundary checks).

The original review-fix proof predates the 49696856 merge; a separate current-head qualification is linked above. The fork-only tests are not a human-author readiness declaration.

Review corrections and current head (November 3, 2026)

Greptile's later review identified two additional input-boundary problems:

  • Evidence operation identity: the offline command previously accepted a list_names Evidence record as a function inventory if its target digest matched. The command now requires operation: "list_procedures" for Evidence-shaped inputs. Raw procedure arrays remain a caller-selected input, with no invented authenticated provenance. A real CLI subprocess regression rejects list_names nonzero without successful output.
  • Input-size enforcement: file metadata alone is not an input-byte bound for pipes/devices reporting size zero. The existing reader now retains its stat fast path and enforces its 1 MiB symbols / 32 MiB inventory ceilings while streaming before decoding or parsing. Linux subprocess regressions use finite head -c streams through pipes with zero metadata size. Their shell/child invocation has a 15-second deadline and bounded output capture, rather than an infinite /dev/zero producer.

These changes remain confined to the original source-tree developer script, its existing verifier, and the PSP guide. No new public REA CLI/MCP operation, provider, executable mutation, or dependency was introduced.

Previous source head (before the November 5 parser correction): bf508507801498ae51f43fd76b02248446e0890e.

  • The prior exact-head verification 41750906302 passed the production streaming guard and real PSP/Ghidra verifier before the finite-stream test refinement.
  • Current exact-head fork-only validation completed successfully after checking out bf508507801498ae51f43fd76b02248446e0890e: source/CLI controls, build/type/lint/docs, and real PSP/Ghidra verification passed. The real fixture produced three address-and-label agreements, and the wrong-base negative control did not agree.
  • The earlier upstream CI failure occurred in tests/boundary/browser/sazWebCapture.test.ts, where a short literal 0042 happened to occur inside a computed Evidence ID. That failure was outside this PR's changed files; no unrelated SAZ test was changed here. Current upstream PR CI completed successfully on bf508507801498ae51f43fd76b02248446e0890e, with 17 successful jobs, 23 skipped jobs, and no failed jobs.

November 5, 2026 — resolved parser review findings

Current commit 2b46964 corrects two Copilot findings in the existing parser and its source verifier: malformed .ppsym data/label records are rejected before being omitted from function comparison, and legacy .sym labels containing commas are parsed using the final comma as the size delimiter. Regression tests cover both failure cases and preserve valid unnamed data records.

Exact-current-head upstream CI 41947131062 passed after this change, including source tests, all required built-test shards, build, static checks, and documentation. Both associated review threads were resolved after that result. Earlier real-Ghidra qualification linked above applies to the previous parser revision; the new change is in the offline symbol parser and its source test only.

Compatibility, safety, and release

No public schema or package change. The script explicitly fails on unsupported/malformed input and never alters Ghidra annotations. Address agreement is not functional equivalence or target authorization.

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

  • Existing function inventory and PSP verifier reused; no duplicate service.
  • Explicit provenance, source/target identity and negative ambiguity controls.
  • Source-only and real-provider checks run.
  • Human owner performs final review and readiness declaration.

@greptile-apps

greptile-apps Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Low impact] The PR appears safe to merge; the previous cleanup finding is fixed.

Summary

Adds an opt-in, read-only script that compares PSP function labels with a caller-selected Ghidra inventory using explicit address bases.

  • Developers can compare PSP labels with a REA function inventory.
  • The PSP Ghidra verifier checks labels against the selected address base.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  S[Selected symbol file] --> P[Bounded parser]
  I[Selected function inventory] --> V[Check rows and Evidence claims]
  P --> C[Compare mapped addresses and names]
  V --> C
  B[Explicit address bases] --> C
  C --> R[Read-only report on stdout]
Loading

Reviews (10) · Last reviewed commit: "test(psp): retain failed symbol verifier..." · Reviewed by Greptile

Comment thread scripts/psp-symbol-correlation.mjs Resolved
Comment thread scripts/psp-symbol-correlation.mjs Resolved
Comment thread scripts/psp-symbol-correlation.mjs Resolved
Comment thread scripts/psp-symbol-correlation.mjs Resolved
Comment thread scripts/psp-symbol-correlation.mjs Resolved
@jaelliot
jaelliot marked this pull request as ready for review November 5, 2026 00:15
Copilot AI balanced review requested due to automatic review settings November 5, 2026 00:15
@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-05T00:15:23.498053Z
We couldn’t complete this review. Comment @codex review to try again.
bf50850 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 parser rejects valid template-style labels containing commas and silently accepts malformed D/L records, causing valid comparisons to abort and invalid inputs to produce successful reports.

2 open issues
What changed in this PR

Adds an opt-in, read-only developer script to correlate PPSSPP-style function labels with captured REA Ghidra inventories, without changing public CLI/MCP tools or modifying targets.

Changes:

  • Parses legacy .sym and modern .ppsym labels with explicit address mapping, input bounds, hashes, and uncertainty reporting.
  • Adds source/command checks and extends real PSP/Ghidra verification with label agreement and wrong-base controls.
  • Documents usage and limitations, and registers the scripts with Knip.
File Description
scripts/​verify-real-ghidra-mips.mjs Adds real PSP inventory correlation and wrong-base verification.
scripts/​verify-psp-symbol-correlation.mjs Adds parser, command, identity, and input-bound controls.
scripts/​psp-symbol-correlation.mjs Implements bounded, read-only symbol correlation and reporting.
knip.json Registers both opt-in scripts as entry points.
docs/​ghidra-psp.md Documents formats, address mapping, provenance limits, and verification.

Review effort: Balanced

Comment thread scripts/psp-symbol-correlation.mjs Resolved
Comment thread scripts/psp-symbol-correlation.mjs Resolved
@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: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior enhancement New feature or request provider: ghidra Analysis provider / engine: ghidra labels Nov 22, 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

@jaelliot
jaelliot force-pushed the codex/rea-psp-symbol-correlation-20261101 branch from 6030f27 to 5882047 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: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior enhancement New feature or request provider: ghidra Analysis provider / engine: ghidra

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants