The app hears how far apart a game's streams are, and Admin says it (#167) #171

Merged
cmoriarty merged 1 commit from worktree-measure-and-show into main 2026-11-15 11:41:31 -05:00
Owner

Step 1 of the milestone "Swaps keep your place" (#167). Nothing a viewer sees changes: no swap lands differently. Landing a swap on the same moment is #168, which builds on what this step learns.

What it does

  • The app hears where each standby is. The watch already downloads each standby's newest segment every 45 s. Its sound is now located in the sound of the stream the channel is playing, which gives the relation between the two streams' own clocks (backend/app/sound.py, backend/app/offsets.py).
  • The game page says it. A kept link's row carries a tag beside its state: "11.6 s ahead", "4.8 s behind", "Same stream" or "No match". A figure that is found but not yet trusted, or that the last samples did not confirm, is a quiet tag with why behind its hover.
  • Every change of stream records how far the picture moved: by the timestamps when both sites carry one stream, by the sound when the two streams have a relation, and not at all otherwise. The game's Log row leads with it in a tag ("Back 6.0 s"), and the Link row's band says it behind its hover.

The owner's two cases

  • A link that shows another game never shows a figure. It scores nothing, and after five minutes of comparing reads "No match". This step does not act on it; #170 does.
  • Streams from different markets with different commercials match during play. A sample that does not match changes nothing, so the relation is kept through a break and confirmed again after it. One match is never trusted on its own: two different games can carry the same commercial, so matches have to agree three minutes apart.

What it costs

  • Requests: none for a stream in the clear. An encrypted standby (the embedsports player's streams) needs its key to be heard: one small request to its key service per comparison, every 45 s until the relation is trusted and every three minutes after.
  • Processor: one short ffmpeg decode per segment compared, in a worker thread, one comparison at a time. On this Mac: 50 ms per segment and 70 ms per search. Copying a segment's audio out as it lands costs 0.3 ms.
  • A new dependency: numpy.
  • STREAM_COMPARE_ENABLED=0 turns all of it off.

How it was checked

  • make test: 1,395 passed and 1 skipped, in 27 s. npm --prefix frontend test: 281 passed. make e2e passed. openspec validate measure-and-show --strict passes.
  • The tests use streams generated in the test (noise from a seed, cut and timestamped differently per stream). No broadcast sound is in the repository.
  • The new code was also run, offline, on the real recordings the research took on 2026-11-14. It found the same relations to the millisecond (Gonzaga vs. LSU -23.637 s, Georgia vs. Missouri +13075.481 s, one stream on two sites 0.000 s), and the wrong-game pair scored 0.04 with no match.
  • The game page of this branch was looked at in a browser at three widths, fed by the live app's own answers (read only) with the new fields filled in by hand. The Links table is no wider than before, and the Log's tag is whole where the detail is cut at two lines.

Not checked on a live game

Nothing here has run against a live stream: opening a channel reads streaming sites, which needs the owner's word. To look at after a deploy:

  • The tag on a game with two different streams, and "No match" on a link showing another game.
  • The Log row after a Swap by hand.
  • An encrypted standby's key requests (the log says when a relation is found, trusted, moved or dropped).
  • How a relation behaves across a break when two streams carry different commercials. No such pair was seen in the research; the log lines of this step are there to show it before #168 relies on it.

Decisions taken without the owner, which he may reverse

  • The figure is how much sooner the link shows a moment than the stream playing, from each stream's freshest listings over ten minutes. The gap between two streams' newest segments at one instant wobbles by a segment or two, so it is not shown.
  • The figure is a tag beside a kept link's state, not a column. Only the standby and the second standby are compared, so a column sat mostly empty, and it made the table scroll sideways on mid-size windows.
  • A change of stream's Log row is two lines tall from the start, so its tag moves nothing when the server adds it a moment after the row appears.
  • Once a relation is trusted the comparison runs every three minutes, to spare the processor and an encrypted stream's key service.
  • A standby that is ahead is looked for three times (at once, 20 s and 45 s later), so a miss is counted 45 s after the sample.

Closes #167 when merged, though its live checks remain.

🤖 Generated with Claude Code

Step 1 of the milestone "Swaps keep your place" (#167). Nothing a viewer sees changes: no swap lands differently. Landing a swap on the same moment is #168, which builds on what this step learns. ## What it does - **The app hears where each standby is.** The watch already downloads each standby's newest segment every 45 s. Its sound is now located in the sound of the stream the channel is playing, which gives the relation between the two streams' own clocks (`backend/app/sound.py`, `backend/app/offsets.py`). - **The game page says it.** A kept link's row carries a tag beside its state: "11.6 s ahead", "4.8 s behind", "Same stream" or "No match". A figure that is found but not yet trusted, or that the last samples did not confirm, is a quiet tag with why behind its hover. - **Every change of stream records how far the picture moved:** by the timestamps when both sites carry one stream, by the sound when the two streams have a relation, and not at all otherwise. The game's Log row leads with it in a tag ("Back 6.0 s"), and the Link row's band says it behind its hover. ## The owner's two cases - **A link that shows another game never shows a figure.** It scores nothing, and after five minutes of comparing reads "No match". This step does not act on it; #170 does. - **Streams from different markets with different commercials** match during play. A sample that does not match changes nothing, so the relation is kept through a break and confirmed again after it. One match is never trusted on its own: two different games can carry the same commercial, so matches have to agree three minutes apart. ## What it costs - **Requests:** none for a stream in the clear. An encrypted standby (the embedsports player's streams) needs its key to be heard: one small request to its key service per comparison, every 45 s until the relation is trusted and every three minutes after. - **Processor:** one short ffmpeg decode per segment compared, in a worker thread, one comparison at a time. On this Mac: 50 ms per segment and 70 ms per search. Copying a segment's audio out as it lands costs 0.3 ms. - **A new dependency:** numpy. - **`STREAM_COMPARE_ENABLED=0`** turns all of it off. ## How it was checked - `make test`: 1,395 passed and 1 skipped, in 27 s. `npm --prefix frontend test`: 281 passed. `make e2e` passed. `openspec validate measure-and-show --strict` passes. - The tests use streams generated in the test (noise from a seed, cut and timestamped differently per stream). No broadcast sound is in the repository. - The new code was also run, offline, on the real recordings the research took on 2026-11-14. It found the same relations to the millisecond (Gonzaga vs. LSU -23.637 s, Georgia vs. Missouri +13075.481 s, one stream on two sites 0.000 s), and the wrong-game pair scored 0.04 with no match. - The game page of this branch was looked at in a browser at three widths, fed by the live app's own answers (read only) with the new fields filled in by hand. The Links table is no wider than before, and the Log's tag is whole where the detail is cut at two lines. ## Not checked on a live game Nothing here has run against a live stream: opening a channel reads streaming sites, which needs the owner's word. To look at after a deploy: - The tag on a game with two different streams, and "No match" on a link showing another game. - The Log row after a Swap by hand. - An encrypted standby's key requests (the log says when a relation is found, trusted, moved or dropped). - How a relation behaves across a break when two streams carry different commercials. No such pair was seen in the research; the log lines of this step are there to show it before #168 relies on it. ## Decisions taken without the owner, which he may reverse - The figure is how much sooner the link shows a moment than the stream playing, from each stream's freshest listings over ten minutes. The gap between two streams' newest segments at one instant wobbles by a segment or two, so it is not shown. - The figure is a tag beside a kept link's state, not a column. Only the standby and the second standby are compared, so a column sat mostly empty, and it made the table scroll sideways on mid-size windows. - A change of stream's Log row is two lines tall from the start, so its tag moves nothing when the server adds it a moment after the row appears. - Once a relation is trusted the comparison runs every three minutes, to spare the processor and an encrypted stream's key service. - A standby that is ahead is looked for three times (at once, 20 s and 45 s later), so a miss is counted 45 s after the sample. Closes #167 when merged, though its live checks remain. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
When the channel changes stream, the picture jumps to another moment of
the game: a new stream starts three segments from its end, and nothing
compares where the two streams are in the game. On 2026-11-14 two
streams of one game ran 5 to 16 s apart, and a swap moved the picture
up to 24 s. The app knew none of it. This is step 1 of the milestone
"Swaps keep your place": measure and show. No swap lands differently.

The watch already downloads each standby's newest segment every 45 s.
Its sound is now located in the sound of the stream the channel is
playing (sound.py: the segment's audio packets copied out, decoded to
8 kHz mono by ffmpeg in a worker thread, and found by normalised
cross-correlation). Where it fits gives the relation between the two
streams' own clocks, kept per pair of streams (offsets.py). A standby
that is ahead shows a moment the playing stream has not reached, so it
is looked for at once and again 20 s and 45 s later. One comparison
runs at a time.

A relation is found at its first match and trusted once matches three
minutes apart agree within 0.1 s: two different games can carry the
same commercial. A sample that does not match changes nothing, so two
streams of one game from different markets keep their relation through
a break. A match at another place replaces it, and a stream whose
clock jumps loses it. A pair compared for five minutes with no match
reads "No match": another game, or another broadcast of this one.

The game page shows it in a tag beside a kept link's state ("11.6 s
ahead", "4.8 s behind", "Same stream", "No match"), quiet until the
relation is trusted and when the last samples did not confirm it. The
figure is how much sooner the link shows a moment than the stream
playing, from each link's freshest listings over ten minutes; the gap
between two streams' newest segments wobbles by a segment or two.

Every change of stream now records how far the picture moved
(moved_seconds, moved_by): by the timestamps when both sites carry one
stream, by the relation when it is trusted or matched within the last
minute, and not at all otherwise. The splice is read off the timeline
once it is stamped, a moment after the event is written, so the event
is amended in memory and by one more line in the events file, which is
merged on load. The game's Log row leads with it in a tag ("Back
6.0 s"), in a row that is two lines tall from the start so the tag
moves nothing, and the Link row's band says it behind its hover.

No request is added for a stream in the clear. An encrypted standby
needs its key to be heard: one small request per comparison, every
45 s until the relation is trusted and every three minutes after.
numpy is a new dependency. STREAM_COMPARE_ENABLED=0 turns it all off.

Tested with streams generated in the test (noise from a seed, cut and
timestamped differently per stream): no broadcast sound is in the
repository. Run offline on the real recordings of 2026-11-14, the new
code found the same relations to the millisecond and no match for the
wrong game. Not yet run against a live stream.

OpenSpec change: measure-and-show.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No labels
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
cmoriarty/sports-breaker!171
No description provided.