Repository navigation
fix(android): keep an ended USB entry until its replacement is admitted; read reconnect supersession stably - #1042
Merged
Conversation
…uest awaits admission Diagnostic regression (fails on current source): after USB loss ends request A's connector, refresh deletes A's settled entry for the new request B; B's admission is refused before its native turn starts, the key is popped, and A's retained handle acquires a second forward in the same pass. Spec: ANYM-997 Signed-off-by: egerev <egor@gosync.ai> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ed; read reconnect supersession stably refresh deleted a settled ended entry before the candidate replacement was admitted. When that admission was refused (the new request's native turn not yet admitted), the key was popped and, in the same pass, the ended request's retained handle acquired a second forward. Keep the previous entry through the existing kept mechanism until a replacement is actually admitted. test_usb_loss_keeps_phone_collection_held_until_reconnected_normal_request_supersedes_it_once waited for exactly two forward rows. Later ordinary acquisitions always add rows and rows are never removed, so a late first poll could never succeed (merge-group run 44280383848, PR run 44266637409). Read the first two rows once at least two exist; every later assertion is unchanged. A new regression observes the first reconnect only after a later reconnect added a third row. Spec: ANYM-997 Signed-off-by: egerev <egor@gosync.ai> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 18, 2026
Merged
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.
test_usb_loss_keeps_phone_collection_held_until_reconnected_normal_request_supersedes_it_once(test_usb_order_restart_recovery.py:342) failed in merge-group run 44280383848 (job 134719532952) and PR run 44266637409. Itsuntilwaited for exactly two forward rows.Mechanism (traced on the real lifecycle with fake ADB and listener). After the reconnect, later ordinary acquisitions always add forward rows, and rows are never removed. A healthy run of the unchanged test ends with three rows.
len(rows) == 2held only for about 0.4–0.6 s aftersecond_requestreturned, so a late first poll can never succeed and the wait times out at 5 s. This is a deterministic false-negative mechanism of the old predicate, and it matches the CI symptom. The retained CI logs have no state dump, so the historical runs' actual first-poll timing and row count remain unknown; this PR does not claim their exact cause.A (test, line 342 only). Read the first two rows once at least two exist:
len(r) >= 2, returningr[:2]. The name, deadline, parameters and every later assertion are unchanged: old id,collection_superseded, reason, new ≠ old, acquisition count, no removal before acquisition, at most one wake per order. Lines 236 and 256 are not touched.B (production, one line). The trace also showed a real flaw in
UsbLifecycle.refresh. The settled branch deleted the ended entry before the replacement request was admitted. When that admission was refused (the new request's native turn was not yet admitted), the key was popped. In the same pass, the ended request's own retained handle acquired a second forward, contrary to #1032's "retaining that request never reacquires its ended connector". The settled branch now keeps the previous entry through the existingkeptmechanism until a replacement is actually admitted.Tests (new files; existing IDs unchanged)
test_usb_reconnect_generation_diagnostics.pyholds only the new request's app-skill offer, which runs before turn admission. On the parent source it fails every time: "the ended request reacquired". With B it passes.test_usb_reconnect_late_observation.pyis a deterministic late observation. A second USB loss and another ordinary request add a third row before the first reconnect is read; its supersession is then checked from the first two rows. The same flow with the original== 2predicate times out every time with 3 rows. There is no sleep-based delay.Validation. Proofs on the real source tree, not an in-memory patch:
order_usb_host.pyis 341 lines, below the size-budget threshold. The change-path greps are empty.Not changed, separate follow-up. After the new request's own entry ends, request R1 can still acquire again later. That is the same request, source and epoch as the connector that ended on USB loss, through its retained handle. The #1032 contract already forbids it. This PR does not change that path.
Spec: ANYM-997
Change path: AUTO (lifecycle entry retention and one test predicate; no permissions, configuration, migration or live action)
Review record: none (owner 11-11: no reviews)
🤖 Generated with Claude Code