Correct the record of a reconnect's replay and of the live module's prerequisite

Section 16 of the design said that after a reconnect to a v1 host the
display is right and only the store is wrong, because Dedup drops the copy
of the event. That holds only for the messages within 4 s of the newest one
seen: Dedup evicts what is older than that relative to the incoming
message, so a replayed older message is shown again as a live Event::Chat
and stored again. Corrected in 4.4, 16.1, 16.4 and F3 (16.5), with the two
ignored tests that pin the display and the store, and in P17 and H10: only
the CHAT-cursor resume cures both, and only within an epoch.

Also: the introduction of section 16 names the two production changes (F1,
F2), not three; the move-back test now sends two messages 10 s apart and
the record says what the single-message version did not prove; the live
module raises the anti-flood limits itself and the record says so and what
ran (a fresh stack before and after, in series and in parallel, and the
smoke script before and after on freshly reset stacks); the toolchains of
the review round, the nightly that replaced 2026-10-19, and the per-commit
checks.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
faumarayandClaude Sonnet 5.5 committed 2026-10-24 04:54:16 +03:00
1 parent 9283191e58
commit efacb41894
1 file changed
+113 -37
+113 -37
View File
@@ -348,7 +348,10 @@ connection).
- **Resume**: `LinkSession` does not offer `resume`. SessionLink keeps the
last `Welcome.resume_token` and the CHAT cursors per session and address,
and sends neither in this half: no `voelin://` connector is registered.
Reconnecting with backoff (protocol 2.5) is the SDK's (H8).
Reconnecting with backoff (protocol 2.5) is the SDK's (H8). Until then a
reconnect to a v1 host replays the window of each CHAT scope: the engine
stores every replayed message again, and shows again those that `Dedup` no
longer holds (F3, 16.5).
### 4.5 Close
@@ -1154,18 +1157,19 @@ again, the comparison with it is the table of section 13):
Slice 2 (section 10: the tests on `FakeSession` and `FakeHost`, the conformance
suite, the TeamSpeak session tests) is in `phase4/session-seam`. It adds tests
and three small changes to the code under test, each found by a test, each in a
commit of its own (16.5).
and two small changes to the code under test, each found by a test, each in a
commit of its own (F1 and F2 in 16.5); a third finding (F3) is open, and a
fourth (F4) is an observation.
### 16.1 What was built
| File | What | Tests |
|---|---|---|
| `tests/session_fake.rs` | The engine through `Engine::start_with_backends` with a `FakeConnector` (scheme `fake`) and a `FakeHost` filled with `put`; `FakeHandle` plays the backend of one session. Public API only. | 16 run, 1 ignored (F3) |
| `tests/session_fake.rs` | The engine through `Engine::start_with_backends` with a `FakeConnector` (scheme `fake`) and a `FakeHost` filled with `put`; `FakeHandle` plays the backend of one session. Public API only. | 16 run, 2 ignored (F3) |
| `tests/link_fake.rs` | Trimmed to the three tests that need the inner link: the stream commands (`stream_commands_reach_a_link_with_streams`), the order of a reconnect's shutdown, a replaced connection that keeps talking. | 3 |
| `src/link/fake_tests.rs` | What needs the crate's private parts: our voice as RTP read from `sent_media`, the voice of other slots, our own voice coming back, the conformance suite through `Backends::connect`. | 4 |
| `src/link/tests.rs` | One more test: a session made outside an engine keeps its watches open (F2). | 1 |
| `src/ts_session/live_tests.rs` | The TeamSpeak `Session` on both development servers (`VOELIN_LIVE=1`): the conformance subset and the session scenarios of 9.3. | 12 live, 2 ignored |
| `src/ts_session/live_tests.rs` | The TeamSpeak `Session` on both development servers (`VOELIN_LIVE=1`): the conformance subset and the session scenarios of 9.3. It raises the servers' anti-flood limits itself before the first connection (16.8). | 12 live, 2 ignored |
`scripts/it-smoke.sh` runs the live module before its engine stage.
@@ -1193,8 +1197,11 @@ another session of the host that dropped its upload); `CreateDirectory`,
`RenameFile` and `DeleteFiles` as `FileEntry` puts and deletes; media routed to
the talker of its slot (an unknown slot, a whisper, 400 ms of silence); a
reconnect (the host sees the first session closed, the second has another
participant, a message said while away arrives, the replay of a message seen
does not show again); a connect that fails, and a second that works.
participant, a message said while away arrives, and the replay of the one
message seen is not shown again, because `Dedup` still holds it; every
replayed message is stored again, and one older than `Dedup`'s 4 s is shown
again, which the two ignored tests of F3 pin); a connect that fails, and a
second that works.
### 16.2 The conformance suite
@@ -1260,12 +1267,25 @@ for the LIVE scope to show it):
- **The CHAT re-subscription after moving back is a full sync**, not a delta
(13): `the_chat_of_a_channel_is_resubscribed_when_we_move_back` asserts two
`Subscribe`s of the channel without `since`, the missed message once, and the
message seen before not again.
messages seen before not again. The `seen` set of `SessionLink` drops them,
within the one connection, before the engine is asked about them: the test
sends two of them 10 s apart, so that `Dedup` (4 s) no longer holds the older
one and could not have dropped it. (With one message only the test passed
without the `seen` check as well, because the newest message seen is held by
`Dedup` too; with the check disabled the two-message test sees "before"
again, 16.8.)
- **A reconnect resumes nothing** (4.4): the second session is another session
of the same host. `a_reconnect_finds_the_state_the_first_session_left` asserts
what that gives (the state of the host, another participant, the first seat
gone from the host, the first session `Local(Normal)`), and F3 what it does
not give.
of the same host, with a `SessionLink` and a `seen` set of its own.
`a_reconnect_finds_the_state_the_first_session_left` asserts what that gives
(the state of the host, another participant, the first seat gone from the
host, the first session `Local(Normal)`, the message said while away shown
once). What it does not give is a clean replay: the host sends the window of
the CHAT scope again, and every replayed message is stored a second time, and
shown a second time unless `Dedup` still holds an equal one (it holds the
messages up to 4 s older than the last it was asked about). The one message
that test sends before the disconnect is inside that window, so its replay is
dropped. The two ignored tests of F3 (16.5) send two messages more than 4 s
apart and pin both effects.
- **Our voice in `FakeHandle::sent_media()`** is a test of `SessionLink`
(`link/fake_tests.rs`): no `Command` of the engine sends voice, the audio
thread does.
@@ -1273,6 +1293,14 @@ for the LIVE scope to show it):
`Backends::connect`, `LocalCtx` and `TsConnector` are crate-private, and
nothing was made public for a test. The live module runs with
`VOELIN_LIVE=1 cargo test -p voelin-core --lib ts_session::live_tests -- --test-threads=1`.
The servers must be the ones of `dev/docker-compose.yml` (the module logs in
to their ServerQuery as `serveradmin`) and may be freshly started: a server
with its default anti-flood limits bans the address of the tests after three
or four connections (`ConnectFailedBanned`), so the module raises
`virtualserver_antiflood_points_needed_ip_block` and
`virtualserver_antiflood_points_needed_command_block` itself, once per server
and run, and clears the bans of an earlier run (`bandelall`), as
`scripts/it-smoke.sh` does in `admin_args`. It leaves the limits raised.
Slice 3 makes `TsConnector` public as `voelin_core::ts` and can move them to
`tests/`.
- **The fake host does not model everything the scenarios use**: it refuses
@@ -1311,23 +1339,55 @@ passed without the session being alive). Test:
`a_session_made_outside_an_engine_keeps_the_watches_of_its_link_open` (fails
with "the identity watch lost its sender" without the change).
**F3 (open; `a_message_the_host_sends_again_after_a_reconnect_is_stored_once`,
ignored).** After a reconnect, a Voelin host sends the window of a CHAT scope
again (the full sync of 4.3), and the engine stores each message of it a second
time. The display is right: `seen` in `SessionLink` is per connection, so the
replay is reported again, and `Dedup` in `session.rs` drops the copy of the
event (same target, author, text and time) but only after `store_live`; the
store merges copies from different sources only, so a replay over the same
source is a second row, and `ChatMessage` does not carry the host's message id
that would let it merge them. TeamSpeak never replays, and no `voelin://`
connector is registered, so no host the engine reaches today meets this. Not
fixed here because the cure is the resume of H8, not a patch: a cursor kept per
CHAT scope and sent as `Subscribe.since` (a delta, or a full sync when the epoch
changed); the cheaper candidates each carry a risk (a time floor per channel
for the messages of a connect-time sync would hide a backlog of a host that
was restored with older clocks; keeping the reported ids across connections
would hide new messages of a host whose ids restart). The ignored test is the
acceptance test of whatever is chosen.
**F3 (open; two ignored tests,
`a_message_the_host_sends_again_after_a_reconnect_is_not_shown_again` and
`a_message_the_host_sends_again_after_a_reconnect_is_stored_once`).** After a
reconnect, a Voelin host sends the window of a CHAT scope again (the full sync
of 4.3), and the engine gets it wrong twice, in the store and on the display.
`seen` in `SessionLink` is per connection, so every message of the replay is
reported again; `session.rs` then stores each one (`store_live`, before
anything looks for a copy) and shows each one unless `Dedup` drops it.
- **The store.** The store merges copies from different sources only, so a
replay over the same source is a second row, whatever `Dedup` does, and
`ChatMessage` does not carry the host's message id that would let it merge
them.
- **The display.** `Dedup` (`route.rs`) recognises a copy only while an equal
message (target, author, text, a timestamp within 2 s) is still held, and it
holds the messages up to 4 s older than the last one it was asked about. A
replayed message that is not equal to a held one is shown again as a live
`Event::Chat`, like a new message: every message of the replayed window that
is more than 4 s older than the newest message seen before the disconnect.
The newest message, and what is within 4 s of it, is dropped.
The first version of the stored-once test sent one message before the
disconnect and looked at the rows only, and the display check of
`a_reconnect_finds_the_state_the_first_session_left` passed on that one message
because it is the newest one, so `Dedup` still held it: no test showed that the
display was wrong too. With two messages 10 s apart ("first" at `t`, "second"
at `t + 10 s`, then "while away" at `t + 30 s` said while the first session is
closed) the two tests see:
| Test | Expected | Seen |
|---|---|---|
| `..._is_not_shown_again` | the events `["while away"]` | `["first", "while away"]` ("second" is held and dropped, "first" is shown again) |
| `..._is_stored_once` | the rows `["first", "second", "while away"]` | `["first", "first", "second", "second", "while away"]` |
`a_reconnect_finds_the_state_the_first_session_left` stays in the default run
and proves only that a message inside `Dedup`'s window is not shown again.
TeamSpeak never replays, and no `voelin://` connector is registered, so no host
the engine reaches today meets this. Not fixed here because the cure is the
resume of H8, not a patch: a cursor kept per CHAT scope and sent as
`Subscribe.since`, which makes the reconnect a delta and cures both effects (the
replayed window is never sent), but only within an epoch: after an epoch change
the host sends a full sync again, and then only the host's message id can tell a
copy, in the store (H10) and on the display. The cheaper candidates each carry a
risk (a time floor per channel for the messages of a connect-time sync would
hide a backlog of a host that was restored with older clocks; keeping the
reported ids across connections would hide new messages of a host whose ids
restart; widening `Dedup` would hide a message said twice on purpose). The two
ignored tests are the acceptance tests of whatever is chosen.
**F4 (observation).** The first snapshot of the TeamSpeak link can come after
the session was handed out (the driver waits 250 ms for it, `FIRST_SNAPSHOT`),
@@ -1346,13 +1406,13 @@ For the protocol repository (workarounds as above):
|---|---|---|
| P15 | The suite's `Fixture::backend` is a `FakeHandle` for every harness, so a session of a real backend hands it an unrelated fake host and the cases that touch the backend fail or wait instead of being skipped. Make it `Option<FakeHandle>` and let a case say that it needs the backend (extends P8). | `EXPECTED` in `live_tests.rs` names the cases to run. |
| P16 | Say whether a host sends a sender its own voice. `FakeSession` loops it back by default and `media_loops_back` pins that for the fake; a consumer cannot tell a rule of the protocol from a setting of the fake. | F1: the engine drops its own slot. |
| P17 | Say what a consumer that reconnects without a resume token does with the replay of a CHAT window (protocol 2.5, 5.4): the `Message` id is the key to merge on, and `Subscribe.since` of a previous connection's cursor is a delta only within an epoch. | F3: nothing yet. |
| P17 | Say what a consumer that reconnects without a resume token does with the replay of a CHAT window (protocol 2.5, 5.4): the `Message` id is the key to merge on, and `Subscribe.since` of a previous connection's cursor is a delta only within an epoch. | F3: nothing yet (the replay is shown again and stored again). |
For the second half:
| # | What |
|---|---|
| H10 | CHAT cursors per session and address in `SessionLink` (or the SDK of H8), sent as `Subscribe.since` after a reconnect; then the ignored test of F3 runs. The host's message id also has to reach the store, or the store has to merge same-source copies by id. |
| H10 | CHAT cursors per session and address in `SessionLink` (or the SDK of H8), sent as `Subscribe.since` after a reconnect; then the two ignored tests of F3 run; the cursor cures the display and the store only within an epoch (16.5). For the full sync after an epoch change the host's message id also has to reach the store (or the store has to merge same-source copies by id) and the display. |
| H11 | The native TeamSpeak session of H1 holds the first sync back until it has the first snapshot (F4), and `ts_session/live_tests.rs` moves with `ts_session` to `voelin-gateway-ts`; its `EXPECTED` table is the conformance record of that crate. |
### 16.7 The broken translation
@@ -1380,22 +1440,38 @@ outputs on `LD_LIBRARY_PATH` (`voelinctl` needs `libvpx.so.12`), and
`cargo check --workspace --all-targets --locked` passes on both toolchains. The
development servers were TeamSpeak 3.13.8 and 6.0.0-beta13.1 of
`dev/docker-compose.yml` (compose project `voelin-seam5`, reset with `down -v`
before each smoke run).
before each smoke run; the review round after the first version of this section
used `voelin-fix2`, reset the same way).
The review round (the corrections of F3, 16.1 and 16.4, the live module's
anti-flood step) ran on 1.94.1 and on the nightly that the store held then,
`rustc 1.101.0-nightly (19833af72 2026-10-20)`: the nightly 2026-10-19 of the
first record was no longer there, so every nightly number below was measured
again on this one. The `nix shell` was the same set plus `expat` and the `.dev`
outputs of `freetype` and `libxkbcommon`; `PKG_CONFIG_PATH` took the `.dev`
outputs of all of them, `LD_LIBRARY_PATH` every output of every one of them
(the `out` output alone left `libvpx.so.12` unfound for `voelinctl`), and
`BINDGEN_EXTRA_CLANG_ARGS` the include directories of `glibc.dev` and of
`clang`'s resource directory.
| Check | Result |
|---|---|
| `cargo fmt $(scripts/own-crates.sh) -- --check` | clean on 1.94. Nightly: the six differences of the baseline (`history.rs`, `encoder.rs`, `discovery.rs`, `chat.rs`, `studio.rs`, `engine.rs`), none in a file of this slice. (`cargo fmt --all` on 1.94 rewrites the vendored `crates/proto`, so it is not the check.) |
| `cargo clippy $(scripts/own-crates.sh) --all-targets --locked --no-deps -- -D warnings` | clean on 1.94, `voelin-ui` and the binaries included. Nightly: the five lints of the baseline in code this slice did not touch (`chunks_exact` four times in `audio.rs`, `result_large_err` in `voice.rs`), none in the new code. Every commit of the slice was checked alone on 1.94 (fmt, clippy, its tests); the first from an archive of its tree. |
| `cargo fmt $(scripts/own-crates.sh) -- --check` | clean on 1.94. Nightly 2026-10-20 (measured again in the review round): the six differences of the baseline, in the same six files (`history.rs`, `encoder.rs`, `discovery.rs`, `chat.rs`, `studio.rs`, `engine.rs`), none in a file of this slice. (`cargo fmt --all` on 1.94 rewrites the vendored `crates/proto`, so it is not the check.) |
| `cargo clippy $(scripts/own-crates.sh) --all-targets --locked --no-deps -- -D warnings` | clean on 1.94, `voelin-ui` and the binaries included. Nightly 2026-10-20 (measured again in the review round): `-p voelin-core --all-targets` gives the five lints of the baseline in code this slice did not touch (`chunks_exact` four times in `audio.rs`, `result_large_err` in `voice.rs`), none in the new code; over all own crates this nightly stops earlier, in `voelin-audio` and `voelin-media`, on lints that are new to it (`chunks_exact` and `chunks_exact_mut` with a constant chunk size, a manual checked division, `sort_by_key`) in two crates the slice did not touch. Every commit of the slice was checked alone on 1.94 (fmt, clippy, its tests); the first from an archive of its tree, the two code commits of the review round (`81d1de8`: the tests of 16.4 and 16.5; `9283191`: the live module) from detached checkouts in this worktree (fmt of the own crates, clippy of `voelin-core --all-targets`, `session_fake` and `link_fake`), and the record of the round is a commit of this file only. |
| `cargo check --workspace --all-targets --locked` | passes on 1.94 and on nightly |
| `cargo test -p voelin-core --locked` | 1.94 and nightly: 236 lib tests pass, 2 are ignored (the live "do not apply" tests), 2 fail; the integration tests pass (`session_fake` 16 and 1 ignored, `link_fake` 3, `session_backends` 2, `gateway` 8, ...). The two failures are the baseline's (`discover::tests::without_records_the_gateway_itself_is_asked`, `web::tests::pictures_go_through_the_proxy_named_for_each_hop`: both reach a server bound to `127.0.0.1` through `localhost`, which resolves to `::1` here); they fail on an unchanged copy of `bfc52e2` too. |
| `cargo test -p voelin-core --locked --features media-desktop` | the same, and a third failure, `media::tests::peer_config_follows_codecs`, which depends on the codecs of the machine and fails on the unchanged copy of `bfc52e2` as well. (`--features media` alone does not compile the crate's tests: `src/media.rs` names `voelin_media::ffmpeg`, which only the desktop backends have; that is the baseline's.) |
| `link_fake` and `session_fake`, 15 consecutive runs | 0 failures (load average about 4) |
| `cargo test -p voelin-core --locked --no-fail-fast` | 1.94: 236 lib tests pass, 2 are ignored (the live "do not apply" tests), 2 fail; the integration tests pass (`session_fake` 16 and 2 ignored, `link_fake` 3, `session_backends` 2, `gateway` 8, `live` 6, `stream_live` 3, `voice_features` 3, `settings` 1). Nightly 2026-10-20: the same integration tests, and 235 lib tests pass with 3 failures: the two below and `identity::tests::improve_level_keeps_the_key` once in seven runs (it passed in six reruns of the single test; it makes a random identity and asserts that the counter grew, which it does not when the key already has the level asked for, so a flake, though that cause was not confirmed; `identity.rs` is unchanged since `59fec5b`). (Without `--no-fail-fast` the run stops at the lib's two baseline failures and the integration tests do not run.) The two failures are the baseline's (`discover::tests::without_records_the_gateway_itself_is_asked`, `web::tests::pictures_go_through_the_proxy_named_for_each_hop`: both reach a server bound to `127.0.0.1` through `localhost`, which resolves to `::1` here); they fail on an unchanged copy of `bfc52e2` too. |
| `cargo test -p voelin-core --locked --features media-desktop` | (first version of this record; not rerun in the review round, which changed tests, the live module and this file only) the same, and a third failure, `media::tests::peer_config_follows_codecs`, which depends on the codecs of the machine and fails on the unchanged copy of `bfc52e2` as well. (`--features media` alone does not compile the crate's tests: `src/media.rs` names `voelin_media::ffmpeg`, which only the desktop backends have; that is the baseline's.) |
| `link_fake` and `session_fake`, 15 consecutive runs (again on the head of the review round, with the changed move-back test) | 0 failures (load average about 4; 9 at the last run of the review round) |
| Mutation (16.7) | `commands_reach_the_host_as_requests` fails with the `self_mute` path dropped; the file was restored |
| Mutation (16.4), `if self.seen.contains(&(channel, id))` in `SessionLink::after` made `if false && ...` | `the_chat_of_a_channel_is_resubscribed_when_we_move_back` with its first version (one message seen before the move) still passes, and so does `a_reconnect_finds_the_state_the_first_session_left`: `Dedup` holds the newest message seen. With the two messages 10 s apart of the present version the test fails (`left: "before"`, `right: "while away"`); the file was restored |
| The two ignored tests of F3, `cargo test -p voelin-core --test session_fake -- --include-ignored` | the other 16 pass; `..._is_not_shown_again` sees `["first", "while away"]`, `..._is_stored_once` sees `["first", "first", "second", "second", "while away"]` (16.5); ten more runs of the two (`-- --ignored`): the same two values each time |
| `a_session_made_outside_an_engine_keeps_the_watches_of_its_link_open` without the change of F2 | fails ("the identity watch lost its sender") |
| `our_own_voice_coming_back_is_not_played_back` without the change of F1 | fails (`[1, 50]` heard) |
| Live module, `VOELIN_LIVE=1 cargo test -p voelin-core --lib ts_session::live_tests -- --test-threads=1` | 12 of 12 pass on both servers, in 16 s; three more serial runs and one parallel run the same; with `--include-ignored` the two ignored tests pass too, each non-applicable case failing as `EXPECTED` says (the output of 16.2) |
| The same command on a freshly started stack (`down -v`, `up -d`, nothing else run before) | Before the module raised the anti-flood limits itself: 4 passed, 8 failed (`ts3 did not connect: session closed: Network("Server refused connection: ConnectFailedBanned")`, the same for ts6). The module as it now is, run straight after that failing run (the ban still in force): 12 passed, 2 ignored. After a fresh reset: 12 passed, 2 ignored in 16 s, and 14 of 14 with `--include-ignored` in 51 s; after another reset, the same module in parallel (the default test threads): 12 passed, 2 ignored in 7 s, the tests that start together waiting for the one that raises the limits. Without that step the module passed only after `scripts/it-smoke.sh` had raised the limits (`admin_args`). `banclear` is refused by both servers (`error id=256 command not found`, read on TeamSpeak 3), `bandelall` is accepted by both. |
| `scripts/it-smoke.sh ts3 ts6` on an archive of `bfc52e2` (before) | every per-server scenario passes (connect and tree, server and channel chat, voice tone, invisible presence, relay chat, gateway, history, pins and reactions, the engine's voice features, and on TeamSpeak 6 the streams and the late and elsewhere streams); the last stage fails in `ts6_banners` (`live.rs:375`, "disabled policy must prevent HTTP requests"), as it does on `59fec5b` |
| `scripts/it-smoke.sh ts3 ts6` at the head of the slice (after) | the same output apart from ids and counters (compared line by line with the numbers and identifiers masked), plus the new stage of the live module (12 passed, 2 ignored); the last stage fails in `ts6_banners` at the same line |
| `scripts/it-smoke.sh ts3 ts6` in the review round, at `2089f7c` (before) and at `9283191` (after), each on a freshly reset stack (`COMPOSE_PROJECT_NAME=voelin-fix2`, the state directory under the scratch directory) | both: every per-server scenario of ts3 and ts6 passes, the live module stage gives 12 passed, 2 ignored (16.2 s before, 16.4 s after), and the last stage fails in `ts6_banners` at `live.rs:375` (5 passed, 1 failed), the baseline's failure. The two outputs have 102 lines each and are equal once uids, stream ids, file names and counters are masked (the only residue is the random token in `history-talker: offline-<token>`). The review round changed tests, the live module and this file, so the smoke is unchanged by construction; it also shows that the raising of the limits in `admin_args` and the module's own coexist. |
| the live binaries by hand, serially, on the head (`--features media-desktop`) | `live` 6 of 6, `media_live` 2, `stream_live` 3, `voice_features` 3, `voelin-stream`'s `live_ts6` 1: those of the baseline |
Not run: `cargo deny` (not installed in this environment; `Cargo.lock` and