Skip to content

test(computers): wait for both pairing handshakes - #575

Merged
nixuuu merged 1 commit into
devfrom
test/pairing-recovery-flake
Nov 12, 2026
Merged

nixuuu merged 1 commit into
devfrom
test/pairing-recovery-flake

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 12, 2026

Copy link
Copy Markdown
Member

The cross-version pairing recovery test read B's saved version immediately after observing A's connected status. In both failed #573 runs it expected 0.2.0-nightly.137 and received the pairing-time 0.0.0-dev. A can finish processing B's hello while B is still processing A's welcome, so A's status is not a barrier for B's database write.

This is test timing. Each side already awaits its hello metadata write before publishing its own connected status. A queues its welcome before that status write; completion across the two independent gateways is asynchronous.

Let the online helper wait for a specified peer/store, and wait for both sides before reading their final versions. Add a controlled barrier around B's metadata write and force the B → A dial after listener startup. The test now proves A can be connected while B still holds the old version, releases B, then waits for B's own connected commit. It retains the trust, protocol, version and upgraded-capability assertions. No sleeps, larger timeouts or assertion retries were added to hide the ordering.

Evidence from the original failures: attempt 1 / job 131276846769, attempt 2 / job 131286358670, both at linked-pairing-recovery.test.ts:267.

Validation on the authorized file only, sequentially with TMPDIR=/var/tmp nice -n 19 bun run check:tmp:

  • Complete file: 10 passed, temp directory clean.
  • Forced-order scenario with --rerun-each 10: 10 passed, temp directory clean.
  • Changed-file lint, formatting and git diff --check passed.

Required CI validation: two complete consecutive green attempts for the same head, rerunning the entire workflow once after the first green result. This is pending; local repetition is not counted as CI evidence.

Related: #573

Force the listener-connected/dialler-metadata-pending ordering and wait for each gateway to commit its own handshake before asserting saved versions.

Related: #573
@nixuuu
nixuuu marked this pull request as ready for review November 12, 2026 16:36
@nixuuu
nixuuu merged commit baab955 into dev Nov 12, 2026
24 of 26 checks passed
@nixuuu
nixuuu deleted the test/pairing-recovery-flake branch November 12, 2026 16:43
nixuuu added a commit that referenced this pull request Nov 12, 2026
The pairing suite could leave a deliberately persisted
`pairing_required` untouched when restoring the original peer. Its
shared fixture starts the runtime before the listener
(`tests/integration/support/computers.ts:42`), so a startup dial races
the listener's first address announcement. That announcement retires
sockets and aborts dials
(`apps/gateway/src/computers/runtime-lan.ts:51`). The suite's single
reconnect tick can observe the closing incoming connection and skip
dialing (`apps/gateway/src/computers/runtime-connection.ts:149`); its
next automatic retry is deliberately 60 seconds away, beyond the
5-second assertion window.

This is fixture timing. The #579 failure occurs in `restoreB()`, after
the test intentionally sets `pairing_required`, not in shared setup or a
previous test. The failed job shows two expected `server_pin_mismatch`
probes followed by an aborted startup connection and no subsequent
successful handshake. Self-heal writes `connected` only after a
successful pinned handshake
(`apps/gateway/src/computers/runtime-frames.ts:316–321`). There is no
evidence here of that write being overwritten.

Pause dialing during fixture startup until its listener and initial
address publication have completed. Explicit ticks then establish links,
and shared setup/recovery wait for each gateway's own committed
connected status. Preserve the cross-version metadata barrier, remove
its route-deletion workaround, and extend the persisted-state recovery
case with a barrier holding listener startup open.

Validation:
- With the previous startup helper, the controlled barrier fails
deterministically: expected zero startup dials, received one.
- Five consecutive complete file runs with `TMPDIR=/var/tmp nice -n 19
bun run check:tmp ./tests/integration/linked-pairing-recovery.test.ts`:
**10 passed, 0 failed each time** (50 test executions), each about 4.4
seconds; every temp-directory check passed.
- Changed-file formatting, lint and `git diff --check` pass. No other
local tests run.
- Pending: two complete consecutive green CI attempts on the same head,
rerunning the entire workflow once.

Related: #573
Related: #575
Related: #579
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant