Skip to content

Fix spurious resyncs from oscillating sync error - #118

Merged
maximmaxim345 merged 1 commit into
mainfrom
fix/transient-jump-sign
Jun 3, 2026
Merged

maximmaxim345 merged 1 commit into
mainfrom
fix/transient-jump-sign

Conversation

@maximmaxim345

Copy link
Copy Markdown
Member

Transient jump confirmation signed the jump by the current error position (Math.sign(rawSyncErrorMs)) instead of the jump direction. When sync error oscillated on one side of zero (e.g. +50 → +10 → +50), both jumps read the same sign and got falsely confirmed as sustained drift, releasing transient suppression and triggering an unnecessary hard resync.

Signing by jumpDeltaMs confirms only genuine same-direction drift. Spike-and-rebound transients now correctly stay suppressed.

Also drops the now-redundant jumpSign !== 0 guard, since abs(jumpDeltaMs) >= 25 already implies a nonzero sign.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes false “confirmed drift” detection in the recorrection transient-jump logic when the raw sync error oscillates, preventing unnecessary hard resyncs triggered by spike-and-rebound patterns.

Changes:

  • Compute jumpSign from jumpDeltaMs (jump direction) instead of rawSyncErrorMs (absolute position) to confirm only same-direction drift.
  • Simplify isJumpDetected by removing the redundant jumpSign !== 0 guard (the jump threshold already implies a nonzero delta).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@maximmaxim345
maximmaxim345 merged commit b2b285d into main Jun 3, 2026
3 of 4 checks passed
@maximmaxim345
maximmaxim345 deleted the fix/transient-jump-sign branch June 3, 2026 15:03
maximmaxim345 added a commit that referenced this pull request Jun 3, 2026
PR #118 signed jumps with `Math.sign(jumpDeltaMs)` to stop oscillation
around zero confirming as drift. That over-corrected: oscillation around
any nonzero value never confirms either, so a sustained drift whose raw
error bounces ≥25ms each check reads as a permanent transient and never
fires, even with smoothed pinned at 2× trigger.

This tracks how long suppression has run while smoothed stays high. Past
`SUSTAIN_MS`, the `transient` diagnosis is treated as wrong and the
breach matures, seeded from when suppression began so jittery drift
fires on the same budget as clean drift.
maximmaxim345 added a commit that referenced this pull request Jun 4, 2026
…st a real aiosendspin server. (#93)

Adds a vitest test suite covering the SDK and an end-to-end run against
a real aiosendspin server. No changes to `src/`.

## Unit tests (13 files, `tests/unit/`)

clock-source, codec-support, core, decoder, decoder-codecs,
output-latency-tracker, protocol-handler, recorrection-monitor,
scheduler, state-manager, time-filter, time-sync-manager,
websocket-manager.

## E2E (1 file, `tests/e2e/`)

`sendspin-core.e2e.test.ts` drives a real aiosendspin Python server
through a line-based stdin/stdout control protocol implemented by
`tests/helpers/sendspin-server.py`. The Node side spawns and controls
the subprocess via `tests/helpers/aiosendspin-server.ts`.

## Stats

234 tests across 14 files. `yarn test` ~32s locally.

## Bugs already caught and fixed

Added a couple more tests which were able to flag bugs in this library.
Each of them was already fixed in a separate PR before this one so all
tests pass:

- #116
- #117
- #118
- #119
- #121
- #122

---------

Co-authored-by: Claude <[email protected]>
Co-authored-by: Maxim Raznatovski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants