Skip to content

feat(mcp): support runtime analysis limit recovery - #7049

Merged
morluto merged 13 commits into
mainfrom
codex/runtime-analysis-settings
Oct 25, 2026
Merged

morluto merged 13 commits into
mainfrom
codex/runtime-analysis-settings

Conversation

@morluto

@morluto morluto commented Oct 24, 2026 •

Copy link
Copy Markdown
Owner

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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 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-25T01:21:04.001260Z 62a5d16 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.

@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: abeb95b4fd

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/application/AnalysisSettings.ts Resolved
@greptile-apps

greptile-apps Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[High impact] The PR appears safe to merge; no new blocking issue was found.

Summary

Adds two MCP tools to inspect and update 11 runtime analysis defaults, allowing agents to adjust supported limits and retry without restarting REA.

  • MCP agents can change REA-owned analysis limits and retry work without restarting REA.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[MCP settings update] --> B[Validate complete change]
  B --> C[Publish new revision]
  C --> D[Next tool call captures settings]
  D --> E[Provider reads accepted values]
  E --> F[Analysis result or structured limit]
  F --> A
  G[Already accepted work] --> H[Keep earlier settings]
Loading

Reviews (7) · Last reviewed commit: "chore: merge main into runtime analysis ..." · Reviewed by Greptile

Comment thread src/main/eagerRuntime.ts Resolved
Comment thread src/process/RegexMatcher.ts Resolved
Comment thread src/domain/analysisErrorBase.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: 3b0a70a49b

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/config/runtimeAnalysisSettings.ts Resolved
Comment thread src/android/JadxProvider.ts Resolved
Comment thread src/server/createServer.ts Resolved
@morluto
morluto merged commit f3ed165 into main Oct 25, 2026
47 of 49 checks passed
@morluto
morluto deleted the codex/runtime-analysis-settings branch October 25, 2026 01:45
@morluto morluto mentioned this pull request Oct 25, 2026
3 tasks done
kaoru0822-kitauji added a commit that referenced this pull request Oct 25, 2026
* fix(mcp)!: return a compact binary_session status by default

binary_session {} with no target open returned about 66 KB, most of it
provider rejection diagnostics and candidate capability sets that the
skill's recovery flow re-reads on every retry. 6.8.0 grew it by 21%
because the shared regex capability limitation began repeating setting
bounds and step-by-step recovery for every search operation of every
provider (#6099, #6267, #6301, #7049) and IDA gained that limitation for
its two search operations (#4862).

The regex limitation now states the effective deadline and heap, their
sources and where to change them; the deadline and heap errors keep the
full recovery. binary_session gains detail: summary (default) or
complete. The summary keeps open state, target identity, the binding,
route capabilities, run, activity and health status, each candidate's
availability and target-support status, code and reason, and every
tool's availability, reason, remediation and modes, and lists the
fields it leaves out in omitted_fields. Complete detail returns the
previous shape. The CLI capabilities and providers commands keep
complete provider facts through the same application projection.

BREAKING CHANGE: binary_session {} no longer returns
analysis_provider_candidates[].availability.diagnostics,
target_support.diagnostics or capabilities, or tool_availability group
surface, effects and annotations. Pass {"detail": "complete"} to get
them.

Fixes #7109

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(mcp): key binary_session output fields by detail

The output schema accepted detail: "complete" with summary candidates or
tool groups, and a summary without omitted_fields, so detail did not
tell callers which fields existed. Each session kind is now crossed
with a detail-specific shape: a summary requires omitted_fields and
summary-only candidates and tool groups; complete requires diagnostics,
candidate capabilities and static tool flags and forbids omitted_fields.
Both the canonical schema and the SDK-validated advertised schema reject
mismatched shapes.

The verifier helper accepts summary candidates only for a validated MCP
summary; CLI provider output still requires candidate capabilities.
Regex limitation tests check values, sources and setting names instead
of whole sentences.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
XiaoBinGan added a commit to XiaoBinGan/rea that referenced this pull request Oct 27, 2026
The provenance section says the untrusted-content marker is on by default and
that "only export_evidence_bundle and record_unknown" omit it. The audited set
has four members:

    export const TARGET_CONTENT_FREE_TOOLS: ReadonlySet<string> = new Set([
      "inspect_analysis_settings",
      "update_analysis_settings",
      "export_evidence_bundle",
      "record_unknown",
    ]);

f3ed165 (feat(mcp): support runtime analysis limit recovery, morluto#7049) added the
two settings tools to that set; its docs hunk did not touch this sentence, so
the exhaustive list there is now short by two names.

Observed through a stdio session: inspect_analysis_settings and
update_analysis_settings return no _meta.provenance, while a tool outside the
set such as list_adb_devices returns
_meta.provenance = {untrusted_content: true, source: "analysis_target"}.

Fixes morluto#7327.
XiaoBinGan added a commit to XiaoBinGan/rea that referenced this pull request Oct 27, 2026
The provenance section says the untrusted-content marker is on by default and
that "only export_evidence_bundle and record_unknown" omit it. The audited set
has four members:

    export const TARGET_CONTENT_FREE_TOOLS: ReadonlySet<string> = new Set([
      "inspect_analysis_settings",
      "update_analysis_settings",
      "export_evidence_bundle",
      "record_unknown",
    ]);

f3ed165 (feat(mcp): support runtime analysis limit recovery, morluto#7049) added the
two settings tools to that set; its docs hunk did not touch this sentence, so
the exhaustive list there is now short by two names.

Observed through a stdio session: inspect_analysis_settings and
update_analysis_settings return no _meta.provenance, while a tool outside the
set such as list_adb_devices returns
_meta.provenance = {untrusted_content: true, source: "analysis_target"}.

Fixes morluto#7327.
XiaoBinGan added a commit to XiaoBinGan/rea that referenced this pull request Oct 27, 2026
The provenance section says the untrusted-content marker is on by default and
that "only export_evidence_bundle and record_unknown" omit it. The audited set
has four members:

    export const TARGET_CONTENT_FREE_TOOLS: ReadonlySet<string> = new Set([
      "inspect_analysis_settings",
      "update_analysis_settings",
      "export_evidence_bundle",
      "record_unknown",
    ]);

f3ed165 (feat(mcp): support runtime analysis limit recovery, morluto#7049) added the
two settings tools to that set; its docs hunk did not touch this sentence, so
the exhaustive list there is now short by two names.

Observed through a stdio session: inspect_analysis_settings and
update_analysis_settings return no _meta.provenance, while a tool outside the
set such as list_adb_devices returns
_meta.provenance = {untrusted_content: true, source: "analysis_target"}.

Fixes morluto#7327.
Plastic-time added a commit to Plastic-time/rea that referenced this pull request Nov 1, 2026
The provenance guide named export_evidence_bundle, record_unknown,
search_guidance and read_guidance_section as the only tools whose results
omit _meta.provenance. TARGET_CONTENT_FREE_TOOLS also exempts
inspect_analysis_settings and update_analysis_settings (morluto#7049) and
guided_workflows (morluto#6995), so a reader of the guide expected markers those
tools never send.

List all seven, and assert in the existing provenance conformance test that
the documented list equals TARGET_CONTENT_FREE_TOOLS, so the next audited
exception cannot be missed again.

Fixes morluto#7327.
@morluto morluto added area: mcp MCP server, transport, and tool registration enhancement New feature or request labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: mcp MCP server, transport, and tool registration enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant