Skip to content

feat(ghidra): select an existing-project program inside a project folder - #3817

Open
whalemenace wants to merge 1 commit into
morluto:mainfrom
whalemenace:feat/ghidra-persistent-project
Open

whalemenace wants to merge 1 commit into
morluto:mainfrom
whalemenace:feat/ghidra-persistent-project

Conversation

@whalemenace

@whalemenace whalemenace commented Oct 15, 2026 •

Copy link
Copy Markdown

Problem

#7236 reuses a caller-selected Ghidra project through a verified read-only copy. Its program selection is limited to the project root: REA_GHIDRA_PROGRAM_NAME refuses /, and the launcher passes the bare project name, so -process only searches /. Projects that keep programs in folders (for example /firmware/v2/app) cannot be reused without first moving the program to the root in Ghidra.

Fix

  • New optional REA_GHIDRA_PROGRAM_FOLDER (requires REA_GHIDRA_PROJECT_PATH): one absolute, non-root project folder such as /firmware/v2. It refuses /, relative paths, trailing slashes, empty, . and .. segments, padded segments, *, ?, backslashes and control characters. The root is selected by omitting the setting, so each folder has one spelling. REA_GHIDRA_PROGRAM_NAME is unchanged and still refuses paths.
  • resolveGhidraProject commits the folder as program_folder in the existing project commitment. The key is absent for the root, so root profiles and their digests do not change.
  • The launcher opens the owned copy as <project>/<folder> with -process <program>, following analyzeHeadless's <project_name>[/<folder_path>] argument. The folder is checked again before arguments are built.
  • The provider client refuses a profile whose committed folder differs from the configured one, as it already does for the path and program name.
  • rea setup keeps the new setting in saved registrations. Installation docs and the skill reference describe it.

Assessment against #7236

  • What the copy/identity owner already does: GhidraProjectSnapshot.ts owns selection and identity. resolveGhidraProject commits the configured path, the resolved project directory and name, the program name and a SHA-256 over the whole .gpr/.rep pair (fingerprintGhidraProject, sorted 64 KiB streaming reads; symlinks and non-regular entries refused). copyExistingGhidraProject copies only that pair into the owned runtime, refuses overlap with the runtime, and re-fingerprints the copy against the committed digest. The launcher runs -process <program> -noanalysis -readOnly on the copy. The bridge still checks the program's recorded import SHA-256 against the admitted target and blocks database edits.
  • What folder selection adds: only a coordinate inside the copy. Folders live inside the .rep database, so the copied content, its fingerprint and the import-digest check are the same for every folder. The folder only changes the project argument passed to analyzeHeadless and becomes part of the committed selection.
  • Why it belongs inside that owner: the folder is part of "which program in which project", which ghidraProjectCommitmentSchema already records. Putting it there makes it part of the profile digest (different folders cannot share cached observations) and reuses the copy, verification, cleanup, Windows refusal and import-override refusals unchanged. No second open path is needed.
  • What was dropped from the original PR, and why: the in-place read-only open of the caller's project, its separate config module, digest handshake, bridge changes, capability rewrite, real-Ghidra script and docs. A tester's real Ghidra 12.1.4 run showed that opening the project in place still rewrote Fixture.rep/idata/~index.bak and ~journal.bak, so it could not promise an untouched original. feat(ghidra): reuse existing projects through verified copies #7236's copy does, and it already covers the reuse, identity, read-only and historical-report parts of the original scope.

Tested

