Screen share 20: fluxer-devserver screenshare scenario (#167) #222
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "screenshare-20-devserver-screenshare"
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?
What this builds
The
fluxer-devserverscreensharescenario (plan Task 20, spec §3.2, §3.6, §12):fixtures/scenarios/screenshare.toml+fixtures/gateway/screenshare_ready.json(the voice guild, owned by relay so the signed-in Moderator is bound by overwrites;@everyonehas SPEAK + STREAM except in Gaming, which denies STREAM; ada streams in Hangout with her own key, grace and hedy watch her) +fixtures/media/stream_preview.jpgserved for ada's key.guild_voice_connection_util.erl,dm_voice_state.erl): the field left out keeps the list (DMs read it as empty),nullclears it, a non-list isVOICE_INVALID_STATE; every key must be a 3-part key of the op 4's channel and scope naming a connection in that channel, otherwise the whole op 4 fails (VOICE_CONNECTION_NOT_FOUNDfor an unknown connection,VOICE_INVALID_STATEotherwise) and nothing changes. A move starts with no keys.gateway.rstakesviewer_stream_keysout of the rawd(newViewerKeys) before decoding the rest, so absent / null / wrong stay distinguishable.self_stream/self_videoforced off without it (permission computed like the fork'scomputePermissions: owner, roles, ADMINISTRATOR, overwrites).GET /streams/{key}/preview(JPEG,no-store, or 404),POST .../preview/upload-url(local presignedPUT /stream-previews/{token}, 1 day,max_bytes1 000 000),POST .../preview(base64). Mutations check key format, channel match, scope, STREAM (MISSING_PERMISSIONS) and ownership (ACCESS_DENIED); bodies must be JPEG and at most 1 000 000 bytes (PREVIEW_MUST_BE_JPEG,FILE_SIZE_TOO_LARGE).start_stream,stop_stream,viewer_join,viewer_leave,revoke_stream_permission(CHANNEL_UPDATE, then self_stream/self_video cleared for everyone there who lost it, the signed-in user included).VoiceScript::streams()returnsLiveStream { user_id, guild_id, channel_id, connection_id, key, viewers }withidentity()=user_<user>_<connection>: what the app's fake room follows to publish a test-patternscreen_shareper remote stream.How it was tested
crates/fluxer-devserver/tests/screenshare.rs, against the realfluxer-apiandfluxer-gateway: the plan's five (op4_with_valid_keys_updates_state,op4_with_foreign_key_is_rejected_whole,self_stream_forced_false_without_permission,preview_upload_url_put_then_get,non_jpeg_preview_rejected) plusscreenshare_scenario_starts_with_ada_streaming_to_two_viewers,stream_steps_change_the_streamer_and_viewers,revoking_stream_permission_stops_every_stream_in_the_channel. The existingbasic/voicetests still pass.FLUXER_SCREENSHOT_TESTS=1 cargo xtask cigreen locally. No capture/encoder/device tests apply to this task.Deviations from the plan
fixtures/scenarios/(the crate's format), notcrates/fluxer-devserver/scenarios/.VoiceStep::user_id()now returnsOption<Snowflake>(revoke_stream_permissionis about a channel); the one caller intests/voice.rsis updated.streams()into the app's--devserverfake room (apps/fluxer/src/runtime.rsfollow_script) is left to Screen share 21, which ownsruntime.rs; this task stays insidefluxer-devserverplus fixtures.Closes #167
🤖 Generated with Claude Code
Independent review: Screen share 20 (devserver screenshare scenario)
Reviewed
git diff 21a3b65..bb392aacold, then checked it against plan Task 20, spec §3.2/§3.6/§12 and the fork gateway (guild_voice_connection_util.erlresolve/validate_viewer_stream_keys,dm_voice_state.erlvalidate_dm_viewer_stream_keys,guild_voice_connection_move.erl).(1) Plan tests: all 5 named tests exist (
op4_with_valid_keys_updates_state,op4_with_foreign_key_is_rejected_whole,self_stream_forced_false_without_permission,preview_upload_url_put_then_get,non_jpeg_preview_rejected). They assert what the plan asks with the spec's values: an absent field keeps the list, null clears it, a non-list isVOICE_INVALID_STATE; one bad key rejects the whole op 4 withVOICE_CONNECTION_NOT_FOUND/VOICE_INVALID_STATEand nothing changes; JPEG only; 1 000 000 bytes is accepted and 1 000 001 is rejected;max_bytes,method: PUT,image/jpeg. There are 3 extra tests (initial READY, scripted steps, permission revoke).(2) Interfaces: the scenario, the op 4 key validation, STREAM per channel (Gaming denies it), the preview GET/upload-url/PUT/POST and the five steps
start_stream/stop_stream/revoke_stream_permission/viewer_join/viewer_leaveall exist. Key validation matches the gateway clause for clause: parse, then channel, then scope, then connection lookup (not found meansvoice_connection_not_found), then channel. In DMs an absent field reads as empty. A move resets the keys to[], which matchesguild_voice_connection_move.erl.VoiceStep::user_id()now returnsOption<Snowflake>; its only caller is updated, andapps/fluxerdoes not call it.(3) Invariants: the devserver crate only, with
bytesadded as a dev-dep (it was already a workspace dep). No core, ui or video changes. Server data that reaches the client is not touched. There is no secret in the fixtures (voicetoken = "dev"is the existing fake-room placeholder). Upload tokens are not logged.(4) Review Focus 2: covered. A foreign-channel key, an unknown connection, another guild, a DM key, an orphan
stream:key, garbage, a non-string and a non-list each reject the whole op 4, and a fresh join with a bad key creates no connection.(5) Local CI:
FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci: fmt, clippy, deny, isolation, parity and every test step passed, including the 8 screenshare and the voice devserver tests. Thescreenshot-testsstep failed once with a SIGSEGV influxer-ui --test screenshots(lavapipe; this PR does not touch that crate). Re-running that step (cargo test --workspace -- --ignoredwith the same env) passed twice with exit 0. I count it as green with a flaky renderer.Findings
screen_share)" and spec §12's screen-audio tone are only half delivered. The devserver exposesVoiceScript::streams()/LiveStream::identity(), butapps/fluxer/src/runtime.rsfollow_script(Task 21's file) still publishes nothing for streams. Also,follow_scriptreacts only to steps, so ada's stream that is live from the start needs astreams()read at startup. Task 21's Interfaces block does not mention this. Please open afollow-upissue linked to #168 and link it from this PR, so Task 21 picks it up. Until then the README and theLiveStreamdoc comment describe behaviour that does not exist yet.image/jpeg, so it causes no harm.upload_urlsis never pruned. That is fine for a devserver.fluxer-uiscreenshot tests. It is worth aciissue if it shows up on the runner.Verdict: APPROVED. No blocking findings, and local CI is green; the one failure was the flaky fluxer-ui screenshot SIGSEGV above, which passed on re-run.
Independent review: Screen share 20 (devserver screenshare), HEAD
89d4edaI reviewed
61a073c..origin/screenshare-20-devserver-screensharecold and checked it against the fork's gateway (guild_voice_connection_util.erl,guild_voice_connection_apply.erl,dm_voice_connect.erl,dm_voice_state.erl).Local gate:
FLUXER_SCREENSHOT_TESTS=1 cargo xtask cipassed (exit 0) in a fresh worktree. livekit-interop was skipped becauseFLUXER_LIVEKIT_TESTSis not set.What I checked
crates/fluxer-devserver/tests/screenshare.rs:op4_with_valid_keys_updates_state,op4_with_foreign_key_is_rejected_whole,self_stream_forced_false_without_permission,preview_upload_url_put_then_getandnon_jpeg_preview_rejected. They assert the spec's values: whole op 4 rejected withVOICE_INVALID_STATE/VOICE_CONNECTION_NOT_FOUND, nothing changed after a refusal, STREAM forced off in Gaming, upload-url{method: PUT, content_type: image/jpeg, max_bytes: 1000000, expires_in: 86400}, latest upload wins, the 1 000 000-byte limit at exactly the boundary, non-JPEG returns 400, and a forged URL returns 403. Three more tests cover the starting state, the steps and the revoke.screensharescenario, the five steps (start_stream,stop_stream,viewer_join,viewer_leave,revoke_stream_permission), the STREAM check per channel (Gaming has none), the preview endpoints andVoiceScript::streams()/LiveStream::identity()are all present.VoiceStep::user_id()now returnsOption<Snowflake>; its only caller in the workspace istests/voice.rs, which was updated.bytes, already in the workspace). There are no secrets in the fixtures:token = "dev"is the existing fake voice token. The new paths have nounwrapor index that client input could make panic. Request paths are not logged, so upload tokens do not reach logs.Findings
[blocking] An op 4 that moves channels skips the viewer-key check (Review Focus 2).
In
voice.rsop4, whenmovingis true the code setsviewer_stream_keys = Vec::new()and never callsresolve_viewer_keys. The gateway does the opposite.proceed_after_restoreandhandle_existing_connectioncallresolve_viewer_stream_keysbefore branching onIsChannelChange, andapply_with_viewer_key(Update, {error, _})refuses the whole op 4 even on a move. Only when the result is{ok, _}are the keys dropped (apply_channel_move).I confirmed this with a throwaway test, which I did not commit: join Hangout with
[ADA_KEY], then send an op 4 moving to Gaming that still carries[ADA_KEY]. The devserver moves the connection and sends no error. The real gateway answersvoice_invalid_state, because ada's connection is in a different channel.This is the exact case Review Focus 2 names: keys of another channel, which a client can easily send stale when it moves while watching. The Interfaces block also promises "op 4 viewer-key validation with the gateway's rules". As it stands, a Screen share 9/21 bug that sends stale keys on a move would pass every devserver test and fail live.
Fix: validate keys on a move too, against the target channel (
resolve_viewer_keys(..., channel), withKeepresolving to the existing keys as the gateway does), return the error if any key is bad, and only then reset to[]for the move. Add a test: a move carrying a key of the old channel is refused whole and the connection stays where it was.[minor] A DM op 4 that leaves out the keys on an existing connection should keep them, not clear them.
resolve_viewer_keysmapsKeepto an empty list wheneverguildisNone. In the gateway,dm_voice_connect:apply_existing_update→resolve_existing_viewer_stream_keys(undefined, …)keeps the existing keys. Only a new DM connection (validate_dm_viewer_stream_keys(undefined)) gets[]. The README sentence "(a DM reads it as empty)" carries the same imprecision. Today this is low impact, because our op 4 always sends a list.[minor] Track the FakeRoom wiring that was handed on.
Deviation (4) gives the
FakeRoomscript, which the Interfaces block lists as produced by this task, to Screen share 21. That is reasonable, since it lives inruntime.rs. Please add a note on #168, or open afollow-upissue linked from this PR, so that the work is not lost.Verdict: changes requested. There is 1 blocking finding (the op 4 move path skips viewer-key validation). CI is green locally.
🤖 Generated with Claude Code
Review round 1, fixed in
aef1739:op4now always runsresolve_viewer_keysagainst the target channel, before the move check, asresolve_viewer_stream_keysdoes ahead ofapply_with_viewer_key. A bad key refuses the whole op 4, and an accepted move then resets the list to[]. If the field is left out, the existing keys are still not checked, as in the gateway. New testop4_move_checks_keys_against_the_target_channel: Hangout to Gaming withADA_KEYgivesvoice_invalid_state, a key naming nobody givesvoice_connection_not_found, a move with the field left out is accepted with[], and a move back with a key valid in the target channel is accepted with[]. The test failed before the fix.Keep(voice.rs): fixed. A left-out field now keeps the existing keys for a DM as well (dm_voice_connect:apply_existing_update/resolve_existing_viewer_stream_keys). A new connection has no keys to keep, so it still starts with[]. New testdm_op4_without_keys_keeps_them, which failed before the fix. The README line is corrected, and it now also describes how a move handles keys.FLUXER_SCREENSHOT_TESTS=1 cargo xtask ciis green locally.Independent review: Screen share 20 (devserver screenshare), HEAD
aef1739I reviewed
git diff 61a073c..origin/screenshare-20-devserver-screensharecold. I checked it against plan Task 20 and spec §3.2, §3.6 and §12, and against the fork's gateway:guild_voice_connection_util.erl(resolve/validate_viewer_stream_keys),guild_voice_connection_update.erl(both callers resolve against the target channel beforenormal_update),guild_voice_connection_move.erl(viewer_stream_keys => []),dm_voice_state.erlanddm_voice_connect.erl.Local gate:
FLUXER_SCREENSHOT_TESTS=1 cargo xtask cipasses (exit 0) in a fresh worktree. All 10 tests incrates/fluxer-devserver/tests/screenshare.rspass. livekit-interop is skipped becauseFLUXER_LIVEKIT_TESTSis not set. I did not check the remote runners.Checks
VOICE_INVALID_STATE/VOICE_CONNECTION_NOT_FOUND, and nothing changes after a refusal (the next accepted state shows it).nullclears it, a non-list is refused.{PUT, image/jpeg, max_bytes 1000000, expires_in 86400}, and the latest upload wins.The round-1 fixes have their own tests (
op4_move_checks_keys_against_the_target_channel,dm_op4_without_keys_keeps_them), and both match the fork. A move resolves the keys against the target first, so a bad key refuses the whole op 4, and an accepted move then resets to[]. A DM op 4 without the field keeps the existing keys.screensharescenario, the op 4 key validation, the per-channel STREAM check (Gaming has none), preview GET / upload-url / PUT / POST, and the stepsstart_stream,stop_stream,revoke_stream_permission,viewer_join,viewer_leave. Two additions are present as well:VoiceScript::streams()/LiveStream::identity().VoiceStep::user_id()now returnsOption<Snowflake>. Its only caller in the workspace (tests/voice.rs) is updated, and no open screenshare-* branch calls it underapps/.fluxer-devserverand fixtures only, plusbytesas a dev-dependency (it is already in the workspace). No core, ui, video or capture crate is touched. There are no tokens or secrets in the fixtures; the scenario'stoken = "dev"is the existing fake. The upload token is minted locally and is never logged. The extraGUILD_CREATE(guild ...393) does not clobber the directory entry of the streaming guild.VOICE_CONNECTION_NOT_FOUND), and keys from another channel, another guild, DM scope and orphan form (VOICE_INVALID_STATE). Each one fails the whole op 4, including a fresh join.Findings
FakeRoomscript listed in the Interfaces block (remote test pattern on the streamer'sscreen_share) is not produced here. It is deferred to Screen share 21 via follow-up #227, which is linked.VoiceScript::streams()gives #168 what it needs to drive it. This is acceptable as tracked, but #168 must pick it up.VoiceStep::user_id()changed its public signature (SnowflakebecameOption<Snowflake>). It has no other consumers today. A task that later matches on it should expect theOption.Verdict: approved. There are no blocking findings, and local ci is green.