Skip to content

fix(adb): project actionable pm path refusal details - #1903

Closed
larinyo wants to merge 17 commits into
morluto:mainfrom
larinyo:pr/adb-pull-filename-validation
Closed

larinyo wants to merge 17 commits into
morluto:mainfrom
larinyo:pr/adb-pull-filename-validation

Conversation

@larinyo

@larinyo larinyo commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

pull_adb_package already refuses unsafe or colliding pm path entries on main (55b6148, 1d4c4eb), but every refusal reaches CLI and MCP callers as the generic "unreadable result / run rea doctor" message, because AnalysisOutputError messages are replaced during projection. A caller cannot see which device path was refused or why, even though the provider knows.

The original three refusal diagnostics are already on current main. This branch additionally uses strict UTF-8 decoding and LF framing, and rejects protocol characters including whitespace; current main preserves whitespace in POSIX paths. That admission difference and its evidence need reconciliation before integration.

Behaviour change

For the three existing pm path refusals (unrepresentable host file name, duplicate local destination, destination reservation failure), the projected error now carries:

  • a stable details.reason: unsafe_device_path, duplicate_local_destination or local_destination_unavailable;
  • details.diagnostics with the raw refused device_path values, the derived file_name, a per-entry reason and, for reservation failures, the filesystem error code;
  • a specific user message naming the package and path, and remediation text pointing at details.diagnostics and details.captured_output instead of "retry / run rea doctor".

code stays unreadable_output, retryable stays false, and captured_output is retained. Device paths in the human-readable message are escaped (\u{202E} and similar) so bidi or invisible code points cannot reorder the rendered text; details keeps the raw values.

Change and scope

  • src/domain/analysisErrorCore.ts, analysisErrorProjection.ts, analysisErrorPresentation.ts: AnalysisOutputError accepts optional userMessage, remediationAction and diagnostics, following the existing pattern of ProviderAdapterError and AnalysisUnsupportedTargetError. The error schema is unchanged because details is an open record.
  • src/adb/AdbProvider.ts: the three refusals use those fields.
  • src/adb/AdbDeviceOutput.ts: displayDevicePath escaping helper.
  • docs/adb-device-analysis.md: documents the projected fields.

History note: earlier commits on this branch added their own name validation, case-fold and reserved-name checks, control-character rejection and adb shell -T framing. main has since solved the same problem with host-specific rules and destination reservations, so the merge of main drops all of that in favour of upstream's design. Thanks to @dandgabr and the Codex reviews for the findings along the way.

Validation

  • After b1eab18542 and 5f68b2ac73: 84 ADB source tests, 4 MCP boundary tests, 72 managed tests, typecheck, targeted formatting and the full check:fast pre-push gate passed with this branch's locked dependencies. One path can now retain both protocol and host filename refusals. A pre-existing managed test group was split to clear the gate without removing cases. No real Android device was used.

  • New domain projection tests for the AnalysisOutputError fields.

  • Provider tests assert the projected reason, diagnostics and messages for each refusal, with no pull and no host directory created.

  • tests/boundary/mcp/adbMcp.test.ts asserts the details reach MCP callers.

  • npx vitest run src/adb src/domain tests/boundary/mcp/adbMcp.test.ts tests/boundary/cli/adbCli.test.ts: 2213 tests pass. tsc, oxlint, module boundaries, format and docs:check are clean.

Limits

No real Android device was used. The branch's whitespace rejection differs from current main and is not established by real Package Manager evidence; strict decoding and framing also remain separate from the diagnostics already on main.

pull_adb_package derived each host file name from the last segment of a
device-reported `pm path` entry and joined it to the package output
directory. A hostile or broken device could report `..`, `.`, an empty
segment, backslash separators, NUL, or control characters and steer the
pull outside the package directory or alias another file.

