[GH-ISSUE #4777] [Feature] Share one APK resource decode across selected locale-table reads #2482

Closed
opened 2026-10-17 21:05:29 +00:00 by bsakaguchi · 3 comments
Owner

Originally created by @N0zoM1z0 on GitHub (Oct 17, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/4777

Current limitation and use case

Reading one APK's default and selected translated string tables uses separate decode_android_resources calls. Every call probes the launcher, snapshots the APK, runs full apktool d --no-src, decodes all resources and enumerates files before projecting a single table. The decoded workspace is removed after each call.

Observed evidence

Production MCP, source 9c56d09c05356c74a7000e4c558ac293639ea33f, official NewPipe0.29.1 (SHA-256 18447bfb1e06d113edc88df93f471827280de06f6f3d4dc42f56f28b9c1bab79) and ApiDemos6.0.18 (SHA-256 a9eecf37b26cd084855c530db81c2bb1b91f4c1b095a04f47aa7c20e2791f686), Apktool3.0.3/JDK21 on Linux. Serial requests: no strings, repeat no strings, default strings, German strings. Instrumented launcher recorded four full decodes in distinct owned workspaces; cleanup verified.

NewPipe: 7.45/11.40/9.94/11.30s per decode; ApiDemos clean serial rerun: 5.47/6.03/5.35/5.30s. One CPU, JVM512MiB, family hard4GiB, zero OOM events. Whole-task offline text-content estimates were ~59.5k/~143.5k cl100k_base tokens respectively, plus catalog/requests; actual agent usage unmeasured. These are baseline measurements, not speedup claims.

Desired outcome and possible direction

Answer selected locale-table questions from one immutable decode, returning common manifest/metadata once and precise per-table identity, partial/missing/unknown status and coverage. Extend existing contracts when appropriate; keep one shared CLI/MCP implementation and complete source Evidence access. Batched homogeneous table projection is a promising first approach.

Design and verification questions

  • Preserve existing primary locale and include_strings choices, aliases and exact decoded-table scope; regional/configuration-qualified resource discovery has separate issue #4612.
  • Bound aggregate XML reads, parsed facts and serialized output before allocation; handle empty/missing tables and malformed XML without losing completed facts.
  • Define per-table failures/cancellation and descriptor/workspace cleanup ownership. Existing provider has raw FileHandle close paths; source inspection alone does not establish failure reproduction or safe reuse.
  • Opaque caller launchers/version strings do not identify all engine contents. Automatic cross-call caching needs a sufficient engine identity, freshness and owned lifetime first. Explicit retained observations are another alternative; do not call them current live state.
  • Compare complete default-plus-selected-locale questions before/after on both real APKs, including schema/call/reply costs, cold/warm wall/CPU/family memory, cancellation, limits and cleanup.

Scope / verification status

Existing static local APK decoding only; no target execution, device attachment or original-byte mutation. No new provider/target-execution authority proposed. Current work is an observed-cost report and design proposal; implementation and optimized measurements are pending. #4771 fixed the separate missing subject identity prerequisite. #4776 handles the narrower class-search producer transfer first.

Originally created by @N0zoM1z0 on GitHub (Oct 17, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/4777 ### Current limitation and use case Reading one APK's default and selected translated string tables uses separate `decode_android_resources` calls. Every call probes the launcher, snapshots the APK, runs full `apktool d --no-src`, decodes all resources and enumerates files before projecting a single table. The decoded workspace is removed after each call. ### Observed evidence Production MCP, source `9c56d09c05356c74a7000e4c558ac293639ea33f`, official NewPipe0.29.1 (SHA-256 `18447bfb1e06d113edc88df93f471827280de06f6f3d4dc42f56f28b9c1bab79`) and ApiDemos6.0.18 (SHA-256 `a9eecf37b26cd084855c530db81c2bb1b91f4c1b095a04f47aa7c20e2791f686`), Apktool3.0.3/JDK21 on Linux. Serial requests: no strings, repeat no strings, default strings, German strings. Instrumented launcher recorded four full decodes in distinct owned workspaces; cleanup verified. NewPipe: 7.45/11.40/9.94/11.30s per decode; ApiDemos clean serial rerun: 5.47/6.03/5.35/5.30s. One CPU, JVM512MiB, family hard4GiB, zero OOM events. Whole-task offline text-content estimates were ~59.5k/~143.5k cl100k_base tokens respectively, plus catalog/requests; actual agent usage unmeasured. These are baseline measurements, not speedup claims. ### Desired outcome and possible direction Answer selected locale-table questions from one immutable decode, returning common manifest/metadata once and precise per-table identity, partial/missing/unknown status and coverage. Extend existing contracts when appropriate; keep one shared CLI/MCP implementation and complete source Evidence access. Batched homogeneous table projection is a promising first approach. ### Design and verification questions - Preserve existing primary `locale` and `include_strings` choices, aliases and exact decoded-table scope; regional/configuration-qualified resource discovery has separate issue #4612. - Bound aggregate XML reads, parsed facts and serialized output before allocation; handle empty/missing tables and malformed XML without losing completed facts. - Define per-table failures/cancellation and descriptor/workspace cleanup ownership. Existing provider has raw `FileHandle` close paths; source inspection alone does not establish failure reproduction or safe reuse. - Opaque caller launchers/version strings do not identify all engine contents. Automatic cross-call caching needs a sufficient engine identity, freshness and owned lifetime first. Explicit retained observations are another alternative; do not call them current live state. - Compare complete default-plus-selected-locale questions before/after on both real APKs, including schema/call/reply costs, cold/warm wall/CPU/family memory, cancellation, limits and cleanup. ### Scope / verification status Existing static local APK decoding only; no target execution, device attachment or original-byte mutation. No new provider/target-execution authority proposed. Current work is an observed-cost report and design proposal; implementation and optimized measurements are pending. #4771 fixed the separate missing subject identity prerequisite. #4776 handles the narrower class-search producer transfer first.
Author
Owner

@abhay-2108 commented on GitHub (Oct 17, 2026):

Hi @N0zoM1z0 , I'd like to take this up! I can implement the batched locale-table projection from a single decode workspace as discussed. Could you please assign this to me? I'll submit a PR soon.

<!-- gh-comment-id:6233900846 --> @abhay-2108 commented on GitHub (Oct 17, 2026): Hi @N0zoM1z0 , I'd like to take this up! I can implement the batched locale-table projection from a single decode workspace as discussed. Could you please assign this to me? I'll submit a PR soon.
Author
Owner

@abhay-2108 commented on GitHub (Oct 17, 2026):

Hi @N0zoM1z0 , I've implemented this feature and opened PR #4804 for review. It projects all selected locale tables from a single decode pass while preserving existing contracts, aggregate limits, and cleanup invariants.

<!-- gh-comment-id:6234602570 --> @abhay-2108 commented on GitHub (Oct 17, 2026): Hi @N0zoM1z0 , I've implemented this feature and opened PR #4804 for review. It projects all selected locale tables from a single decode pass while preserving existing contracts, aggregate limits, and cleanup invariants.
Author
Owner

@morluto commented on GitHub (Oct 17, 2026):

Source review of #4804 at f6ec9d4ed4857ea2dd831ca41d5bc6508e26634a, against the current ownership and Evidence contracts. Sharing one immutable decode workspace is a useful direction; this is not candidate runtime/performance verification.

Before integration:

  • Reuse the current owned workspace/file observations and typed failure algebra. The proposed catch converts non-cancellation filesystem/physical failures to malformed XML, and its previous command-owner lifecycle predates subsequent cleanup fixes.
  • Charge aggregate limits for emitted/retained table copies, including aliases and the primary table. Charging only canonical input tables misses representation expansion. Aliases and requests are bounded, but those bounds do not account for the duplicated output cost.
  • Preserve legacy single-table payloads: always adding string_tables duplicates primary strings and changes retained Evidence identity. Optional schema properties alone do not preserve legacy responses.
  • Use the locale owner’s physical table identity for paths. A caller label such as pt-BR is not the decoded values-pt-rBR directory; retain caller choice separately.
  • Ground the 20-table, 32 MiB and 10,000-entry policies in explicit resource bounds and compare equivalent completed workflows, including discovery, retained Evidence and retries. Define skipped/budget/cancellation partial results and cleanup retry before integration.

#4820 fixes one underlying defect independently: malformed or wrong-root documents now have unknown entry counts, rather than a fabricated one omitted entry. It does not implement shared decoding or qualify the proposed performance claims. The previously recorded real-provider baseline remains baseline evidence; no equivalent candidate NewPipe/ApiDemos run was performed here.

<!-- gh-comment-id:6235952661 --> @morluto commented on GitHub (Oct 17, 2026): Source review of #4804 at f6ec9d4ed4857ea2dd831ca41d5bc6508e26634a, against the current ownership and Evidence contracts. Sharing one immutable decode workspace is a useful direction; this is not candidate runtime/performance verification. Before integration: - Reuse the current owned workspace/file observations and typed failure algebra. The proposed catch converts non-cancellation filesystem/physical failures to malformed XML, and its previous command-owner lifecycle predates subsequent cleanup fixes. - Charge aggregate limits for emitted/retained table copies, including aliases and the primary table. Charging only canonical input tables misses representation expansion. Aliases and requests are bounded, but those bounds do not account for the duplicated output cost. - Preserve legacy single-table payloads: always adding string_tables duplicates primary strings and changes retained Evidence identity. Optional schema properties alone do not preserve legacy responses. - Use the locale owner’s physical table identity for paths. A caller label such as pt-BR is not the decoded values-pt-rBR directory; retain caller choice separately. - Ground the 20-table, 32 MiB and 10,000-entry policies in explicit resource bounds and compare equivalent completed workflows, including discovery, retained Evidence and retries. Define skipped/budget/cancellation partial results and cleanup retry before integration. #4820 fixes one underlying defect independently: malformed or wrong-root documents now have unknown entry counts, rather than a fabricated one omitted entry. It does not implement shared decoding or qualify the proposed performance claims. The previously recorded real-provider baseline remains baseline evidence; no equivalent candidate NewPipe/ApiDemos run was performed here.
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#2482
No description provided.