[PR #7049] [MERGED] feat(mcp): support runtime analysis limit recovery #7605

Closed
opened 2026-11-03 13:39:03 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/7049
Author: @morluto
Created: 10/24/2026
Status: ✅ Merged
Merged: 10/25/2026
Merged by: @morluto

Base: main ← Head: codex/runtime-analysis-settings


📝 Commits (10+)

  • 637c0e7 feat(mcp): support runtime analysis limit recovery
  • 77b96b4 refactor(config): remove unused limit re-exports
  • abeb95b fix(android): keep fixture release metadata dependency-free
  • c1642f5 fix(settings): preserve provider budgets and recovery facts
  • e682853 Merge remote-tracking branch 'origin/main' into codex/runtime-analysis-settings
  • bf4246b fix(tests): resolve lint plugins from their repository owner
  • 3b0a70a refactor(mcp): verify guidance delivery without frozen wording
  • 0a9c922 fix(android): align availability with runtime timeout
  • 1ecfd4e test(recovery): assert limit facts instead of frozen wording
  • e487f92 fix(mcp): share runtime settings with the default JADX provider

📊 Changes

120 files changed (+2899 additions, -884 deletions)

View changed files

📝 .agents/skills/reverse-engineer-anything/references/connection-and-recovery.md (+11 -0)
📝 .agents/skills/reverse-engineer-anything/references/javascript-applications.md (+7 -3)
📝 .agents/skills/reverse-engineer-anything/references/native-and-artifacts.md (+12 -8)
📝 bridge/ghidra/ReaGhidraBridge.java (+17 -4)
📝 docs/design/limits-and-recovery.md (+85 -26)
📝 docs/mcp-contracts.md (+16 -0)
📝 docs/testing.md (+10 -0)
➕ docs/verification/runtime-analysis-settings.md (+83 -0)
📝 scripts/lib/catalog-builders.mjs (+1 -0)
📝 scripts/lib/catalog-core.mjs (+1 -0)
📝 scripts/verify-real-ghidra-decompile-timeout.mjs (+26 -3)
📝 src/adb/AdbCommand.test.ts (+7 -17)
📝 src/adb/AdbVersionProbe.test.ts (+12 -8)
📝 src/android/JadxConfiguration.ts (+17 -6)
📝 src/android/JadxFailure.ts (+1 -1)
📝 src/android/JadxJavaProbe.ts (+1 -1)
📝 src/android/JadxOperationTimeout.test.ts (+14 -8)
➕ src/android/JadxOperationTimeout.ts (+16 -0)
📝 src/android/JadxProvider.ts (+11 -4)
📝 src/android/JadxRelease.ts (+1 -14)

...and 80 more files

📄 Description

Summary

Allow agents to recover from REA-owned admission, timeout and worker-heap limits through MCP, then retry the original request without restarting REA. Related: #6176.

Problem and expected behavior

An ASAR index above the default 16 MiB admission could prevent full-archive analysis even when the machine had capacity. Changing launch configuration could not repair a running MCP server. A returned limit now identifies its editable setting and bounds; the agent can update it directly and retry the same archive on the same connection.

Change and scope

Add inspect_analysis_settings and update_analysis_settings for 11 curated defaults across ASAR, Ghidra/Hopper startup, Ghidra decompilation, JADX, regex, capture decoding, JavaScript and WABT. Updates are atomic, support reset and optional revision checks, survive target close/open, and disappear on REA restart. Explicit per-call arguments win; accepted work keeps its snapshot. No framework dependency or upstream changes. JADX release metadata stays dependency-free for pre-install fixture scripts. Invalid JADX launch settings remain provider-local and can be inspected, replaced and reset through MCP. IDA consumes the shared regex controls; Ghidra is excluded from those controls. WASM preserves omitted caller parameters separately from its effective budget, including partial Evidence; shared error copies preserve structured limit recovery.

Contract and boundary impact

  • Semantic owner and earliest changed stage: AnalysisSettings owns validated runtime overrides and accepted-operation snapshots. Pure domain definitions share existing bounds with environment parsers; injected readers reach provider composition. Removed superseded constant declarations and unused re-exports; launch parsing and provider lifecycle ownership remain distinct.
  • Contribution scope fit and linked maintainer decision: existing local analysis controls; no new target-execution, injection, mutation or protection-recovery authority. Separate scope decision not applicable.
  • CLI and MCP/tool-catalog contract: two named MCP tools; typed details.limit recovery metadata. CLI launch/per-call controls remain supported.
  • Provider, bridge, target-format, or platform compatibility: additive Ghidra request deadline field, with launch-descriptor fallback when omitted. Existing bounds/defaults retained.
  • Evidence, artifact, provenance, or reconstruction contract: preserve caller inputs and Evidence. Transient Ghidra failures remain uncached; cached ASAR headers are rechecked against lowered admission.
  • Target selection, authority, upstream behavior, and cleanup: updates neither retry work nor restart providers or clear cleanup blockers. Host deadlines/buffers and fixed limits remain separately reported.
  • Generated metadata, package, or installation impact: update catalog family ownership and authored skill guidance; setup forwards REA_ASAR_MAX_HEADER_BYTES. No dependency or generated-output commit.

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.

The setter changes runtime configuration only. Existing analysis workflows retain their owned worker/provider launches and local bridge communication.

Evidence and regression coverage

  • Tests added or updated: atomic validation, revision conflicts, reset/isolation, explicit argument precedence, deferred-handler snapshots, target close/open persistence, cached-header decreases, and SDK-converted schemas.
  • Executed reproduction: built stdio MCP rejects a valid >16 MiB ASAR index, accepts a 32 MiB runtime admission, and completes unchanged full-archive inventory and JavaScript analysis. Reset rejects it again.
  • Real Ghidra: a natural one-second timeout recovers the same slow function after a 60-second runtime update, retaining the same Program/session run ID; subsequent analysis and cleanup succeed.
  • Representative MCP call: update_analysis_settings({"changes":[{"setting":"asar.max_header_bytes","action":"set","value":33554432}]}) returns revision: 1, active_work_changed: false, and rea_restart_required: false.
  • Remaining proof gaps: synthetic ASAR rather than the original Loom archive; real engine coverage is Ghidra on macOS. Other providers have source/boundary coverage. Linux/Windows engines and Bun are unverified for this change.

Boundary coverage includes admission before allocation, immutable accepted budgets during overlapping writes, cache revalidation, and preserved cleanup/queue regressions. See verification and task-cost measurements.

  • 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

  • Merge validation against main at ab720b421: 54 focused tests passed, with two platform skips; full npm run check and npm run docs:check passed. Preserved main's move of CLI coverage declarations into the boundary test and retained both MCP-only settings entries there.

  • Recovery assertion cleanup: 300 distinct tests across 27 source, boundary and acceptance files passed, including the failing ASAR boundary case, full-archive MCP update/retry/reset, real HAR heap exhaustion, retained timeout Evidence, bridge admission and startup cleanup. Assertions use structured facts or canonical guidance delivery instead of frozen explanatory wording. Testing guidance records this convention.

  • Mutation verification: a harmless regex-recovery rewording passed; a deliberately incorrect effective deadline failed the structured assertion. Both mutations were restored.

  • npm run check passed, including typecheck, lint/module boundaries, formatting, metadata, architecture, unused-code/reachability checks and typed lint. npm run docs:check passed, including 9 consistency tests; discovery found all 2,465 test files once.

  • Earlier feature verification: real Ghidra 12.1.4 / Java 21 timeout recovery passed on macOS with session reuse and complete cleanup. JADX availability/execution repair, Android fixture bootstrap without installed dependencies, lint-plugin resolution in temporary checkouts, IDA regex recovery and WABT partial Evidence passed their focused regressions. Simulated providers do not establish real-engine behavior.

  • Review follow-up: 42 distinct focused tests passed, with two platform skips. The embedded-server regression failed before repair and now proves that default JADX composition consumes runtime updates and reset. It deliberately stops at the missing-JAR prerequisite; this is not a real-JADX execution claim. All deferred-server gates now use bounded acknowledgements and release/join work in finally; injected failures at the two reviewed gates exited in 0.6 seconds without teardown timeouts.

  • CI follow-up: the ASAR shard now passes. A later shard exposed missing MCP-only declarations for the two settings tools; that failure was reproduced locally and fixed in the catalog owner, preserving the CLI coverage assertion. A complete new-head CI pass remains pending.

Compatibility, safety, and release

  • Breaking changes or migration steps: none; overrides are opt-in and runtime-only.
  • Real Hopper/Ghidra, browser, or OS coverage: Ghidra/macOS verified; other real-provider/platform gaps listed above.
  • Package or release metadata impact: additive MCP catalog entries; no version bump or new dependency.
  • Security, privacy, process, or containment review: finite schema-bound settings, no arbitrary environment/path writes; externally owned limits remain outside setter authority. Inspection explicitly leaves active worker values unobserved.

Author readiness

Human owner: @morluto

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

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/7049 **Author:** [@morluto](https://github.com/morluto) **Created:** 10/24/2026 **Status:** ✅ Merged **Merged:** 10/25/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `codex/runtime-analysis-settings` --- ### 📝 Commits (10+) - [`637c0e7`](https://github.com/morluto/rea/commit/637c0e73982eb781efb4e724712b4d0772e01f9e) feat(mcp): support runtime analysis limit recovery - [`77b96b4`](https://github.com/morluto/rea/commit/77b96b441778ba5a8312f97e074ffb23bdb2052e) refactor(config): remove unused limit re-exports - [`abeb95b`](https://github.com/morluto/rea/commit/abeb95b4fde64a62dcf62971b70b93262d9b5940) fix(android): keep fixture release metadata dependency-free - [`c1642f5`](https://github.com/morluto/rea/commit/c1642f5f8e3cec8dee60512e8caca5dc169e15d4) fix(settings): preserve provider budgets and recovery facts - [`e682853`](https://github.com/morluto/rea/commit/e682853fca904c6105bae27af84133927543079b) Merge remote-tracking branch 'origin/main' into codex/runtime-analysis-settings - [`bf4246b`](https://github.com/morluto/rea/commit/bf4246b30df9ccee98bee87d12bf5d9789d2a0b5) fix(tests): resolve lint plugins from their repository owner - [`3b0a70a`](https://github.com/morluto/rea/commit/3b0a70a49b71c47f16bff6a1af5fa2283e610cd8) refactor(mcp): verify guidance delivery without frozen wording - [`0a9c922`](https://github.com/morluto/rea/commit/0a9c92237a1a7c7a36a535bbab10cd80e8bd1088) fix(android): align availability with runtime timeout - [`1ecfd4e`](https://github.com/morluto/rea/commit/1ecfd4e05d5fbbdb95e25e9d0892657d81e3c6c5) test(recovery): assert limit facts instead of frozen wording - [`e487f92`](https://github.com/morluto/rea/commit/e487f920a34109d48eb4312a98109b2940fac233) fix(mcp): share runtime settings with the default JADX provider ### 📊 Changes **120 files changed** (+2899 additions, -884 deletions) <details> <summary>View changed files</summary> 📝 `.agents/skills/reverse-engineer-anything/references/connection-and-recovery.md` (+11 -0) 📝 `.agents/skills/reverse-engineer-anything/references/javascript-applications.md` (+7 -3) 📝 `.agents/skills/reverse-engineer-anything/references/native-and-artifacts.md` (+12 -8) 📝 `bridge/ghidra/ReaGhidraBridge.java` (+17 -4) 📝 `docs/design/limits-and-recovery.md` (+85 -26) 📝 `docs/mcp-contracts.md` (+16 -0) 📝 `docs/testing.md` (+10 -0) ➕ `docs/verification/runtime-analysis-settings.md` (+83 -0) 📝 `scripts/lib/catalog-builders.mjs` (+1 -0) 📝 `scripts/lib/catalog-core.mjs` (+1 -0) 📝 `scripts/verify-real-ghidra-decompile-timeout.mjs` (+26 -3) 📝 `src/adb/AdbCommand.test.ts` (+7 -17) 📝 `src/adb/AdbVersionProbe.test.ts` (+12 -8) 📝 `src/android/JadxConfiguration.ts` (+17 -6) 📝 `src/android/JadxFailure.ts` (+1 -1) 📝 `src/android/JadxJavaProbe.ts` (+1 -1) 📝 `src/android/JadxOperationTimeout.test.ts` (+14 -8) ➕ `src/android/JadxOperationTimeout.ts` (+16 -0) 📝 `src/android/JadxProvider.ts` (+11 -4) 📝 `src/android/JadxRelease.ts` (+1 -14) _...and 80 more files_ </details> ### 📄 Description ## Summary Allow agents to recover from REA-owned admission, timeout and worker-heap limits through MCP, then retry the original request without restarting REA. Related: #6176. ## Problem and expected behavior An ASAR index above the default 16 MiB admission could prevent full-archive analysis even when the machine had capacity. Changing launch configuration could not repair a running MCP server. A returned limit now identifies its editable setting and bounds; the agent can update it directly and retry the same archive on the same connection. ## Change and scope Add `inspect_analysis_settings` and `update_analysis_settings` for 11 curated defaults across ASAR, Ghidra/Hopper startup, Ghidra decompilation, JADX, regex, capture decoding, JavaScript and WABT. Updates are atomic, support reset and optional revision checks, survive target close/open, and disappear on REA restart. Explicit per-call arguments win; accepted work keeps its snapshot. No framework dependency or upstream changes. JADX release metadata stays dependency-free for pre-install fixture scripts. Invalid JADX launch settings remain provider-local and can be inspected, replaced and reset through MCP. IDA consumes the shared regex controls; Ghidra is excluded from those controls. WASM preserves omitted caller parameters separately from its effective budget, including partial Evidence; shared error copies preserve structured limit recovery. ## Contract and boundary impact - Semantic owner and earliest changed stage: `AnalysisSettings` owns validated runtime overrides and accepted-operation snapshots. Pure domain definitions share existing bounds with environment parsers; injected readers reach provider composition. Removed superseded constant declarations and unused re-exports; launch parsing and provider lifecycle ownership remain distinct. - Contribution scope fit and linked maintainer decision: existing local analysis controls; no new target-execution, injection, mutation or protection-recovery authority. Separate scope decision not applicable. - CLI and MCP/tool-catalog contract: two named MCP tools; typed `details.limit` recovery metadata. CLI launch/per-call controls remain supported. - Provider, bridge, target-format, or platform compatibility: additive Ghidra request deadline field, with launch-descriptor fallback when omitted. Existing bounds/defaults retained. - Evidence, artifact, provenance, or reconstruction contract: preserve caller inputs and Evidence. Transient Ghidra failures remain uncached; cached ASAR headers are rechecked against lowered admission. - Target selection, authority, upstream behavior, and cleanup: updates neither retry work nor restart providers or clear cleanup blockers. Host deadlines/buffers and fixed limits remain separately reported. - Generated metadata, package, or installation impact: update catalog family ownership and authored skill guidance; setup forwards `REA_ASAR_MAX_HEADER_BYTES`. No dependency or generated-output commit. Expected effects: - [x] Read existing files or captured data. - [x] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [x] 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. The setter changes runtime configuration only. Existing analysis workflows retain their owned worker/provider launches and local bridge communication. ## Evidence and regression coverage - Tests added or updated: atomic validation, revision conflicts, reset/isolation, explicit argument precedence, deferred-handler snapshots, target close/open persistence, cached-header decreases, and SDK-converted schemas. - Executed reproduction: built stdio MCP rejects a valid >16 MiB ASAR index, accepts a 32 MiB runtime admission, and completes unchanged full-archive inventory and JavaScript analysis. Reset rejects it again. - Real Ghidra: a natural one-second timeout recovers the same slow function after a 60-second runtime update, retaining the same Program/session run ID; subsequent analysis and cleanup succeed. - Representative MCP call: `update_analysis_settings({"changes":[{"setting":"asar.max_header_bytes","action":"set","value":33554432}]})` returns `revision: 1`, `active_work_changed: false`, and `rea_restart_required: false`. - Remaining proof gaps: synthetic ASAR rather than the original Loom archive; real engine coverage is Ghidra on macOS. Other providers have source/boundary coverage. Linux/Windows engines and Bun are unverified for this change. Boundary coverage includes admission before allocation, immutable accepted budgets during overlapping writes, cache revalidation, and preserved cleanup/queue regressions. See [verification and task-cost measurements](https://github.com/morluto/rea/blob/codex/runtime-analysis-settings/docs/verification/runtime-analysis-settings.md). - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed - Merge validation against `main` at `ab720b421`: 54 focused tests passed, with two platform skips; full `npm run check` and `npm run docs:check` passed. Preserved main's move of CLI coverage declarations into the boundary test and retained both MCP-only settings entries there. - Recovery assertion cleanup: 300 distinct tests across 27 source, boundary and acceptance files passed, including the failing ASAR boundary case, full-archive MCP update/retry/reset, real HAR heap exhaustion, retained timeout Evidence, bridge admission and startup cleanup. Assertions use structured facts or canonical guidance delivery instead of frozen explanatory wording. Testing guidance records this convention. - Mutation verification: a harmless regex-recovery rewording passed; a deliberately incorrect effective deadline failed the structured assertion. Both mutations were restored. - `npm run check` passed, including typecheck, lint/module boundaries, formatting, metadata, architecture, unused-code/reachability checks and typed lint. `npm run docs:check` passed, including 9 consistency tests; discovery found all 2,465 test files once. - Earlier feature verification: real Ghidra 12.1.4 / Java 21 timeout recovery passed on macOS with session reuse and complete cleanup. JADX availability/execution repair, Android fixture bootstrap without installed dependencies, lint-plugin resolution in temporary checkouts, IDA regex recovery and WABT partial Evidence passed their focused regressions. Simulated providers do not establish real-engine behavior. - Review follow-up: 42 distinct focused tests passed, with two platform skips. The embedded-server regression failed before repair and now proves that default JADX composition consumes runtime updates and reset. It deliberately stops at the missing-JAR prerequisite; this is not a real-JADX execution claim. All deferred-server gates now use bounded acknowledgements and release/join work in `finally`; injected failures at the two reviewed gates exited in 0.6 seconds without teardown timeouts. - CI follow-up: the ASAR shard now passes. A later shard exposed missing MCP-only declarations for the two settings tools; that failure was reproduced locally and fixed in the catalog owner, preserving the CLI coverage assertion. A complete new-head CI pass remains pending. ## Compatibility, safety, and release - Breaking changes or migration steps: none; overrides are opt-in and runtime-only. - Real Hopper/Ghidra, browser, or OS coverage: Ghidra/macOS verified; other real-provider/platform gaps listed above. - Package or release metadata impact: additive MCP catalog entries; no version bump or new dependency. - Security, privacy, process, or containment review: finite schema-bound settings, no arbitrary environment/path writes; externally owned limits remain outside setter authority. Inspection explicitly leaves active worker values unobserved. ## Author readiness Human owner: @morluto - [x] 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. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 13:39:03 +00:00
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#7605
No description provided.