parsePmPathOutput now validates every derived file name against
`^[A-Za-z0-9][A-Za-z0-9._-]*\.apk$` and reports failures in
`rejectedPaths` with the raw device path and a specific reason instead of
returning them as pullable entries. The provider refuses the whole pull
with an AnalysisProtocolError (`unreadable_output`) before creating any
host directory or invoking `adb pull`; the message names the JSON-escaped
raw device path and the error retains the `pm path` output as captured
evidence. Names are never rewritten.

Validation: parser cases for `..`, `.`, empty, backslash, NUL, ESC,
hidden and non-APK names; provider stub test asserting no pull runs and
no output directory is created. Real-device lane not re-run; ordinary
`base.apk`, `split_*.apk`, and system module names are unaffected.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-07T16:33:29.930463Z 5f68b2a New commits
ℹ️ 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 chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8cb18a33e5

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/adb/AdbProvider.ts Resolved
Comment thread src/adb/AdbDeviceOutput.ts Resolved
Addresses two review findings on the pm path file-name validation.

Ordering: when `pm path` printed only an unsafe entry, for example
`package:/data/app/x/..`, both `paths` and `unparsedLines` were empty, so
the legacy empty-output guard returned AnalysisUnsupportedTargetError
("may not be installed") and dropped the raw path and captured output.
The rejected-path check now runs before the empty/unparsed guards, so any
rejected entry fails the pull as `unreadable_output` with the
JSON-escaped device path in the message and the `pm path` output as
captured evidence.

Source-exact paths: each line was trimmed before matching, so a hostile
entry such as `package:/data/app/x/base.apk\t` was accepted as `base.apk`
and `adb pull` ran against a path different from the one reported. The
parser now strips only the protocol line terminator (`\n` or `\r\n`),
matches `^package:(.+)$` on the untrimmed line, keeps the device path
byte-for-byte, and rejects any path containing whitespace or control
characters (`\s`, `\p{Cc}`, including NUL, C1 controls and a stray `\r`).
Whitespace before the `package:` prefix is no longer trimmed away and the
line is reported as unrecognized. Lines that are entirely blank are still
skipped.

Validation: parser cases for trailing tab, trailing space, leading space
in the path, a space inside a directory, a C1 control, a leftover `\r`
from `\r\r\n`, an indented `package:` line, and CRLF output that must
still parse; provider stub tests where the only entry is `..` or has a
trailing space assert `unreadable_output`, no `adb pull`, and no output
directory. The new cases fail on the previous commit.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d78a26ab7b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/adb/AdbDeviceOutput.ts Resolved
Comment thread src/adb/AdbDeviceOutput.ts Resolved
Addresses two further review findings on the pm path file-name policy.

Case-folded aliases: on Windows and default macOS volumes, a hostile
listing with distinct APKs named `base.apk` and `BASE.apk` passed the
host file-name pattern, and the pull loop's duplicate guard compared exact
strings, so the second pull could replace bytes already digested for the
first while both artifacts were reported as complete. The provider now
refuses the whole pull, before the package directory is created or any
`adb pull` runs, when two entries' file names differ as strings but are
equal under case folding or NFC/NFKC normalisation. The refusal is an
AnalysisProtocolError (`unreadable_output`) that names both raw device
paths and retains the `pm path` output. The check is deliberately
host-independent rather than probing the destination filesystem, so the
same listing yields the same evidence wherever REA runs. Exact repeats
keep the existing per-file overwrite refusal.

Reserved device names: `NUL.apk`, `con.apk`, `COM1.apk`, `lpt9.apk` and
similar matched the pattern even though Win32 resolves those basenames to
a device regardless of extension. The reserved-name predicate used by
webScriptExportPlan is extracted to src/domain/windowsReservedFileName.ts
and both call sites use it; pm path entries with such names are rejected
case-insensitively on every host, with the same tagged error.

Tests cover the alias pair (case and Unicode forms), reserved names with
and without extensions, near misses (`console.apk`, `com10.apk`), and a
lone mixed-case `Base.apk` that is still pulled unchanged.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: aa4a00ffcd

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/adb/AdbProvider.ts Resolved
Comment thread src/adb/AdbDeviceOutput.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7ac0b0b643

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/adb/AdbDeviceOutput.ts Resolved
Comment thread src/adb/AdbDeviceOutput.ts Resolved
…e normalization alias

