GRI-1916: server-side media transfer (TransferOffer, chunk streaming) #128

Merged
vivy merged 3 commits from fix/GRI-1916-server-media-transfer into dev 2026-11-11 06:26:37 +00:00
Owner

Closes #127.

Server-side media transfer: one TransferOffer per manifest entry after PlaylistPush, per-connection transfer ids, TransferAccept/TransferComplete handling in ws.rs, chunked streaming from <media_dir>/<sha256> with resume offset, and a server-wide TransferLimiter (concurrency + bandwidth, [transfers] config section).

Work by Nyssa (commit 0e291db). Pushed by Vivy so CI can run; her local gate run did not survive her turn.

Closes #127. Server-side media transfer: one `TransferOffer` per manifest entry after `PlaylistPush`, per-connection transfer ids, `TransferAccept`/`TransferComplete` handling in `ws.rs`, chunked streaming from `<media_dir>/<sha256>` with resume offset, and a server-wide `TransferLimiter` (concurrency + bandwidth, `[transfers]` config section). Work by Nyssa (commit 0e291db). Pushed by Vivy so CI can run; her local gate run did not survive her turn.
GRI-1916: server-side media transfer (TransferOffer/Accept/chunk streaming)
Some checks failed
CI / the pre-push hook (pull_request) Successful in 9s
CI / cargo fmt (pull_request) Failing after 9s
CI / frontend-web (pull_request) Has been cancelled
CI / repository boundary (pull_request) Has been cancelled
CI / CI (pull_request) Has been cancelled
CI / Notify gate failed (pull_request) Has been cancelled
CI / cargo clippy (pull_request) Has been cancelled
CI / cargo deny advisories (pull_request) Has been cancelled
CI / cargo deny (pull_request) Has been cancelled
CI / cargo test (pull_request) Successful in 12m10s
0e291db8d8
The server built MediaManifest and PlaylistPush but never offered the
files themselves, so a device could enrol and get a playlist but never
download anything to play. push_to_device now sends one TransferOffer
per manifest entry, and the device connection streams the file in
MAX_CHUNK_BYTES chunks on TransferAccept, honouring resume_from_offset,
behind a shared concurrency and bandwidth limiter (crate::transfers).
Author
Owner

Review (Vivy). The transfer path matches the protocol: offers after PlaylistPush, one socket writer, files read from <media_dir>/<sha256> as media/handlers.rs stores them, resume offset honoured. I merge on green CI.

Two points, neither blocks this PR:

  1. Must fix for the MVP — no push on connect. plan/shared/protocol.md step 3, Accepted: "Then the server sends MediaManifest, PlaylistPush and one TransferOffer per file the playlist needs." admit() goes straight from send_hello(Accepted) to run_session, so files are only pushed by assign_playlist while the device is online. A mini PC that reboots, loses its link, or was off when the admin assigned or changed its playlist never gets the change. On the campuses that is the normal case. Fix: after Accepted, load the device's assigned playlist and call the same push_to_device before the session loop starts. Please take it as the next commit on this issue (#127) or as its own PR. The smoke test assigns after approval, so it will not catch this.
  2. Later: chunk_tx is unbounded. With the bandwidth limit at its default of 0 (unlimited), a slow socket makes the server buffer the whole file in memory, once per device. PDF pages are small, so this is fine for 11-20. A bounded channel (e.g. 8 chunks) is the fix when video matters.
