Skip to content

fix(snapshot): retain one-shot Ghidra pseudocode results - #8089

Merged
morluto merged 3 commits into
morluto:mainfrom
xu91102:codex/one-shot-decompile-snapshot
Nov 4, 2026
Merged

morluto merged 3 commits into
morluto:mainfrom
xu91102:codex/one-shot-decompile-snapshot

Conversation

@xu91102

@xu91102 xu91102 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #8085. An explicit one-shot Ghidra decompilation snapshot retains an exact replay entry, so repeating the same target/profile/procedure can reuse the original Evidence.

Problem and expected behavior

The original main 317bf3fe returned identical pseudocode Evidence but launched Java on both decompile --snapshot calls (10.39 s / 10.24 s). The snapshot retained Evidence without a matching replay entry; analyze was a working replay control. The measured report preceded implementation. These original measurements are historical, not a general performance claim.

Change and current main integration

The direct CLI supplies an internal one-shot target context only for an explicit pseudocode snapshot. The shared snapshot-admission owner accepts it only for Ghidra procedure_pseudo_code; the existing exact source/profile/parameter, mutation, permission, live-result, source-closure, capacity and Windows-admission checks remain. Persistent documentless MCP, other providers and decompile_all retain their existing policy.

The normal merge now includes main d48e472fa6a664cacbb400560e673533005795ce. Its three conflicts came from old incidental Knip prerequisites: main now owns the shared Node timer limit and a separate debugger-control reply budget. All eight prerequisite files match main exactly, including GDB; none remains an unrelated contribution delta. Main's shared snapshot replay limitation constant is preserved. The relative-main diff is eight snapshot production/test/documentation paths (243 insertions, 6 deletions).

The permanent legacy Evidence-only regression preserves its original complete evidence_bundle, clears replay entries, confirms one refresh restores the entry, then replays without another provider query. The earlier migration review was already delivered and resolved; this integration preserves it.

Contract and boundary impact

  • Semantic owner: existing AnalysisSnapshotCache admission, called through DirectAnalysis/BinarySession. No parallel cache, guessed document identity, parser, dependency or public schema change.
  • Exact original Evidence, target digest, selector/profile identity and provenance remain preserved. Missing selectors and changed targets refuse without replacing a valid snapshot.
  • Existing provider/cleanup owners remain responsible for cancellation, final close and process cleanup. The owned fixture target was never executed. No new target execution, mutation or network authority.
  • No new CLI parameters, MCP tools or serialized snapshot format. Authored CLI documentation changes; no generated catalogs or build outputs committed.

Expected effects of the existing decompile workflow:

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

The code-run effect is the existing Ghidra bridge script, not target execution or target injection. Writes are the selected snapshot and existing private analysis workspace; target bytes remain unchanged.

Current integration evidence

  • Six complete focused files: 164 passed, 2 existing Windows skips. Fresh README validation: 9 passed. Total 173 distinct passes / 2 skips; historical and overlapping runs are not added.
  • Real official Ghidra 12.1.4, JDK21, macOS arm64, owned inert Mach-O: 10 compiled CLI calls (8 success, 2 expected typed refusals) and one persistent stdio MCP session / 4 calls. Session and transport cleanup awaited.
  • First/repeat decompile return identical complete Evidence. Legacy upgrade/repeat preserve the complete Evidence bundle. Missing-selector and changed-target refusals preserve snapshot bytes; valid queries recover afterward. Analyze first/repeat remains equal; persistent MCP still exports no documentless pseudocode replay entry.
  • An initial external acceptance harness wrongly required the session replay marker inside exact-original CLI Evidence. Both CLI calls exited 0 with identical Evidence; its assertion failure is retained. Only that external harness was corrected, and the entire 10-call workflow was rerun fresh. Product code was not changed to satisfy the mistaken marker requirement; the earlier two calls are not counted.

Representative observed output, with local paths omitted:

