Skip to content

test(computers): wait for home snapshots after reconnect - #484

Merged
nixuuu merged 1 commit into
devfrom
test/flaky-mirror-snapshot
Nov 10, 2026
Merged

nixuuu merged 1 commit into
devfrom
test/flaky-mirror-snapshot

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 10, 2026

Copy link
Copy Markdown
Member

Change

During a linked-computer reconnect, an offline WatchThread can end after delivering only its cached syncing=true snapshot. watchUntil() also returns when its stream ends without satisfying the predicate, so the mirror-delta fixture could finish open() before any home snapshot was requested. The failed release log has no new home-watch subscription before the assertion. This is a test readiness race.

Make the file-local open() retry an ended stream until it observes a full snapshot with syncing=false, with a bounded condition wait and an explicit completion assertion. Force the failure window in the existing older-home test: wait for disconnection, observe the offline seed, then reconnect the legacy home. Keep the exact 2,999-item home-snapshot assertion, the no-delta assertions and the legacy publisher checks. No product or protocol changes and no fixed sleeps.

Failure: https://github.com/itsoltech/canopy/actions/runs/42796634169

Verification

  • Sequential full-file runs using TMPDIR=/var/tmp bun run check:tmp tests/integration/thread-mirror-deltas.test.ts: unchanged baseline 30/30 passed; corrected implementation with controlled reconnect 30/30 passed. Each loop ran 360 tests, with zero failures or skips; all 60 runs confirmed temp-directory cleanup. The natural flake did not reproduce in the baseline.
  • With the controlled reconnect and the original completion rule, the file failed at the same 2,999-item home-snapshot assertion: 11 passed, 1 failed. The corrected helper passed that scenario in all 30 verification runs.
  • bun install, bun run typecheck, bun run lint, bun run format:check and git diff --check passed. The final lint correction added only a blank line.
  • Full-suite check:tmp, generation checks and the web build were not run locally in this focused verification scope.

Based on the latest dev at task start, 0e4a8855.

An offline watch can end after its cached syncing seed without reaching the home. Retry ended watches until a non-syncing full snapshot arrives, and force the offline-to-legacy reconnect in the existing integration test while preserving its full-history and no-delta assertions.
@nixuuu
nixuuu merged commit f5e0f93 into dev Nov 10, 2026
9 checks passed
@nixuuu
nixuuu deleted the test/flaky-mirror-snapshot branch November 10, 2026 10:56
nixuuu added a commit that referenced this pull request Nov 10, 2026
The native cursor-handoff test can overlap the five-second durable
revision probe while its turn runs. Probe deadlines align to wall-clock
intervals, so this can happen even during a short test. The gateway
supervisor correctly opens a new `WatchThread` when the revision
advances, but the test counted that new RPC's initial snapshot against
the original subscription's native-event assertion. CI attempt 1 shows
`reason: "revision"` immediately before the failure:
https://github.com/itsoltech/canopy/actions/runs/42855632346/attempts/1.

Observe a single home `WatchThread` over the real gateway link, wait for
its initial delta against the committed mirror cursor, and then require
both a completed turn and an advanced `watch_cursor`. Liveness and
coalescing stay enabled. Keep the native-event assertion and the
prohibition on any further snapshot or delta, including across that
revision heartbeat. The existing mirror-first/UI-checkpoint tests and
the separate liveness suite retain coverage of routed reads and
automatic recovery. Document this distinction in
`docs/linked-computers.md`.

This is a test race with intentional recovery, with no production or
protocol change. PR #484 fixed the separate ended-stream readiness race
in this file. PR #509's bot-list cache invalidations do not enter this
thread revision path; the shared probe in #410 compares durable
revisions against snapshot checkpoints even when native events arrived
successfully.

## Verification

- Unchanged baseline: **30/30 sequential full-file runs passed**, 360
tests, zero failures or skips, with private temp cleanup passing every
time. The natural flake did not reproduce locally.
- Finished change: **30/30 sequential full-file runs passed**, another
360 tests, zero failures or skips, with private temp cleanup passing
every time. Every native-handoff test waited for the normal revision
heartbeat; no sleeps or timing overrides remain.
- Controlled reproduction with a temporary 1 ms home revision probe: the
original test failed at the reported no-extra-snapshot/delta assertion
after `reason: "revision"`; the revised test passed with the same fast
probe and liveness/coalescing enabled. The timing override was removed.
- Mutation check: temporarily duplicating the home stream's initial
delta made the revised test fail at the retained no-extra-snapshot/delta
assertion while still receiving native events. The mutation was removed.
- `bun install`, `bun run format`, `bun run typecheck`, `bun run lint`,
`bun run format:check`, and `git diff --check` passed. Self-review
covered the test boundary, cursor acknowledgement, native-event
coverage, revision heartbeat, cancellation, and unchanged recovery
behavior. No UI copy changed.

All repeated file runs used `TMPDIR=/var/tmp bun run check:tmp
tests/integration/thread-mirror-deltas.test.ts`, one test process at a
time. Broader unfiltered tests, generation checks, and the web build
were not run under the workspace's focused verification limits. Based on
latest `dev` at task start, `7317c3bc6`.

Related: #484
Related: #410
Related: #509
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