Sync exchange v2: ensure implicit aborts go to terminal state#8990
Open
CDRussell wants to merge 2 commits into
Open
Sync exchange v2: ensure implicit aborts go to terminal state#8990CDRussell wants to merge 2 commits into
CDRussell wants to merge 2 commits into
Conversation
Member
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
3b7c4c3 to
c4c0727
Compare
c4c0727 to
f0ff4aa
Compare
14 tasks
f78e252 to
f94c91c
Compare
f94c91c to
9255d4f
Compare
CDRussell
commented
Jul 3, 2026
|
|
||
| @SuppressLint("DenyListedApi") | ||
| @RunWith(AndroidJUnit4::class) | ||
| class RealSyncCodeDispatcherTest { |
Member
Author
There was a problem hiding this comment.
Revisited most of this test class as I didn't like the previous use of coroutines (wasn't using Turbine), nor the feature flag interactions. Resulted in a noisier diff but it's leaving it in a better state.
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.

Task/Issue URL: https://app.asana.com/1/137249556945/project/1203822806345703/task/1215724271421988?focus=true
Description
Per the Transport Tech Design ("other error/incompatibility/bug in the other party is detected" → tear down), implicit aborts in the v2 SM now drive to a terminal state instead of leaving the session in a non-terminal one. Previously the runner only tore down on
isTerminal(), so out-of-sequence messages let sessions linger until the 5-min client timed out.Now, if the peer sends an unexpected/out-of-sequence message then treated as
UNEXPECTED_EVENTrather than the genericPAIRING_FAILEDFinally, if there is a terminal error in the manual code entry screen, after the user sees the error message they are taken back to sync settings screen (instead of returned only to the barcode scanning screen on a bad session).
Steps to test this PR
Note
Requires the Python pairing reference client
For each scenario below, start with no existing sync account before testing.
1.
response-without-hello— exercises the newBootstrapped → AbortedpathDirection: Android = Presenter (shows code), Python = Scanner (pastes Android's code).
Paste the other device's code:, paste Android's code2.
duplicate-hello— sanity check on second-hello-in-Negotiating teardownDirection: Android = Presenter, Python = Scanner.
3.
hello-from-presenter— same teardown contract, opposite role assignmentDirection: Android = Scanner (pastes Python's code), Python = Presenter (shows code).
https://duckduckgo.com/sync/pairing/#&code2=…— copy this URL.Note
Medium Risk
Changes sync v2 pairing session teardown and user-visible error classification; impact is limited to the connect/pairing path but wrong mapping would confuse users or leave sessions uncleared.
Overview
V2 exchange state machine now moves implicit aborts and out-of-sequence local triggers into terminal states (
Aborted,Host.Aborted,Joiner.AbortedLocal) instead of leaving the session stuck in non-terminal states, so the runner can tear down per session lifecycle. Late messages on already-terminal states stay defensive (state unchanged).RealSyncCodeDispatchermaps those terminals more precisely:Joiner.AbortedLocalandHost.AbortedusePAIRING_CANCELLEDonly when the user explicitly denied; wire-driven protocol errors usePAIRING_FAILED(generic "Sync failed" copy) instead of cancellation messaging.Tests in
ExchangeV2StateMachineTestandRealSyncCodeDispatcherTestassert terminal transitions and the new outcome codes for present/linking flows.Reviewed by Cursor Bugbot for commit 4a41c40. Configure here.