[PR #5392] [CLOSED] fix(ghidra): publish the stable launcher root when it proves the install #6919

Closed
opened 2026-11-01 21:44:03 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/5392
Author: @XiaoBinGan
Created: 10/20/2026
Status: ❌ Closed

Base: main ← Head: fix/ghidra-stable-opt-root


📝 Commits (3)

  • d028c22 fix(ghidra): publish the stable launcher root when it proves the install
  • 824e7aa fix(ghidra): resolve a launcher target from its physical parent
  • 6ac5e97 fix(ghidra): keep a stable ancestor alias when resolving a launcher target

📊 Changes

2 files changed (+189 additions, -4 deletions)

View changed files

📝 src/ghidra/GhidraInstallation.test.ts (+143 -1)
📝 src/ghidra/GhidraInstallation.ts (+46 -3)

📄 Description

Summary

PATH discovery realpathed the launcher and returned the resolved directory, so a package-manager opt prefix was published for registration as the versioned keg path. An upgrade then moves the keg, removes the old one, and the published GHIDRA_INSTALL_DIR is missing even though the stable prefix still resolves.

Fixes #5381

Problem and expected behavior

  • Smallest trigger: a bin/ghidra launcher symlinked to ../opt/ghidra/libexec/ghidraRun where opt/ghidra is itself a symlink to ../Cellar/ghidra/12.1.4. Discovery returned <prefix>/Cellar/ghidra/12.1.4/libexec, and the doctor projection published that same directory as registrationEnvironment.GHIDRA_INSTALL_DIR.
  • Violated invariant: the published registration spelling is a versioned path even though the installation is reachable through a stable prefix that resolves to it, so package-manager cleanup invalidates the registration while the installation remains installed.
  • Expected: publish the stable spelling when its identity provably matches the validated discovered root, keep the discovered root when alias identity cannot be proven, and leave an explicitly selected GHIDRA_INSTALL_DIR untouched. Homebrew documents opt as the active-keg symlink.

Change and scope

  • src/ghidra/GhidraInstallation.ts: after the resolved root is validated, the launcher's own symlink target is spelled back through its declared directory; that directory is published only when its realpath equals the validated root. A launcher that is not a symlink, an alias whose directory does not resolve to the same root, and a non-existent alias all keep the resolved root.
  • src/ghidra/GhidraInstallation.test.ts adds the report's authored Cellar/opt/bin layout, asserts the stable spelling is published, asserts an alias outside the installation keeps the resolved root, then moves opt to a new keg, deletes the old one, and asserts discovery still publishes the stable spelling.
  • Not included: no change to inspectGhidraInstallation, the doctor projection, or setup's environment handling; they consume the discovered root unchanged.

Contract and boundary impact

  • Semantic owner and earliest changed stage: Ghidra PATH discovery in src/ghidra/GhidraInstallation.ts.
  • Contribution scope fit and linked maintainer decision: not applicable — an ordinary fix inside an existing boundary.
  • CLI and MCP/tool-catalog contract: no schema or tool-catalog change. The doctor's reported installation path becomes the stable spelling, which is the same installation.
  • Provider, bridge, target-format, or platform compatibility: Ghidra discovery only; Windows launchers are regular files, so they keep the resolved root.
  • Evidence, artifact, provenance, or reconstruction contract: unchanged; the installation properties, launcher validation and header probe keep their behaviour.
  • Target selection, authority, upstream behavior, and cleanup details: unchanged. No executable is run; the new lookup only reads the launcher symlink.
  • Generated metadata, package, or installation impact: none.

Expected effects (check known effects; use documentation-only on its own).

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

Evidence and regression coverage

  • Tests added or updated: the stable-spelling discovery test in GhidraInstallation.test.ts (authored Cellar, opt and bin trees, a real symlinked launcher, no Ghidra executable).
  • Base reproduction or other evidence: on 074768901 the new test fails with the report's two distinct paths — expected '<prefix>/opt/ghidra/libexec' to be '<prefix>/Cellar/ghidra/12.1.4/libexec'. After the change it passes, including the post-upgrade step where opt points at 12.1.5 and 12.1.4 no longer exists.
  • User-visible CLI/MCP output (if applicable): doctor and setup now register GHIDRA_INSTALL_DIR=<prefix>/opt/ghidra/libexec instead of the versioned keg path.
  • Remaining proof gaps: no real Homebrew installation or Ghidra executable was used; the layout, launcher and properties files are authored as in the report. Real upgrade behaviour and its frequency remain NOT_ENOUGH_INFO.

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

  • npx vitest run src/ghidra/GhidraInstallation.test.ts — 93 passed, including the new test; with the publication reverted, that test fails with the two-path assertion.
  • npx vitest run src/ghidra — 731 passed across 27 files.
  • npm run format:check — all matched files use the correct format.
  • npm run verify:test-discovery — all 1720 test files discovered exactly once.
  • npm run typecheck — no diagnostic in the changed files; the only errors come from this checkout's install predating the @bufbuild/protobuf dependency on current main.
  • npm run lint — 0 errors, module boundaries resolved in 2265 source files.

Compatibility, safety, and release

  • Breaking changes or migration steps: an existing registration that already pins a Cellar path is not rewritten; only new PATH discovery publishes the stable spelling.
  • Real Hopper/Ghidra, browser, or OS coverage: none claimed; no Ghidra executable was run.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: none; the change reads one symlink and never executes the launcher.

Author readiness

Human owner: @XiaoBinGan

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

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/5392 **Author:** [@XiaoBinGan](https://github.com/XiaoBinGan) **Created:** 10/20/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/ghidra-stable-opt-root` --- ### 📝 Commits (3) - [`d028c22`](https://github.com/morluto/rea/commit/d028c225158facd68169de6a8c9a50efa27c4127) fix(ghidra): publish the stable launcher root when it proves the install - [`824e7aa`](https://github.com/morluto/rea/commit/824e7aa4b5e1a284b0b6fe35d110d74e0e1cbafe) fix(ghidra): resolve a launcher target from its physical parent - [`6ac5e97`](https://github.com/morluto/rea/commit/6ac5e97a2b4659f85dbab8adc3a530d5c87965c9) fix(ghidra): keep a stable ancestor alias when resolving a launcher target ### 📊 Changes **2 files changed** (+189 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `src/ghidra/GhidraInstallation.test.ts` (+143 -1) 📝 `src/ghidra/GhidraInstallation.ts` (+46 -3) </details> ### 📄 Description ## Summary PATH discovery realpathed the launcher and returned the resolved directory, so a package-manager `opt` prefix was published for registration as the versioned keg path. An upgrade then moves the keg, removes the old one, and the published `GHIDRA_INSTALL_DIR` is missing even though the stable prefix still resolves. Fixes #5381 ## Problem and expected behavior - Smallest trigger: a `bin/ghidra` launcher symlinked to `../opt/ghidra/libexec/ghidraRun` where `opt/ghidra` is itself a symlink to `../Cellar/ghidra/12.1.4`. Discovery returned `<prefix>/Cellar/ghidra/12.1.4/libexec`, and the doctor projection published that same directory as `registrationEnvironment.GHIDRA_INSTALL_DIR`. - Violated invariant: the published registration spelling is a versioned path even though the installation is reachable through a stable prefix that resolves to it, so package-manager cleanup invalidates the registration while the installation remains installed. - Expected: publish the stable spelling when its identity provably matches the validated discovered root, keep the discovered root when alias identity cannot be proven, and leave an explicitly selected `GHIDRA_INSTALL_DIR` untouched. Homebrew documents `opt` as the active-keg symlink. ## Change and scope - `src/ghidra/GhidraInstallation.ts`: after the resolved root is validated, the launcher's own symlink target is spelled back through its declared directory; that directory is published only when its realpath equals the validated root. A launcher that is not a symlink, an alias whose directory does not resolve to the same root, and a non-existent alias all keep the resolved root. - `src/ghidra/GhidraInstallation.test.ts` adds the report's authored `Cellar`/`opt`/`bin` layout, asserts the stable spelling is published, asserts an alias outside the installation keeps the resolved root, then moves `opt` to a new keg, deletes the old one, and asserts discovery still publishes the stable spelling. - Not included: no change to `inspectGhidraInstallation`, the doctor projection, or setup's environment handling; they consume the discovered root unchanged. ## Contract and boundary impact - Semantic owner and earliest changed stage: Ghidra PATH discovery in `src/ghidra/GhidraInstallation.ts`. - Contribution scope fit and linked maintainer decision: not applicable — an ordinary fix inside an existing boundary. - CLI and MCP/tool-catalog contract: no schema or tool-catalog change. The doctor's reported installation path becomes the stable spelling, which is the same installation. - Provider, bridge, target-format, or platform compatibility: Ghidra discovery only; Windows launchers are regular files, so they keep the resolved root. - Evidence, artifact, provenance, or reconstruction contract: unchanged; the installation properties, launcher validation and header probe keep their behaviour. - Target selection, authority, upstream behavior, and cleanup details: unchanged. No executable is run; the new lookup only reads the launcher symlink. - Generated metadata, package, or installation impact: none. Expected effects (check known effects; use documentation-only on its own). - [x] 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. ## Evidence and regression coverage - Tests added or updated: the stable-spelling discovery test in `GhidraInstallation.test.ts` (authored `Cellar`, `opt` and `bin` trees, a real symlinked launcher, no Ghidra executable). - Base reproduction or other evidence: on `074768901` the new test fails with the report's two distinct paths — `expected '<prefix>/opt/ghidra/libexec' to be '<prefix>/Cellar/ghidra/12.1.4/libexec'`. After the change it passes, including the post-upgrade step where `opt` points at `12.1.5` and `12.1.4` no longer exists. - User-visible CLI/MCP output (if applicable): doctor and setup now register `GHIDRA_INSTALL_DIR=<prefix>/opt/ghidra/libexec` instead of the versioned keg path. - Remaining proof gaps: no real Homebrew installation or Ghidra executable was used; the layout, launcher and properties files are authored as in the report. Real upgrade behaviour and its frequency remain NOT_ENOUGH_INFO. For evidence-bearing changes: - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed - `npx vitest run src/ghidra/GhidraInstallation.test.ts` — 93 passed, including the new test; with the publication reverted, that test fails with the two-path assertion. - `npx vitest run src/ghidra` — 731 passed across 27 files. - `npm run format:check` — all matched files use the correct format. - `npm run verify:test-discovery` — all 1720 test files discovered exactly once. - `npm run typecheck` — no diagnostic in the changed files; the only errors come from this checkout's install predating the `@bufbuild/protobuf` dependency on current main. - `npm run lint` — 0 errors, module boundaries resolved in 2265 source files. ## Compatibility, safety, and release - Breaking changes or migration steps: an existing registration that already pins a Cellar path is not rewritten; only new PATH discovery publishes the stable spelling. - Real Hopper/Ghidra, browser, or OS coverage: none claimed; no Ghidra executable was run. - Package or release metadata impact: none. - Security, privacy, process, or containment review: none; the change reads one symlink and never executes the launcher. ## Author readiness Human owner: @XiaoBinGan - [x] 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. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [x] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-01 21:44:03 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#6919
No description provided.