A pm path entry such as /data/a\u034F/base.apk passed the device-path
check: U+034F COMBINING GRAPHEME JOINER, the Hangul fillers (U+115F,
U+3164, U+FFA0) and variation selectors are default-ignorable but not
Cf, so neither \s nor Cc/Cf/Cs/Co matched them and displayDevicePath
left them unescaped. Reject every Default_Ignorable_Code_Point and
Noncharacter_Code_Point anywhere in the path, and escape
default-ignorables in the caller-facing message. Both properties are
stable across Unicode versions, unlike the unassigned set, so the same
listing is refused the same way on every runtime.

parsePmPathOutput admits only ASCII [A-Za-z0-9._-] file names, for
which NFKC is the identity, so normalization_alias could never be
returned. Reduce the collision key to an ASCII case fold, drop the
normalization_alias reason, its synthetic test, and the docs mention.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fc9290c4bb

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/adb/AdbDeviceOutput.ts Resolved

@dandgabr dandgabr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review findings

P2 — Preserve or reject a CR immediately before LF

src/adb/AdbDeviceOutput.ts splits with /\r?\n/, so a carriage return at the end of a device-reported path is consumed as CRLF before unsafeDevicePathReason validates it. For example, if pm path emits package:/data/app/x/base.apk\r\n with the CR belonging to the path and LF as the record terminator, the parser accepts /data/app/x/base.apk and the provider pulls that altered path. This bypasses the control-character refusal and can select a different remote file while recording the altered path as evidence. Preserve the raw payload through validation: split on LF if that is the guaranteed ADB framing, then reject any remaining CR; otherwise reject this ambiguous record rather than silently normalizing it.

…urns

parsePmPathOutput split records on /\r?\n/, so a CR that belonged to a
device path (package:/data/app/x/base.apk\r\n with LF as the terminator)
was consumed as CRLF framing before unsafeDevicePathReason saw it. The
pull then targeted /data/app/x/base.apk, a different remote file, and
recorded that altered path as evidence.

Framing evidence: REA runs `adb shell pm path PKG` through execFile with
piped stdin. On a device with the shell v2 protocol, adb defaults to a
raw (non-PTY) session whenever a command is given, so output is LF-only.
On a device without shell v2 (Android 6 and earlier) adb always asks for
a remote PTY, whose output translation rewrites LF as CRLF, so CRLF
framing was possible and indistinguishable from a path-owned CR. No
fixture or documented compatibility relied on CRLF output.

Rule chosen: make the framing unambiguous at the source. pm path now
runs as `adb shell -T pm path PKG`. -T forbids a remote PTY; a device
that only supports a PTY shell makes adb refuse the command ("device
only supports allocating a pty"), which is now reported as
unsupported_target before any host directory exists. Every accepted
listing is therefore raw LF-framed output, and the parser splits on LF
only: any remaining U+000D stays in the device path and is refused as
whitespace_or_control with the raw path and the captured output. A
record that holds only a CR is reported as unparsed instead of being
skipped as blank.

Tests cover the reviewer example, a double CR, uniform CRLF, mixed
framing, a final CR without LF, LF-only parsing, the exact pm path argv,
the legacy PTY-only device refusal, and CLI and MCP projections of the
CR refusal with no pull and no host directory.
@larinyo

larinyo commented Oct 12, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @dandgabr, this was a real hole: splitting on /\r?\n/ let a path-owned CR disappear before validation, so REA could pull and record a different remote file. On framing, REA runs pm path through execFile with a command argument, so on devices with the shell v2 protocol adb already picks a raw non-PTY session and the output is LF-only; CRLF only appears on devices without shell v2 (Android 6 and earlier), where adb always allocates a PTY and the line discipline rewrites LF as CRLF, which is exactly the ambiguity you describe. In 6ffdd9e I made the framing unambiguous at the source: pm path now runs as adb shell -T pm path PKG, so a PTY-only device makes adb refuse the command (reported as unsupported_target, nothing created on the host), and the parser splits on LF only and leaves any CR in the device path, where it is refused as whitespace_or_control. New tests cover your exact package:/data/app/x/base.apk\r\n example (refused with the raw path /data/app/x/base.apk\r, no pull, no host directory), mixed and uniform CRLF framing, the exact argv, the PTY-only device refusal, and the CLI and MCP projections; the change is documented in docs/adb-device-analysis.md. The trade-off is explicit: pull_adb_package now refuses Android 6 and older devices instead of guessing their framing. If you would rather keep them supported, I can switch to accepting CRLF only when every record in the output is CR-terminated and refusing single-record or mixed outputs, but that still cannot tell a path-owned CR from framing on a one-APK package, so I chose the refusal.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6ffdd9e49a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/adb/AdbDeviceOutput.ts Resolved
Comment thread src/adb/AdbDeviceOutput.ts Resolved
Upstream now validates pm path file names itself (55b6148, 1d4c4eb):
AdbHostFileName derives the final POSIX segment and applies only the
selected host's rules, duplicate names are refused before output, and
exact-name mkdir reservations detect case and Unicode aliases on the
real destination volume. Conflicts were resolved by taking upstream's
AdbDeviceOutput, AdbProvider, their tests and adbCli tests, and the
following parts of this branch were dropped as superseded or contrary
to upstream's design: the portable APK name pattern, the case-fold
alias check applied on every host, the shared Windows reserved-name
helper, the format/default-ignorable character rejection, the fake adb
fixture, and the adb shell -T / LF-only framing (upstream deliberately
treats CRLF as framing and accepts any valid POSIX name).

Kept as the remaining delta: AnalysisOutputError carries an optional
caller message, remediation and structured diagnostics that the error
projection publishes under details.diagnostics. pull_adb_package uses
them for upstream's three pm path refusals (unsafe_device_path,
duplicate_local_destination, local_destination_unavailable with the
filesystem error code), so callers get the refused raw device paths
and actionable guidance instead of the generic unreadable-output
message, and refusal prose escapes invisible and bidi code points.
@larinyo larinyo changed the title fix(adb): reject unsafe pm path file names before pulling packages fix(adb): project actionable pm path refusal details Oct 12, 2026
@larinyo

larinyo commented Oct 12, 2026

Copy link
Copy Markdown
Contributor Author

Upstream main (55b6148, 1d4c4eb) now validates pm path file names itself, with host-specific rules and exact-name destination reservations, so I merged main and dropped this PR's own name pattern, case-fold check, reserved-name helper, invisible-character rejection and adb shell -T framing in favour of upstream's design. What remains is the projection: the three existing pm path refusals now return stable details.reason tokens, details.diagnostics with the raw refused device paths (and the filesystem error code for reservation failures), and actionable message and remediation text instead of the generic "unreadable result, run rea doctor" message. Refusal prose escapes bidi and invisible code points. I have updated the title and description to match the reduced scope.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4c3a5cf18f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/domain/analysisErrorCore.ts Resolved
@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

@greptileai review

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with no outstanding findings.

Summary

This PR gives callers useful details when pull_adb_package refuses device paths.

  • Package pulls check device paths before using them.
  • Package path refusals name the package and rejected paths.
  • Managed decoding tests keep their cases in separate groups.

Reviews (10) · Last reviewed commit: "test(managed): split operand coverage gr..." · Reviewed by Greptile

Preserve LF-framed Package Manager paths, refuse hidden/control path characters and oversized host filenames before pulls, preserve output-error fields through explicit redaction, and escape the blank braille cell in display. Existing destination reservation owns case/Unicode alias detection.

Source inspection and git diff --check; tests/builds/typechecks/CI reruns skipped at explicit user request.
Comment thread src/adb/AdbProvider.ts Resolved
Comment thread src/adb/AdbDeviceOutput.ts Resolved
Comment thread src/adb/AdbHostFileName.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a53a80e9a9

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tests/boundary/mcp/adbMcp.test.ts Resolved
Comment thread src/adb/AdbProvider.test.ts Resolved
Comment thread src/adb/AdbProvider.test.ts Resolved
Comment thread src/adb/AdbDeviceOutput.ts Resolved
Merge pinned main and preserve its common error context owner. Update package-pull stub argv and refusal assertions, enforce host-specific filename length, and parse the exact Package Manager payload after LF framing.

Source inspection and git diff --check only. Tests, builds and typechecks skipped by explicit user request. GitHub review writes paused globally.
Comment thread src/adb/AdbProvider.test.ts Resolved
Merge pinned main and preserve its common error context owner. Update package-pull stub argv and refusal assertions, enforce host-specific filename length, and parse the exact Package Manager payload after LF framing.

Source inspection and git diff --check only. Tests, builds and typechecks skipped by explicit user request. GitHub review writes paused globally.
@morluto morluto added area: runtime Process capture and runtime observation area: domain Domain logic, errors, and pure functions area: providers Provider and capability discovery, including provider proposal triage P2: medium Medium priority issue labels Oct 13, 2026
@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Source fixes and publication evidence for the review findings below. Tests and executable checks were skipped at the maintainer's request. Findings that still require a decision or execution evidence remain open.

review thread

Malformed UTF-8 previously became a generic protocol error with no stable public reason. The producer now returns an invalid_utf8 AnalysisOutputError with explicit remediation and base64-preserved source bytes; adapters retain the tagged reason. Source inspection followed error projection and captured output; git diff --check passed. Regression source was added but not run.

review thread

Rejected paths were fully escaped into caller-facing prose, expanding a bounded adb response into a large error. The shared display owner now limits the excerpt to 160 source characters while structured diagnostics retain the complete path. Source inspection followed parser, display helper, and CLI/MCP error projection; git diff --check passed. Regression source was added but not run.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3c5b8a6b4a

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/adb/AdbDeviceOutput.ts Resolved
@larinyo

larinyo commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

Thanks a lot for picking this up and for the follow-up commits. I'll leave the branch in your hands from here and won't push anything else to it unless you ask me to. Happy to help with any of the open threads if that would be useful.

Comment thread src/adb/AdbProvider.ts Resolved
Comment thread src/adb/AdbProvider.test.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a03ffac072

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/adb/AdbProvider.ts Resolved
@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Source fixes and publication evidence for the review findings below. Tests and executable checks were skipped at the maintainer's request. Findings that still require a decision or execution evidence remain open.

review thread

Status: Source fix pushed; public head verified with gh pr view. Validation is source-only; no tests/builds/checks/CI reruns were run. Root cause, owner-level fix, and any residual cleanup are recorded in the per-PR result. This is not a claim of exact CI reproduction.

@greptile-apps

greptile-apps Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Want your agent to iterate on Greptile's feedback? Try greploops.

@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Source fixes and publication evidence for the review findings below. Tests and executable checks were skipped at the maintainer's request. Findings that still require a decision or execution evidence remain open.

review thread

The refusal chose its remediation based on whether any entry had a protocol violation, while the message described only the first entry. A mixed listing could therefore conceal the second policy that also prevents the pull. The producer now classifies protocol and host filename refusal classes across the complete rejected set and reports combined user guidance when both occur; a source regression covers host-first mixed input and verifies that no pull runs. Targeted formatting and git diff --check passed; tests were not run under the wave instructions. Public fix: cd92590.

Comment thread src/adb/AdbHostFileName.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 814e3e6f25

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/adb/AdbDeviceOutput.ts Resolved
@CassieFox23

CassieFox23 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR: Main already explains why a file name is refused. That came in with d4bd65c. So head 814e3e6 adds less than the title says. What is left is new: head refuses paths with a space, a tab or a bidi character, which main still tries to pull. The PR description says the accepted paths do not change, so it needs an update.

Edit (7 Nov): I ran this PR at head 5f68b2a in a VM, and the results are here.

I used a fake adb script, not a real device. Head conflicts with main af6a998 today, so I tested head as pushed and main separately.

Results

Each row ran pull-adb-package with --json against the same fake adb. The JSON output was identical on Node 24.18.0 and 26.11.1 for the first seven rows.

Fake pm path output Main af6a998 Head 814e3e6
path ends in two dots refused, clear reason and details refused, clear reason and details
two APKs, same name refused, message omits the paths refused, message names both paths
304-letter name refused, empty folder left refused, no folder made
empty name plus a space refused, names the first refusal only refused, names both refusals
space in the path tries adb pull on it refused, clear reason and details
trailing tab tries adb pull on it refused, clear reason and details
bidi U+202E character tries adb pull on it refused, shown escaped
/data/My App/.. (Node 24 only) refused as a dot segment refused as a space; the dot segment is not named

On main, the space, tab and bidi rows reach adb pull. My fake pull fails by design, so main then shows the vague "run rea doctor" message. With a real device the pull may succeed. On head, no pull ran in any row. The last row matches an open review thread about hidden host failures.

PR test files (5 files, 144 tests): on head, 143 pass and 1 fails on both Nodes. On main, the same 5 files pass (151 tests). The failing test is "reports both path policies for mixed host and protocol refusals". The test has a bug, not the code: with one line fixed in a scratch copy, all 63 tests in its file pass on Node 24. The format check also flags src/adb/AdbHostFileName.ts and src/domain/explicitSensitiveFailure.ts.

Not run

  • A real Android device, and old Android 6 devices. Head runs shell -T pm path and main runs shell pm path.
  • A case-folding output folder, as on macOS or Windows.
  • Head merged onto current main. A text-level merge shows 13 conflict hunks in 6 files, unchecked beyond that.
  • The full test suite, Windows and macOS.

Thanks, larinyo, for the PR, and thanks, morluto, for the follow-up commits.

Test file details

The failing test uses a variable before it exists. Node says "Cannot access 'root' before initialization" at line 602 of src/adb/AdbProvider.test.ts. The scratch fix renames the stub callback argument and uses it in that one line.

tests/boundary/filesystem/productCatalog.test.ts also fails on head and passes on main (Node 24). It reports that docs/readme/README_tr.md links differ from README.md. This PR changes no README file, and both files on head are byte-identical to the base. Main changed them later in 96e7c22 (#3228). So the failure comes from the base, not from this PR. I did not run the test on the base itself.

The CI run on this head also failed test shards 1 and 4 and the Static checks job. Those match the failures I reproduced here. I read that from the CI logs and did not rerun CI.

The author said in a comment that the -T framing was dropped, but head still has it.

Test setup
  • Box: Nobara 44 (Fedora 44 base), Linux 7.2.9
  • CPU: AMD Ryzen 9 5900X, 12 cores / 24 threads
  • RAM: 32 GB DDR4-3600
  • Node: 24.18.0, 26.11.1
  • Head: 814e3e6
  • Base: 97268f4
  • Other: main af6a998; fake adb shell script via REA_ADB_PATH; the box was shared with other jobs (load average 10 to 16 on 24 threads)
Commands
npm ci && npm run build && npm run test:prepare
node scripts/run-development-tests.mjs focused src/adb/AdbDeviceOutput.test.ts src/adb/AdbProvider.test.ts src/domain/analysisErrorProjection.test.ts tests/boundary/mcp/adbMcp.test.ts tests/boundary/cli/adbCli.test.ts
node scripts/run-development-tests.mjs focused tests/boundary/filesystem/productCatalog.test.ts
node scripts/rea.mjs pull-adb-package emulator-5554 <package> --output-directory <dir> --json
node_modules/.bin/oxfmt --check src/adb src/domain docs tests/boundary/mcp/adbMcp.test.ts tests/boundary/cli/adbCli.test.ts

The build and test runs sat under systemd-run --user --scope -p MemoryMax=6G. The CLI runs and the format check ran under nice -n 19 only. The fake adb answers version and -s emulator-5554 shell [-T] pm path <package>, and records any pull call. Eight fake packages covered the eight table rows.

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊

@CassieFox23

Copy link
Copy Markdown
Contributor

TL;DR: I ran head 814e3e6 and main on a real tablet. Both found the same APK paths and pulled byte-identical files. No real path on this tablet hit a refusal. So the new refusals only matter for odd paths.

This follows my earlier comment, which used a fake adb. Main has moved since then. This run used main 4692bb3, not af6a998.

Results

I ran pull-adb-package --json on a Samsung Galaxy Tab A8 over USB. The tablet runs Android 14 and a normal user build. I only read from it: pm path, pm list packages, getprop, and adb pull of installed APKs.

App on the tablet APK files Main 4692bb3 Head 814e3e6
System app in /system/priv-app 1 pulled, no refusal pulled, no refusal; same file as main
App with a split APK in /data/app 2 (base and one split) pulled both, no refusal pulled both; same files as main
User-installed app in /data/app 1 pulled, no refusal pulled; same file as main
Another user-installed app in /data/app 1 pulled, no refusal pulled; same file as main
  • Each pulled file has the same sha256 on main, on head and on the tablet itself. That makes 5 files per tree.
  • The JSON output was identical on head and main. Only evidence_id differed. I did not check why.
  • Coverage was complete and failures was empty on every run.
  • The tablet has 177 packages. None has a space, tab, control or bidi character in its path. So the new space, tab and bidi refusals never had a real path to act on.

What matched the fake adb run

Plain paths pull the same on head and main, as the fake run showed. The fake run showed one more thing: head sends shell -T pm path and main sends shell pm path. The real adb log shows the same two commands. On this tablet, shell -T pm path and shell pm path print byte-identical output.

What the fake run could not show

A split app and a system app both pull on head and on main. The fake run had no split app. The tablet reports the same paths with -T as without it.

Still not run

  • Android 6 and older, which have no shell v2.
  • A real device that reports a path with a space, a tab or a bidi character. I found none on this tablet.
  • Head merged onto current main.
  • Windows and macOS.
Test setup
  • Box: Nobara 44 (Fedora 44 base), Linux 7.2.9
  • CPU: AMD Ryzen 9 5900X, 12 cores / 24 threads
  • RAM: 32 GB DDR4-3600
  • Node: 24.18.0
  • Head: 814e3e6
  • Base: 97268f4
  • Main: 4692bb3
  • Tablet: Samsung Galaxy Tab A8 (SM-X200), Android 14, normal user build, USB
  • Other: adb 37.0.0 from the android-tools package
Commands
npm ci && npm run build && npm run test:prepare
node scripts/rea.mjs pull-adb-package <serial> <package> --output-directory <dir> --json
adb -s <serial> shell -T pm path <package>
adb -s <serial> shell pm path <package>

REA_ADB_PATH pointed at a small wrapper. It logged each argument list and then ran the real adb. Builds ran under nice -n 19 and systemd-run --user --scope -p MemoryMax=6G.

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5f68b2ac73

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

it("refuses a payload CR without treating it as transport framing", () => {
const devicePath = "/data/app/base.apk\r";
expect(parsePmPathOutput(`package:${devicePath}\n`).rejectedPaths).toEqual([
{ device_path: devicePath, reason: "unsupported_protocol_character" },

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Make the CR rejection expectation platform-aware

When this source test runs on Windows, adbHostFileName also rejects the trailing CR as unsupported_character, so parsePmPathOutput correctly includes additional_reasons: ["unsupported_character"] in the rejected entry. This unguarded, exact toEqual assertion omits that field and therefore fails on Windows despite correct parser behavior. Account for the Windows host-validation reason in the expected record rather than assuming the POSIX result.

Useful? React with 👍 / 👎.

@CassieFox23

Copy link
Copy Markdown
Contributor

TL;DR: I ran head 5f68b2a in a VM. The 5 changed test files pass on Node 22, 24 and 26, including the file whose test failed on 814e3e6. /data/My App/.. is still refused as a space first, and the dot segment is now in the error details but not in the message.

This follows my review above. I used a fake adb script, not a real device. No test job ran in CI on this head. Only three checks ran. Greptile passed. PR readiness and the author check both failed. GitHub still shows the branch as conflicting with main 015a02d, and I did not merge it.

Results

Check Node 22.23.4 Node 24.22.1 Node 26.12.1
5 changed test files, 213 tests 213 pass 213 pass 213 pass
11 fake pm path rows, JSON output same as Node 24 reference same as Node 24

The format check (oxfmt) on the 13 changed files passes on Node 24.

Each fake row ran pull-adb-package --json. All 11 were refused. No adb pull ran and no output folder was made.

Fake pm path row Message says Details say
/data/My App/.. "violate both" policies, names unsupported_protocol_character only adds dot_segment
space in the path "rejected by Package Manager's path policy" one reason
trailing tab same, tab shown as \t one reason
bidi U+202E same, shown as \u{202E} raw character kept
x/.. plus a space path "violate both", names dot_segment, "and 1 other path(s)" both reasons listed
two APKs with one name, 304-letter name, path ending in two dots refused, reason named reason named
  • Dot segment: the details now say additional_reasons: ["dot_segment"] for /data/My App/... The message does not name it.
  • Test and format failures: both are gone at this head.
  • One policy: a path with only a space does not read "both". The message says "both" only when a second policy is hit.
  • MCP test: adbMcp.test.ts now checks the device path in the message and the reasons in the details. It no longer checks a reason in the message.
  • -T: head still sends shell -T pm path, read from the fake adb's log. The PR description's history note says the merge dropped it. Its summary says the LF framing stays.
  • PR description: it now says the branch rejects whitespace paths that main accepts. That answers my earlier point.

Thanks, morluto, for the two new commits. The dot segment now shows in the details. The test and format failures I saw are gone.

Still not run

  • A real Android device, and Android 6 and older, which have no shell v2.
  • Main or the base through these rows this round.
  • A case-folding output folder, as on macOS or Windows.
  • Head merged onto main.
  • The full test suite, Windows and macOS.
Test setup
  • Box: Fedora 44 VM (4 vCPUs, 8 GB), Linux 7.2.11, on my box (Nobara 44, AMD Ryzen 9 5900X, 12 cores / 24 threads, 32 GB DDR4-3600)
  • Node: 22.23.4, 24.22.1, 26.12.1
  • Head / base: 5f68b2a / 97268f4
  • Other: main 015a02d; fake adb shell script via REA_ADB_PATH; installs ran offline from a filled npm cache
Commands
npm ci --offline && npm run prepare && npm run test:prepare
npm run test:focused -- src/adb/AdbDeviceOutput.test.ts src/adb/AdbProvider.test.ts src/domain/analysisErrorProjection.test.ts tests/boundary/mcp/adbMcp.test.ts src/dotnet/ManagedCilDecoding.test.ts
node scripts/rea.mjs pull-adb-package emulator-5554 <package> --output-directory <dir> --json
node_modules/.bin/oxfmt --check <the 13 files the PR changes>

The fake adb answers version and -s emulator-5554 shell -T pm path <package> by package name, logs every call, and fails any pull. Eleven fake packages covered the 11 rows: the eight from my first review, plus a space in the file name, two space-only paths, and a dot-segment path with a space path.

🤖 Written and tested with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊

@morluto

morluto commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Thank you for this fix! Actionable pm path refusal userMessage, remediationAction, and diagnostics for unsafe_device_path and duplicate_local_destination (src/adb/AdbProvider.ts), along with projecting AnalysisOutputError.userMessage and AnalysisOutputError.remediationAction (src/domain/analysisErrorPresentation.ts), have already landed on main in commit d4bd65c53c ("fix(providers)!: preserve readiness, coverage, and diagnostic ownership"), so we are closing this PR as already landed.

@morluto morluto closed this Nov 24, 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 area: providers Provider and capability discovery, including provider proposal triage area: runtime Process capture and runtime observation bug Something isn't working P2: medium Medium priority issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants