Repository navigation
fix(android): a USB entry that never claimed or bound does not strand later requests - #1036
Merged
Merged
Conversation
… later requests UsbLifecycle.refresh kept an ended Entry with receipt=None forever, so a connector cancelled or refused before its first serial claim blocked every later, separately admitted request for that owner/device until restart. Replace such an entry only when its connector never left cleanup 'not_needed' (no serial claim, no bind call, so no forward, watch or receipt), its close has settled, and the candidate is a different request. The old entry stays until the new request actually passes packages, journal and admission checks. A bind that failed before its receipt, the ended request itself (run or retained handle), epoch changes and every receipt-bearing path keep their existing held/no-retry behaviour. Spec: ANYM-997 Signed-off-by: egerev <egor@gosync.ai> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Record each request whose entry ended before claiming the serial or calling bind, and never let it replace a later untouched entry: without this, request A could take the entry back once B's replacement also ended untouched. Correct the cancellation test, which wrongly forbade the new request's own ordinary forward removal; it now asserts no removal before the single acquisition. Spec: ANYM-997 Signed-off-by: egerev <egor@gosync.ai> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
UsbLifecycle.refreshnever replaced an endedEntrywhosereceiptisNone. A connector cancelled or refused before its first serial claim therefore blocked every later, separately admitted request for the same owner/device until service restart (the open finding retained in #1029).An entry is replaced only when all of these hold:
cleanupnever leftnot_needed._runsetscleanup_unconfirmedsynchronously after the serial claim and beforebind_usb, sonot_neededmeans no claim, no bind call, and therefore no forward, watch or receipt.The old entry stays in place until the new request actually passes
packages(),journal.blocked()andadmit(). If the new request has no active order or is refused, the old entry is kept. Every receipt-bearing path is unchanged.New real-service tests use the shared synthetic ADB forward table and phone listener. One barrier holds the first connector tasks before their first statement.
cleanup_unconfirmed, so later requests stay held: no retry, no--no-rebind, no row.Validation: the cancellation case fails on the parent source and the re-admission case fails without the ended-request record. All four pass after the fix. The full Android suite passes locally: 1057 passed, 5 skipped, existing tests unchanged. Ruff is clean. The source is 341 lines, below the size-budget threshold. No live phone, ADB, model or provider action.
First head 26746c4 (run 44266637409):
checks / servicesfailed on two Android tests.test_usb_order_restart_recovery.py:342timed out waiting for the superseding row. 22 local runs passed, including single-CPU runs. A local probe showed the new branch is never reached in that test, and that module runs before the new one, so this change did not plausibly cause it. Without a state dump the interleaving is unidentified; it is the same location as the earlier run 44045047078 race. Not retried; this new head runs normal CI.Security reportalso fails on main's latest push: new advisory GHSA-fc5q-39xc-vjpf for picomatch 4.0.7 inservices/calls/frontend/package-lock.json, unrelated to this diff.Not covered: installed adb/listener behaviour remains live acceptance. Source and CI completion is not installation.
Spec: ANYM-997
Change path: AUTO (lifecycle entry replacement; no permissions, configuration, migration or live action)
Review record: none (owner 11-11: no reviews)
🤖 Generated with Claude Code