Skip to content

feat(android): trace callers of external DEX methods - #8154

Merged
gensokyo-dev merged 5 commits into
mainfrom
feat/8096-android-external-methods
Oct 30, 2026
Merged

gensokyo-dev merged 5 commits into
mainfrom
feat/8096-android-external-methods

Conversation

@gensokyo-dev

@gensokyo-dev gensokyo-dev commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Trace callers of an exact external DEX method through the existing trace_android_references CLI/MCP operation. APK-defined queries keep their existing behavior. External results identify observed prototypes, direct invoke sites and follow-up caller selectors without inventing external class definitions or bodies.

Absorbs #8096 by @xu91102; fixes #7811. The contributor branch does not allow maintainer edits. This integration integrates main 675d4076d, preserves its resource controls, and excludes unrelated Hopper/debugger cleanup and JavaScript worker-test changes.

Implementation

  • One raw invoke decoder and a bounded prototype inventory, reused for the current exact session/class/method query. Target/session changes and failed rebuilds invalidate it. Caller scans remain fresh.
  • Mandatory complete caller identity is reserved before optional instruction sites; representation expansion is checked before descriptor/signature copies. Capacity failures remain typed, nonretryable resource constraints.
  • Bridge identity 9 → 10 is checked during connection; the pinned engine remains unmodified JADX headless 0.7.1. The new reply distinguishes reference-only external prototypes from APK class definitions.
  • Adds direct_invokes_coverage in the shared normalization layer: complete/partial/unknown using-node counts and retained site count. This exposes bounded positions while preserving coverage: complete for the complete using-node inventory. Historical omission stays unexamined.

No APK execution, external classpath, reflection/JNI resolution, inherited lookup or runtime dispatch inference. No new provider, tool or dependency. Caller identity, DEX carrier, raw method ID, code-unit offset, opcode, target digest and retained raw Evidence remain available through both adapters. External class selectors use exact DEX spelling, including $ for nested classes. The operation still returns its complete bounded caller inventory; it does not add caller paging.

Validation

Linux x64, Node 24.22.1/npm 11.16.0, existing OpenJDK 21.0.12.1:

  • All 13 Android boundary files: 322 passed, 1 existing Windows-specific skip. Includes protocol/identity, invalid selectors, historical omission, new complete/partial/unknown position statistics, archive lifecycle, configuration, cancellation and cleanup. check:fast, docs:check (9 consistency tests), formatting and diff checks passed.
  • npm run verify:android passed with the checksum-pinned JAR and ApiDemos fixture, JVM heap 512 MiB and 2 processors. Covers actual compiled CLI/stdio MCP, single/multidex external calls, overloaded/nested caller source follow-up, 10,000-site + 10-short-caller truncation, oversized method/caller inventories, refusal/recovery, APK replacement, SIGTERM and awaited cleanup. 414.294 s elapsed / 552.218 CPU s. That initial RSS sampler tracked a session only, so its RSS is not claimed as complete process-family memory.
  • Real NewPipe 0.29.1 (SHA-256 18447bfb1e06d113edc88df93f471827280de06f6f3d4dc42f56f28b9c1bab79): NotificationManager.notify(int, Notification) returns exactly 6 callers / 7 sites across classes.dex and classes3.dex, matching independent AOSP dexdump 11 in caller identity, carrier, code-unit offset and opcode. Baseline main refuses the same query. APK bytes remained unchanged.
  • Measured fresh CLI runs, filesystem cache uncontrolled, 1 GiB JVM heap / 2 processors / four CPU affinity: baseline refusal 16.587 s / 18.914 CPU s / 1.05 GiB sampled peak family RSS; successful query 18.257 s / 19.516 CPU s / 1.16 GiB. The corrected sampler follows PPID and process start times across separate sessions, at 100 ms intervals. These are different outcomes and establish no speedup. Successful full JSON: 14,835 bytes / tokenx 1.3.0 estimate 4,938 tokens; actual model billing and complete schema costs are unmeasured.

Relevant trace_android_references / inspect_android_method input definitions estimate 599 → 678 tokens; full definitions including output schemas estimate 9,386 → 9,731 tokens. Tool count is unchanged. These schema estimates are separate from the 4,938-token CLI result above; actual agent scaffolding/billing remains unmeasured.

Latest-main refresh 083cfe9b0: 98 direct Android tests, check:fast and docs:check (9 tests) passed again. Android production and real-verifier files are byte-identical to the real-engine-tested b382333f4; the intervening main change is test maintenance plus a CLI inventory empty-result guard. Runtime evidence above is reused only for those unchanged Android inputs.

Follow-up 5d7b4f5b2 removes the external verifier's duplicate JAVA_HOME/compiler selection and compiles both Java regressions in the existing metadata-owned cohort. The complete real lane passed again on this source: 400.379 s elapsed, 558.709 CPU s, 2.16 GiB sampled peak process-family RSS (corrected ancestry/start-time sampler), 512 MiB JVM heap / 2 processors. CodeQL and Greptile passed on this head; no suppression, budget increase or production behavior change was introduced by the verifier refactor.

Current-head CI and automated review are tracked separately. Scope remains read-only static analysis; device/runtime behavior and other real host platforms were not locally verified.

Credit

Original implementation and conformance work: @xu91102, #8096. The integration retains the original commits and author identity. The position-coverage aggregate and removal of unrelated changes were added during maintainer-side integration.

Author readiness

Human owner: @gensokyo-dev

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

The user explicitly authorized this integration, ready-for-review publication and waiver of the human-declaration gate. Automation leaves the declarations unchecked rather than attesting that human review occurred.

@chatgpt-codex-connector

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 ⚠️ Failed 2026-10-30T16:24:53.266098Z
We couldn’t complete this review. Comment @codex review to try again.
b382333 PR opened
ℹ️ 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

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@greptile-apps

greptile-apps Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

[Medium impact] The latest changes appear safe to merge; no new blocking issue was found.

Summary

Adds caller tracing for exact external DEX methods, including observed prototypes, caller selectors and instruction coverage. The latest update compiles both Java regressions in one shared call.

  • Android reference tracing finds callers of exact external DEX methods.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  Q["Exact class and method"] --> D{"APK class exists?"}
  D -->|Yes| A["Existing APK references"]
  D -->|No| P["Bounded observed prototypes"]
  P --> S["Select exact prototype"]
  S --> C["Reserve complete caller identities"]
  C --> I["Retain bounded invoke sites"]
  A --> N["Normalize caller and instruction coverage"]
  I --> N
  N --> O["CLI and MCP Evidence"]
Loading

Reviews (3) · Last reviewed commit: "refactor(android): compile verifier regr..." · Reviewed by Greptile

@gensokyo-dev

Copy link
Copy Markdown
Collaborator Author

Investigated CodeQL at external-invokes.mjs:331: the executable was selected from operator JAVA_HOME, not APK data, using argument-array execution. It also duplicated compiler selection and a compiler launch already owned by metadata.mjs. Commit 5d7b4f5 compiles both Java regression programs in the existing validated compiler cohort, then the external verifier consumes those classes. No suppression or budget increase; rerunning the complete real Android lane and the current-head scans.

@gensokyo-dev
gensokyo-dev merged commit 0ffed7a into main Oct 30, 2026
47 of 50 checks passed
@gensokyo-dev
gensokyo-dev deleted the feat/8096-android-external-methods branch October 30, 2026 17:07
@morluto morluto mentioned this pull request Nov 11, 2026
3 tasks done
@morluto morluto added enhancement New feature or request area: runtime Process capture and runtime observation labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: runtime Process capture and runtime observation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] trace_android_references: find APK callers of a framework or library method that the APK doesn't define

4 participants