Skip to content

feat(android): make the JADX operation deadline configurable - #4466

Merged
morluto merged 2 commits into
morluto:mainfrom
SandstromPL:feat/jadx-operation-timeout
Oct 16, 2026
Merged

morluto merged 2 commits into
morluto:mainfrom
SandstromPL:feat/jadx-operation-timeout

Conversation

@SandstromPL

@SandstromPL SandstromPL commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #3918.

JADX operations had two fixed 120-second limits:

  • the provider's whole-operation deadline (OPERATION_TIMEOUT_MS in JadxProvider.ts)
  • a separate per-call bound on every upstream MCP call (timeout: 120_000 in JadxSession.ts)

A large multidex APK whose cold load exceeds 120 s therefore always ended in provider_timeout, and raising only the MCP client's timeout could not extend either limit.

This PR adds an optional setting, REA_JADX_OPERATION_TIMEOUT_MS. It is a decimal millisecond count from 1 to 2147483647, and the default stays 120000. One parsed value bounds both the whole operation and each upstream call. Unset keeps today's behavior.

Problem and expected behavior

  • What the reporter saw: on rea-agents 6.4.0 (macOS arm64, Temurin 21), the operation hit provider_timeout at exactly timeout_ms: 120000 on a large multidex APK. A rea_jvm_status reply was retained, but the load never completed.
  • What wasn't reproduced: no redistributable APK exists, so this was not reproduced, and it is not a confirmed OOM.
  • Expected, per the issue: a caller can select a longer finite deadline, with provider and session deadlines coordinated and the effective value reported. The default, explicit cancellation, bounded output, partial observations and verified owned-process cleanup must be preserved.

Change and scope

  • Parsing (src/android/JadxConfiguration.ts): readOperationTimeout parses the setting once, reusing providerStartupTimeoutSchema. The error text matches REA_KUNA_TIMEOUT_MS.
    • Invalid values get the new failure kind operation_timeout, classified config_drift.
    • The remediation text and DEFAULT_JADX_OPERATION_TIMEOUT_MS live in JadxRelease.ts.
  • Provider (src/android/JadxProvider.ts): #execute resolves the deadline as a Result before acquiring any file handle, workspace or engine.
    • The value feeds AbortSignal.timeout and both AnalysisTimeoutError sites.
    • It is passed to JadxSession.execute. The deadline still starts at the queue front.
    • The fixed constant is removed.
  • Session (src/android/JadxSession.ts): every callTool uses the selected value instead of 120_000.
    • The bound stays explicit; omitting it would fall back to the SDK's 60 s default.
    • Because the provider's timer starts earlier with the same length, it always fires first, so a timeout is still classified as AnalysisTimeoutError.
  • Doctor and setup:
    • inspectJadxAvailability reports operation_timeout_ms, and the passing JADX doctor check exposes it in details.
    • JadxDoctor publishes an explicit value in registrationEnvironment, like REA_JADX_HEAP_MIB, so rea setup forwards it.
  • Docs: docs/android-analysis.md, docs/client-configuration.md, and the skill reference references/android-applications.md.

Contribution scope: a configuration option for an existing read-only static provider, so a maintainer scope decision is not applicable.

Intentionally not included:

  • Counting the deadline in setup's client tool timeout. The derived Codex tool_timeout_sec and Kimi toolTimeoutMs (mcpStartupPolicy.ts, doctorRuntime.ts resolveProviderRequestBudget) don't count this setting. This matches REA_KUNA_TIMEOUT_MS and REA_KUNA_PROJECT_TIMEOUT_MS, which are also forwarded without counting. Including it would mean restructuring a seam that currently runs only for ida/auto, so I've documented the gap in client-configuration.md and android-analysis.md instead. I'm happy to do it as a follow-up.
  • A timeout remediation that names the setting. AnalysisTimeoutError presentation still says "Try a smaller request". Changing that needs a shared error-presentation change, so it's deferred.
  • Changes to the bridge's 30 s startup handshake or the upstream 90 s decompilation limit. Raising the deadline extends neither. At the audited upstream revision the 90 s value wraps only per-class/method decompilation, not load_apk (source-derived).
  • A per-call MCP/CLI argument. There is no tool-schema change.

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/android/JadxConfiguration.ts, at provider configuration before target admission.
  • Contribution scope fit and linked maintainer decision: within the existing JADX provider boundary, with no new authority; not applicable.
  • CLI and MCP/tool-catalog contract:
    • No tool or schema change.
    • provider_timeout details.timeout_ms now reports the selected value.
    • An invalid value returns capability_unavailable (open_options_invalid) before Java starts.
    • The JADX doctor configuration check gains details.operation_timeout_ms (additive).
  • Provider, bridge, target-format, or platform compatibility: the bridge and jadx-headless-mcp 0.7.1 are unchanged. Behavior on real JADX is not verified (see Evidence).
  • Evidence, artifact, provenance, or reconstruction contract: unchanged. Partial observations and cleanup on timeout are asserted by the new tests.
  • Target selection, authority, upstream behavior, and cleanup details:
    • Cancellation precedence is unchanged.
    • The deadline path releases the owned process group and workspace before provider shutdown (asserted).
    • An invalid value fails before any handle, workspace, probe or launch.
  • Generated metadata, package, or installation impact:
    • Only the authored skill reference text changes. generate-skill-metadata.mjs --check passes, and no skill version bump is needed.
    • No catalog change is expected, and skills/ is not committed.
    • The reviewed rea setup plan can now forward an explicitly set REA_JADX_OPERATION_TIMEOUT_MS into client registrations. The ambient environment is never persisted.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data. (existing JADX analysis behavior, unchanged)
  • Launch or attach to a process. (existing JADX engine launch; only its deadline is now selectable)
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration. (existing reviewed rea setup client registration may now include an explicitly set REA_JADX_OPERATION_TIMEOUT_MS, like REA_JADX_HEAP_MIB)
  • 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

