Skip to content

feat(kuna): allow independent decompile retries - #8793

Merged
morluto merged 9 commits into
mainfrom
codex/kuna-independent-retry
Nov 7, 2026
Merged

morluto merged 9 commits into
mainfrom
codex/kuna-independent-retry

Conversation

@morluto

@morluto morluto commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

Summary

A completed Kuna project export can retain a failed function even when a new standalone decompile succeeds. This adds an explicit independent attempt while retaining the original observation. Related: #8167.

Problem and expected behavior

Repeating procedure_pseudo_code against the same partial project returns its null body again. When the provider declares support, analysis: "independent_fresh" requests a new attempt; the CLI equivalent is rea decompile <path> <procedure> --analysis independent_fresh. The result may use different analysis context and may still fail.

Change and scope

Kuna owns the independent single-function run, its bounded admission, and cleanup. The application refuses the selection when a provider has not declared it and prevents both in-session and pre-open snapshot replay. A cold request does not start a project export. Timeout recovery names the configured deadline without promising that an export exists, and CLI/MCP share the same selection schema. The failed project block gives the next step; its structured failure reason is kept independently of limitation ordering. Identical results may share a content-addressed Evidence ID; this does not provide a separate run receipt or automatically link attempts.

Contract and boundary impact

  • Semantic owner and earliest changed stage: Kuna project reader owns per-function failure reasons; shared session and direct CLI paths enforce the fresh request before replay.
  • Contribution scope fit and linked maintainer decision: existing static decompilation authority; no new target execution, injection, mutation or protection recovery. Maintainer scope decision not applicable.
  • CLI and MCP/tool-catalog contract: optional pseudocode selection and independent_decompile capability; unsupported providers refuse it. Grouped capability facts remain associated with the operation.
  • Provider, bridge, target-format, or platform compatibility: implemented for Kuna; other providers do not declare it.
  • Evidence, artifact, provenance, or reconstruction contract: original failure and independent result remain separate; result identifies single-function source and context limitation.
  • Target selection, authority, upstream behavior, and cleanup: existing target and Kuna selection; the new run uses existing slots and cleanup ownership.
  • Generated metadata, package, or installation impact: generated catalogs follow the authored contracts; no dependency or installer changes.

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 boundary controls cover compact/full schemas, retained failure and fresh Evidence, repeated new provider calls, cold admission and timeout guidance, and cleanup retry after an unproven stop. The queued cleanup test uses a bounded slot-admission acknowledgement and joins the request before restoring its spy; the timeout assertion checks the projected recovery contract. Provider coverage checks a failed project and explicit dossier reason. Snapshot boundary coverage includes an artificially constructed valid matching imported entry: without the replay guard, direct analysis returned it instead of calling the provider. Unsupported-provider selection is refused even with such an entry.
  • Real Kuna 1.989 on macOS arm64, with a test-only launcher injecting a worker panic, produced a partial export and null project result; CLI and both MCP profiles displayed the recovery path and returned standalone pseudocode on request. Original and new Evidence remained in the exported bundle. A cold CLI control recorded functions and decompile, with no decompile-project. Real Ghidra 12.1.4 refused the undeclared selection. The target was not executed or changed.
  • Representative guidance: To try an independent decompile, call procedure_pseudo_code with analysis: independent_fresh, or use rea decompile --analysis independent_fresh.
  • The injected panic and synthetic cleanup controls do not establish natural failure frequency, cross-platform cleanup, or all concurrent interleavings. No independent-attempt receipt or automatic Evidence link is claimed. The separate fix(mcp): report native value flow support in session status #8786 changes overlap the grouped capability schema; a disposable combined worktree passed focused checks, but the branches will require conflict resolution when integrated.

Current-main integration

Merged main through 2e2f981c. Retained both the independent decompile selector and the current pseudocode detail/retained-view contract; retained both sets of snapshot regressions. Node 24.22.1 focused snapshot and single-function suites passed 48 tests (2 skipped), the simulated-provider compact/full MCP boundary passed 4 tests, and the Kuna provider boundary passed 39 tests. build:cached passed (3 tasks, 1 cached), check:fast passed uncached, and changed-file formatting passed. Full format:check passed after integrating the upstream formatting fix #9280. No real Kuna or Ghidra run was performed on this merged head; earlier real-provider evidence is historical.

Validation performed

  • After merging main 106ba173, preserved fresh independent-decompile cache bypass alongside the new source-evidence options contract. Node 24 check:fast and format:check passed; four snapshot, Kuna provider and MCP suites passed 124 tests with 2 skipped. Real Kuna was not rerun after the merge.

  • Focused snapshot, Kuna MCP, batch, and provider boundary tests — passed; 2 snapshot tests skipped on this host. The two imported-snapshot variants passed after the full focused run.

  • npm run check:ci:fast — passed.

  • npm run docs:check — passed.

  • Real CLI and compact/full MCP controls described above — passed on macOS arm64.

Compatibility, safety, and release

  • Additive optional CLI/MCP input and capability field; no migration required.
  • Other OSes and providers' independent implementations were not verified. No package or release metadata changes.

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: plus

[Medium impact] The PR appears safe to merge, with one non-blocking issue in how fresh retries report unavailable sibling tools.

Fix All in CodexFindings

  1. P2 Failed tools stay listed ▶
Fix with agent prompt
### Issue 1
src/kuna/KunaSessionClient.ts:869-876
If a regular pseudocode call returns while the export is running and that export later fails, a successful `independent_fresh` retry skips `#settledExportUnavailable` and returns no `siblingUnavailability`. `binary_session` keeps advertising `procedure_assembly` and `analyze_function` as available, although both will fail until the target is reopened. This costs users another failed call.

Share the failed-export facts between regular and independent single-function answers without sharing their cached text.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Adds explicit independent Kuna decompile attempts through CLI and MCP.

  • Kuna can retry one function without replacing its project result.
  • Callers can request a fresh decompile only from providers that support it.
  • Fresh decompile requests skip saved snapshot answers.
  • Failed Kuna results keep their reason and show how to retry.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A["CLI or MCP pseudocode request"] --> B{"Independent fresh?"}
  B -->|No| C["Existing project or shared single-function path"]
  B -->|Yes| D{"Provider declares support?"}
  D -->|No| E["Refuse request"]
  D -->|Yes| F["Bypass snapshot replay"]
  F --> G["Resolve selected procedure"]
  G --> H["Acquire foreground slot"]
  H --> I["Run standalone Kuna decompile"]
  I --> J["Return separate Evidence"]
  I --> K{"Process stop proven?"}
  K -->|Yes| L["Release slot"]
  K -->|No| M["Retain owner and slot for cleanup retry"]
Loading

Reviews (10) · Last reviewed commit: "Merge branch 'main' of https://github.co..." · Reviewed by Greptile

Comment thread src/kuna/KunaSessionClient.ts Resolved
Comment thread src/cli/coreBinaryCommands.ts Resolved
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 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:37:33.509911Z b44fd0a 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.

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

A failed export still reports that per-function records are not exposed,
and an explicit fresh decompile remains a separate single-function run.
@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 81c0988 into main Nov 7, 2026
8 of 10 checks passed
@morluto
morluto deleted the codex/kuna-independent-retry branch November 7, 2026 15:37
@morluto morluto mentioned this pull request Nov 11, 2026
3 tasks done
Comment on lines +869 to +876
return ok({
result: standalone.value,
source: { kind: "single-function" },
locations,
limitations: [
"This is a fresh independent single-function decompile; it does not use the project export's whole-program prototypes.",
...classification,
],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Failed tools stay listed

If a regular pseudocode call returns while the export is running and that export later fails, a successful independent_fresh retry skips #settledExportUnavailable and returns no siblingUnavailability. binary_session keeps advertising procedure_assembly and analyze_function as available, although both will fail until the target is reopened. This costs users another failed call.

Share the failed-export facts between regular and independent single-function answers without sharing their cached text.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/kuna/KunaSessionClient.ts
Line: 869-876

Comment:
**Failed tools stay listed**

If a regular pseudocode call returns while the export is running and that export later fails, a successful `independent_fresh` retry skips `#settledExportUnavailable` and returns no `siblingUnavailability`. `binary_session` keeps advertising `procedure_assembly` and `analyze_function` as available, although both will fail until the target is reopened. This costs users another failed call.

Share the failed-export facts between regular and independent single-function answers without sharing their cached text.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Codex

@morluto morluto added area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior enhancement New feature or request provider: kuna Analysis provider / engine: kuna 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 provider: kuna Analysis provider / engine: kuna

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants