Commit Graph
328 Commits
  • fix(backup): bound operator room restores through installation
    The authenticated site-owner route now acquires the same room restore slot and upload budget as the per-room route. RestoreRoom retains the permit through installation, independently of archive shape. The original handler consumed the body under an occupied slot and returned 400; the corrected handler returns 409 before polling it. Full integration and backup tests passed.
  • refactor(audio): use the upstream WASAPI capture reader
    wasapi 0.27 correctly handles SILENT packets and exposes frame flags and QPC timestamps. Replace local GetBuffer/ReleaseBuffer pointer ownership with its slice reader and one reusable packet buffer, preserving the existing Float32 stereo clock and capture scopes.
    
    The Microsoft GetNextPacketSize shared-mode contract guarantees the buffer size used by the next read. Five Windows synthetic and initialization checks pass, plus integrated Rust compilation. Actual device capture and the reported field silence remain separate acceptance.
  • feat(forwarding): make Server forwarding an operator-controlled fallback
    The owner decided how a Server forwards. Forwarding spends the operator's
    bandwidth, so the operator offers it and it is off by default. Once offered,
    rooms use it without a second switch, a room manager can decline it, and the
    service ranks after participant paths (canon: P2P first, load is shared, the
    same rule for every node, automatic).
    
    a. Operator switches. PIIK_CHANNEL_SERVICE_TRANSIT is the master switch, off
    by default. PIIK_CHANNEL_SERVICE_TRANSIT_SCREEN, _VOICE and _FILES default to
    true and each turns one kind off. Files include original video forwarded for
    watching together. With the master switch off nothing is offered. The offer
    reaches room hosts with the service socket. The room removes the service from
    the relays of a kind it does not offer, and the channel rejects a projection
    that gives the service such a kind as site transit. A service that offers no
    kind reads as unavailable.
    
    b. A new room allows the service. Creation paths apply only an explicit
    choice, so Browser, App and Server-hosted rooms and room copies take the
    default, and a stored false stays false. The setting reads as declining a
    default, and its note says the site forwards only the kinds its operator
    offers, in all five locales.
    
    c. The planner names the service as the fallback. When a route is assigned it
    first extends the tree with participant relays only, then lets the service
    reach the receivers still waiting. It keeps that tree unless the joint tree,
    where the service may take a scarce output, serves more receivers, so ties go
    to participants. A strict participant-first pass could spend the source's
    outputs on direct listeners and leave those reachable only through the
    service unserved; a test reproduces that. The ranking among participants is
    unchanged.
    
    The rule applies when a route is assigned. A receiver already served through
    the service keeps that route until it fails or demand ends, even if a
    participant path appears later. A screen viewer can still make the usual move
    to a direct path from the person sharing.
    
    Left open: in a public room the service's session has ordinary read access,
    so a modified room host can list it as a plain participant relay, without the
    transit view that carries the room's choice and the operator's kinds, even
    when forwarding is off. Closing it needs the channel to recognise the
    Server's own session by identity in rooms that session does not host.
    
    Tests added in channel-core: a participant wins over the service; the service
    serves only receivers no participant path reaches; the service takes a scarce
    source output when that serves more receivers; a moved child takes a ready
    participant before the service; the service carries only the kinds its
    operator offers; a service that offers no kind reads as unavailable; a new
    room uses the offered service until its manager declines. Expectations
    changed for the new default in host_review, service_transit, stored_room and
    the first test of tests/service-transit-wasm.test.ts.
    
    Verified on the lane: cargo test for piik-channel-core with and without
    sqlite, cargo check for channel-server and channel-browser, the
    room_creation_policy test, a rebuilt WASM package, tsc -b, the whole vitest
    suite and the docs check. The channel-native suites were not run.
  • perf(native): keep the connection future at its lifecycle boundary
    Box only the connected phase after a successful WebSocket handshake. The same drive future still owns cancellation, recovery and cleanup. This keeps the large inner state machine from being carried inline through each outer caller without spawning another task.
    
    Measured Windows Rust 1.91 run_host future size drops from 33208 to 17904 bytes without capture and 33544 to 17904 with capture. The current and prior-wrapper candidates passed the same real two-process admission/resume/restart test. Current baseline already passed; this is a bounded frame-size improvement, not a claim about measured peak stack headroom.
  • fix(native): process state through one async frame
    Pass the current retirement set straight to the state owner instead of retaining a full Snapshot in an additional awaiting wrapper. The redundant layer overflowed the Windows Native main-thread stack during the real competing-process room admission check.
    
    Validation: the original integration executable and corrected Native CLI passed all 12 real-session tests; 20 capture-enabled Native session tests also passed. No larger thread stack, heap wrapper or retry was added.
  • fix(storage): isolate rooms with ambiguous local records
    Discover managed SQLite rooms by their durable identity and refuse an ambiguous target before offline deletion or restore installation. Healthy rooms and new room creation survive unrelated file failures. A resumed writer retires its known binding even when the operator cannot read that room; Core accepts retirement from the current authenticated owning session while still rejecting stale outputs.
    
    Validation: 20 Windows Native and four Server checks cover actual SQLite locks, duplicate/repaired stores, offline restore and hidden rooms. Sixteen Core room-access and seven service-transit controls verify resumed HostStop without accepting the stale socket, another session, wrong binding or unregistered HostOutput. All six source files match the validated v4 candidate. Public directory deletion retains its existing independent authority.
  • fix(session): keep draining peer events while retiring a reader
    Route watch-reader revocation through the existing await_peer owner, as registration and the other awaited Driver operations already do. The Session must continue consuming peer output while its bounded command send is pending.
    
    A controlled dispatch gate observed zero events on the old handler and one on the corrected handler. The 35 Native Session checks include the existing saturated Driver regression and reader retirement. This does not claim a field reproduction of both queues filling during revocation.
  • fix(native): admit video from the representations a receiver can use
    Integrate Claude 151f6601 with independent allocator and supply corrections. Reserve each optional flow minimum and its audio before distributing surplus; preserve standalone voice. Compute admission rates and forwarding from the same receiver-compatible supply, including reversed RID costs and H264 profile constraints.
    
    Evidence: the observed 187043/121722/53370 budget case and four reproduced failures in simultaneous optional admission, zero video budget, inverted RID costs and High-only forwarding. Corrected Windows capture checks passed 32; no-capture Native passed 195 with two hotkey checks skipped; all 125 Server checks passed. The original full capture run had two readiness timeouts that passed the same-binary serialized control. No physical-network or capture-device claim.
  • fix(native): give video admission one owner
    The allocator admitted an optional trial with a positive grant below every
    representation of its source, and the video Input then deactivated it
    silently. The flow was neither waiting nor rejected, so the route owner saw an
    admitted trial that sent audio and never video. The same split disabled a
    selected flow on a relay that cannot re-encode once the estimate fell below its
    only representation.
    
    The supply now reports a deliverable floor: the cheapest full or temporal
    representation, unknown before a complete observation and zero while idle. An
    output that the producer's encoder can serve in an accepted format has a zero
    floor, because any positive grant is usable. The allocator owns admission: an
    optional trial whose known floor exceeds its budget waits or is rejected,
    including when no selected incumbent is present. Established selected video
    keeps its floor when the estimate falls below it, which is charged before
    optional work, so floors beyond the estimate admit no optional load. Startup
    without feedback and unknown floors keep the existing bootstrap. This follows
    the shape of libwebrtc's allocator, which gives an enforced-minimum stream its
    minimum when the total is too low and pauses the others explicitly:
    https://webrtc.googlesource.com/src/+/refs/heads/main/call/bitrate_allocator.cc
    
    The Input keeps layer selection and keyframe readiness only. A positive grant
    that no longer fits after planning carries the cheapest representation until
    the next plan; Paused and a zero grant still deactivate it.
    
    Allocator tests cover the observed 187,043/121,722/53,370 bps case, exact and
    below-floor trials, unknown and idle sources, startup, the branch without an
    incumbent and selected floors above the estimate. Fixture tests whose subject
    is RTP identity or source lifetime now hold their second flow as selected media
    or give it a fixed estimate instead of relying on optional admission against
    the loopback estimate.
  • fix(native): retire a failed reader through its source owner
    A reader panic must deliver the same terminal SourceEnded event as a normal
    return. Keep the existing reader identity and source cleanup so healthy voice
    on the same pair survives, rather than retiring the entire transport.
    
    The full transport module passes 31 tests on Windows, including an actual
    injected video-reader panic with continued sibling RTP. Native without capture
    also compiles. Parent cancellation retains its existing abort-and-join path.
  • test(native): capture RTP ownership when stream reuse fails
    The cross-review machine reports fresh-SSRC failures while fixture input keeps
    advancing. On that failure, print both ends' MID/SSRC/track mappings, counters
    and bounded observation histories. Preserve the original error if diagnostic
    queries fail or their bounded collection expires.
    
    The instrumented test compiles and passes once locally without capture. This
    does not explain or dismiss the independently reproduced intermittent failure.
  • fix(native): drain peer events while checking ended captures
    An actor blocked on its full event output cannot answer the consumer's capture
    query. Share a non-recursive event pump between the session loop and await_peer;
    query-time notifications join the next bounded set of owned publications.
    
    Real Session and Driver tests exercise the saturated 64-slot queue and retain
    active replacement video and audio-only captures. Capture ownership remains in
    the Driver; no duplicate capture snapshot or unbounded queue is added.
  • refactor(audio): normalize capture scope at its authority boundary
    Validate the existing request once after cancelled audio cleanup and capture
    lease checks. Downstream producers consume Off, Source, ExcludeProcessTree or
    RenderEndpoint instead of reinterpreting independent optional fields.
    
    Preserve the current wire shape, required explicit selections and ordinary
    capture warnings. Windows, Linux capture and Android API 29 checks pass;
    a regression preserves capture_not_owned before invalid endpoint errors.
  • test(runtime): coordinate races and allocate UDP independently
    Use request barriers to select the updater provider instead of millisecond
    sleep races. Allocate the integration test's UDP port through UDP rather than
    assuming the OS accepts the separately allocated TCP port.
    
    Refresh RTP baselines at the actual warm switch and compare modular progress.
    Keep media reuse deadlines and add failing phase/cycle context. This improves
    test causality without claiming the reported intermittent capture failure fixed.
  • test(native): cover transport failure during session resume
    A real WebSocket control verifies that a dead Driver on resumed admission
    releases the old session and that a fresh Driver can reuse the fixed sockets.
    Keep the transport test lease helper confined to capture-enabled tests.
  • fix(native): isolate individual room storage failures
    Opening or installing one room must not retire independently hosted siblings.
    Handle that failure at the existing room operation, retain global directory
    and identity failures as host failures, and report the failed CLI room ID.
    
    Session and real Server tests cover a locked room, creation installation
    failure, healthy sibling chat/history, recovery after unlocking and a second
    process that cannot steal an existing binding. Invalid global layout still
    ends the HTTP service and leaves the data unchanged.
  • fix(capture): use requested keyframes across native encoders
    Linux and Windows hardware use the shared 3000-frame WebRTC interval. Linux
    caps GOP to the plugin's advertised maximum, keeping unrelated numeric
    properties strict. Windows preserves a usable driver when the optional GOP
    property is unsupported.
    
    Android follows libwebrtc's 3600-second MediaCodec interval, which avoids the
    negative-value initialization failures described in upstream 419344264cfc.
    Existing explicit keyframe requests remain unchanged.
    
    Validation includes real x264 force-key-unit output, a synthetic NVIDIA MFT
    comparison, Linux capture compilation and Android API 29 links on both ABIs.
    Physical Android and other hardware drivers remain in TODO.
    
    Sources: https://webrtc.googlesource.com/src/+/refs/heads/main/api/video_codecs/video_encoder.cc
    https://webrtc.googlesource.com/src/+/419344264cfc7445af3e82024bd285303e17b3d6%5E!/
  • fix(watch): retain confirmed source handoffs across reconnects
    The room retains the original source and current successor for its subscribed
    viewers. Ordinary snapshots project that typed predecessor, including when a
    viewer misses more than one replacement. Local playback and receiving-method
    choices remain with the Browser.
    
    Remove one-shot channel event decoration. Joining, leaving, access loss and
    session expiry retire the room record. A leave for an already-retired screen
    is routed only through that viewer's authorized pending handoff.
    
    Core regressions exercise both cross-kind chains, session recovery, revocation,
    fresh sessions and independent viewer exits. Shared Web schemas and Native
    constructors use the same pending Domain 46 contract. The existing network
    design owns the lifecycle; no persisted-data format changes.
  • fix(capture): send Windows software keyframes on request, not every two seconds
    The Windows software H.264 and VP8 encoders were configured with a
    keyframe interval of twice the frame rate. A static screen was therefore
    re-encoded as a full picture every two seconds, which spends bitrate on
    content that did not change and, under CBR, replaces a converged picture
    with a coarser one each time. The new test shows the real Media Foundation
    encoder emitting that keyframe at frame 20 of a 10 fps static sequence.
    
    Stock WebRTC does not send keyframes on a timer: libwebrtc sets
    keyFrameInterval to 3,000 frames for VP8 and H.264 and passes it to libvpx
    as kf_max_dist, and Chromium's Media Foundation encoder uses
    kDefaultGOPLength = 3000. Recovery and late joiners already use the
    existing force-keyframe path. Use the same 3,000 frames here, from one
    constant.
    
    Not changed, because they cannot be built or run on this host: Linux
    (key-int-max / gop-size, same two seconds) and Android (i-frame-interval
    2). Windows hardware H.264 and macOS set no interval and keep their
    encoder default.
    
    Sources:
    https://webrtc.googlesource.com/src/+/refs/heads/main/api/video_codecs/video_encoder.cc
    https://webrtc.googlesource.com/src/+/refs/heads/main/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc
    https://chromium.googlesource.com/chromium/src/+/main/media/gpu/windows/media_foundation_video_encode_accelerator_win.cc
  • fix(native): probe distinct ports in the random UDP search
    The searching side of a random-port preparation sent 512 requests but
    cycled twice over the same 256 ports. Coverage, not the number of requests,
    sets the chance that a probe reaches one of the peer's 256 mappings: with M
    mappings and N distinct targets in a pool of R ports the idealized hit
    probability is 1 - exp(-M*N/R), as docs/research/nat-traversal.md records.
    For M = 256 and R = 64,512 that is 63% at N = 256 and 87% at N = 512, for
    the same packets, pacing and deadline.
    
    A second pass over one set only protects against a lost request, and it
    loses to distinct targets at any loss rate: at 30% loss the repeated set
    covers about 233 ports and the distinct set about 358. The peer signals
    Ready after its mappings exist, so a first probe is not early.
    
    The request budget stays 520 and the pool side is unchanged. Lab evidence
    in nat-traversal.md was taken with 256 targets and is not re-measured here.
    
    Reference: https://tailscale.com/blog/how-nat-traversal-works (birthday
    search against a hard NAT).
  • Merge remote-tracking branch 'origin/feat/channel-prototype' into refactor/claude-review
    room.rs conflicted where the active line added Watch.replace_id beside the
    parents and refused fields that the queue moved into ByteTree. Both are
    kept: Watch carries replace_id and one ByteTree.
  • fix(native): supervise the transport runtime from its Driver
    The transport pump's lifetime had no owner beyond its happy path. The
    ServerUdp lease was a bare flag reset only after the pump loop ended
    normally, so a panicked or aborted pump left the fixed sockets leased
    forever and every later Runtime on that service returned at once, failing
    each call with "transport closed". Nothing above noticed: the Driver only
    saw per-call errors, failed pairs one by one, and replanned into the same
    failure. Runtime had no Drop either, and its engines hold command senders,
    so a Runtime dropped by a panicking Driver kept its pump, sockets and
    readers alive.
    
    The lease is now an RAII guard owned by the pump task, so return, panic
    and abort all release it, and the flag is private to server_udp.rs.
    Runtime aborts its task on Drop, and each socket reader is aborted with
    the Socket that owns it, so an idle reader no longer holds its port after
    an aborted pump. Runtime::stopped resolves when the command receiver,
    owned only by the pump task, is dropped; the Driver's main select ends
    the Driver with an error on it. Retirement still runs once through
    Driver::close on every exit, and a clean close stops the runtime only
    after the loop, so it is not reported as a failure.
  • fix(app): preserve action feedback and software video color
    Keep room deletion failures with their initiating surface and retain room identity after that surface closes. Recover local autoplay guidance when the owner pauses, preserve narrow playback focus, and remove duplicate SDK shutdown cleanup. Declare the software encoder output color from its configured SDR contract.
  • fix(app)!: bind Android capture confirmation to its request
    Present the Android confirmation entry only after its capture is registered, and keep late intents scoped to that capture. Rejected desktop preparations no longer cancel another pending OBS source.
    
    BREAKING CHANGE: Internal Web and App builds must use App Control protocol 24. Domain protocol and saved-data formats are unchanged.
  • feat(transport): reuse native sockets and support TURN streams
    Native peers can use configured TURN over TCP or TLS and share ordinary IPv4 sockets within their endpoint runtime. Retire the last socket and gateway owner without interrupting sibling paths. Preserve explicit viewer playback errors, bound desktop decoder inputs, and stop copying cancelled retained files.
  • fix(runtime): preserve App selection and media continuity
    Keep chat history and scroll position across reconnects, bind App operations to the active control connection, and release background shortcuts while text or remote input owns the keyboard. Assemble H.264 pictures with their referenced parameter sets without transcoding.
  • fix(files): retire failed responses and retain confirmed saves
    Cancel unsent chunks on the first failed response without affecting healthy siblings, and report each response failure once. Keep an acknowledged native save receipt independent of later download cancellation while its optional IndexedDB write completes.
  • fix(client): retain actionable controls and release audio resources
    Keep remote-control approval and password actions visible through the shared playback owner. Centre avatars through Pawn geometry, reuse shared App controls and show loading only on the owning action. Acquire Windows audio event ownership before fallible registration and derive IPv6 presence from accepted ICE candidates.
  • fix(media): complete late IPv6 discovery and clarify input failures
    Start the existing NAT64 lookup when initial ICE gains its first usable IPv6 address, and retire it at nomination. Distinguish unsupported OBS offers from observed SPS limits. Keep invitations bound to their room and preserve usable playback controls in short windows.
  • fix(channel): cancel retired file work and simplify runtime ownership
    Release unsent file frames by request without disrupting sibling traffic. Build route-repair views only when needed and retain only capture scope and acknowledgements after commands are sent. Keep pane navigation and keyboard focus coordinated, and guide incompatible saved data back to its owning version.
  • fix(channel): retire obsolete work and preserve active selections
    Retire initial ICE probes, stale bot requests, completed cache sources, and duplicate chat effects at their owning boundaries. Preserve webpage selection across DOM replacement and screen selection handoff. Reduce hidden voice polling and playback overlay coverage, align participant state labels and shared popup navigation, and remove duplicate discovery and status representations.
  • fix(runtime): keep room restoration and pending operations scoped
    Validate restored room ownership, preserve current capture and input state, and retire obsolete view requests. Keep App metrics independent of media reads and hide provider windows with their page. Package stripped Android libraries with matching native symbols.
  • refactor(runtime): consolidate media and conversation ownership
    Keep applied Browser quality in the media owner and submit each Native domain view to the RTC driver once. Propagate shared signaling failures to carrier recovery, bound Node history by the Core page contract, and reuse unchanged voice-level samples. Clarify room-writer and version-specific presentation responsibilities.
  • fix(media): preserve selected paths and aligned source data
    Clear obsolete ICE send errors on path selection and check source assignment through an OS bind. Include queued microphone frames before mixing, preserve live HLS time anchors, and refresh path-scoped cookies across media redirects. Keep authorized physical connections visible during signaling recovery and clarify endpoint roles in the shared graph.
  • fix(runtime): serialize room views and preserve active encoders
    Read Browser room summaries after their storage turn, enqueue authority fanout in order, and validate ICE configuration before first-start persistence. Retain derived encoding incumbents during original-source handoff. Cancel attachment preparation promptly, refresh device choices on entry, and restore the complete known profile directory after reconnect.
  • fix(runtime): preserve source intent and isolate scoped failures
    Keep media selections explicit across refreshed catalogs and let page playback commands progress while buffering. Align file availability with eligible sources, restore independent rooms after policy refusal, and retain pending Unicode releases. Correct Android root failure reporting, bookmark refresh, lazy-module guidance and compact playback feedback; use the shared native modal backdrop for the title bar.
  • fix(runtime): preserve media and history across handoffs
    Keep live messages and paging anchors while history requests finish. Separate identity retirement from transport shutdown during restore. Preserve adopted file copies, release unused audio contexts, and activate Android microphone replacement correctly. Retain DASH discovery and static resource identity, reconcile encoded-frame limits, and simplify the profile image picker.