Skip to content

refactor(providers)!: key Ghidra and Hopper analysis profiles on the producer identity instead of hand-bumped markers - #11320

Merged
morluto merged 12 commits into
mainfrom
feat/producer-identity-cache-key
Nov 15, 2026
Merged

morluto merged 12 commits into
mainfrom
feat/producer-identity-cache-key

Conversation

@morluto

@morluto morluto commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

Ghidra analysis profiles commit one producer identity (the REA release plus a digest of the packaged bridge scripts) instead of 53 hand-bumped -vN semantic markers. A behaviour change in REA now invalidates earlier snapshots without anyone remembering to bump a marker. Refs #3664, refs #10510.

Carries #11324 (collapsed into this branch): Hopper analysis profiles commit the same producer identity for bridge/hopper_bridge.py in place of their function_dossier_coverage marker. Before this, Hopper profiles had no bridge or REA input at all.

Problem and expected behavior

Snapshot and Evidence validity for Ghidra depended on hand-maintained marker strings such as instruction_references: "exact-address-incoming-without-synthetic-entry-v3". #3664 was a forgotten bump: old snapshots replayed results the new code would no longer produce. #10562 added bridge_sources_sha256, which covers Java bridge edits, but TypeScript projection changes still needed a bump (for example #8831 changed only TypeScript and bumped instruction_references), and the REA release was not part of the profile at all.

Expected: a snapshot replays only under the same producer. A new REA release or an edited bridge script refuses it, with no marker to maintain.

