A swap carries on from the same moment of the game (#168) #172
Loading…
Reference in a new issue
No description provided.
Delete branch "aim-the-swap"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Step 2 of the milestone "Swaps keep your place" (#168). Step 1 (#167, live since 2026-11-15) taught the app how far apart two streams' clocks are. This uses it: a change of stream carries on from the same moment of the game. Not merged, not deployed.
What it does
backend/app/tscut.py); nothing is re-encoded. Only segments no player was sent are cut or dropped. The join is a discontinuity, as before, and the channel's clock runs on.aimed(yes,unconfirmed,no),aim_whyandin_hand_seconds, besidemoved_seconds. The game page says it in the tag that leads the Log row ("Same place", "Back 4.2 s", "Not confirmed", "Not aimed") and behind the hover of the Link row's band.The owner's two cases
Found on a real recording: two streams taken for one
This changes something step 1 does on the live app, so it is worth a look before merging.
Found by an independent review, and fixed
A second reader ran the join on the test harness before this pull request. It reproduced four faults and read a fifth. Each has a test now.
The same reader ran 96 ordinary swaps between two matched streams with the audio step on, both directions, ahead and behind: no timestamp went back, every sequence number was sent once, and the record matched the decoded picture within 0.15 s.
What it costs
Found on the way, and fixed here
Timeline.append_upstreamnumbered it only once it appended). A renewed link on another host (#136) had the same fault.Decisions taken without the owner
How it was checked
make test: 1,475 passed, 1 skipped, 34 s (about 27 s before this change).npm --prefix frontend test: 287 passed. The frontend builds.make e2e: every part passed on the final code, run with its try of a real source page turned off, as CI runs it. An earlier run of the plain target in this work did make that try: see "Not checked".openspec validate aim-the-swap --strict: valid.backend/tests/test_channel_join.py). Every case of the ticket's "Done when" is there.ffmpeg -f hls -c copy -copytsacross an aimed join: no timestamp goes backwards and no frame is lost. hls.js in headless Chromium plays through it with one unbroken buffer. The research had not read a head-cut segment inside a playlist.Not checked
make e2etried the first listed game's real source page before its local fake source: one read of the hub, answered by a Cloudflare challenge. The later runs had that try turned off.Left for later
resolution.same_streamalso decides which standby is "a copy" when a stream fails and which standby is kept (#74, #91, #95, #101). It still goes by the clock alone there.🤖 Generated with Claude Code
An independent read of the join, run on the test harness before the pull request, reproduced four faults and read a fifth. Filler in front of a join. A join puts every segment it took on the clock at once, and their sound is then made one by one. Filler that came due in between went in front of the first segment not listed yet (Timeline.insert_filler) and was stamped after all of them: 17 s forward and 21 s back for a reader that copies timestamps. One landed segment could do the same before this change. No filler goes in now while game on the clock is waiting for its sound; the audio step is run instead. The stream measured from. After a stream that landed nothing (its segments did not come) the timeline still ends on the stream before it, while the relation at hand is the dead stream's. The join mixed the two: the 6 s still held were dropped and the picture skipped 5 s, recorded as unconfirmed. A join is now made only from the stream that was left ("not aimed: the stream left had not landed"), and the record's seconds are not worked out across such a gap (offsets._splice). A restart inside the new stream's window. A window holding two clocks was joined across the restart with one relation: up to 13 s skipped, recorded as aimed. What a join downloads must now run on one clock with no discontinuity listed between, or the swap lands as before. A cut that leaves no picture. In a stream that reorders its frames, a cut among a segment's first decoded frames dropped all of its video and kept its listed length. The stream now ends with the segment before it (Channel._old_end). The playlist's media sequence. A join that dropped more held segments than it appended, on a timeline longer than the window, moved EXT-X-MEDIA-SEQUENCE back and listed scrolled-out segments again. The window no longer starts before one already shown (Timeline.window_floor). A test for each. make test: 1,475 passed, 1 skipped, 34 s. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>Stage 1 of the test plan: done, before merge
All offline, on this machine. Nothing touched the live app or a streaming site.
A second, independent review of the parts the first review had not seen: the rule for streams whose clocks agree, and the five fixes in
17628e4. It found two faults, both fixed in27b8031with a test each.The rest it checked held up. That covers the filler hold (it cannot stick), the playlist window floor, where the old stream ends, and the "stream left had not landed" check.
Sweeps of random swaps on generated streams
The join on every research recording that holds both streams
There are 19 recordings, each joined with the audio step on and off: 38 joins.
Lanes on
27b8031:make test1,480 passed, 1 skipped, 34 s.npm --prefix frontend test287 passed. The e2e lane passed with its real-page try turned off.openspec validate aim-the-swap --strictis valid.Still the owner's: reading this pull request and its "Decisions taken without the owner", then the merge. Stage 2 (deploy checks) and stage 3 (the live presses) follow from that.