Tests added or updated:

  • tests/boundary/process/jadxIntegration.test.ts, which uses the real owned-subprocess fake JADX MCP producer:
    • Queued deadline: two queued stalled inspect_android_package requests with REA_JADX_OPERATION_TIMEOUT_MS=1500. Each ends as AnalysisTimeoutError with timeoutMs: 1500 and its own engine launch (2 launches). Each keeps the rea_jvm_status partial observation and projects provider_timeout with details.timeout_ms: 1500. Ownership is released before provider.close().
    • Maximum value: a successful operation under 2147483647, so there is no 1 ms timer clamp.
    • Invalid values: "" and 2147483648 are refused with no Java probe and no launch.
    • Session boundary: each upstream call rejects with SdkErrorCode.RequestTimeout and data.timeout: 300 when timeoutMs: 300. This is a module-level test because the former fixed 120 s call limit is unreachable in a workflow test.
  • tests/boundary/android/jadxConfiguration.test.ts: effective operation_timeout_ms for unset (120000), 1, 900000 and 2147483647. The full invalid matrix ("", 0, -1, 1.5, 1e3, " 5", abc, 2147483648) returns open_options_invalid with failure_kind: operation_timeout.
  • tests/boundary/android/jadxDoctor.test.ts: the default and explicit details.operation_timeout_ms, the registration environment carrying the explicit value, and invalid-value remediation naming the setting.
  • tests/fixtures/android/jadx.ts: optional settings overrides. Since 6373f60 (review follow-up), the fixture no longer inherits REA_JADX_* settings from the developer's shell, so an exported deadline or heap value cannot change tests that never selected one.

Base reproduction: on base fe2a398dd with only src/android/ reverted, 8 of the new or changed tests fail. The two deadline tests fail by hitting vitest's 30 s timeout, because the setting was ignored and the fixed 120 s limits applied. The other 67 pass, including the largest-deadline success control, which is expected because the base ignores the setting.

Example output:

  • Timeout projection: {"code":"provider_timeout","details":{"operation":"inspect_android_package","timeout_ms":1500}}
  • Invalid value: REA_JADX_OPERATION_TIMEOUT_MS must be a decimal millisecond count from 1 to 2147483647; received abc.

Remaining proof gaps:

  • No full JDK or real jadx-headless-mcp run, so there is no evidence that a longer deadline lets the reporter's APK finish loading. The real cold-load cost was not measured.
  • Windows and macOS were not run; these integration tests skip on win32.
  • Client-side tool timeouts in Codex, Kimi and Claude were not exercised.

For evidence-bearing changes:

  • 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

Run on Linux with Node 24.18.0 and npm 11.16.0:

  • npm run test:focused -- on the 3 JADX test files plus 13 related Android, doctor, capability and module-boundary test files (16 files listed below): 16 files, 268 tests passed.
    • Files: tests/boundary/process/jadxIntegration.test.ts, tests/boundary/android/jadxConfiguration.test.ts, tests/boundary/android/jadxDoctor.test.ts, src/application/CapabilityInventory.test.ts, src/doctorRuntime.test.ts, tests/acceptance/nonBinaryComposition.test.ts, tests/boundary/android/JadxAnalysis.test.ts, tests/boundary/android/jadxMcpTransport.test.ts, tests/boundary/android/jadxProtocol.test.ts, tests/boundary/mcp/androidLateCompletionMcp.test.ts, tests/boundary/mcp/androidPackageSummaryMcp.test.ts, tests/boundary/process/androidAnalysisMcp.test.ts, tests/boundary/process/androidSearchEvidenceBudget.test.ts, tests/boundary/process/jadxHashCleanup.test.ts, tests/boundary/providers/android/androidLateCompletion.test.ts, tests/evaluation/moduleBoundaries.test.ts.
  • The same 3 JADX files with only src/android/ reverted to base: 8 failed, 67 passed (as described above).
  • npx tsc -p tsconfig.json --noEmit: clean.
  • npm run check: passed. Lint reports 0 errors, and the touched files have the same per-rule warning counts as base.
  • npm run docs:check: passed (includes the skill metadata and doc-facts checks).
  • npm run verify:test-discovery: discovered all 1417 test files exactly once.
  • npx oxfmt --check on the changed files: passed.
  • The checks above ran on 4f2c54b. After the test-only follow-up 6373f60:
    • With REA_JADX_OPERATION_TIMEOUT_MS=1 REA_JADX_HEAP_MIB=abc REA_JADX_ACTIVE_PROCESSOR_COUNT=0 exported, npm run test:focused -- on the 7 fixture-based Android boundary files passed 63/63. Before the fix, jadxIntegration.test.ts alone had 38 failures under the same exports.
    • In a clean shell, 9 Android test files passed 95/95. npx tsc -p tsconfig.json --noEmit was clean, and npm run check:fast passed.
  • Not run:
    • npm run check:pr
    • npm run verify:package (downloads [email protected]; CI runs it)
    • npm run verify:android (needs a full JDK and downloaded public fixtures)

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Unset keeps the 120000 ms default and identical behavior. The only new failure is an invalid value of the new variable.
  • Real Hopper/Ghidra, browser, or OS coverage: Linux only, with the synthetic JADX producer. No real JDK or JADX.
  • Package or release metadata impact: skill reference text only.
  • Security, privacy, process, or containment review:
    • The value is non-secret and appears in errors and diagnostics, like REA_JADX_HEAP_MIB.
    • A longer deadline lets a stalled engine run longer, but it is still finite, explicitly selected, cancellable, and cleaned up with verified ownership.
    • Performance: one string parse per operation or inspection on the default path; not measured.

Author readiness

Human owner: @SandstromPL

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

🤖 Generated with Claude Code

JADX operations used a fixed 120 s provider deadline and a separate fixed
120 s per-call bound in the session, so an APK whose cold load exceeds
120 s could not complete, and raising only the MCP client timeout could
not extend either. Add REA_JADX_OPERATION_TIMEOUT_MS, parsed once by the
JADX configuration owner (decimal milliseconds from 1 to 2147483647,
default 120000). The provider resolves it before acquiring anything and
uses it for the operation deadline and its timeout errors, and the session
uses it for every upstream call. Doctor reports the effective value, and
setup forwards an explicit value like the other JADX settings.

Fixes morluto#3918

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@SandstromPL
SandstromPL marked this pull request as ready for review October 16, 2026 13:46
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 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-16T13:53:37.894694Z 4f2c54b Draft marked ready
ℹ️ 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 16, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the previous fixture issue is fixed and no new blocking issue was found.

Summary

Makes the JADX operation deadline configurable through REA_JADX_OPERATION_TIMEOUT_MS, while keeping the 120000 ms default.

  • JADX analysis uses one selected deadline for the operation and its upstream calls.

Reviews (2) · Last reviewed commit: "test(android): isolate JADX fixtures fro..." · Reviewed by Greptile

Comment thread tests/fixtures/android/jadx.ts Resolved
The shared JADX protocol fixture spread the developer's process.env, so an
exported REA_JADX_OPERATION_TIMEOUT_MS (or REA_JADX_HEAP_MIB) changed every
provider test that never selected one. Keep inheriting the host environment
for process launch, but take REA_JADX_* settings only from the fixture.

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

morluto commented Oct 16, 2026

Copy link
Copy Markdown
Owner

Good catch for this one!

@morluto
morluto merged commit f433786 into morluto:main Oct 16, 2026
1 check passed
@morluto morluto added area: setup Setup, packaging, upgrade, install, Doctor, and client registration enhancement New feature or request provider: jadx Analysis provider / engine: jadx labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: setup Setup, packaging, upgrade, install, Doctor, and client registration enhancement New feature or request provider: jadx Analysis provider / engine: jadx

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Make JADX operation deadlines configurable for slow multidex APK loading

2 participants