rea decompile TARGET --provider ghidra --snapshot SNAPSHOT --procedure _main --json
first:  exit 0
repeat: exit 0; complete original Evidence identical
missing selector: invalid_input; original snapshot bytes unchanged
changed target: integrity_mismatch; original snapshot bytes unchanged
legacy Evidence-only snapshot: one refresh; original bundle preserved; subsequent replay identical
  • 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, npm run docs:check, npm run verify:test-discovery — PASS; 2,883 test files discovered once.
  • npm run verify:package — PASS: actual installed CLI/MCP, 233 tools / 6 prompts, exact 6.8.0 update, verified process lineage and awaited cleanup. This is package workflow acceptance, separate from the compiled Ghidra feature calls above.
  • Retained fresh tarball: all 2,668 archive/current product files match byte-for-byte; explicit npm pack --dry-run — PASS. This comparison does not claim a separate complete installed-file hash audit.
  • Independent frozen Standards and Spec reviews — PASS (one nonblocking existing comment-wording observation). Normal hooks ran; all 6,855 raw files, 5 Git links, net patch, 77 immutable evidence inputs and product bytes matched before push and again after push.
  • Current integrated head: 1e8a45cc13bc036fa923adde11728bda5169e5d7. Its CI41155603444 attempt1 is SUCCESS: 45 jobs, 25 executed successes and 20 conditional skips. All 25 execution jobs checked out synthetic merge a73c2d87067b7099c12421f0fdfe54348fb2cbdd, whose parents are main d48e472f and this feature head. Source tests: 22,236 passed / 16 skipped; source plus eight built shards aggregate 39,038 passed / 262 skipped. Portable is that summary, not another execution. The changed cache owner file executed all 39 tests, and the replay file executed 28 tests / 2 skips on Linux and 27 tests / 3 skips in the actual Windows lane. Generic native package baselines ran on Linux x64, Linux arm64 and macOS arm64; Windows capability/package acceptance also ran on Windows. These platform baselines are separate from the dedicated Ghidra snapshot feature workflow. Complete logs and every job's first source checkout were checked. Current-head Codex completion is NOT ESTABLISHED; the older 3fb0b151 usage notice is historical. CI, local validation and independent review do not establish Codex, security, human review or maintainer approval.

Compatibility, safety, and release

Dedicated installed-package Ghidra feature calls, the Ghidra snapshot feature workflow on Windows/Linux, full native engines / real applications, agent/model and general performance are NOT RUN. The Windows CI lane and its partial replay regressions above are separate evidence; the test named realGhidraWindowsWorkflow checks a workflow definition and does not execute that provider. Existing Windows focused cases remain skipped on the local macOS host. No breaking migration, dependency, permission or serialized-format change.

Author readiness

Human owner: @xu91102

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

@greptile-apps

greptile-apps Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

[Medium impact] This PR appears safe to merge; no actionable defects were found.

Summary

This PR lets explicit one-shot Ghidra pseudocode snapshots retain an exact replay entry through the existing snapshot owner.

  • One-shot Ghidra pseudocode snapshots can reuse the same saved result.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A["CLI decompile with snapshot"] --> B{"Exact replay allowed?"}
  B -->|Yes| C["Return retained Evidence"]
  B -->|No| D["Run isolated Ghidra query"]
  D --> E["Apply shared retention checks"]
  E --> F["Save Evidence and eligible replay entry"]
  F --> C
Loading

Reviews (3) · Last reviewed commit: "fix(snapshot): preserve replay across ma..." · Reviewed by Greptile

@xu91102
xu91102 marked this pull request as ready for review October 30, 2026 06:53
@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-10-30T06:53:48.165825Z
We couldn’t complete this review. Comment @codex review to try again.
3fb0b15 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.

@morluto
morluto merged commit ebea0f0 into morluto:main Nov 4, 2026
53 checks passed
@morluto morluto added area: cli CLI adapter and one-shot commands 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: cli CLI adapter and one-shot commands bug Something isn't working provider: ghidra Analysis provider / engine: ghidra

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] A repeated rea decompile with the same --snapshot runs Ghidra again instead of replaying

2 participants