Run on a Windows x64 host with Node 24.22.1. Existing-project mode is unavailable on Windows, so the launcher tests that copy and launch a project skip on this host.

  • npm run typecheck: exit 0.
  • Focused suites, run with node scripts/run-exact-tests.mjs run (the test:focused build step needs the packaged Windows native addon, which this checkout does not have): tests/boundary/providers/ghidra/ghidraProjectSnapshot.test.ts, tests/boundary/providers/ghidra/ghidraLauncher.test.ts, src/ghidra/GhidraProvider.behavior.test.ts: 232 passed, 12 skipped, 6 failed. The 6 failures are launcher tests that need that native addon (PrivateRuntimeRootUnavailableError). They fail the same way with main's source.
  • 11 new tests (4 snapshot/config, 6 launcher argument, 1 provider) all pass. With main's source and only the new tests applied, 10 of them fail; the 11th guards the copy identity check and passes either way.
  • Wider run over 55 files (src/ghidra, src/config, tests/boundary/providers/ghidra, plus the doctor, startup-policy and project-read-cancellation suites): main 1085 passed / 107 failed / 102 skipped; this branch 1096 passed / 107 failed / 102 skipped. The failing test lists are identical (Windows host and native addon).
  • oxfmt --check on changed files: clean. oxlint on changed TypeScript files: no new warnings.
  • Real Ghidra 12.1.4 on the same Windows host, on a project with one app.exe at the root and a different app.exe in /sub/dir. The provider refuses existing projects on Windows, so a small script drove this branch's pieces directly: parseConfig with REA_GHIDRA_PROGRAM_FOLDER=/sub/dir, resolveGhidraProject, copyExistingGhidraProject with the committed SHA-256, and ghidraHeadlessArguments (POSIX argument form), then ran analyzeHeadless on the copy with a probe post-script in place of the bridge. It opened /sub/dir/app.exe from the copy (the program's executable SHA-256 matched the folder input; functions and decompilation present). With the folder unset it opened /app.exe; with /sub/nope, analyzeHeadless stopped with Specified project folder not found: /sub/nope. Ghidra rewrote ~index.bak and removed ~journal.bak in each copy, while every file of the original project, those two included, kept its size, mtime and SHA-256.
  • Not run: npm run docs:check (same native-addon build step), a Linux run, and the full provider and bridge on a folder program.

@kaoru0822-kitauji
kaoru0822-kitauji marked this pull request as ready for review October 15, 2026 06:17
@chatgpt-codex-connector

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

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-10-15T06:17:19.014338Z 916a2f9 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.

@greptile-apps

greptile-apps Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Low impact] The new folder-selection changes appear safe to merge, with two earlier non-blocking findings still outstanding.

Findings

  1. P2 Selected project names change ▶
  2. P2 Raw Programs hide digest errors ▶
Fix with agent prompt
### Issue 1
src/config/ghidraPersistentProject.ts:86-90
On POSIX, a project basename containing a backslash passes validation but changes before launch. For example, `/work/prefix\Game.gpr` becomes project location `/work` and project name `Game`. The launcher then opens a different project or fails to find it.

Reject basenames that cannot be passed unchanged, including after `realpath`, rather than dropping part of the selected name.

### Issue 2
bridge/ghidra/ReaGhidraBridge.java:229-235
The persistent digest check runs after the old raw-import preparation check. If the selected target is an admitted PE or ELF but `REA_GHIDRA_PROGRAM` points to an ordinary raw-imported Program, the bridge throws for a missing REA preparation marker before reaching this branch. The caller gets a generic startup failure instead of `unsupported_target` naming both digests.

Run the persistent identity path before import-only checks, and keep those checks out of persistent startup.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Builds on existing-project reuse already merged in #7236. The current diff adds REA_GHIDRA_PROGRAM_FOLDER to select a Program below the project root.

  • Ghidra opens a selected program from its project folder.

No new actionable findings were established. Review was source-based; no tests or real Ghidra session were run.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Project, Program and optional folder] --> B[Validate selection]
  B --> C[Commit folder and project fingerprint]
  C --> D[Check configuration against profile]
  D --> E[Copy and verify whole project]
  E --> F[Open copied project and folder]
  F --> G[Process one Program read-only]
Loading

Reviews (2) · Last reviewed commit: "feat(ghidra): select an existing-project..." · Reviewed by Greptile

Comment thread src/ghidra/GhidraProviderClient.ts Resolved
Comment thread src/config/ghidraPersistentProject.ts Outdated
Comment on lines +86 to +90
projectLocation: path.dirname(project.projectFile),
projectName: finalComponent(project.projectFile).slice(
0,
-GHIDRA_PROJECT_FILE_SUFFIX.length,
),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Selected project names change

On POSIX, a project basename containing a backslash passes validation but changes before launch. For example, /work/prefix\Game.gpr becomes project location /work and project name Game. The launcher then opens a different project or fails to find it.

Reject basenames that cannot be passed unchanged, including after realpath, rather than dropping part of the selected name.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/config/ghidraPersistentProject.ts
Line: 86-90

Comment:
**Selected project names change**

On POSIX, a project basename containing a backslash passes validation but changes before launch. For example, `/work/prefix\Game.gpr` becomes project location `/work` and project name `Game`. The launcher then opens a different project or fails to find it.

Reject basenames that cannot be passed unchanged, including after `realpath`, rather than dropping part of the selected name.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@whalemenace I independently checked this at head 916a2f9d7 using an actual Linux temporary file named prefix\\Game.gpr. POSIX realpath preserves the backslash as part of the filename, but the current acceptance predicate treats it as a separator, and ghidraPersistentProjectLocation produces projectName: "Game" instead of the selected filename's stem.

This was an isolated Node reproduction of the relevant source logic, not REA's Zod/Vitest suite or a real Ghidra launch. A focused regression could create that filename, pass it through ghidraProjectFileSchema and resolved-path handling, then assert either an actionable early rejection or exact preservation of the requested project name. I’m adding the confirmation to this existing thread rather than repeating the finding as a new top-level report. Happy to contribute the regression to your branch.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Confirmed — this reproduces a real correctness bug. On POSIX, \ is a valid filename character, but finalComponent() treats it as a separator, so ghidraPersistentProjectLocation() can launch with a truncated projectName rather than the caller-selected project.

The safest fix is to reject \ in the .gpr basename during schema validation, matching analyzeHeadless’s cross-platform argument handling, and add the focused regression you described. Thanks for independently validating it; a regression test covering early rejection or exact preservation would be welcome.

Tip: You can customize Greptile's behavior for this repo with .greptile/rules.md and .greptile/config.json.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@whalemenace, following up with a tested correction for this existing review finding, based on your current PR head 916a2f9d7696f3679ed6074638875a320c3e6399.

My isolated fork branch contains a focused path regression and a small fix: use the platform's path parser for project basename extraction, reject backslash-bearing POSIX project paths before launch, and revalidate the resolved realpath so a safe-looking symlink cannot select an unsafe marker. A normal Fixture.gpr project + nested Program selection remains accepted. The test and source-fix commits are separate from the fork-only CI workflow.

The original PR code failed the two new unsafe-path cases (and passed the ordinary-path control): failing run. The corrected branch passed 72 focused tests (4 Windows-only skips) spanning this regression, existing GhidraPersistentProject and launcher tests, plus test discovery, docs checks and fresh typecheck/lint with zero cached static tasks: verified run.

These are genuine Node/REA boundary tests on Ubuntu 24.04 / Node 24.18.0, not a real Ghidra execution or Windows-native test. The path fix is deliberately limited to the existing review finding and does not address your separate seed-metadata issue.

If it fits your approach, feel free to incorporate it; I'm happy to adjust the tests to your preferred owning boundary. No competing PR was opened.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the tested correction. I rechecked the current implementation: finalComponent() unconditionally treats both separators as delimiters, so a POSIX .gpr basename containing \\ is indeed truncated before analyzeHeadless is invoked. The symlink case is also relevant when the resolved marker path is what gets launched: validating only the lexical path can allow the resolved basename to violate the same argument boundary.

The proposed fix—use the selected platform parser for basename extraction, reject backslashes in POSIX project-marker names before launch, and revalidate the resolved realpath—addresses the finding while preserving ordinary and nested Program paths. The focused regression and reported 72-test verification provide appropriate coverage. Please incorporate the source and regression changes, without requiring the fork-only workflow; I’ll consider the original finding resolved once they are on the PR head.

Comment thread bridge/ghidra/ReaGhidraBridge.java Outdated
Comment on lines +229 to +235
if (persistentProject(descriptor)) {
// A caller-selected project may hold another artifact. Serve only the
// handshake so REA can report both digests, and refuse every analysis.
persistentProgramSha256 = importedSha256 != null &&
importedSha256.toLowerCase(Locale.ROOT).matches("[0-9a-f]{64}")
? importedSha256.toLowerCase(Locale.ROOT) : null;
persistentIdentityRefused = !identityMatches;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Raw Programs hide digest errors

The persistent digest check runs after the old raw-import preparation check. If the selected target is an admitted PE or ELF but REA_GHIDRA_PROGRAM points to an ordinary raw-imported Program, the bridge throws for a missing REA preparation marker before reaching this branch. The caller gets a generic startup failure instead of unsupported_target naming both digests.

Run the persistent identity path before import-only checks, and keep those checks out of persistent startup.

Knowledge Base Used: Ghidra integration

Prompt To Fix With AI
This is a comment left during a code review.
Path: bridge/ghidra/ReaGhidraBridge.java
Line: 229-235

Comment:
**Raw Programs hide digest errors**

The persistent digest check runs after the old raw-import preparation check. If the selected target is an admitted PE or ELF but `REA_GHIDRA_PROGRAM` points to an ordinary raw-imported Program, the bridge throws for a missing REA preparation marker before reaching this branch. The caller gets a generic startup failure instead of `unsupported_target` naming both digests.

Run the persistent identity path before import-only checks, and keep those checks out of persistent startup.

**Knowledge Base Used:** [Ghidra integration](https://app.greptile.com/pre/-/custom-context/knowledge-base/morluto/rea/-/docs/ghidra-integration.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

@CassieFox23

Copy link
Copy Markdown
Contributor

TL;DR: Thanks, whalemenace, for this work. Both test files, the typecheck and the real Ghidra 12.1.4 script pass on Linux. Opening the project changed two backup files, and the script does not check those.

Results

The 2 test files are the unit file and the launcher file (names in the Commands fold). The 4 skipped launcher tests are Windows-only, and main skips them too. "Main" is c7f6b8b (#4179). "Merged" is main plus this pull request (head 916a2f9), joined with a 3-way merge of 19 changed files and 5 new files. Every file merged with no conflict. This is a new feature, so there is no before and after on main.

Check Result
tsc --noEmit on main Pass (exit 0)
tsc --noEmit on merged Pass (exit 0)
Persistent project unit file, 35 tests All pass
Launcher file, 37 tests 33 pass, 4 skipped
verify-real-ghidra-persistent.mjs, real Ghidra 12.1.4 Pass (exit 0), 21 seconds
What the real script checked

What the real script showed:

  • It built a saved Ghidra project from a fixture made by the repo's own script. REA then opened it with REA_GHIDRA_PROJECT and REA_GHIDRA_PROGRAM. The import mode in the evidence was persistent-project-read-only.
  • The decompiled entry used the name rea_project_entry. That name exists only in the saved project, so the project really was read.
  • annotate_native_function was refused with capability_unavailable.
  • Opening a different executable was refused with unsupported_target. The message named both SHA-256 digests.
  • The script reported no leftover processes.

Note for the author

The script reports that opening the project changed two files: Fixture.rep/idata/~index.bak and Fixture.rep/idata/~journal.bak. Its check fails only on .gbf and .gpr files, so it passed. Those two names look like Ghidra backup files. I did not check why they change. Is that expected, and is it worth a line in the docs?

Not run

  • The old-style plain patch of the diff onto main. The plan step before this run reported 2 failed hunks in two Ghidra files (unverified by me). GitHub says the pull request is mergeable.
  • The stacked pull request that adds a PDB file option. It does not combine with this one without a manual merge.
  • Windows and macOS. The script's own text says the Windows run is a later step.
  • A project made by a different Ghidra version.
  • Tests outside the two named files and the script. No full suite.
  • Repository CI. GitHub shows one check, Greptile Review (a review bot), and it passes. No project CI job appears on this pull request.

No test in these files makes a network call. The script starts only local processes: Ghidra headless and REA's own server.

Thanks, whalemenace, for the clear tests and the script.

Commands
git -C ~/code/rea-mirror/rea.git fetch origin
# main c7f6b8bad extracted to a scratch folder; for each file the pull request changes:
git merge-file -p <main-version> <merge-base-version> <head-version>
npm ci && npm run build && npm run test:prepare
npm run typecheck
npm run test:focused -- src/ghidra/GhidraPersistentProject.test.ts tests/boundary/providers/ghidra/ghidraLauncher.test.ts
npm run build
GHIDRA_INSTALL_DIR=~/.local/opt/ghidra_12.1.4_PUBLIC JAVA_HOME=~/.local/opt/jdk-21.0.12.1+1 \
  systemd-run --user --scope -p MemoryMax=8G -- node scripts/verify-real-ghidra-persistent.mjs
Raw output
"ghidra_version": "12.1.4",
"project_analysis_ms": 7149,
"rea_open_and_first_decompile_ms": 5796,
"import_mode": "persistent-project-read-only",
"annotation_refusal": "capability_unavailable",
"mismatch_refusal": "unsupported_target",
"project_files_changed_by_open": [
  "Fixture.rep/idata/~index.bak",
  "Fixture.rep/idata/~journal.bak"
],
"cleanup": "complete"
Test setup

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

@morluto

morluto commented Oct 26, 2026

Copy link
Copy Markdown
Owner

Thank you for the real-project investigation and verification. #7236 now reuses a caller-selected project through a verified read-only copy, with the original project left unchanged. Your PR also proposes selecting a program inside a project folder and opening the original project directly; the merged mode selects a root program and deliberately uses a copy. I am keeping this open for that distinct scope. If you would like to continue, could you focus on the folder-selection use case and assess it against the existing copy/identity owner? I did not rerun Ghidra in this pass.

REA_GHIDRA_PROGRAM_FOLDER selects a non-root project folder for the
program named by REA_GHIDRA_PROGRAM_NAME. The selection goes through the
existing verified-copy owner: the folder is committed in the project
profile (absent for the root, so root profiles keep their digest), the
whole selected project is still fingerprinted, copied and re-verified,
and the owned copy is opened as <project>/<folder> with -process naming
one program. Malformed folders are refused at configuration and again
before the headless arguments are built; a profile resolved for one
folder does not open under another.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@whalemenace
whalemenace force-pushed the feat/ghidra-persistent-project branch from 916a2f9 to f8abf28 Compare October 28, 2026 01:56
@whalemenace whalemenace changed the title feat(ghidra): open a caller-selected persistent project read-only feat(ghidra): select an existing-project program inside a project folder Oct 28, 2026
@whalemenace

Copy link
Copy Markdown
Author

Thanks for merging #7236, and for keeping this one open for the folder case. I agree the verified copy is the right owner. Cassie's run showed that opening the project in place still rewrote ~index.bak and ~journal.bak, so I've dropped the in-place open and its separate digest path completely, and force-pushed the branch with just the narrowed commit. The PR is now narrowed to one thing: REA_GHIDRA_PROGRAM_FOLDER selects a program inside a project folder, and that selection is committed in the same project profile and goes through the #7236 fingerprint, copy and re-verification before Ghidra opens the copy as <project>/<folder>. Typecheck is clean, the 11 new folder tests pass, and the rest of the Ghidra suites give the same results as main on my machine. I also ran it against real Ghidra 12.1.4 on a Windows host (this branch's config, resolveGhidraProject, copyExistingGhidraProject and launcher arguments driven by a script, since the provider refuses existing projects on Windows) and it passed: with an app.exe at the root and a different one in /sub/dir, it opened /sub/dir/app.exe from the verified copy, and every file of the original project, ~index.bak and ~journal.bak included, stayed byte-identical. If you'd rather have REA_GHIDRA_PROGRAM_NAME take a project path than add a second setting, I'm happy to switch it.

@morluto

morluto commented Oct 31, 2026

Copy link
Copy Markdown
Owner

Real-provider follow-up on exact head f8abf28cc9a62f23520166bc90696ae5b42c12e0, macOS arm64, Node 24.22.1, JDK 21 and Ghidra 12.1.4. I built this head with its locked dependencies and exercised the public stdio MCP server.

I copied a self-owned project, then used separate headless Ghidra scripts to create two programs named workflow: one at the root and one in /group, imported from the same Mach-O SHA-256 but with different function names and comments. Root selection returned the root annotation; REA_GHIDRA_PROGRAM_FOLDER=/group returned the nested annotation and did not resolve the root-only name. A snapshot saved from the root was refused with profile_mismatch for the nested selection. An attempted nested-session annotation was refused as read-only. Source-project file contents (12 regular files) and target digest remained unchanged during the REA calls; both sessions closed successfully.

One recovery case merits attention when resolving the existing merge conflict: with folder /missing, open_binary bound the target lazily but the first query returned generic execution_failure and doctor advice; Ghidra's captured output said Specified project folder not found: /missing. Selecting a missing program inside the valid /group folder also returned generic doctor advice at this exact head. The same missing-program result appeared at root on this head, which predates merged #8222; current main has since gained typed root-program recovery, so I have not tested the eventual merged combination. The existing missing-program remediation on main refers to a root program and may need the selected-folder context if reused here.

This is one small macOS project and Ghidra version; no Windows provider, folder changes during copying, CLI, unusual folder characters or large-project performance were tested. The root import logged unrelated unrecoverable DWARF expressions; no debug-info completeness claim is made. The selected binary was not executed.

@morluto

morluto commented Oct 31, 2026

Copy link
Copy Markdown
Owner

CLI and target-identity follow-up on the same exact head f8abf28cc9a62f23520166bc90696ae5b42c12e0 and project:

  • rea decompile <matching-target> selected_nested --provider ghidra --format json --full-output, with /group selected, returned the nested program's annotated pseudocode and exited 0.
  • With the same explicit project, folder and program selection but a different self-owned arm64 Mach-O as the admitted target, the CLI exited 1. The nested diagnostics reported Ghidra imported-byte digest does not match the admitted target; it did not fall back to a fresh import or return pseudocode. The top-level error was generic execution_failure with doctor advice, consistent with the existing digest-recovery concern in [Bug] Ghidra project digest mismatch is hidden behind generic provider startup failure #8169.
  • A CLI query with /missing likewise exited 1 with generic doctor advice and retained Specified project folder not found: /missing in Ghidra output.

The selected project and both target-file SHA-256 inventories were unchanged after the calls, and neither binary was executed. These are positive and negative checks of this old PR head, not a test of a future conflict resolution or of other platforms.

@morluto

morluto commented Oct 31, 2026

Copy link
Copy Markdown
Owner

I checked the interaction with the newer missing-program recovery in a local exploratory merge, not the PR head or a proposed final conflict resolution. Base was main 22e5aa97af8d726400f3f932cae10e0083412038, PR head f8abf28cc9a62f23520166bc90696ae5b42c12e0. The two textual conflicts were resolved locally by retaining main's typed blank-program admission check, the PR's folder validation, and both sets of snapshot tests. npm run build:cached passed. No contributor branch was changed or pushed.

On the same real macOS/Ghidra 12.1.4 project through MCP:

  • /group plus valid workflow returned the nested annotation.
  • A missing program at the root returned configuration_invalid with the expected root-program recovery.
  • The same missing program under /group also returned configuration_invalid, but its message and remediation said to select a root program. That is actionable for the root control and misleading for the selected-folder case.
  • A nonexistent folder still returned generic execution_failure and doctor advice; Ghidra's captured output identified the missing folder.

All sessions closed; target and 12 source-project file content hashes were unchanged. This was one merge resolution, host, project and provider version. It is evidence to inform the eventual conflict resolution, not a claim that this exact merge is ready or that any particular log-parsing technique is safe. A precise recovery should preserve the caller's folder choice and distinguish a missing folder from a missing program where the producer establishes that distinction.

@morluto

morluto commented Oct 31, 2026

Copy link
Copy Markdown
Owner

Current-main POSIX follow-up to the earlier exact-head and older-merge tests: I applied PR head f8abf28cc9a62f23520166bc90696ae5b42c12e0 to REA main d54a4661da20382ad8456564a08569fdd24131c5 in a disposable worktree. The PR is conflicting; my local resolution kept main's typed missing-program admission and analyzer-override test, plus this PR's folder validation and tests. This is an experimental merge, not a tested merge commit or a proposed replacement PR.

With real Ghidra 12.1.4 on macOS arm64, I copied the owned test project and, before the REA calls, created /analysis 1/nested 2/workflow with the same imported target as /workflow and /group/workflow but a distinct function name/comment. In separate MCP sessions, root, /group, and /analysis 1/nested 2 returned their respective authored results. The nested selection's project profile included the exact folder; importing the root snapshot into that nested profile was refused with profile_mismatch. The nested project remained read-only to the annotation tool. The source project and target file hashes remained unchanged during REA calls, and the target was not executed. CLI decompilation of the space-containing folder returned the exact same Evidence ID and text as MCP.

The two recovery gaps from the earlier merge test remain on this resolution:

  • A missing program under /analysis 1/nested 2 returns configuration_invalid but says to choose a root program and does not name the selected folder.
  • A nonexistent selected folder returns generic execution_failure / doctor guidance; the Ghidra diagnostics contain the folder failure. No fresh-import fallback occurred.

npm run build:cached passed. The three focused launcher, project-snapshot and provider behavior files passed (265 passed, 3 skipped). These are one host/project and do not cover Windows, unusual valid project names beyond spaces, source-project copy races, cancellation, or large projects. I have not pushed the conflict resolution or made a readiness claim.

@morluto

morluto commented Oct 31, 2026

Copy link
Copy Markdown
Owner

Cross-session Evidence handoff on the same locally resolved PR/main experiment described above:

  1. A root-program MCP session analyzed selected_root and exported its complete parent dossier Evidence. A new MCP process configured for /analysis 1/nested 2 imported that bundle, opened the same target, and analyzed selected_spaces.
  2. compare_functions accepted the two retained dossier IDs. It reported the differing name, pseudocode and comment observations, but overall unknown / function_match: ambiguous; it did not establish correspondence merely because the reported entry numbers matched. Exporting the combined bundle and repeating the comparison in a fresh targetless MCP server reproduced the normalized result and Evidence ID.
  3. Separately, both real Ghidra sessions mapped 0x100000430 to file offset 1072 and returned the same first 16 memory bytes; those bytes also matched a direct read of the owned target at that offset. Independent load-image verification remained unsupported for Mach-O. These bounded observations corroborate this constructed pair but do not generally prove equivalent program mappings, function bodies or runtime behavior.

The agent can therefore preserve and compare Evidence across the currently required process restart, but it still must explicitly manage the bundle and inspect the source profiles/mappings. Source inspection shows the current existing-project profile does not supply a common function-coordinate commitment; the conservative ambiguous comparison is expected and should not be “fixed” by equating addresses across arbitrary projects. The target and source-project hashes were unchanged during these REA calls. This test is of the local conflict resolution, not the exact PR head or a merged change.

jaelliot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

@whalemenace — I revisited this PR's exact unchanged head f8abf28 and prepared a fork-only, two-commit correction for the previously reproduced POSIX project-path ambiguity, without changing your branch or opening a competing upstream PR.

  • Comparison against your head | candidate head 91bc440. Three existing files, +48 lines, no deletions.
  • ghidraProjectPathSchema now rejects literal backslashes in POSIX .gpr paths (Windows is unchanged); resolveGhidraProject reuses that schema on the resolved canonical marker, so a safe-looking parent symlink can't hide a backslash-bearing path.
  • Two focused cases were added to the existing project-snapshot test: a real POSIX marker named prefix\\Game.gpr and an alias parent that resolves to part\\dir/selected.gpr. Ordinary path/symlink controls already exist in the suite.

I ran an isolated Node/POSIX filesystem reproduction (4/4 controls passed); the complete REA Vitest suite, formatter/typecheck and real Ghidra were not run on this candidate. The earlier real-host verification in this thread is separate. If this approach fits your narrowed folder-selection PR, please review/incorporate these small hunks on your branch; I'd avoid creating another upstream PR.

The other outstanding issue is the existing current-main integration/recovery work that @morluto already reproduced: missing program under a selected folder should not recommend the root, and a nonexistent folder still produces generic guidance. That should be reconciled against current main and fixed at the owning error boundary, not by guessing from Ghidra log strings. I haven't added a speculative recovery parser or altered that behavior.

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

@whalemenace — qualification follow-up to my earlier #3817 path-validation patch: the formatted source candidate is now fe315ad, a non-force descendant of your unchanged head f8abf28. Compare only the three changed files: 56 additions, no deletions; no new subsystems or runtime dependencies.

Exact-source fork CI passed on a separate, workflow-only validation branch (its source files are byte-identical to fe315ad):

  • 77 focused Ghidra project-selection/launcher tests passed; 3 Windows-specific tests skipped on Linux.
  • Repository test discovery found all 2,680 test files exactly once.
  • Clean npm ci, package/build preparation, fresh typecheck and lint, and focused oxfmt formatting all passed.
  • No real Ghidra process was launched, and this run does not qualify the eventual conflict resolution against newer upstream main.

This updates the earlier source-only evidence; the two-line formatter correction is already in the candidate. I've left your branch untouched and haven't opened an upstream replacement. Your current-main missing-folder/missing-program recovery findings remain a separate, unaddressed integration concern.

@morluto

morluto commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Hey @whalemenace, thanks for this! The addition looks good. What's left: it has merge conflicts with main in src/ghidra/GhidraLauncher.ts and tests/boundary/providers/ghidra/ghidraProjectSnapshot.test.ts (merging main into the branch is fine) and the CI required check is failing (failing job: Windows capability and package lane). There are 2 unresolved review threads from Greptile, all on outdated lines, so if they're already addressed, resolving them should be all that's needed. Happy to merge once that's sorted.

@morluto morluto added enhancement New feature or request provider: ghidra Analysis provider / engine: ghidra labels Nov 23, 2026

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

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