Repository navigation
fix(android): serialize legacy gateway discovery - #131001
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: found issues before merge. Reviewed August 27, 2026, 12:53 PM ET / 16:53 UTC. ClawSweeper reviewWhat this changesThe PR serializes Android 12–13 NSD gateway resolutions so multiple nearby gateways are queued rather than silently omitted. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessKeep open for normal maintainer handling. The queue repair is at the legacy resolver owner and no P0–P2 introduced defect was found; remove the release-owned changelog edit and complete platform-contract verification before merge. Priority: P2 Review scores
Verification
How this fits togetherAndroid Gateway settings and onboarding turn nearby DNS-SD advertisements into selectable gateway endpoints. Android 12–13 use one-shot resolution, while Android 14+ uses streaming callbacks. flowchart LR
A[Nearby gateway advertisements] --> B[Android NSD discovery]
B --> C{Android version}
C -->|12-13| D[One-slot resolution queue]
C -->|14+| E[Streaming service callback]
D --> F[Gateway endpoint registry]
E --> F
F --> G[Onboarding and Settings list]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceDocs +1, Other +216. Total +217 across 3 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the queue at the legacy resolver owner, remove the release-owned changelog hunk, and verify the Android NSD callback contract before exact-head Android CI completes. Do we have a high-confidence way to reproduce the issue? Unclear for independent reproduction: the PR body supplies an API-33 before/after replay, but this read-only environment could not run it or retrieve the Android framework contract. Is this the best way to solve the issue? Unclear: the repair is at the correct ownership boundary and preserves Android 14+ behavior, but the Android 12–13 callback-dispatch contract still needs direct confirmation. Full review comments:
Overall correctness: patch is correct AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against aa0647d06d27. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Maintainer disposition for the latest review and its Rank-up moves: retaining the existing changelog entry under explicit maintainer instruction for this user-facing repair. The requested removal is consciously declined; this is a changelog-policy exception only, not a waiver of CI, review, or platform verification. The follow-up commit only relocates that unchanged line to avoid a parallel insertion conflict; the entire Android subtree is byte-identical to the previously tested commit. The Android 12–13 callback-dispatch contract is now directly verified against primary framework source. Android 12 NsdManager creates one HandlerThread/ServiceHandler at lines514–517 and directly dispatches discovery and terminal resolution callbacks at415–420 and450–457. Android 13 NsdManager routes binder callbacks through its manager handler (497–569); the exact discovery and resolution overloads used here choose Production growth is explicitly accepted: +51/−25, net+26; tests +199/−9, net+190. The state belongs to the legacy resolver and retains the physical platform slot until its terminal callback, including loss/rediscovery identity and caller cancellation. A lock around the asynchronous call would end too early, and coroutine cancellation does not cancel the outstanding legacy platform request. The repair reuses listener identity storage and removes the reflective one-shot path and ignored failure callback. Iterative draining handles synchronous rejection without the stack overflow demonstrated by the rejected recursive candidate. This is a concrete ownership/lifetime justification, not an assertion that every possible net-neutral implementation was disproved. Android 14+ and wide-area paths remain unchanged. The refreshed exact head |
|
Merged via squash.
|
* fix(android): serialize legacy gateway discovery resolution * chore(android): avoid parallel changelog insertion conflict
* fix(android): serialize legacy gateway discovery resolution * chore(android): avoid parallel changelog insertion conflict
Additional instructions
MUST: Keep Allow edits from maintainers enabled for this PR so maintainers can help update the branch when needed.
What Problem This Solves
Fixes an issue where users browsing nearby gateways in Android Gateway settings would see only some available gateways when several were advertised together on Android 12, 12L, or 13 (API 31–33).
On a real API 33 emulator, three task gateways were advertised before opening the ordinary app. Gateway settings showed only one. The production list still contained just that one after the full UI scan, although all three subsequently resolved successfully through the public Android SDK. The matched fixed replay exposes all three.
Why This Change Was Made
Legacy Android NSD accepts only one active resolution per client; submitting another before the first finishes is rejected. Discovery now owns that slot through the real success or failure callback and queues other discovered services. Losing an active service invalidates its result without releasing the still-live platform slot; lost queued services are removed, and an old completion cannot overwrite a rediscovered service.
The queue reuses the existing service-identity registry and has one iterative drain for synchronous SDK rejection and asynchronous completion. This replaces reflective fire-and-forget resolution rather than adding retries, delays, configuration, or trust policy. Android 14+ streaming discovery, address selection, wide-area DNS, and process-owned discovery lifetime are unchanged.
Production LOC: +51/-25 (net +26). Tests: +199/-9 (net +190). Changelog: +1. Growth is the required ownership of the legacy platform slot and pending service generations; shared identity handling absorbs the old duplicate setup, and seven added lines are house-format wrapping.
User Impact
Nearby gateway lists on supported older Android releases can expose all simultaneously advertised gateways instead of silently losing extra resolutions. Departed services are still removed. Pairing, credentials, permissions, connection policy, and settings do not change.
Evidence
Matched real Android flow
The independent discovery observer establishes advertisement availability, not a count of the production listener's callbacks. Both runs capture the initial app observation before independent SDK controls, so those controls cannot warm the resolver cache first. No credentials were supplied and no gateway connection was attempted. Elapsed times identify the runs, not a performance comparison.
Both runs used the same archived native test APK, SHA256
e4a44ab05d8ad2d45118c6dbbcc101af1e61face1bd2f2f285073f280628d8e8, on actual API 33 Google APIs ARM64. The platform-specific fixture is disposable proof infrastructure and is not included in this PR. Each run ended before task-process and emulator cleanup. Startup and accessibility warnings are retained in the evidence; this is not a warning-free-log claim.Fixed APK SHA256
ab5d6b1bedf72371a283b8d7990bcacde40c61c3f7d43f81eb78a34f105a9ccdwas built from the reviewed source snapshot before commit. Its packaged metadata records baseline9bd50c803cce88f2ab387ddaf6cc29b4ef004005, not the later fix commit. All three files incb8f669a648a8dce6c33e32e1a38f7c8a74bbf32were byte-compared with that reviewed source archive; production SHA256 is35f11b430afce3f12c7432a9fedba425b6b5ad6e7a5e3d1638f4ef0c4bbd80c1.Before: one visible gateway despite three independently resolvable advertisements. After: all three visible before the SDK controls. Only synthetic task names, guest addresses, and empty credential fields appear in these unedited captures.
Regression and repository checks
The additional synchronous-rejection case failed with
StackOverflowErroragainst the exact initial unlanded recursive candidate, then passed against the iterative fix in both flavors (65/85 ms). This is SDK-boundary unit stress evidence, not a claim of a shipped or native app crash.The dependency contract was inspected directly in Android 13 NsdService and NsdManager callback/resolve handling, with Android 12 corroboration. Modern discovery and wide-area DNS were inspected as unchanged siblings. This does not claim a live wide-area DNS query, Android 14+ native replay, or gateway authentication/transport proof.
Named follow-up outside this fix: Android's release-task heuristic also matches
Releaseinside a debug test filter. The original 11-case replay used a single-match wildcard for that method and verified the exact executed names; no signing settings or credentials changed.AI-assisted with Codex; source, tests, and native evidence independently reviewed.