Skip to content

feat(native): retry failed directory decompiles independently - #8811

Merged
morluto merged 22 commits into
mainfrom
codex/decompile-directory-independent-retry
Nov 7, 2026
Merged

morluto merged 22 commits into
mainfrom
codex/decompile-directory-independent-retry

Conversation

@morluto

@morluto morluto commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

Summary

When a Kuna project export reports a function decompilation failure, a direct independent retry can succeed but decompile_all still records only the project failure. Allow an explicit directory retry and preserve both observations. Related: #8167.

#8793 merged into main as 81c09888 and #8805 as b97023809f. GitHub retargeted this PR to main after #8793 merged; the current head reconciles the squash history without changing the tested result tree.

Problem and expected behavior

An analyst exporting pseudocode can opt into retry_failed: "independent_fresh" (CLI --retry-failed independent_fresh). When a project failure is reported without the opt-in, the affected failure row explains how to resume with it. REA appends the project failure before independently retrying, records the new attempt and its actual source, and leaves the project observation unchanged. Independent analysis can have different context. Errors and missing export blocks without an explicit function-failure observation do not trigger this retry.

Change and scope

Kuna's project reader owns the distinction between a reported failure and an absent export block. The directory workflow uses that typed observation, not error-message matching. Missing facts remain unknown; a missing export block does not prove that a function lacks a body. Retry failure, cancellation and incomplete cleanup preserve the first journal entry. Contribution scope decision: not applicable; this uses the existing local static analysis capability and output directory authority.

Contract and boundary impact

  • Semantic owner and earliest changed stage: Kuna project reader emits the typed absence; the shared directory workflow decides whether to retry.
  • CLI and MCP/tool-catalog contract: optional retry policy; procedure_pseudo_code may expose raw_result.pseudocode_absence. Directory records can include the same fact.
  • Provider, bridge, target-format, or platform compatibility: the automatic policy requires a provider-reported function failure and independent decompile support; current reporting is Kuna-specific.
  • Evidence and provenance: original failed row is retained before retry, and the resulting row reports its own source; missing source and absence facts remain unknown. The index keeps the latest attempt; the journal retains previous attempts and their caveats, and omission guidance names both.
  • Target selection, authority and cleanup: uses the caller-selected binary and output directory; retains process ownership when cleanup is incomplete.
  • Generated metadata: catalog regenerated and checked by the normal build; generated outputs are not committed.

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Change process memory, registers, files, or configuration. (Writes caller-selected output and provider cache; does not alter target bytes.)
  • Inject instrumentation or run scripts/code.
  • 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

  • Controlled public MCP boundary tests cover both schema profiles, explicit failure versus export omission, retained source for both attempts, timeout, cancellation, and incomplete cleanup followed by ownership release.
  • Real Kuna 1.989 on macOS arm64, with an injected project-worker failure: compact/full MCP and CLI directory exports each retained a failed file-range observation followed by a written independent observation. The project still reported its original failure, and the target digest stayed unchanged. This is an injected failure, not a naturally reproduced provider crash.
  • Separate real Kuna MCP resume controls in both schema profiles and a CLI resume control first exported one success and one failure, then showed the retry guidance, skipped the successful file and recovered the failed function using the indicated resume and retry options. The journal retained both failure observations and the successful retry. The worker failure was injected.
  • A real Mach-O import slot was absent from the export and a direct independent attempt failed; REA reports not-in-export rather than claiming a body is absent. This does not classify other omissions.
  • Remaining proof gaps: no natural crash reproduction; the lifecycle failure paths use a controlled provider; no Linux or Windows real-provider verification for this change. Existing Ghidra success-path smoke coverage does not establish Ghidra failure behavior.

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

On the reconciled tree built from #8793 head b44fd0aa26 and Node 24.22.1, npm run build:cached passed (2 tasks executed, 1 cached), and npm run check:fast passed with typecheck and lint both executed. Four focused directory retry, Kuna MCP and workflow Evidence suites passed 95 tests; targeted formatting on all 14 changed files and git diff --check passed. The #8793 squash tree at 81c09888 is byte-identical to b44fd0aa26, and this PR head has the same tree that passed those checks. No real Kuna or other-provider run was repeated on the reconciled head. The older validation below applies to the earlier temporary-base branch.

  • npm run test:focused -- tests/boundary/providers/kuna/kunaDirectoryIndependentRetryMcp.test.ts tests/boundary/providers/kuna/kunaBatchDecompileMcp.test.ts src/application/decompileDirectory/decompileAll.test.ts src/application/WorkflowEvidence.test.ts — 89 passed.
  • npm run check:ci:fast — passed, with existing lint warnings.
  • npm run docs:check — passed.
  • Real Kuna stdio MCP and CLI controls, and separate import-slot controls — passed as described above.

Compatibility, safety, and release

  • Older strict journal readers can reject records containing the new optional pseudocode_absence field. New code accepts earlier records with the fact unknown; no backwards-reader compatibility is claimed. This is in addition to the source fields introduced by feat(native): retain decompile export source facts #8805.
  • Real Ghidra/Hopper, browser, and other OS coverage: no real-provider failure-path verification for this change.
  • Package/release metadata: no authored package changes.
  • The retry starts an additional Kuna process only after explicit selection; cleanup follows existing resource ownership rules. Target bytes are not modified.

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

@morluto
morluto marked this pull request as ready for review November 3, 2026 15:10
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 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-07T15:42:27.812501Z 305df99 New commits
ℹ️ 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 3, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The reviewed changes appear safe to merge; no new actionable defect was confirmed.

Summary

Adds an opt-in independent retry for directory exports after Kuna explicitly reports a function failure.

  • Directory exports can retry reported decompile failures with a fresh analysis attempt.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Read project pseudocode] --> B{Null with reported function failure?}
  B -- No --> C[Keep normal outcome]
  B -- Yes --> D{Independent retry selected?}
  D -- No --> E[Record failure with retry guidance]
  D -- Yes --> F[Append and sync original failure]
  F --> G[Run independent decompile]
  G --> H[Record retry outcome separately]
  G --> I[Cancellation or incomplete cleanup]
  I --> J[Keep original journal entry and cleanup owner]
Loading

Reviews (5) · Last reviewed commit: "chore: reconcile merged independent retr..." · Reviewed by Greptile

morluto and others added 6 commits November 3, 2026 23:34
Fresh independent decompiles stay uncached, and one-shot pseudocode
can still replay. Failed-export limitations keep both the fresh-run
fact and main's export-state checks.
A failed export still reports that per-function records are not exposed,
and an explicit fresh decompile remains a separate single-function run.
@morluto
morluto changed the base branch from codex/retry-provenance-base to codex/kuna-independent-retry November 7, 2026 15:14
@greptile-apps

greptile-apps Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Comments Outside Diff

These findings could not be posted inline.

  • P2 Tests freeze repair wording tests/boundary/providers/kuna/kunaJournalRecoveryMcp.test.ts:83 ▶

    This new journal-recovery test freezes the full error explanation and repair instructions. docs/testing.md requires checking structured facts and recovery behavior instead of freezing explanatory sentences, so harmless wording changes should not fail this test.

    Keep the error-code, missing schema-repair advice, and unchanged-file checks. Check guidance delivery against its owning formatter or constant rather than duplicating the sentences. This repository requirement must be satisfied before merging.

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Base automatically changed from codex/kuna-independent-retry to main November 7, 2026 15:37
@morluto
morluto merged commit e47bb15 into main Nov 7, 2026
8 of 10 checks passed
@morluto
morluto deleted the codex/decompile-directory-independent-retry branch November 7, 2026 15:51
@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.

2 participants