Screen share 7: proto-api-streams (#154) #186
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "screenshare-7-proto-api-streams"
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
fluxer-proto
stream:StreamKey { scope: StreamScope::{Guild, Dm, Orphan}, channel_id, connection_id }withStreamKey::new(guild_id, channel_id, connection_id),FromStr,Display, serde as text,is_orphan()/is_sendable()/guild_id()(getStreamKey/parseStreamKeyof the fork;@me:reads asdm:; guild/channel must be snowflakes, connection id non-empty).StreamPreviewUploadUrl(upload_url: SecretString,Debugprints<redacted>, noSerialize) plus the two request bodies.VoiceState.viewer_stream_keys: Option<Vec<String>>(absent/null =None, empty =Some(vec![]), written back as read). Existing users updated (proto tests, devserver).rtc:SelectProtocol::with_capabilities(rtc_connection_id, encode, decode)(voice_onlynow delegates with both empty; output unchanged against the existing fixture),SessionUpdate::new(..),MIGRATION_TOPIC,MAX_MIGRATION_MESSAGE_BYTES(4096) andMigrationMessage::{Candidate, Ready, Commit, Abort, Break, Unknown}::parsewith the fork's validators (ids/sids 1-256, reasons 1-512, generation safe integer, lower-case codec names).limits:LimitConfig,LimitRule,LimitFilter,Traits,resolve(&config, key, &traits, &guild_features) -> Option<f64>followingLimitResolver.ts+LimitRuleRuntime.ts(user context), including the wire format'sexpandWireFormat(rules withoverridesexpanded over the defaults) and the snapshot format;default_limitforfeature_higher_video_quality(0) andmax_screen_share_bitrate(9 000 000).WellKnown.limitsparses leniently (unreadable limits =None, discovery never fails).fixtures/gateway/voice_stream_*.json(sharer's two op 4s, viewer of two streams, DM viewer, a sharer's voice state),fixtures/rest/stream_preview_upload_url.json,fixtures/instance/limits_{wire,snapshot}.json.fluxer-api (
streams.rs):stream_preview(&key) -> Option<Bytes>(404 =None),stream_preview_upload_url(&key, channel_id),put_stream_preview(&upload, jpeg)(no token, noX-Fluxer-*headers,Content-Typefrom the response, transport errors stripped of the URL viawithout_url),post_stream_preview(&key, channel_id, jpeg)(base64). All four bypass theObserver(ApiClient::unobserved), so neither the upload URL nor frame bytes reach--record. The key is percent-encoded in the path beyond[A-Za-z0-9:_.~-].How it was tested
stream_key_forms_round_trip,orphan_key_parses_but_is_flagged,viewer_keys_absent_vs_empty,op4_sharer_and_viewer_fixtures_serialise_like_the_fork(tests/stream.rs);capability_advert_flags_follow_arguments,voice_only_unchanged,session_update_shape,migration_messages_parse_and_oversize_rejected(tests/rtc.rs);limits_resolve_rules_with_filters,well_known_without_limits_still_parses(+limit_values_that_are_not_numbers_are_dropped) (tests/limits.rs);upload_url_debug_hides_url; wiremockpreview_get_404_is_none,upload_url_then_put_without_auth,post_preview_sends_base64(fluxer-api/tests/streams.rs, which also assert nothing reaches the observer and no error text holds the URL).spec_contract.rs: newstream_preview_upload_url_matches_spec(fields vsStreamPreviewUploadUrlResponseSchema, all required and non-null).models_roundtrip.rs:limitsis no longer an ignored field ofwell_known.json(it round-trips exactly), the upload-url fixture is covered by a custom check (noSerialize).FLUXER_SCREENSHOT_TESTS=1 cargo xtask cigreen locally. No real-device tests apply.Deviations from the plan
WellKnown.limitsisOption<Box<LimitConfig>>, notOption<LimitConfig>: unboxed it grewCoreEvent::Discoverenough to trip clippy'slarge_enum_variantonfluxer_ui::UiMessage. Access is the same through auto-deref /as_deref().fixtures/tree (as all merged code does), notcrates/fluxer-proto/fixtures/; limits fixtures in a newfixtures/instance/.RtcError::TooLargetext is now topic-neutral (variant shape unchanged).fluxer-devserver/src/voice.rs(3 lines) to wrap the now-optional viewer keys inSome.UserPrivatedoes not modeltraits, so the core cannot yet pass the user's traits toresolve: follow-up #185.Closes #154
🤖 Generated with Claude Code
Independent review: Screen share 7 (proto-api-streams), commit
6ac431dScope:
git diff 53e3d60..origin/screenshare-7-proto-api-streams. It merges cleanly withorigin/screenshare(currently53e3d60).Plan tests (1): all 14 tests named in the plan exist and assert what the plan says:
stream_key_forms_round_trip,orphan_key_parses_but_is_flagged,viewer_keys_absent_vs_empty,op4_sharer_and_viewer_fixtures_serialise_like_the_fork,upload_url_debug_hides_urlare in prototests/stream.rs.capability_advert_flags_follow_arguments,voice_only_unchanged,session_update_shape,migration_messages_parse_and_oversize_rejectedare intests/rtc.rs.limits_resolve_rules_with_filters,well_known_without_limits_still_parsesare intests/limits.rs.preview_get_404_is_none,upload_url_then_put_without_auth,post_preview_sends_base64are in apitests/streams.rs.Checked against the fork:
ScreenSharePublicationMigration.ts.resolvematchesLimitResolver.tsandLimitRuleRuntime.ts: stable sort by specificity,isValidLimitValue, set for unfiltered rules and max for filtered ones, traits compared without case and features exactly.DEFAULT_RESTRICTED_LIMITS: 0 forfeature_higher_video_qualityand 9 000 000 for the bitrate, matchingLimitConstants.ts.StreamPreviewUploadUrlResponseSchema.Interfaces (2): every name and signature exists as the plan writes it, with one exception, see finding 1.
Invariants (3):
lenient_limitsandlenient_values, andMigrationMessage::parsechecks the size before parsing..invalid.Review Focus #5 (the part that belongs to this task): verified.
unobserved(), and tests assert that the recorder sees nothing.http()client, so it sends no Authorization orX-Fluxer-*headers (tested). A transport error goes throughwithout_url()(tested with a dead port). An HTTP error builds anApiErrorwithout reading the body.StreamPreviewUploadUrlhas noSerialize, and itsDebugredacts the URL.CI (5):
FLUXER_SCREENSHOT_TESTS=1 cargo xtask ciin the review worktree: all steps passed (livekit-interop skipped as designed).Findings
WellKnown.limitsisOption<Box<LimitConfig>>; the plan saysOption<LimitConfig>. The Box is justified: without it, clippy'slarge_enum_variantfails onUiMessage. Consumers (Task 11) must call.as_deref()to getOption<&LimitConfig>. The plan's Interfaces block should be updated so later tasks expect it.resolvereturnsNonefor guild-scoped keys. The fork'sresolveLimitin the user context returns the default for them, and only skips the rules. This does not affect the two keys this program resolves. It is documented in the code.UserPrivatedoes not modeltraits, so core cannot pass real traits toresolveyet. This is follow-up #185, which is linked.nullviewer_stream_keysasNone, the same as absent, is consistent with spec §3.2 (the gateway treatsnullas "clear"). Codec selection then treats such a participant as a viewer, which is conservative. Acceptable.Verdict: APPROVE. No blocking findings, and local CI is green.