Skip to content

feat(native): retain decompile export source facts - #8805

Merged
morluto merged 3 commits into
mainfrom
codex/decompile-provenance
Nov 4, 2026
Merged

morluto merged 3 commits into
mainfrom
codex/decompile-provenance

Conversation

@morluto

@morluto morluto commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

Summary

A resumed decompile_all directory can contain functions from different provider exports while recording only each output file's digest. This adds per-attempt source facts when the provider can supply them, without retaining every pseudocode body in the session ledger. Related: #8260.

Problem and expected behavior

When one Kuna function succeeds in a partial project and another is recovered from a separately built project with the same profile, the existing index cannot identify either producing project file. A written or failed pseudocode observation now records a provider-reported file digest and byte range, a single-function method, or an explicit unknown. A matching pre-existing file is adopted with its original producer unknown.

Change and scope

The provider reports a compact typed descriptor with the observation. The directory workflow records it only after target/profile checks and pairs it with that attempt's journal outcome. A failed pseudocode observation retains its source in the append-only journal; resume preserves earlier successful records. Snapshot replay does not restore this transient descriptor, so its absence stays unknown. A file range reports source facts; it does not retain or authenticate the source file, and a single-function method is not a unique run identity. This does not produce retrievable per-function Evidence records or establish a Ghidra session-edit revision.

Contract and boundary impact

  • Semantic owner and earliest changed stage: the Kuna adapter owns source facts; the directory journal owns their association with attempts and the derived index.
  • Contribution scope and decision: existing static decompilation; no new target execution, injection, mutation or protection recovery. Maintainer scope decision not applicable.
  • CLI and MCP/tool-catalog contract: manifest unchanged; the on-disk journal/index can contain provider_source. Older records may omit it and are unknown. Older REA versions that reject unknown journal fields cannot resume a newly written journal; retain the directory and use a current version or a new output directory.
  • Provider, bridge, format or platform compatibility: Kuna supplies source facts; other providers without a descriptor report unknown. Real controls ran on macOS arm64 only.
  • Evidence, artifact and provenance: no per-function Evidence links are invented; a source path may disappear and journal contents are not authenticated.
  • Target selection, authority and cleanup: existing selected target, provider execution, publication and cleanup boundaries apply.
  • Generated metadata, package or installation impact: none beyond normal generated documentation checks.

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

  • Public MCP fixture: a partial export records one failed attempt and one successful file; a clean export resumes the directory, preserves the original file and source, and records the new file's different source digest. A torn trailing journal line is repaired; a removed source cache retains its historical descriptor; a modified output is refused and, after its original bytes are restored, its original source record is restored; an unjournaled matching file is adopted with unknown origin. The source assertion fails on the base revision.
  • Snapshot boundary: a CLI export after a saved pseudocode snapshot invokes the provider and records the fresh execution's descriptor. The complete directory-service suite also passed.
  • Real Kuna 1.989 on macOS arm64: a test-only wrapper injected a project worker panic. A partial export and a separate clean export produced different C-file digests; resume retained the first successful file and its original source, retained the failed source in the journal, and wrote the recovered function with the clean source. A cold CLI export reported {"status":"reported","source":{"kind":"single-function-decompile"}}.
  • Real Ghidra 12.1.4 MCP: the sampled function reported source_not_available; a matching unjournaled file remained existing_file_origin_unknown. In separate real Kuna and Ghidra controls, a deliberately modified output was left untouched and restoring its prior bytes recovered its prior source record. These controls used one unexecuted, unchanged test target.
  • Gaps: the injected failure does not establish natural failure frequency. Separate real Kuna controls removed or changed the first test-owned source file before resume; the output and historical descriptor remained unchanged, and the changed file no longer matched the recorded digest. A file path/digest is a historical source description, not an independently authenticated record or retention guarantee. Ghidra live-edit revision identity, full per-function Evidence retrieval, other hosts and cross-provider mixed runs are not established here. A separate headless Ghidra probe found that different fresh sessions can have the same modification counter after different edits; see [Design] Preserve per-function producer provenance across decompile export resume #8260.

Validation performed

  • Focused directory, snapshot and Kuna MCP suites — 87 passed, 2 skipped before the final method-name simplification; the 27 applicable boundary cases passed again after it.
  • npm run check:ci:fast — passed.
  • npm run docs:check — passed.
  • Real Kuna CLI/MCP and Ghidra MCP controls described above — passed on macOS arm64.

Compatibility, safety, and release

  • Older journal records remain accepted, with absent source treated as unknown. Older REA versions may reject journals containing the new field; the output files are not overwritten by this change.
  • No target execution or package/dependency changes. No other platform verification is claimed.

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.

@greptile-apps

greptile-apps Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

[Medium impact] The PR appears safe to merge; the added recovery checks agree with how resume preserves the original written record.

Summary

Adds provider-reported source facts to decompile journal records and the derived index.

  • Decompile exports keep the source facts for each pseudocode attempt.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Provider observation] --> B[Check target and profile]
  B --> C[Record attempt outcome and source facts]
  C --> D[Append-only journal]
  D --> E[Derived index]
  D --> F[Resume and check saved output]
  F --> G{Bytes still match?}
  G -->|Yes| H[Reuse original written record]
  G -->|No| I[Keep file and record conflict]
Loading

Reviews (2) · Last reviewed commit: "test(native): retain source after export..." · Reviewed by Greptile

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 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 ✅ Completed 2026-11-04T16:55:54.375626Z b55b0c3 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.

@morluto
morluto merged commit b970238 into main Nov 4, 2026
56 of 57 checks passed
@morluto
morluto deleted the codex/decompile-provenance branch November 4, 2026 17:48
@morluto morluto mentioned this pull request Nov 11, 2026
3 tasks done
@morluto morluto added area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior enhancement New feature or request labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant