Skip to content

fix(limits)!: let apktool and assetutil take producer_limits.output_bytes and type Android and process capture refusals - #14624

Merged
morluto merged 11 commits into
mainfrom
limits/android-apple-producers
Nov 26, 2026
Merged

morluto merged 11 commits into
mainfrom
limits/android-apple-producers

Conversation

@morluto

@morluto morluto commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

Part of #14237 and #14234. decode_android_resources (Apktool) and inspect_asset_catalog (assetutil) refused larger producer output with a fixed capture ceiling and no override. Both now take producer_limits.output_bytes and report details.limit for it. Three more refusals in the same producer family now carry typed recovery, and two fixed ceilings are reclassified with their reasons.

Change and scope

  • Apktool (src/domain/apktool/apktoolResourceAnalysis.ts, src/apktool/ApktoolProvider.ts, src/cli/apktoolCommands.ts):
    • producer_limits: { output_bytes } sets the retained apktool d stdout and stderr. The default is 4 MiB, as before.
    • The maximum is buffer.constants.MAX_STRING_LENGTH, because the retained output is decoded into one JavaScript string.
    • The refusal sets limit with parameter: "producer_limits.output_bytes", and the CLI takes --producer-limits as JSON text.
  • assetutil (src/domain/apple/appleAssetCatalog.ts, src/artifacts/apple/AppleAssetCatalogAnalysis.ts, src/cli/artifactCommands.ts):
    • producer_limits.output_bytes defaults to 64 MiB, as before, with a maximum of 128 MiB. The JSON is decoded in REA's own process and every catalog's records are retained; raising the maximum would need a streaming decoder.
    • One budget now covers what was a per-run capture plus a separate untyped combined-metadata check. Each run captures only the stdout that earlier catalogs left of it, so both cases end in the same typed capture refusal. The separate MAX_TOTAL_METADATA_BYTES check is removed.
  • capture_process: the retained-frame normalization refusal (src/process/capture/ProcessNormalization.ts) reports details.limit for limits.output_bytes. DEFAULT_PROCESS_OUTPUT_BYTES now owns the 1,000,000-byte default the schema already used.
  • JADX: a JVM heap failure reported by the bridge during load_apk is marked measuredExhaustion. It is exhaustion of the heap the JVM had, not a request above a configured budget, and it keeps its REA_JADX_HEAP_MIB remediation.

Registry:

Entry Before After Reason
ApktoolProvider.ts apktool output capture pending #14237 removed now producer_limits.output_bytes
AppleAssetCatalogAnalysis.ts assetutil capture pending #14237 removed now producer_limits.output_bytes
native/parsers/lipo.ts lipo field retention pending #14237 derived The fields are sliced from lipo's captured output and bounded by the same native command output allowance, so the ceiling changes only with that capture allowance. That allowance (NativeCommandAnalysisError.ts) remains pending.
android/JadxSession.ts external DEX representation pending #14237 protocol One eighth of the JADX bridge's 8 MiB local MCP frame, less its envelope. The prototype reply, the reference reply and their retained, Evidence and MCP copies must fit together. Raising it needs a paged bridge reply.

The prose-only baseline shrinks by 2 (JadxSession.ts, ProcessNormalization.ts).

Contract and boundary impact

  • CLI and MCP: optional producer_limits on decode_android_resources and inspect_asset_catalog. The advertised schema summaries are updated.
  • Docs: the Apktool guide and the producer-limits table in docs/reference/limits-and-recovery.md.

Evidence and regression coverage

  • tests/boundary/providers/apktoolDecodeOutputLimit.test.ts (new): a launcher writes more than output_bytes: 64. The public decode_android_resources provider call refuses with details.limit for producer_limits.output_bytes and with no details.refusal.
  • src/artifacts/apple/AppleAssetCatalogAnalysis.test.ts:
    • A stand-in assetutil above the per-stream budget reports details.limit.
    • Two catalogs whose combined output is one byte over the budget are refused with the limit, and are admitted at the exact budget.
    • The existing output-limit case now asserts limit in place of fixedAllowance.
  • src/process/capture/ProcessNormalization.test.ts: a retained frame that no longer fits reports details.limit for limits.output_bytes.
  • src/apktool/ApktoolDecodeTimeout.test.ts: the deadline remediation now names producer_limits.output_bytes as the separate control.
  • Remaining proof gaps: no real Apktool or macOS assetutil run with a raised budget. The tests use stand-in launchers through the real owned-process supervisor.

Adoption of #14625 (merged from main)

  • Per-call refusals bind AnalysisParameterLimit with no authored remediationAction. The generated adjustable_budget recovery spells the CLI flag or MCP field. The authored text is removed from the Apktool and assetutil capture refusals, the shared producer command output refusal and the capture_process normalization refusal.
  • required_value: the shared selected-input refusal (ArtifactAnalysisResources.selectedFileSize, used by packet capture and signal recording) reports the file size the stable read observed.
    • That size is the complete need: the input budget admits only that one file, so a retry at that size is not refused by the same limit unless the file changes.
    • Values above Number.MAX_SAFE_INTEGER are omitted.
    • Capture and normalization refusals stop at the budget, so they report no required_value.
  • Shared helper change (minimal): ArtifactReaderFailure gains an optional observedBytes, set only by readStableArtifact's file-size refusal. This is how the observed size reaches the refusal.

Validation performed

  • npm run test:focused -- on the apktool, asset catalog, process normalization, JADX protocol and apktool CLI/MCP tests (35 files): passed
  • npm run typecheck: clean
  • node scripts/verify/fixed-ceilings.mjs: 97 registered, 76 pending, 101 authored-only (this branch alone, from main)
  • node scripts/verify/architecture-guards.mjs, npm run docs:check, npm run verify:advertised-schemas -- --update-summary: passed
  • npx oxfmt --check .: clean

Compatibility, safety, and release

  • Breaking: Apktool and assetutil output refusals report details.limit (producer_limits.output_bytes) and no longer carry a fixed_ceiling refusal. The combined assetutil metadata refusal is now the same typed capture refusal. Behaviour is unchanged when producer_limits is omitted.
  • Safety: assetutil stays within a 128 MiB in-process decode. Apktool output is only retained text.
  • Not included: AndroidMappingFile.ts and the JNI report allowance in JadxAnalysis.ts still carry prose-only recovery. Both are fixed resource policies that need their own per-call controls.

…ytes and type Android and process capture refusals

decode_android_resources and inspect_asset_catalog refused larger apktool or
assetutil output with a fixed capture ceiling. Both now accept
producer_limits.output_bytes (defaults 4 MiB and 64 MiB) and report
details.limit for it. assetutil's budget covers each stream and the JSON
retained across catalogs, capped at 128 MiB for the in-process decode.

capture_process's retained-frame refusal reports details.limit for
limits.output_bytes, and a JADX JVM heap failure is marked as measured
exhaustion. The lipo field-retention allowance is reclassified as derived from
the native command output capture, and the JADX external DEX representation
allowance as protocol (a fraction of the bridge's local MCP frame).

BREAKING CHANGE: apktool and assetutil output refusals report details.limit for
producer_limits.output_bytes instead of a fixed_ceiling refusal.
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-26T02:12:17.401299Z
We couldn’t complete this review. Comment @codex review to try again.
b6f0178 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

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@greptile-apps

greptile-apps Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The reviewed changes appear safe to merge; no blocking issues were identified.RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The reviewed changes appear safe to merge; no blocking issues were identified.

Summary

Adds per-call output budgets for Apktool and assetutil, reports typed recovery for capture failures, and carries measured input sizes into retry guidance.

  • Apktool decodes can use a caller-selected output budget.
  • Asset catalog inspections share a caller-selected output budget.
  • Artifact size refusals can report the observed file size.
  • Process capture names its adjustable output limit in refusals.
  • JADX reports bridge heap failures as measured exhaustion.
  • The registry ties lipo field retention to its captured output allowance.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[CLI JSON or MCP input] --> B[Shared input schema]
  B --> C[Selected output budget]
  C --> D[Owned process capture]
  D -->|Budget exceeded| E[Typed limit and generated recovery]
  D -->|Complete output| F[Decode or inspect result]
Loading

Reviews (9) · Last reviewed commit: "merge: keep the session output control f..." · Reviewed by Greptile

… check deadlines leave the output budget unchanged
Per-call output refusals for Apktool, assetutil and process normalization
drop their authored recovery for the generated adjustable_budget text. The
shared selected-input refusal reports required_value from the size the stable
read observed, and producer command output refusals drop duplicated prose.
Comment thread src/resources/ArtifactReader.ts Resolved
@morluto
morluto enabled auto-merge (squash) November 26, 2026 05:13
The generated recovery sentence is not the contract. The refusal names
capture_process_scenario and limits.output_bytes.
@cursor

cursor Bot commented Nov 26, 2026

Copy link
Copy Markdown

@greptileai please review the current head 9e51e3aba.

commandContext now receives the output limit from its caller, which is
how producer.output_bytes reaches packet and signal captures. Apktool
and assetutil keep their own defaults and maxima, so that setting does
not supply their omitted producer_limits.output_bytes.

Co-authored-by: morluto <[email protected]>
@cursor

cursor Bot commented Nov 26, 2026

Copy link
Copy Markdown

@greptileai please review the current head 77eed105f.

@morluto
morluto merged commit 0eb19a3 into main Nov 26, 2026
56 checks passed
@morluto
morluto deleted the limits/android-apple-producers branch November 26, 2026 06:26
@morluto morluto added area: domain Domain logic, errors, and pure functions bug Something isn't working labels Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: domain Domain logic, errors, and pure functions bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants