Record slice 1 in the design; consume a host that is no TeamSpeak one

- docs/session-seam.md: the status line, and section 13 with how the code
  differs from the design, a follow-up for the protocol repository (P12), and
  what ran against the baseline.
- docs/architecture.md and the crate docs describe the engine on the Session.
- A departed client's talk state is dropped before the new snapshot replaces
  the table it is looked up in.
- The backend of a host that names none is its product and version.
- A unit test drives the engine over the protocol repository's FakeSession
  through the registry: connect, presence, a move, chat in the channel,
  disconnect.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
faumarayandClaude Sonnet 5.5 committed 2026-10-20 22:25:56 +03:00
1 parent c473ab216e
commit 1b7abdf4c7
7 files changed
+244 -20

No files matched your search

+86 -2
View File
@@ -1,7 +1,7 @@
# The session seam: the engine on `voelin_proto::link::Session`
Status: design (2026-10-20), nothing implemented yet; section 10 has the
slices.
Status: design (2026-10-20); slice 1 is implemented (section 13 says how it
differs from this text); section 10 has the slices.
Design for the first half of plan step 7 (Phase 4): the engine consumes
`voelin_proto::link::Session`, `ServerLink` becomes an adapter over it, and
@@ -844,3 +844,87 @@ Nothing here blocks this half: each has a workaround above.
| A uid that round-trips through `User.uid` on one side and through `Foreign` on the other (F10) would key contacts and private history differently. | Both sides use one rule (canonical base64 → bytes, anything else → `Foreign`), asserted by the round-trip test on TeamSpeak 3 and 6 uids, ServerQuery login names and the FakeLink fixtures' `alice=`; checked live (contacts and private history keyed by uid). |
| The model crate switch collides with other branches. | 11.3; the switch is manifest-only. |
| Two adapters cost CPU per voice packet (RTP wrap and unwrap in process). | About a hundred bytes copied per 20 ms per talker; measured once in slice 1 against the baseline's CPU with the smoke's voice scenario. |
## 13. Slice 1 as implemented
Slice 1 (the adapter, section 10) is in `phase4/session-seam`: step 1 is the
commit that takes `voelin-model` from the protocol repository, step 2 the
commit that puts the engine on the `Session`. `session.rs` is unchanged
(`git diff 59fec5b -- crates/voelin-core/src/session.rs` is empty), and no
public item was removed. Where the code differs from the text above:
- **Files.** `ts_session` is a directory (`mod.rs` with `LinkConnector`,
`TsConnector`, `connect_params` and the `Session` impl; `driver.rs`, the
task that plays the host; `entities.rs`, the presence as v1 entities and
its diff; `ids.rs`; `media.rs`, voice as RTP and back). The unit tests of
the mapping are `link/tests.rs`; the presence round trip is in `book.rs`,
next to the book fixtures. `bytes` is a direct dependency now (the RTP
packets of `MediaPacket`).
- **`LinkSession` is not generic.** It holds the inner link as an
`Arc<dyn ServerLink>`; `LinkConnector::new(link, schemes)` and
`LinkConnector::any(link)` are the generic part, and `TsConnector` is a
`LinkConnector` over `TsLink` for `ts3server` and `teamspeak`.
- **The account-proof watches** (`myts_identity`, `myts_data`) travel in
`LocalCtx`, from the engine's `LinkCtx` to the connection, not in
`TsConnector` (section 4.8): `Engine::start_with_backends` takes a
registry that is made before the engine exists, so the watches cannot be
handed to a connector in it. `LocalCtx::standalone()` makes a context
(with the watches' senders kept alive) for a connector called outside an
engine; the plain `Connector::connect` of `LinkConnector` uses it.
- **`OpenWrite` hands a connection, not a write half** (`BoxDuplex`): the
upload's `done` has to see the server close it. `UploadBody` reports the
shutdown of the body to `done`, which then waits for the end of the
connection (30 s at most), as `files::upload` always did.
- **Media before pushes.** SessionLink's loop polls the media queue before
the pushes (section 4.2 says the reverse): the in-process task writes a
talker's `VoiceState` before its first packet, but nothing orders a push
and a media packet across two channels, and the fake-link tests play
`Audio`, `Poke` and `Error` in one go and wait for the events in that
order. A packet from a slot the replica does not know yet fetches the
queued pushes first and tries again, so a talker's first packet is not
lost either way.
- **CHAT scopes are re-subscribed in full.** The replica drops a scope's
cursor and entities when it is unsubscribed and refuses a delta sync
without a baseline, so SessionLink does not keep cursors for a delta
after moving back (section 4.3); the full sync repeats the window and the
engine's `seen` set reports each `(channel, id)` once. `LinkSession` does
answer `Subscribe.since` of its own epoch with a delta.
- **Fixtures** (section 5.4), beyond the builders listed there:
`presence()` gives the own client the unique id the `Connected` event names
and the server the version of the backend; in
`a_replaced_connection_is_ignored` the new connection's presence puts the
own client in the lobby, where its `OwnChannel` and its channel chat are
(a TeamSpeak server delivers channel chat for the channel we are in only,
section 4.3). In the book round trip a TeamSpeak 6 client with no
streaming flag in the book comes back as `Some(false)` (v1 has no
"unknown").
- **Known limits.** Two clients with one identity (one database id) are two
users of the replica (the higher client id gets a user id made of its
client id). A `Put Message` before any snapshot is handed to the link
whatever the channel. `Welcome.limits` is partly filled. `Backends` has a
slot for an `AccountAgent` and for a `HostTrust` (refusing by default);
nothing sets either yet.
Follow-up for the protocol repository, found while writing the code:
- **P12.** `FileEntry.from_path` should say whether it includes the file's
name. The TeamSpeak side reads it as the whole old path (`/dir/name`),
with `path` and `name` of the entry the new place.
What ran against the baseline (main `59fec5b`; the dev servers of
`dev/docker-compose.yml` as the compose project `voelin-seam`, TeamSpeak
3.13.8 and 6.0.0-beta13.1):
| Check | Baseline | Adapter |
|---|---|---|
| `scripts/it-smoke.sh ts3 ts6`, every per-server scenario (connect and tree, server and channel chat, voice tone, invisible presence, relay chat, gateway, history, pins and reactions, streams and late and elsewhere streams on TS6, the engine's voice features: file upload, link, list, download and delete; avatar; poke; private and offline messages; friend; blocked poke) | all pass | all pass, same output |
| the script's last stage, `cargo test -p voelin-core --features media-desktop --test live --test stream_live --test media_live` (parallel) | 5 pass, `ts6_banners` fails (4 HTTP requests where 0 are expected: another test's engine shares the mock server) | the same |
| `live` (serial, `--test-threads=1`) | 6 of 6 | 6 of 6 |
| `voice_features`, `stream_live`, `media_live` (serial) | 3, 3, 2 pass | 3, 3, 2 pass |
`cargo test -p voelin-core` has two failures that exist on the baseline too
(`discover::tests::without_records_the_gateway_itself_is_asked`,
`web::tests::pictures_go_through_the_proxy_named_for_each_hop`: they need
the network). Not measured: the CPU cost of the second adapter per voice
packet (section 12); the packets are a hundred bytes each way every 20 ms
per talker.