Skip to content

feat(ghidra): bound one procedure's decompile without closing the session - #5662

Merged
gensokyo-dev merged 20 commits into
morluto:mainfrom
RishTheFish21:feat/ghidra-decompile-timeout
Oct 23, 2026
Merged

gensokyo-dev merged 20 commits into
morluto:mainfrom
RishTheFish21:feat/ghidra-decompile-timeout

Conversation

@RishTheFish21

@RishTheFish21 RishTheFish21 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #5340.

An opt-in REA_GHIDRA_DECOMPILE_TIMEOUT_SECONDS bounds each native decompile without asking Ghidra to close the session. Unset remains unbounded; 1–2,147,483 whole seconds follows Ghidra's signed-int millisecond conversion.

Function dossiers retain listing facts, mark pseudocode/native API/value flow unavailable and remain live for retry. Atomic decompiles return the existing provider_timeout contract with retryable: true, timeout_ms and remote_code: decompile_timed_out. Caller cancellation still closes the session. Queue-owned wording preserves cancellation and incomplete-cleanup facts; Java regex failures describe engine facts, with lifecycle interpreted by the same provider owner.

The function capability advertises this optional control. Derived setup deadlines are single-decompile estimates. Multi-function calls, including trace_native_values, need allowance for every attempted function and other work; callers can select fewer functions, split/resume exports or change their client deadline. Existing positive deadlines are preserved. No tool schema changes.

Validation:

  • Full npm run check and docs:check passed on the published implementation; all 42 deadline/registration cases passed. The preceding provider/queue/session selection had 236 passes and one independently reproduced main SIGKILL wording failure.
  • Real Linux Ghidra 12.1.4 / JDK 21 lane: 41 Java checks, actual one-second-configured provider capability and complete cleanup. Old production fails the new capability and trace-advice assertions. The earlier pinned natural timeout, CLI/MCP, same-session reuse, two-item batch and maximum-setting export/resume observations are retained in the report. Refreshed full-inventory verification encounters an independent main symbol schema error; it is not claimed as passing.
  • Earlier paired complete MCP task: 237.602 → 95.388 s elapsed, 232.779 → 90.945 s waited CPU, 2051.3 → 2008.8 MiB sampled family RSS; estimated context 983,317 → 989,913 tokens (+0.67%). Avoiding re-imports explains this fixture's result. Later main/capability wording costs were not measured by that pair.
  • CI 40038742775: all 13 failed/cancelled job logs, aggregation and terminal diagnostics audited. All 1,066 visible assertion markers map to independently observed main failures. The intermittent Kuna doctor case has both passing and failing exact-base controls; its cancelled CI log lacks a full diagnostic, so diagnostic equality is not claimed. PR title/readiness checks pass. See the maintenance comment for attribution and the authorized CI bypass.

Verification report. Maintenance real-provider scope is Linux; Windows/macOS, natural regex overflow, long client timers and large-batch capacity remain unverified. Targets were never executed. The verifier rejects oversized fixture overrides before allocation using a 1 MiB generated-source budget.

Contribution scope: optional resource control within the existing static Ghidra workflow, with no new provider, target execution, injection, executable mutation or attached-GUI authority.

Author readiness

Human owner: @RishTheFish21

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 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-10-23T23:23:42.610062Z fb6c88d 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 Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the remaining regex wording issue is non-blocking.

Findings

  1. P2 Closed session called usable ▶
Fix with agent prompt
### Issue 1
src/ghidra/GhidraProviderClient.ts:979-982
The cancellation-aware fix changes only `remediationAction`. The real `regex_stack_exhausted` message still says “the session remains usable,” and this branch passes it unchanged into the public error. When cancellation closes the session while that failure settles, callers get conflicting answers and may expect session-only annotations to survive.

Keep session-state wording in one place, and test the actual bridge message rather than “Observed Ghidra failure.”

---

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

Summary

Adds an optional native decompile deadline while keeping the Ghidra session open.

  • Ghidra can stop one slow decompile and keep the session available.
  • Setup estimates a client deadline for one Ghidra decompile.
  • Cancellation explanations preserve both the Ghidra failure and session state.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Native decompile] --> B{Deadline reached?}
  B -->|No| C[Return decompiled facts]
  B -->|Yes| D{Request type}
  D -->|analyze_function| E[Return listing facts and unavailable decompiler facets]
  D -->|Atomic request| F[Return provider_timeout]
  E --> G[Keep session open]
  F --> G
  A -->|Caller cancels| H[Close session and await cleanup]
Loading

Reviews (5) · Last reviewed commit: "merge: preserve Ghidra OOM diagnostics a..." · Reviewed by Greptile

Comment thread src/ghidra/GhidraProviderClient.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e067efd6ed

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/ghidra/GhidraProviderClient.ts Resolved
Keeps BinarySession from marking every Ghidra operation unavailable after one procedure's decompile reaches the limit, and names the MCP tool-call deadline in the remediation.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0f2a2e5e63

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/config/environment.ts Resolved
Comment thread src/ghidra/GhidraProviderClient.ts Resolved
…d sessions

Adds REA_GHIDRA_DECOMPILE_TIMEOUT_SECONDS to the derived Codex/Kimi tool deadline and forwards it through setup. Marks a remote failure that settles after caller cancellation so the timeout projection no longer promises session reuse.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cb754c9258

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/mcpStartupPolicy.ts Resolved
@RishTheFish21

RishTheFish21 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor Author

CI is green after the review follow-ups:

  • the timeout is a request-level provider_timeout, so other Ghidra tools stay available;
  • setup and doctor include the limit in the derived MCP tool deadline;
  • the message no longer promises session reuse when a cancellation closed the session

Comment thread src/ghidra/GhidraProviderClient.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2252af3b40

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/ghidra/GhidraProviderClient.ts Resolved
@gensokyo-dev

gensokyo-dev commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Authorized maintenance merge attribution for head be5cea4096fe56bec7ac63c9d0cbd3b496326288.

  • PR CI checked synthetic merge 28fbfdf128e5e189967b0a328f83821499ff6ab4 over base 960b742581f6f71a573dc30701806f315a9ee986. All failed and all seven cancelled test-shard logs were audited: 671 visible assertion markers, including the Portable tests report aggregation, no unidentified case. The built markers expose 202 distinct failures already present among 226 failed assertions in all eight completed shards of main CI.
  • Source CI has 101 failures: the same 99 cases and complete diagnostics as that main run (only three generated fixture-directory suffixes differ), plus the two SIGKILL wording assertions introduced on 960b74258. Both additional assertions and the OpenCode failure reproduce on that exact base with identical assertion diagnostics and source. Raw stack offsets and an async scheduler frame vary; raw-stack equality is not claimed.
  • The completed failed built shard has 19 assertions also failed on main. Complete diagnostics agree, accounting for two optional Node async scheduler frames. Cancelled shards' additional assertion markers all match failed main cases; cancellation leaves their later coverage unverified.
  • Local selected checks: 427 passed, 10 platform skips, three reproduced baseline failures. Build, check:fast and docs:check passed. The current real explicit-address Ghidra probe confirms the configured timeout, authenticated same per-launch run ID, identical next pseudocode and complete cleanup. The refreshed full verifier's separate inventory symbol schema failure was reproduced on real main; that workflow is not claimed passing.
  • Latest-main admission uses ba9c5bc6867272d02d2fcc9d5c7c2ea83f234067 plus this unchanged PR head. Private validation b4e105a48c381f1f1f86e277f771edf98e37ea6a has tree 8629327e0e799430392702f06530c1c5e1ef603b, exactly the computed merge tree. Full npm run check passed (typecheck, lint, format, knip, metadata and architecture). Every feature source, test, verifier and bridge file is byte-identical to the real-provider-tested PR head.

The Portable tests job merges the available Vitest reports, repeating already-attributed failures; CI required fails because its upstream gates failed. Full historical CI is not green. The authorized bypass applies to the independently established baseline failures above. Performance measurements and platform/coverage limitations remain in the linked verification report; initial human readiness declarations are preserved.

Merge remains pending: two new review findings require a producer/projection wording fix and an explicit existing-deadline setup explanation. These findings are being fixed, not bypassed.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3f2e3a389b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6d8dcdb621

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread bridge/ghidra/ReaGhidraBridge.java Resolved
@gensokyo-dev

Copy link
Copy Markdown
Collaborator

Final admission for head fb6c88d518ab9b84ed396cf82dcb1c28a608c501:

  • CI 40038742775 checked synthetic commit 85b71caadccef3ebad24342ba7bab3b3b4f00dbd, parents main 3d4f55652b25856a9ee810b786e19847fa622a29 and this head; tree aeb6824bbbb293c215f762742c9f568839593d73. Static checks/docs/build pass. PR title and author-readiness checks pass.
  • Completed CI: 9 success, 6 failure, 17 skipped, 7 cancelled. Every failed/cancelled job log was downloaded, including Portable tests and CI required. All 1,066 visible assertion markers (duplicates across reporter output/aggregation included) map to independently observed main failure cases; terminal errors were checked separately. CI required is the downstream gate result.
  • Attribution includes the completed main source/built reports, nine extra cases reproduced on an exact earlier base, 118 JavaScript cases reproduced on exact base 091d6209, all eight completed built shards from that base, and independent main Windows failures. Case matching is not a claim of universal byte-identical diagnostics; paths, timings and some reporter titles differ.
  • One cancelled-only Kuna doctor marker required additional investigation. On the unmodified exact CI base 3d4f5565, the public CLI test first passed (15.276 s case duration), then independently failed at fake Kuna probe did not start. That base's CI also passes the case. The actual PR merge control hit its 20-second CLI deadline. The original cancelled log has only the failure title, so its exact assertion cause remains unavailable. This establishes an intermittent pre-existing case, rather than exact error-message equivalence. Both passing and failing controls are retained.
  • Current main fc2dddc1d9b7f1d26423240ac6f87794428d3b76 also includes local-path admission and native/managed/JavaScript fact fixes. The merge is clean (candidate tree 4baf16b289aedc5ff489a6fb7bd771e8079ac8d8); the intervening CLI path changes were inspected and leave the verified absolute-path native workflow applicable. This is distinct from the earlier CI tree above.
  • Local published-source full npm run check, docs check and 42 deadline/registration tests pass. Real Linux producer verification with a one-second setting passes 41 Java checks plus the actual capability assertion and completes cleanup. All actionable review threads are resolved; the original human owner's declarations remain unchanged.

The repository owner explicitly authorized merging with failures established unrelated to this PR. The above baseline failures are being bypassed on that authorization; they are not reported as green or fixed here. Raw logs, all controls and the audit are under /tmp/rea-maintenance-20261023/5662/ci-capability-trace/.

@gensokyo-dev
gensokyo-dev merged commit a062529 into morluto:main Oct 23, 2026
32 of 46 checks passed
@morluto morluto mentioned this pull request Oct 25, 2026
3 tasks done
taiqi-dev added a commit to taiqi-dev/rea that referenced this pull request Oct 26, 2026
Adapt upstream morluto#5356, morluto#4650 and morluto#5662 to the Windows fork. Preserve listing facts and live retry policy, carry explicit settings into client setup, and qualify natural timeouts with a source-owned Windows DLL. Windows acceptance, default real-provider checks and SDK schema regressions passed; details in the verification record.
@morluto morluto added area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior enhancement New feature or request provider: ghidra Analysis provider / engine: ghidra labels Nov 23, 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: ghidra Analysis provider / engine: ghidra

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Optional per-function Ghidra decompile deadline that fails one request instead of closing the session

3 participants