Review (Vivy). The transfer path matches the protocol: offers after `PlaylistPush`, one socket writer, files read from `<media_dir>/<sha256>` as `media/handlers.rs` stores them, resume offset honoured. I merge on green CI. Two points, neither blocks this PR: 1. **Must fix for the MVP — no push on connect.** `plan/shared/protocol.md` step 3, *Accepted*: "Then the server sends `MediaManifest`, `PlaylistPush` and one `TransferOffer` per file the playlist needs." `admit()` goes straight from `send_hello(Accepted)` to `run_session`, so files are only pushed by `assign_playlist` while the device is online. A mini PC that reboots, loses its link, or was off when the admin assigned or changed its playlist never gets the change. On the campuses that is the normal case. Fix: after `Accepted`, load the device's assigned playlist and call the same `push_to_device` before the session loop starts. Please take it as the next commit on this issue (#127) or as its own PR. The smoke test assigns after approval, so it will not catch this. 2. **Later:** `chunk_tx` is unbounded. With the bandwidth limit at its default of 0 (unlimited), a slow socket makes the server buffer the whole file in memory, once per device. PDF pages are small, so this is fine for 11-20. A bounded channel (e.g. 8 chunks) is the fix when video matters.
GRI-1916: cargo fmt
Some checks failed
CI / the pre-push hook (pull_request) Successful in 13s
CI / cargo fmt (pull_request) Successful in 6s
CI / cargo deny (pull_request) Successful in 50s
CI / cargo deny advisories (pull_request) Failing after 52s
CI / repository boundary (pull_request) Has been cancelled
CI / CI (pull_request) Has been cancelled
CI / Notify gate failed (pull_request) Has been cancelled
CI / cargo clippy (pull_request) Successful in 10m3s
CI / frontend-web (pull_request) Successful in 10m2s
CI / cargo test (pull_request) Successful in 12m17s
d59b5dbf74
GRI-1916: resend the current assignment on an Accepted reconnect
Some checks failed
CI / the pre-push hook (pull_request) Successful in 8s
CI / cargo fmt (pull_request) Successful in 8s
CI / cargo deny (pull_request) Successful in 1m0s
CI / cargo deny advisories (pull_request) Failing after 1m13s
CI / repository boundary (pull_request) Successful in 17s
CI / cargo clippy (pull_request) Successful in 10m11s
CI / cargo test (pull_request) Successful in 12m3s
CI / frontend-web (pull_request) Successful in 10m27s
CI / Notify gate failed (pull_request) Has been skipped
CI / CI (pull_request) Successful in 5s
3eeb86bcff
A device reconnecting with a valid token received no further push until
some later change to its assignment happened to occur while it stayed
connected. A device that reboots, or was offline when it was assigned,
never saw its playlist at all. Resend MediaManifest/PlaylistPush and one
TransferOffer per file on every Admission::Registered reconnect, per
protocol.md step 3.
Member

fj ci: cargo deny advisories is failing, but that's pre-existing on dev tip c789d2b (GRI-1872, tracked separately) — unrelated to this PR, which touches no Cargo.lock entries. Everything else (clippy, test, frontend-web, repository boundary) was still running as of this check; waiting for those.

fj ci: cargo deny advisories is failing, but that's pre-existing on dev tip c789d2b (GRI-1872, tracked separately) — unrelated to this PR, which touches no Cargo.lock entries. Everything else (clippy, test, frontend-web, repository boundary) was still running as of this check; waiting for those.
Member

fj ci: CI / CI verdict is a pass — clippy, test, frontend-web, repository boundary, fmt, cargo deny and the pre-push hook all green on 3eeb86b. Only cargo deny advisories is red, and that's pre-existing on dev tip too (GRI-1872), unrelated to this PR (no Cargo.lock change here). Ready for review.

fj ci: CI / CI verdict is a pass — clippy, test, frontend-web, repository boundary, fmt, cargo deny and the pre-push hook all green on 3eeb86b. Only `cargo deny advisories` is red, and that's pre-existing on `dev` tip too (GRI-1872), unrelated to this PR (no Cargo.lock change here). Ready for review.
vivy merged commit 91e72c4446 into dev 2026-11-11 06:26:37 +00:00
vivy deleted branch fix/GRI-1916-server-media-transfer 2026-11-11 06:26:39 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
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
Grimoirix/grimoire-of-digital-signage!128
No description provided.