Change and scope

  • New owner src/filesystem/ProducerIdentity.ts: ProducerIdentity = {rea_version, sources_sha256}, packagedSourcesDigest(directory, names) (name-sorted, each source framed by name and byte length; a missing source throws), and packagedProducerIdentity(...) (computed once per process). It is generic so the other providers with hand-typed bridge identities (Hopper, JADX) can migrate in follow-up PRs.
  • src/ghidra/GhidraBridgeSources.ts exports ghidraProducerIdentity() built on it; the private digest copy is removed.
  • GhidraAnalysisProfile.ts commits producer in place of bridge_sources_sha256 and removes every constant revision marker: the 19-entry shared semantics block, load_image_evidence, entry_seed, pdb_observations, jump_table_evidence, plus dol_import (DOL) and instruction_context_evidence (MIPS).
  • Values that record a runtime selection keep their meaning and lose the revision suffix: language_selection (provider-pinned / configured / caller-supplied), annotation_policy, import_mode for existing projects, relocation, no-return and launch policy, Windows ARM PE import, MIPS/PowerPC/PSP lanes, mips_abi_basis, selected_project_relationship_coverage.
  • Not changed: the calling-convention policy ids shared with the Java scripts (ilp32-prototype-v1, o32-soft-float-prototype-v1), which are wire values, not cache markers.
  • Kuna and Native AOT (from refactor(providers): key Kuna exports and the Native AOT profile on the producer identity #11353, collapsed into this branch): NATIVE_AOT_PROFILE_CONTRACT_REVISION and native_aot_metadata.contract_revision are deleted from the Ghidra PE profile, which producer already covers. Kuna's hand-bumped CACHE_LAYOUT is replaced by producer: { rea_version } (releaseProducerIdentity()) in the export cache key and manifest. Entries written by another REA release, or in the old layout format, are rebuilt and retired through the existing owned-cache cleanup.
  • Hopper (from fix(hopper)!: commit the REA release and bridge script in Hopper analysis profiles #11324): src/hopper/HopperBridgeSources.ts owns the packaged bridge URL (the provider launches from it) and hopperProducerIdentity(). The Hopper profile commits producer in place of function_dossier_coverage.
  • Not included: JADX. It now reads its bridge identity from the bridge source, and no cache keys on it. This PR also leaves out the larger ContentCache design from the audit (bounds/freshness).

Accepted limitation: between releases (a development checkout), a TypeScript-only change does not change rea_version, so a snapshot saved by an earlier dev build of the same version can still replay. Released builds are always covered. Digesting the compiled TypeScript was left out to keep the change small.

Contract and boundary impact

  • Semantic owner and earliest changed stage: ProducerIdentity (foundation) -> Ghidra analysis profile -> snapshot binding and Evidence analysis_profile. Superseded: the private bridge digest and all constant Ghidra markers.
  • Contribution scope fit and linked maintainer decision: structural cleanup plan W12 step 1; no new authority.
  • CLI and MCP/tool-catalog contract: no schema change; analysis_profile.parameters is an open JSON object.
  • Provider, bridge, target-format, or platform compatibility: Ghidra only; bridge scripts unchanged.
  • Evidence, artifact, provenance, or reconstruction contract: Ghidra profile parameters and digests change, so Ghidra Evidence IDs change (breaking, see below).
  • Target selection, authority, upstream behavior, and cleanup details: not applicable.
  • Generated metadata, package, or installation impact: none.

Expected effects:

  • 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:
    • tests/boundary/filesystem/producerIdentity.test.ts: editing a producer script changes the digest without a marker; name/length framing; order independence; a missing source throws; the REA release is committed.
    • GhidraSnapshotCache.test.ts: the 19-row "outdated marker" table is replaced by snapshots from an edited bridge script, another REA release, and no producer identity. Each is refused with EvidenceIntegrityError and makes no provider call.
    • GhidraProvider.behavior.test.ts: the historical PDB-marker case becomes "Evidence from an earlier producer is retained but not replayed".
    • Profile, lane and boundary tests read the renamed selection values and producer.
  • Base reproduction or other evidence: source-derived. On main, the snapshot binding has no REA release, so a snapshot from an earlier release with identical bridge bytes is admitted. I did not replay that on the base revision.
  • Review fixes: scripts/lib/ghidra-reference-snapshot-e2e.mjs (verify:ghidra) built its legacy snapshot by removing function_references. It now uses an earlier producer, like the value-scope verifier. producerIdentity.test.ts uses createTestTempDirectory.
  • Hopper: hopperAnalysisProfile.test.ts "commits the REA release and packaged bridge script it runs".
  • Remaining proof gaps: real Ghidra verifiers (scripts/verify-real-ghidra-*.mjs) were updated for the renamed values but not run. No Ghidra installation was used.

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

  • npm run check:fast: passed (typecheck, lint, architecture guards across 2812 files)

  • npx oxfmt --check .: passed

  • npm run docs:check: passed

  • (refactor(providers): key Kuna exports and the Native AOT profile on the producer identity #11353) npm run check:fast: passed; npm run test:focused -- tests/boundary/providers/kuna/kunaProjectCache.test.ts src/ghidra/GhidraProvider.behavior.test.ts: 348 passed; producerIdentity, GhidraRawProfileDigest, GhidraSnapshotCache, hopperAnalysisProfile and seven Kuna boundary tests: 11 files, 121 passed; npm run docs:check: passed

  • (fix(hopper)!: commit the REA release and bridge script in Hopper analysis profiles #11324) npm run test:focused -- tests/boundary/providers/hopper/hopperAnalysisProfile.test.ts src/hopper/HopperAnalysisProfile.test.ts src/hopper/HopperProvider.test.ts tests/boundary/providers/hopper/hopperRelativeLauncher.test.ts tests/boundary/providers/hopper/hopperClient.protocol.test.ts: 79 passed

  • After review fixes: npm run check:fast passed; npm run test:focused -- tests/boundary/filesystem/producerIdentity.test.ts: 5 passed; node --check scripts/lib/ghidra-reference-snapshot-e2e.mjs: ok (not run against real Ghidra)

  • npm run test:focused -- the 14 changed or affected test files (producer identity, Ghidra bridge sources, raw profile digest, snapshot cache, DOL/language/MIPS/PowerPC/RISC-V profiles, provider behavior, session values, PSP extension, Ghidra evidence and inventory MCP): 14 files, 609 tests passed

  • Gate refusal fix (d870a1b): scripts/verify-ghidra-bridge-sources.mjs loads src/ghidra/GhidraBridgeSources.ts directly with Node type stripping, which does not resolve .js specifiers. The ProducerIdentity import made every verifier run fail with ERR_MODULE_NOT_FOUND (tests/boundary/filesystem/ghidraBridgeSources.test.ts, 10 cases). The source table is import-free again, and ghidraProducerIdentity moved to src/ghidra/GhidraProducerIdentity.ts. The other two modules the scripts load directly (GhidraJavaProperties.ts, GhidraReleasePolicy.ts) have only type imports.

  • Merged current main. Resolved a HopperProvider.ts conflict: main's launcher verification options are kept, together with this PR's HOPPER_BRIDGE_SCRIPT_URL.

  • npm run check:fast: passed. npm run test:focused -- with the 7 Ghidra producer/bridge test files and 30 Hopper test files: 578 passed, 6 skipped.

  • briefs/local-gate.sh 11320 after the push: passed (60 affected test files, 1386 passed).

Compatibility, safety, and release

  • Breaking changes or migration steps: BREAKING CHANGE: Ghidra Evidence analysis_profile.parameters replace the marker keys and bridge_sources_sha256 with producer ({rea_version, sources_sha256}), and selection values drop their -vN suffix (e.g. language_selection: "provider-pinned"). Ghidra Evidence IDs and profile digests change, and analysis snapshots saved by earlier builds are refused at open (evidence_integrity_mismatch). Migration: open the target without the old snapshot and save a fresh one. Readers of the removed marker keys should compare producer. Keeping the old markers alongside would bring back the hand-bump this PR removes.
    BREAKING CHANGE: (fix(hopper)!: commit the REA release and bridge script in Hopper analysis profiles #11324) Hopper Evidence analysis_profile.parameters replace function_dossier_coverage with producer. Hopper profile digests and Evidence IDs change, and Hopper snapshots saved by earlier builds are refused at open. Migration: open the target without the old snapshot and save a fresh one.
  • Real Hopper/Ghidra, browser, or OS coverage: none run.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: reads packaged bridge files only (as before).

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.

…tead 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.
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-15T16:14:19.658209Z
We couldn’t complete this review. Comment @codex review to try again.
768377e 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@greptile-apps

greptile-apps Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The reviewed changes appear safe to merge, with no new blocking issue found.

Summary

Replaces hand-maintained cache markers with producer identities.

  • Ghidra profiles tie saved analysis results to the REA release and bridge scripts.
  • Hopper profiles identify the REA release and bridge script behind each result.
  • Kuna export-cache entries are keyed to the REA release that produced them.
  • Import and formatting cleanup leaves unrelated workflows unchanged.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  Release["REA release"] --> Identity["Producer identity"]
  Scripts["Packaged bridge scripts"] --> Identity
  Identity --> Profile["Ghidra or Hopper profile digest"]
  Profile --> Match{"Saved digest matches?"}
  Match -->|No| Refuse["Refuse snapshot"]
  Match -->|Yes| Reuse["Allow matching results"]
  Release --> Kuna["Kuna export key and manifest"]
Loading

Reviews (8) · Last reviewed commit: "fix(artifacts): import the moved file so..." · Reviewed by Greptile

Comment thread src/ghidra/GhidraAnalysisProfile.ts Resolved
…ysis 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.
@morluto morluto changed the title refactor(ghidra)!: key analysis profiles on the producer identity instead of hand-bumped markers refactor(providers)!: key Ghidra and Hopper analysis profiles on the producer identity instead of hand-bumped markers Nov 15, 2026
…aded 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.
…y-cache-key

# Conflicts:
#	src/hopper/HopperProvider.ts
@morluto

morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

@greptileai review

# Conflicts:
#	src/artifacts/MachOSliceArtifactReader.ts
@morluto

morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

@greptileai review — latest head b57bccf (main merged; import-path conflict in MachOSliceArtifactReader resolved to main's src/domain/apple/machoLoadCommandReader). local-gate.sh 11320 passed on this head.

# Conflicts:
#	tests/boundary/providers/kuna/kunaProjectCache.test.ts
@morluto

morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

@greptileai review — latest head aa1741b (main merged; the Kuna cache test conflict resolved by keeping this PR's layouts 1, 2, 3 and "release" and main's shared phaseGate harness, which made the local deferred helper unused). local-gate.sh passed on aa1741b.

# Conflicts:
#	src/artifacts/ArtifactHash.ts
#	src/artifacts/DotnetBundleArtifactReader.ts
#	src/artifacts/NodeSeaArtifactReader.ts
#	src/artifacts/PyInstallerArtifactReader.ts
#	src/artifacts/deno/DenoVirtualFs.ts
#	src/artifacts/extraction/ArtifactExtraction.ts
#	src/artifacts/pyinstaller/PyInstallerPyzStore.ts
#	src/resources/StableRootArtifact.ts
Entrpi added a commit to Entrpi/rea that referenced this pull request Nov 22, 2026
Main's morluto#11320 dropped revision markers from profile-only values, and this
lane's code writes language_selection configured and provider-pinned,
processor_labels not-applied and arm_float_prototype
dwarf-default-stdcall-softfp. The guides still showed -v1 on each. Lane
ids such as elf32-exec-le-eabi5-armv7-m-pinned-v1 keep their suffix,
because the code still emits it.
@morluto morluto added area: providers Provider and capability discovery, including provider proposal triage provider: ghidra Analysis provider / engine: ghidra provider: hopper Analysis provider / engine: hopper labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: providers Provider and capability discovery, including provider proposal triage provider: ghidra Analysis provider / engine: ghidra provider: hopper Analysis provider / engine: hopper

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant