[GH-ISSUE #5271] feat(ghidra): run long analyses as background jobs with bounded waits #3218

Open
opened 2026-10-31 00:37:58 +00:00 by bsakaguchi · 2 comments
Owner

Originally created by @goncalompontes on GitHub (Oct 19, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/5271

Title

feat(ghidra): run long analyses as background jobs with bounded waits

Problem

open_binary blocks one MCP call for the whole Ghidra import and auto-analysis. Long analyses (#3751 measured 74 minutes on a 191 MiB binary) either exceed the startup deadline or the client's idle timeout (#3509).

Cancellation discards the work. An aborted or timed-out request reaches a forced stop, which skips the project-cache publish and removes the runtime, so the next open starts over.

Coding agents also run inside LLM prompt caches with reported TTLs of 5 to 30 minutes. A long blocking call leaves the model idle, and the next turn may re-read the context uncached. This is reasoning from the reported TTLs, not a measurement.

Proposal

  • Optional background analysis. open_binary gains analysis_mode (foreground default, background, experimental auto). The job is owned by the MCP server, and no request's cancellation stops it.
  • Bounded waits. binary_session and analysis tools take wait_ms (default 180 s, max 290 s). A call on a still-starting target returns analysis_in_progress with elapsed time and progress.
  • auto promotes a foreground open to a background job after a configured run time (default 120 s).
  • close_binary cancels a job through the existing forced-stop path. No new tool.
  • The CLI refuses background mode, because a one-shot process cannot own a job.

Limitation accepted for v1: a job ends with its server process. A detached supervisor is a separate question.

  • #3509 (idle-timeout cancellation), #3751 (long analyses; pre-analysed projects), #1048.
  • #3531 (project cache; the publish path this depends on), #4161 (progress notifications), #4439 (streamed progress and an analysis cache). Both touch the same provider code, so their owners should be consulted.

Design

Design draft: docs/specs/analysis-jobs/spec.md on design/analysis-jobs (uncommitted). It depends on the per-target slot model in the multi-target draft.

Scope check

This changes the open_binary and binary_session contracts and provider process lifetime. Per CONTRIBUTING.md, a maintainer scope decision is needed before substantial implementation.

Verification plan

Unit tests with the client factory seam; MCP stdio boundary test with fakeGhidra; and a real Ghidra 12.1.4 Linux run covering foreground versus background, a client abort mid-wait, and server exit mid-job. Results will be reported as observed.

Originally created by @goncalompontes on GitHub (Oct 19, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/5271 ## Title feat(ghidra): run long analyses as background jobs with bounded waits ## Problem `open_binary` blocks one MCP call for the whole Ghidra import and auto-analysis. Long analyses (#3751 measured 74 minutes on a 191 MiB binary) either exceed the startup deadline or the client's idle timeout (#3509). Cancellation discards the work. An aborted or timed-out request reaches a forced stop, which skips the project-cache publish and removes the runtime, so the next open starts over. Coding agents also run inside LLM prompt caches with reported TTLs of 5 to 30 minutes. A long blocking call leaves the model idle, and the next turn may re-read the context uncached. This is reasoning from the reported TTLs, not a measurement. ## Proposal - Optional background analysis. `open_binary` gains `analysis_mode` (`foreground` default, `background`, experimental `auto`). The job is owned by the MCP server, and no request's cancellation stops it. - Bounded waits. `binary_session` and analysis tools take `wait_ms` (default 180 s, max 290 s). A call on a still-starting target returns `analysis_in_progress` with elapsed time and progress. - `auto` promotes a foreground open to a background job after a configured run time (default 120 s). - `close_binary` cancels a job through the existing forced-stop path. No new tool. - The CLI refuses background mode, because a one-shot process cannot own a job. Limitation accepted for v1: a job ends with its server process. A detached supervisor is a separate question. ## Related - #3509 (idle-timeout cancellation), #3751 (long analyses; pre-analysed projects), #1048. - #3531 (project cache; the publish path this depends on), #4161 (progress notifications), #4439 (streamed progress and an analysis cache). Both touch the same provider code, so their owners should be consulted. ## Design Design draft: `docs/specs/analysis-jobs/spec.md` on `design/analysis-jobs` (uncommitted). It depends on the per-target slot model in the multi-target draft. ## Scope check This changes the `open_binary` and `binary_session` contracts and provider process lifetime. Per CONTRIBUTING.md, a maintainer scope decision is needed before substantial implementation. ## Verification plan Unit tests with the client factory seam; MCP stdio boundary test with `fakeGhidra`; and a real Ghidra 12.1.4 Linux run covering foreground versus background, a client abort mid-wait, and server exit mid-job. Results will be reported as observed.
Author
Owner

@goncalompontes commented on GitHub (Oct 19, 2026):

Design draft is now visible: analysis-jobs spec and tasks. It is committed at 219535a95 on the fork branch design/analysis-jobs. The companion multi-target design is here, and it defines the per-target slots these jobs run in. Feedback welcome, especially on O3 (whether a detached supervisor belongs in v2).

<!-- gh-comment-id:6273083188 --> @goncalompontes commented on GitHub (Oct 19, 2026): Design draft is now visible: [analysis-jobs spec](https://github.com/goncalompontes/rea/blob/219535a95/docs/specs/analysis-jobs/spec.md) and [tasks](https://github.com/goncalompontes/rea/blob/219535a95/docs/specs/analysis-jobs/tasks.md). It is committed at `219535a95` on the fork branch [`design/analysis-jobs`](https://github.com/goncalompontes/rea/tree/design/analysis-jobs). The companion multi-target design is [here](https://github.com/goncalompontes/rea/blob/219535a95/docs/specs/multi-target-sessions/spec.md), and it defines the per-target slots these jobs run in. Feedback welcome, especially on O3 (whether a detached supervisor belongs in v2).
Author
Owner

@goncalompontes commented on GitHub (Oct 19, 2026):

Draft implementation is on the stacked branch: https://github.com/goncalompontes/rea/pull/2 (delta from the multi-target PR). It adds analysis_mode=background/auto, job-owned starts, wait_ms, analysis_in_progress, and analysis state. Upstream PR creation was rejected by GitHub permissions for the second PR; the compare link is https://github.com/morluto/rea/compare/main...goncalompontes:feat/background-analysis-jobs?expand=1.

<!-- gh-comment-id:6274857515 --> @goncalompontes commented on GitHub (Oct 19, 2026): Draft implementation is on the stacked branch: https://github.com/goncalompontes/rea/pull/2 (delta from the multi-target PR). It adds analysis_mode=background/auto, job-owned starts, wait_ms, analysis_in_progress, and analysis state. Upstream PR creation was rejected by GitHub permissions for the second PR; the compare link is https://github.com/morluto/rea/compare/main...goncalompontes:feat/background-analysis-jobs?expand=1.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#3218
No description provided.