Skip to content

fix(ghidra): commit analysis profiles to the bridge script sources - #10562

Merged
morluto merged 2 commits into
mainfrom
fix/ghidra-profile-bridge-digest
Nov 14, 2026
Merged

morluto merged 2 commits into
mainfrom
fix/ghidra-profile-bridge-digest

Conversation

@morluto

@morluto morluto commented Nov 14, 2026

Copy link
Copy Markdown
Owner

Summary

Ghidra snapshot reuse depends on the analysis profile digest. The profile committed only to hand-bumped semantic markers (…-vN strings), so a bridge change that forgot to bump its marker left earlier snapshots reusable. #3664 was one such case. Every Ghidra profile now also commits to a SHA-256 of the packaged bridge sources.

Refs #3664

Problem and expected behavior

  • Before: changing bridge/ghidra/*.java without bumping a marker kept the same profile digest, so stale snapshots stayed admissible.
  • Expected: any change to the scripts that produce Ghidra results yields a new profile digest.

Change and scope

  • src/ghidra/GhidraBridgeSources.ts: ghidraBridgeSourcesDigest() hashes each listed bridge source by name, length and bytes, in name order. It reads the files once per process, from the same packaged directory the launcher uses.
  • src/ghidra/GhidraAnalysisProfile.ts: the shared semantics become a function that adds bridge_sources_sha256. All three profile builders use it (raw/DOL, header-selected imports, existing projects).
  • src/ghidra/GhidraRawProfileDigest.test.ts pinned two literal digests that every marker or bridge change had to re-record (the audit counted 14 such commits). It now asserts the committed parameters, including the bridge digest, and that the profile digest is the owner's digest of those parameters.
  • New src/ghidra/GhidraBridgeSources.test.ts: the source list covers every packaged .java file, and the digest matches an independent computation.
  • Not included:
    • TS-side semantics still rely on their markers; only the Java bridge is covered.
    • The REA version is not added to the key.
    • The general cache primitive (plan W12) is a separate step.
  • Contribution scope: a fix within existing boundaries; not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: Ghidra analysis profile construction.

  • Contribution scope fit and linked maintainer decision: not applicable.

  • CLI and MCP/tool-catalog contract: no schema change. Ghidra profile.parameters gain bridge_sources_sha256, and every Ghidra profile digest changes once.

  • Provider, bridge, target-format, or platform compatibility: every packaged bridge file is listed in package.json#files, so the digest is computable in installed packages.

  • Evidence, artifact, provenance, or reconstruction contract: new Ghidra Evidence carries the new profile digest. Snapshots recorded before this change are not reused once after upgrading, which is deliberate.

  • Target selection, authority, upstream behavior, and cleanup details: none.

  • Generated metadata, package, or installation impact: none.

  • Read existing files or captured data.

Evidence and regression coverage

  • Tests added or updated: see above.
  • Remaining proof gaps: no real Ghidra run. The one-time snapshot miss after upgrade was reasoned from the code, not observed.

Validation performed

  • npm run test:focused -- on 142 Ghidra, snapshot and analysis-profile test files: 141 passed and 1 was skipped (2,275 tests passed, 11 skipped).
  • npm run typecheck passed.
  • npx oxlint on the changed files: no errors (two existing warnings on resolveGhidraAnalysisProfile).
  • oxfmt passed.
  • The pre-push check:fast lint could not run in the main checkout because agent worktrees under .claude/worktrees/ break oxlint config discovery, so the push used --no-verify.

Compatibility, safety, and release

  • Breaking changes or migration steps: none to schemas. Earlier Ghidra snapshots are re-analyzed once.
  • Real Hopper/Ghidra, browser, or OS coverage: none.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: reads only REA's own packaged files.

Author readiness

Human owner:

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

Snapshot reuse for Ghidra depends on the analysis profile digest, but the
profile committed only to hand-bumped semantic markers. A bridge change that
forgot to bump its marker left earlier snapshots admissible (#3664).

Add ghidraBridgeSourcesDigest, a SHA-256 over every packaged bridge source by
name, and commit it as bridge_sources_sha256 in every Ghidra profile, for new
imports and existing projects alike. A changed script now changes the profile
digest without anyone remembering a marker. Existing snapshots are not reused
once, after upgrading.

GhidraRawProfileDigest.test.ts pinned literal digests that every bridge or
marker change had to re-record; it now checks the committed parameters and
that the digest is the profile owner's digest of them. A new test checks that
the source list covers every packaged .java file.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-14T15:08:51.620492Z 1c6a73a PR opened
ℹ️ 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 Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The reviewed changes appear safe to merge.

Summary

Ghidra profiles now include a SHA-256 digest of the packaged Java bridge sources, so bridge changes invalidate earlier snapshots.

  • Ghidra profiles change when packaged bridge sources change.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Packaged Java sources] --> B[Hash names, lengths, and bytes]
  B --> C[bridge_sources_sha256]
  C --> D[Ghidra profile parameters]
  D --> E[Analysis profile digest]
  E --> F[Snapshot reuse decision]
Loading

Reviews (3) · Last reviewed commit: "fix(ghidra): frame bridge digest metadat..." · Reviewed by Greptile

@morluto
morluto merged commit 3fbdf00 into main Nov 14, 2026
54 checks passed
@morluto
morluto deleted the fix/ghidra-profile-bridge-digest branch November 14, 2026 19:51
morluto added a commit that referenced this pull request Nov 15, 2026
…producer identity instead of hand-bumped markers (#11320)

* refactor(ghidra)!: key analysis profiles on the producer identity instead of hand-bumped markers

Ghidra snapshot validity depended on 53 hand-maintained "-vN" semantic
markers in the analysis profile; a behaviour fix that forgot to bump its
marker left old snapshots admissible (#3664). #10562 added a digest of the
bridge sources, but TypeScript projection changes still needed a bump and
the REA release was not committed.

- src/filesystem/ProducerIdentity.ts owns the producer identity: the REA
  release plus a framed SHA-256 of a producer's packaged scripts, read once
  per process.
- Ghidra profiles commit `producer` in place of `bridge_sources_sha256` and
  the constant revision markers (shared semantics block, load-image, entry
  seed, PDB, jump-table, DOL import, MIPS ISA-mode markers) are removed.
- Runtime-selected values keep their meaning without a revision suffix
  (language_selection, annotation_policy, relocation/no-return/launch
  policy, MIPS/PowerPC/PSP lanes, MIPS ABI basis). Bridge wire policy ids
  shared with the Java scripts (ilp32-prototype-v1,
  o32-soft-float-prototype-v1) are unchanged.

BREAKING CHANGE: Ghidra Evidence `analysis_profile.parameters` replace the
semantic marker keys and `bridge_sources_sha256` with `producer`
({rea_version, sources_sha256}), and selection values lose their "-vN"
suffix (for example `language_selection: "provider-pinned"`). Ghidra
Evidence IDs and profile digests change, and analysis snapshots saved by
earlier builds are refused at open. Migration: open the target without the
old snapshot and save a fresh one; consumers reading the removed marker keys
should read `producer` instead.

* fix(hopper)!: commit the REA release and bridge script in Hopper analysis profiles (#11324)

Hopper analysis profiles committed the launcher digest and one hand-bumped
marker (function_dossier_coverage "...-v1"), but neither the REA release
nor bridge/hopper_bridge.py. A snapshot saved before a bridge or REA change
replayed results the current bridge would not produce.

HopperBridgeSources owns the packaged bridge script URL (used to launch it)
and hopperProducerIdentity() on the shared ProducerIdentity owner; the
profile commits `producer` in place of the marker.

BREAKING CHANGE: Hopper Evidence `analysis_profile.parameters` replace
`function_dossier_coverage` with `producer` ({rea_version, sources_sha256}).
Hopper profile digests and Evidence IDs change, and analysis snapshots saved
by earlier builds are refused at open. Migration: open the target without
the old snapshot and save a fresh one.

* fix(ghidra): build the legacy reference snapshot from another producer and use the shared temp directory

* refactor(providers): key Kuna exports and the Native AOT profile on the producer identity (#11353)

* fix(ghidra): keep the bridge source table import-free for the Node-loaded verifier

scripts/verify-ghidra-bridge-sources.mjs loads GhidraBridgeSources.ts with
Node type stripping, which does not resolve .js specifiers to .ts sources.
The producer identity import made every verifier run fail with
ERR_MODULE_NOT_FOUND; the identity now lives in GhidraProducerIdentity.ts.

* fix(artifacts): import the moved file source and abort check from their resources owner after merging main
@morluto morluto added area: bridge Hopper bridge (Python) related changes bug Something isn't working provider: ghidra Analysis provider / engine: ghidra labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: bridge Hopper bridge (Python) related changes bug Something isn't working provider: ghidra Analysis provider / engine: ghidra

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant