[PR #6843] [MERGED] fix(adb): pass int intent extras to am without leading zeros #7425

Closed
opened 2026-11-01 21:47:47 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/6843
Author: @Abelo9996
Created: 10/23/2026
Status: ✅ Merged
Merged: 10/23/2026
Merged by: @gensokyo-dev

Base: main ← Head: fix-6807-intent-extra-leading-zeros


📝 Commits (2)

  • 06d7512 fix(adb): pass int intent extras to am without leading zeros
  • 410c335 Merge branch 'main' into fix-6807-intent-extra-leading-zeros

📊 Changes

2 files changed (+45 additions, -1 deletions)

View changed files

📝 src/adb/AdbProvider.test.ts (+40 -0)
📝 src/adb/AdbProvider.ts (+5 -1)

📄 Description

Summary

Fixes #6807.

start_adb_activity accepts an int extra as signed decimal text (^-?\d+$), but forwarded the string unchanged as the --ei operand. Android's am reads --ei through Integer.decode, where a leading zero means octal, so 010 would arrive as 8, -010 as -8, and 08 would fail to parse. The provider now drops redundant leading zeros from int extras before building the argv, so 010 is sent as 10. Other extra types and the reported request are unchanged.

Problem and expected behavior

In AdbProvider.startActivity, every extra becomes [flag, key, extra.value]. For --extra int:count:010 the device gets --ei count 010. In Android 16's Intent.parseCommandArgs, --ei calls decodeInteger, which delegates to Integer.decode (only a hex fallback on failure), and Java documents that a leading 0 selects octal. Expected: the value REA accepted as decimal is the value the activity receives, so 010, -010 and 08 deliver 10, -10 and 8.

Change and scope

For int extras only, the argv builder applies value.replace(/^(-?)0+(?=\d)/u, "$1"): keep the sign, drop leading zeros while at least one digit remains. 010 becomes 10, -010 becomes -10, 08 becomes 8, 000 becomes 0, and values without a leading zero are untouched. The schema and its "signed decimal text" contract are unchanged.

long extras are left alone on purpose: --el is parsed with Long.valueOf, which is always decimal, so a leading zero is already harmless there. Out-of-range values are not touched by this change; Android still reports those as before.

Follow the contribution scope.
Scope decision: not applicable (ordinary fix within existing boundaries).

Contract and boundary impact

  • Semantic owner and earliest changed stage: AdbProvider.startActivity, when the am start argument vector is built from the validated request.
  • Contribution scope fit and linked maintainer decision: ordinary bug fix, not applicable.
  • CLI and MCP/tool-catalog contract: no schema or output change. parameters.extras and normalized_result.extras still echo the caller's value ("010"); only the --ei operand passed to adb changes.
  • Provider, bridge, target-format, or platform compatibility: adb provider only. Matches the --ei parsing in Android 16 release source; older am versions were not checked.
  • Evidence, artifact, provenance, or reconstruction contract: none.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): same device, same am start -W call; the integer operand is now the canonical decimal form of the accepted value.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs and skills/; edit authored instructions in .agents/skills/reverse-engineer-anything/ and never commit build outputs): none.

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.
  • 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 existing am start launch; this PR only changes the integer operand it receives.)

Evidence and regression coverage

  • Tests added or updated: src/adb/AdbProvider.test.ts gets an it.each that runs start_adb_activity against the file's adb stub, records the argv, and checks the tail for int values 10, 010, -010, 08 and 000. Each case also sends the same value as a long extra and expects it unchanged.

  • Base reproduction (executed): with the test and without the fix:

    ✓ passes int extra 10 to am as decimal 10
    × passes int extra 010 to am as decimal 10
    × passes int extra -010 to am as decimal -10
    × passes int extra 08 to am as decimal 8
    × passes int extra 000 to am as decimal 0
    -   "10",
    +   "010",
          Tests  4 failed | 97 passed (101)
    

    With the fix: Tests 101 passed (101).

  • User-visible CLI/MCP output (if applicable): the issue's CLI trigger against a freshly compiled runtime (scripts/rea.mjs), with REA_ADB_PATH pointing at a small adb stub that answers version, prints an am start success, and logs the argv it receives. The JSON output is the same before and after; the argv is what changes.

    Before:

    $ rea start-adb-activity emulator-5554 android.intent.action.VIEW --extra int:count:10 --format json --filter-output normalized_result.extras,normalized_result.reported_status
    {"normalized_result":{"extras":[{"key":"count","type":"int","value":"10"}],"reported_status":"ok"}}
    exit=0
    $ rea start-adb-activity emulator-5554 android.intent.action.VIEW --extra int:count:010 --format json --filter-output normalized_result.extras,normalized_result.reported_status
    {"normalized_result":{"extras":[{"key":"count","type":"int","value":"010"}],"reported_status":"ok"}}
    exit=0
    $ rea start-adb-activity emulator-5554 android.intent.action.VIEW --extra int:count:-010 --format json --filter-output normalized_result.extras,normalized_result.reported_status
    {"normalized_result":{"extras":[{"key":"count","type":"int","value":"-010"}],"reported_status":"ok"}}
    exit=0
    $ rea start-adb-activity emulator-5554 android.intent.action.VIEW --extra int:count:08 --format json --filter-output normalized_result.extras,normalized_result.reported_status
    {"normalized_result":{"extras":[{"key":"count","type":"int","value":"08"}],"reported_status":"ok"}}
    exit=0
    -- argv received by the adb stub
    -s emulator-5554 shell am start -W -a android.intent.action.VIEW --ei count 10 
    -s emulator-5554 shell am start -W -a android.intent.action.VIEW --ei count 010 
    -s emulator-5554 shell am start -W -a android.intent.action.VIEW --ei count -010 
    -s emulator-5554 shell am start -W -a android.intent.action.VIEW --ei count 08 
    

    After (same four commands, identical JSON output and exit codes):

    -- argv received by the adb stub
    -s emulator-5554 shell am start -W -a android.intent.action.VIEW --ei count 10 
    -s emulator-5554 shell am start -W -a android.intent.action.VIEW --ei count 10 
    -s emulator-5554 shell am start -W -a android.intent.action.VIEW --ei count -10 
    -s emulator-5554 shell am start -W -a android.intent.action.VIEW --ei count 8 
    
  • Remaining proof gaps: no Android device or emulator was used, so what a receiving activity reads is not observed. The octal reading of 010 is source-derived from Android 16's Intent.java (--ei calls decodeInteger, which calls Integer.decode; --el calls Long.valueOf) and Java's documented Integer.decode rules. MCP was not run by hand; it shares the same provider, and tests/boundary/mcp/adbStartMcp.test.ts passes.

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 with Node 24.18.0 on macOS arm64.

  • npm run test:focused -- src/adb/AdbProvider.test.ts: 101 passed (4 failed without the fix, shown above)
  • npm run test:focused -- src/adb/AdbProvider.test.ts src/domain/adb/adbDeviceAnalysis.test.ts src/contracts/toolEffects.test.ts tests/boundary/cli/adbCli.test.ts tests/boundary/mcp/adbMcp.test.ts tests/boundary/mcp/adbStartMcp.test.ts tests/process-global/adbStartMcp.test.ts: 7 files, 145 passed
  • npm run check tasks run individually: typecheck, lint:built (0 errors), knip, metadata:check and verify:architecture-guards passed. format:check was run as oxfmt --check on the changed files (clean), because the repo-wide run in my checkout also picks up unrelated untracked local notes.
  • npm run compile, then the CLI commands above against the adb stub.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. A caller who sent a leading-zero int on purpose to get octal was relying on behavior that contradicts the documented decimal contract; such values now arrive as decimal.
  • Real Hopper/Ghidra, browser, or OS coverage: no device or emulator; macOS host with an adb stub only.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no new arguments; the operand is still a single argv element built from schema-validated digits.

Author readiness

Human owner: @Abelo9996

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

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/6843 **Author:** [@Abelo9996](https://github.com/Abelo9996) **Created:** 10/23/2026 **Status:** ✅ Merged **Merged:** 10/23/2026 **Merged by:** [@gensokyo-dev](https://github.com/gensokyo-dev) **Base:** `main` ← **Head:** `fix-6807-intent-extra-leading-zeros` --- ### 📝 Commits (2) - [`06d7512`](https://github.com/morluto/rea/commit/06d7512cf5b57614db7f6f9fe8ce66d99a00fd0f) fix(adb): pass int intent extras to am without leading zeros - [`410c335`](https://github.com/morluto/rea/commit/410c3358531fcf38efe9c0d67e633c92901aceb4) Merge branch 'main' into fix-6807-intent-extra-leading-zeros ### 📊 Changes **2 files changed** (+45 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `src/adb/AdbProvider.test.ts` (+40 -0) 📝 `src/adb/AdbProvider.ts` (+5 -1) </details> ### 📄 Description ## Summary Fixes #6807. `start_adb_activity` accepts an `int` extra as signed decimal text (`^-?\d+$`), but forwarded the string unchanged as the `--ei` operand. Android's `am` reads `--ei` through `Integer.decode`, where a leading zero means octal, so `010` would arrive as 8, `-010` as -8, and `08` would fail to parse. The provider now drops redundant leading zeros from `int` extras before building the argv, so `010` is sent as `10`. Other extra types and the reported request are unchanged. ## Problem and expected behavior In `AdbProvider.startActivity`, every extra becomes `[flag, key, extra.value]`. For `--extra int:count:010` the device gets `--ei count 010`. In Android 16's `Intent.parseCommandArgs`, `--ei` calls `decodeInteger`, which delegates to `Integer.decode` (only a hex fallback on failure), and Java documents that a leading `0` selects octal. Expected: the value REA accepted as decimal is the value the activity receives, so `010`, `-010` and `08` deliver 10, -10 and 8. ## Change and scope For `int` extras only, the argv builder applies `value.replace(/^(-?)0+(?=\d)/u, "$1")`: keep the sign, drop leading zeros while at least one digit remains. `010` becomes `10`, `-010` becomes `-10`, `08` becomes `8`, `000` becomes `0`, and values without a leading zero are untouched. The schema and its "signed decimal text" contract are unchanged. `long` extras are left alone on purpose: `--el` is parsed with `Long.valueOf`, which is always decimal, so a leading zero is already harmless there. Out-of-range values are not touched by this change; Android still reports those as before. Follow the [contribution scope](https://github.com/morluto/rea/blob/main/CONTRIBUTING.md#contribution-scope). Scope decision: not applicable (ordinary fix within existing boundaries). ## Contract and boundary impact - Semantic owner and earliest changed stage: `AdbProvider.startActivity`, when the `am start` argument vector is built from the validated request. - Contribution scope fit and linked maintainer decision: ordinary bug fix, not applicable. - CLI and MCP/tool-catalog contract: no schema or output change. `parameters.extras` and `normalized_result.extras` still echo the caller's value (`"010"`); only the `--ei` operand passed to adb changes. - Provider, bridge, target-format, or platform compatibility: adb provider only. Matches the `--ei` parsing in Android 16 release source; older `am` versions were not checked. - Evidence, artifact, provenance, or reconstruction contract: none. - Target selection, authority, upstream behavior, and cleanup details (if applicable): same device, same `am start -W` call; the integer operand is now the canonical decimal form of the accepted value. - Generated metadata (`docs/public/product-catalog.json`), package, or installation impact (CI generates and validates ignored catalogs and `skills/`; edit authored instructions in `.agents/skills/reverse-engineer-anything/` and never commit build outputs): none. 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. - [x] 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 existing `am start` launch; this PR only changes the integer operand it receives.) ## Evidence and regression coverage - Tests added or updated: `src/adb/AdbProvider.test.ts` gets an `it.each` that runs `start_adb_activity` against the file's adb stub, records the argv, and checks the tail for `int` values `10`, `010`, `-010`, `08` and `000`. Each case also sends the same value as a `long` extra and expects it unchanged. - Base reproduction (executed): with the test and without the fix: ``` ✓ passes int extra 10 to am as decimal 10 × passes int extra 010 to am as decimal 10 × passes int extra -010 to am as decimal -10 × passes int extra 08 to am as decimal 8 × passes int extra 000 to am as decimal 0 - "10", + "010", Tests 4 failed | 97 passed (101) ``` With the fix: `Tests 101 passed (101)`. - User-visible CLI/MCP output (if applicable): the issue's CLI trigger against a freshly compiled runtime (`scripts/rea.mjs`), with `REA_ADB_PATH` pointing at a small adb stub that answers `version`, prints an `am start` success, and logs the argv it receives. The JSON output is the same before and after; the argv is what changes. Before: ``` $ rea start-adb-activity emulator-5554 android.intent.action.VIEW --extra int:count:10 --format json --filter-output normalized_result.extras,normalized_result.reported_status {"normalized_result":{"extras":[{"key":"count","type":"int","value":"10"}],"reported_status":"ok"}} exit=0 $ rea start-adb-activity emulator-5554 android.intent.action.VIEW --extra int:count:010 --format json --filter-output normalized_result.extras,normalized_result.reported_status {"normalized_result":{"extras":[{"key":"count","type":"int","value":"010"}],"reported_status":"ok"}} exit=0 $ rea start-adb-activity emulator-5554 android.intent.action.VIEW --extra int:count:-010 --format json --filter-output normalized_result.extras,normalized_result.reported_status {"normalized_result":{"extras":[{"key":"count","type":"int","value":"-010"}],"reported_status":"ok"}} exit=0 $ rea start-adb-activity emulator-5554 android.intent.action.VIEW --extra int:count:08 --format json --filter-output normalized_result.extras,normalized_result.reported_status {"normalized_result":{"extras":[{"key":"count","type":"int","value":"08"}],"reported_status":"ok"}} exit=0 -- argv received by the adb stub -s emulator-5554 shell am start -W -a android.intent.action.VIEW --ei count 10 -s emulator-5554 shell am start -W -a android.intent.action.VIEW --ei count 010 -s emulator-5554 shell am start -W -a android.intent.action.VIEW --ei count -010 -s emulator-5554 shell am start -W -a android.intent.action.VIEW --ei count 08 ``` After (same four commands, identical JSON output and exit codes): ``` -- argv received by the adb stub -s emulator-5554 shell am start -W -a android.intent.action.VIEW --ei count 10 -s emulator-5554 shell am start -W -a android.intent.action.VIEW --ei count 10 -s emulator-5554 shell am start -W -a android.intent.action.VIEW --ei count -10 -s emulator-5554 shell am start -W -a android.intent.action.VIEW --ei count 8 ``` - Remaining proof gaps: no Android device or emulator was used, so what a receiving activity reads is not observed. The octal reading of `010` is source-derived from Android 16's `Intent.java` (`--ei` calls `decodeInteger`, which calls `Integer.decode`; `--el` calls `Long.valueOf`) and Java's documented `Integer.decode` rules. MCP was not run by hand; it shares the same provider, and `tests/boundary/mcp/adbStartMcp.test.ts` passes. For evidence-bearing changes: - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed Run with Node 24.18.0 on macOS arm64. - `npm run test:focused -- src/adb/AdbProvider.test.ts`: 101 passed (4 failed without the fix, shown above) - `npm run test:focused -- src/adb/AdbProvider.test.ts src/domain/adb/adbDeviceAnalysis.test.ts src/contracts/toolEffects.test.ts tests/boundary/cli/adbCli.test.ts tests/boundary/mcp/adbMcp.test.ts tests/boundary/mcp/adbStartMcp.test.ts tests/process-global/adbStartMcp.test.ts`: 7 files, 145 passed - `npm run check` tasks run individually: `typecheck`, `lint:built` (0 errors), `knip`, `metadata:check` and `verify:architecture-guards` passed. `format:check` was run as `oxfmt --check` on the changed files (clean), because the repo-wide run in my checkout also picks up unrelated untracked local notes. - `npm run compile`, then the CLI commands above against the adb stub. ## Compatibility, safety, and release - Breaking changes or migration steps: none. A caller who sent a leading-zero `int` on purpose to get octal was relying on behavior that contradicts the documented decimal contract; such values now arrive as decimal. - Real Hopper/Ghidra, browser, or OS coverage: no device or emulator; macOS host with an adb stub only. - Package or release metadata impact: none. - Security, privacy, process, or containment review: no new arguments; the operand is still a single argv element built from schema-validated digits. ## Author readiness Human owner: @Abelo9996 - [x] 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. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [x] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-01 21:47:47 +00:00
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#7425
No description provided.