Skip to content

Add real ICE restart and stable stream/component teardown APIs to rice-proto - #1

Draft
bitflows with Copilot wants to merge 4 commits into
mainfrom
copilot/add-ice-restart-api
Draft

Add real ICE restart and stable stream/component teardown APIs to rice-proto#1
bitflows with Copilot wants to merge 4 commits into
mainfrom
copilot/add-ice-restart-api

Conversation

Copilot AI commented Aug 21, 2026

Copy link
Copy Markdown

rice-proto did not have a real ICE restart path: callers could only recreate the agent, which drops selected pairs, gathered sockets, and live TURN state. This change adds restart semantics at stream and agent scope, plus the missing stream/component removal APIs, while keeping stream ids stable and preserving reusable local transport state.

  • API surface

    • Add StreamMut::restart(&mut self, Credentials, Instant) for explicit per-stream restart.
    • Add random-credential restart support via StreamMut::restart_with_random_credentials(Instant).
    • Add Agent::restart(&mut self, Instant) to restart every stream with fresh credentials.
    • Add Agent::remove_stream(&mut self, usize) and StreamMut::remove_component(&mut self, usize).
  • Restart semantics

    • Restart updates local ICE credentials on both StreamState and the checklist.
    • Remote credentials are cleared and remote candidates are discarded for the new generation.
    • Checklist check state, valid/nominated state, triggered queues, and end-of-candidates flags are reset.
    • Existing local candidates, sockets, gatherers, and TURN allocations are retained.
    • Consent freshness entries for the restarted stream/components are stopped and re-established only after a new selected pair is chosen.
    • Restart does not change the agent role; set_controlling() remains the role control point.
  • Checklist and agent internals

    • Add explicit checklist restart/reset entry points instead of reconstructing checklists.
    • Track whether remote credentials are actually set so restarted checklists do not reuse stale credentials.
    • Preserve ancillary checklist configuration across restart: controlling mode, tie-breaker, ICE-lite/trickle settings, timing, and retransmit config.
    • Remove the end_of_remote_candidates() restart FIXME by re-arming end-of-candidates across generations.
  • Stable teardown / id reuse

    • Convert agent stream storage to tombstoned slots so removing a stream does not shift stream ids.
    • Keep component slot reuse working by fixing re-add into None holes.
    • On stream/component removal, clean checklist/runtime state and emit socket removals only for resources no longer backing surviving candidates.
  • Coverage

    • Add focused unit tests for:
      • restart preserving local candidates
      • credential propagation + remote credential clearing
      • end-of-candidates re-arming
      • consent freshness reset/restart
      • no socket removal on restart
      • stream/component removal behavior and id stability
    • Add rustdoc coverage for the new stream restart/removal APIs.

Example:

use rice_proto::agent::Agent;
use rice_proto::stream::Credentials;
use stun_proto::Instant;

let mut agent = Agent::default();
let stream_id = agent.add_stream();

let mut stream = agent.mut_stream(stream_id).unwrap();
stream.restart(
    Credentials::new("ufrag".into(), "a-very-long-password-value".into()),
    Instant::ZERO,
);

// Or restart the whole agent with fresh generated credentials per stream.
agent.restart(Instant::ZERO);

Copilot AI and others added 3 commits August 21, 2026 13:55
Co-authored-by: bitflows <19825042+bitflows@users.noreply.github.com>
Co-authored-by: bitflows <19825042+bitflows@users.noreply.github.com>
Co-authored-by: bitflows <19825042+bitflows@users.noreply.github.com>
Copilot AI changed the title [WIP] Add real ICE restart API to rice-proto Add real ICE restart and stable stream/component teardown APIs to rice-proto Aug 21, 2026
Copilot AI requested a review from bitflows August 21, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants