Skip to content

fix(adb): observe daemon startup notices emitted on stderr - #3073

Closed
viniciusdsandrade wants to merge 7 commits into
morluto:mainfrom
viniciusdsandrade:fix/adb-cold-daemon-startup
Closed

viniciusdsandrade wants to merge 7 commits into
morluto:mainfrom
viniciusdsandrade:fix/adb-cold-daemon-startup

Conversation

@viniciusdsandrade

Copy link
Copy Markdown
Contributor

Summary

list_adb_devices / list-adb-devices reports may_have_started_adb_server: false on the first query against a cold ADB server because daemon startup notices printed by ADB to stderr were not inspected by parseAdbDevicesOutput.

Fixes #3051

Problem and expected behavior

When ADB runs devices -l against a cold or stopped ADB server, modern adb binaries (including platform-tools r34 and r37) emit daemon startup notices to stderr:

* daemon not running; starting now at tcp:5037
* daemon started successfully

while stdout receives the standard device table banner:

List of devices attached

In src/adb/AdbProvider.ts, runAdb captures both stdout and stderr, but list_adb_devices passed only ran.value.stdout to parseAdbDevicesOutput. In src/adb/AdbDeviceOutput.ts, parseAdbDevicesOutput only accepted a stdout parameter. As a result, when ADB started a background server process during the device query, daemonStarted was not detected, and the structured response reported may_have_started_adb_server: false.

Expected behavior per docs/adb-device-analysis.md: the ADB client starting its local server on first query is recorded in the tool result when observed (may_have_started_adb_server: true), while subsequent queries or runs against an already running server report false. Unrecognized line reporting and device parsing continue to apply strictly to stdout.

Change and scope

  • In src/adb/AdbDeviceOutput.ts: update parseAdbDevicesOutput to accept an optional stderr parameter. When daemonStarted was not found in stdout and stderr is non-empty, scan stderr lines for * daemon ... started successfully notices. Device lines and unparsed line tracking continue to evaluate stdout only.
  • In src/adb/AdbProvider.ts: forward ran.value.stderr alongside ran.value.stdout into parseAdbDevicesOutput.
  • In src/adb/AdbDeviceOutput.test.ts: add a unit test asserting daemonStarted: true when daemon notices are emitted on stderr.
  • In src/adb/AdbProvider.test.ts: add a regression test asserting may_have_started_adb_server: true when the stub prints daemon notices to stderr.

Contract and boundary impact

  • Semantic owner and earliest changed stage: ADB device output parsing in src/adb/AdbDeviceOutput.ts and provider delegation in src/adb/AdbProvider.ts.
  • Contribution scope fit and linked maintainer decision: not applicable; routine bug fix within existing ADB provider boundaries.
  • CLI and MCP/tool-catalog contract: unchanged schemas. Retains existing may_have_started_adb_server boolean field.
  • Provider, bridge, target-format, or platform compatibility: Android SDK platform-tools adb.
  • Evidence, artifact, provenance, or reconstruction contract: device entries, unparsed line handling, and limitations remain unmodified.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): preserves caller-selected adb execution boundaries; does not launch or kill background processes.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none.

Expected effects:

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

Evidence and regression coverage

  • Tests added or updated:
    • src/adb/AdbDeviceOutput.test.ts: verifies parseAdbDevicesOutput detects daemon startup notices from stderr while parsing stdout devices.
    • src/adb/AdbProvider.test.ts: verifies list_adb_devices returns may_have_started_adb_server: true when adb prints daemon startup notices to stderr.
  • Base reproduction or other evidence: on the base revision, list_adb_devices passes only stdout to parseAdbDevicesOutput, so daemon startup notices on stderr leave may_have_started_adb_server: false.
  • User-visible CLI/MCP output (if applicable): may_have_started_adb_server: true when the first query against a cold adb server starts a background server.
  • Remaining proof gaps: tests were verified by source inspection; CI executes the deterministic suite.

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

  • No local commands were run: verification is source-derived; CI executes the deterministic suite.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: none run.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no added execution authority; preserves existing input validation and honest reporting of unparsed stdout lines.

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.

@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 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable defects were found.

Summary

The PR reports ADB server startup notices from stderr without mixing stderr into device listings.

  • Device listings now report daemon startup notices from stderr.

Reviews (4) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

Comment thread src/adb/AdbDeviceOutput.test.ts Resolved
@kaoru0822-kitauji kaoru0822-kitauji added the ci-fix-wip Claimed by the CI-fix track label Oct 14, 2026
# Conflicts:
#	tests/process-global/cleanLinuxHopperRuntime.test.ts
@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator

CI-fix track: none of the failures came from this PR. IDA native admission, the JavaScript semantic, endpoint and empty-literal tests, and the Hopper startup test all broke on main while it was red, and #3080 fixed them. I merged current main to clear the conflict in cleanLinuxHopperRuntime.test.ts. Main already has the identical fix (mirroring the fixture process into the synthetic proc root in both modes), so that file now matches main, and this PR keeps its ADB stderr daemon-notice change. src/adb passes locally (118), and check:fast is clean.

@kaoru0822-kitauji kaoru0822-kitauji removed the ci-fix-wip Claimed by the CI-fix track label Oct 14, 2026
morluto added a commit that referenced this pull request Oct 14, 2026
Recognize exact current and legacy ADB startup notices without treating stderr as device inventory or accepting error lookalikes.

Fixes #3051.
Reviewed-PR: #3073
Co-authored-by: Vinícius DS Andrade <[email protected]>
@morluto

morluto commented Oct 14, 2026

Copy link
Copy Markdown
Owner

Superseded by 57bb7ec5ca44388b9e4ced1588eda0a72bd879ac. ADB daemon startup notices are parsed from both output streams without treating stderr as device inventory or accepting error lookalikes. Validation: src/adb/AdbDeviceOutput.test.ts (20 tests) and src/adb/AdbProvider.test.ts (59 tests), including stderr notices and invalid/lookalike cases, passed in the phase-five source log. This verifies parser/adapter behavior, not a cold real ADB server. Thanks to the PR author and reviewers.

@morluto morluto closed this Oct 14, 2026
@morluto morluto added the bug Something isn't working label Oct 14, 2026
@morluto morluto added the area: runtime Process capture and runtime observation label Nov 26, 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 bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] list_adb_devices reports may_have_started_adb_server false after adb starts its server

3 participants