Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Ferroswitch integration: tracking

Work on the Ferroswitch integration and reliability specification (a delta on the media engine): what the checkout had, what each step adds, the evidence, and what is left. Updated with every step.

Baseline

  • rtpflux: cac94112d993ae1e61614b0c4bbb8e416d45059c (0.2.0, native API v1 and rtpflux-client-async). It matches the specification’s baseline.
  • ferrosip: 60b20fc2ee38eba830705ee2e257f6da7b9eaf4a (0.2.0, with sip-ua). Cross-repository tests pin this revision.

What the baseline had

AreaState at the baseline
EndpointsCreated both ways, parked, bridged across workers, renegotiated with prepare/commit/abort, destroyed with 5-minute in-memory tombstones; leases; tenants; generations and revisions
IdempotencyAn in-memory reply cache keyed by (tenant, idempotency_key), 5 minutes. A reused key with a different request got the cached reply: no conflict
RecoveryEndpoints and their media saved with the dialogs (state file, at most once a second, or Redis): a crash loses up to a second. Streams, mixers, playback and recordings of endpoints are not tracked across a restart, and nothing reports what was lost
EventsBounded, non-blocking, at most once, with gaps; no replay, no cursor, no boot id
Worker confirmationBarrier after bridge, stream and mixer changes; no topology revision
Async SDKTyped create/apply/attach/detach/destroy/prepare/commit/abort/query/list, pool, deadlines, cancellation, reconnect, events with gaps
HANone
PCMTwo OS threads per stream; one thread per mixer

Test evidence at the baseline

  • cargo test --workspace: 581 passed, 0 failed.
  • ferrosip at 60b20fc against the baseline’s release binary: cargo test -p sip-ua --test b2bua_rtpflux passed (ng protocol); tests/e2e_rtpflux.py 35/35; tests/e2e_scenarios.py --only m15-media-relay 36/36.

Deviations from the specification’s picture

  • sip-ua drives rtpflux over ng only; there was no native-API adapter.
  • The specification’s “five-minute in-memory response cache” is exact; it also did not detect a reused key with a different request.

Plan and status

StepPriorityStatus
1. Durable operation ledger, fingerprints, operation.query, external_idP0done
2. Inventory, boot id, recovery reportP0done
3. Topology revisions, bridge CAS, half-bridge compensation, renegotiation both waysP0done
4. Replayable critical events with cursorsP0done
5. Async SDK: capabilities, inventory, operations, cursors, recoveryP0done
6. Cross-repository test: ferrosip sip-ua + async SDK + rtpfluxP0done
7. Fencing epochs issued by an ownership authorityP0-HAdone
8. PCM on shared I/O and DSP shards; flush generationsP1done
9. Detectors without a stream, DTMF send, tones, sensitive digitsP1done
10. Recording pause/resume with identity and state; ACLs, quotas, token rotation, auditP1done
11. Media graph, conference recoveryP2done
12. Benchmarks against the baselinealldone

Step 1: operation ledger and external ids

  • control/ledger.rs: fingerprints (SHA-256 of the canonical intent), the ledger in memory or durable (append-only, synced; torn last line skipped; pending without an outcome becomes unknown at start; compaction by rewrite; mode 0600), retention, per-tenant quota without early eviction.
  • Native requests: envelope checks first (never recorded); a keyed mutation runs pending → apply → synced state (save_durable) → synced outcome → reply; same key and another intent is conflict; an old first attempt is expired; unknown_outcome after a crash. operation.query. New error codes unavailable, expired, unknown_outcome, and detail on errors. hello states the guarantees.
  • external_id on endpoint.create, unique per tenant, kept with the tombstones (never evicted early); replaces_generation for a new endpoint under a destroyed one’s id; endpoint.lookup. Tombstones and id counters are saved with the state.
  • Feature fault-injection (tests only): RTPFLUX_FAULT kills the relay (SIGKILL) at a boundary.

Evidence: cargo test -p rtpflux --features fault-injection --test crash (CI runs it in the all-features test job); cargo test --workspace: 584 passed.

  • A SIGKILL at after_pending, after_apply, after_state and after_outcome, then a retry and reconciliation, leaves one endpoint per external id; the outcome is either replayed or reported unknown_outcome.
  • Durable keys and external ids work across a clean restart.

Unit tests in ledger.rs cover fingerprints, a torn last line, pending turning unknown on restart, expiry and the quota.

Residual: mixers, streams, playback and recordings are deduplicated by operation keys, but have no external id of their own (step 2 reports those that a restart loses). A ledger costs two fsyncs and a state-file write per keyed mutation; this is measured in step 12.

Step 2: inventory and recovery report

  • control/inventory.rs: inventory.list (six kinds, id order, pages of at most 500, a cursor bound to the run and topology_epoch, a conflict when anything changed between pages, a watermark on every page); recovery.report; recording.query.
  • A boot id per run (in hello), and the previous one after a restart.
  • topology_epoch changes with every mutation, endpoint end, recording end.
  • Recordings have ids and a state (active, stopped, completed, failed), updated from the media events, saved with the state.
  • Saved with the state: the streams, mixers, recordings and each endpoint’s playback and recording. After a restart, streams and mixers are reported lost, and so is a playback the relay did not restore (one from a blob).

Evidence: tests/native.rs inventory_and_recovery_report. It pages through five endpoints, refuses a stale cursor, lists the bridges, the recordings and the mixers, then restarts. Afterwards previous_boot_id matches, six endpoints are restored, the mixer is reported lost, the recording is still active, and the bridge is intact.

Residual: leases start again at a restart (documented). The epoch is coarse: any mutation invalidates a paged walk.

Step 3: topology and renegotiation

  • Created parties in either orientation. create, create answer and create from offer find a created party’s dialog whoever offered last (created_dialog), so the relay can re-offer to an endpoint that offered first, and an endpoint the relay offered to can re-offer.
  • Prepare in both directions, by what it is given.
    • remote_sdp is answered at once, and its checkpoint is kept by an internal flag until the commit.
    • The relay’s re-offer is committed by its answer.
    • Abort is an exact rollback (it fails visibly if nothing was taken back), and the endpoint is bridged again as it was.
  • topology_revision per endpoint. CAS on both endpoints of an attach (topology revision, and the peer’s generation and revision), and expected_topology_revision on any request that names an endpoint.
  • A failed attach is compensated: every endpoint involved, the former peers included, is detached on the workers and in the records. A worker that does not confirm leaves topology_state: "unconfirmed".
  • Fault injection: connect_half refuses a cross-worker bridge’s second end after the first was taken.

Evidence:

  • tests/native.rs renegotiation_both_ways_and_topology_cas. The IVR leg’s own hold re-offer is aborted, then committed; the caller’s leg gets the relay’s re-offer, aborted, then committed. Media flows after each step, and a stale topology revision is a conflict.
  • tests/crash.rs a_half_made_bridge_is_compensated. It fails when the compensation is removed (mutation check): the former peer is then still reported bridged while its media is not.

Residual: worker acknowledgements are synchronous barriers on the control thread (at most a second), so a late acknowledgement cannot overwrite a newer intent. Early media and delayed SDP are the existing endpoint flows, exercised end to end in step 6.

Step 4: replayable events

  • Every event has event_id (<boot_id>:<global_seq>) and boot_id, and goes into a bounded in-memory journal ([control] native_event_journal).
  • events.subscribe takes a cursor. It replays what came after, then goes live (resumed: true). A cursor of another run (boot_changed) or older than the journal (retention_expired) gets an explicit gap. The reply’s cursor and the inventory’s watermark are cursors (a snapshot and a subscription without a race).
  • An overflowing subscriber gets a gap with resume_cursor as soon as it has room, even when no event follows. Pending gaps are flushed on every pass of the control thread.
  • Events dropped before the journal (the workers’ queue was full) are attributed where possible: the endpoints get endpoint.events_lost and events_indeterminate: true, and the gap is media_overflow.

Two bugs were found and fixed while testing:

  • Destroying an endpoint whose relay offer was never answered deleted nothing, leaking its session and ports. Its dialog had no to-tag yet.
  • A subscriber’s overflow gap was only sent with its next event, so a burst followed by quiet left the subscriber unaware.

Evidence (tests/native.rs):

  • events_resume_from_a_cursor: replay in order after a disconnect; boot_changed; subscribing from a watermark.
  • an_overflowing_subscriber_resumes_without_loss: 3000 events to a subscriber that does not read, resumed from the gaps’ cursors, every event seen once after deduplication; a cursor older than the journal is retention_expired.

Residual: the journal is in memory. Events of a run do not survive a relay restart, which is reported as boot_changed, and the terminal results are reconciled from the saved state. Events are not persisted across power loss by design.

Step 5: the async SDK

  • Typed hello (Capabilities, Guarantees, keeping unknown fields), inventory and inventory_all (restarting a walk that raced a change), operation (OperationState), lookup, renew, recovery_report; MediaEvent with event_id and boot_id; EventFilter::cursor; error codes unavailable, expired, unknown_outcome.
  • Event streams keep a position and resubscribe from it after a broken connection, a relay overflow, or the consumer falling behind (they stop reading, so memory stays bounded). Repeats are dropped by event number. Only unrecoverable losses reach the consumer as gaps.
  • Bug found and fixed: events the relay writes while a subscription is being made (a replay, a boot_changed gap) could come before the subscription’s reply and were dropped. They are now delivered first.
  • Documented: ordering across pooled connections, correlation ids unique across reconnects, no automatic retries.

Evidence:

  • rtpflux-client-async/tests/client.rs: a slow consumer gets every event once and in order; after a relay restart, boot_changed.
  • tests/typed.rs: capabilities, operations by key, an external id, a lease, the whole inventory and a subscription from its watermark, the recovery report.
  • tests/cancel.rs, against a fake relay:
    • a request cancelled while queued is never written;
    • a cancelled request’s late reply is not taken for the next request’s;
    • fragmented replies are read;
    • a request in flight when the connection drops is Disconnected { sent: true }, and the client reconnects with new ids;
    • an unanswered request is Timeout { sent: true }, and carries its deadline.
  • rtpflux/tests/native.rs fragmented_and_oversized_frames: a request written one octet at a time, and a frame over 1 MiB.

Step 6: cross-repository test

integration/ferroswitch is a crate outside the workspace, so the workspace builds without the private repository. Its pieces:

  • sip-ua from ferrosip, pinned by rev 60b20fc in its Cargo.toml and Cargo.lock;
  • a B2BUA on simulated SIP engines;
  • an in-process rtpflux with a durable ledger, driven through rtpflux-client-async;
  • real RTP between UDP sockets.

The B2BUA creates one endpoint per leg. The relay answers each side’s re-offers itself, and the B2BUA bridges the legs.

The CI job ferroswitch checks ferrosip out at the pinned rev using the FERROSIP_TOKEN secret. It runs with REQUIRE_FERROSIP=1, and is skipped without the token.

Evidence (tests/b2bua.rs, 4 tests):

TestWhat it covers
early_offer_hold_resume_and_byemedia both ways; the callee’s sendonly/sendrecv re-offers are answered recvonly/sendrecv on the same relay port; media both ways after the resume
delayed_offer_and_bye_from_the_callerthe relay offers in the 2xx, and the caller’s answer arrives in the ACK
a_refused_renegotiation_is_rolled_backa PCMA re-offer to the caller is refused; endpoint.abort leaves the revision unchanged; media flows
blind_transfer_to_a_third_partyREFER; the target is bridged to the callee, the referrer’s leg is released

Every test ends with the checks after BYE: each endpoint is destroyed and reported by event, the inventory is empty, and the recovery report lists no unknown operations.

Deviation found: the relay does not refuse a re-offer with an unknown codec, or with no media. It passes them through, as rtpengine does. A softswitch that must refuse those has to check the SDP itself. Recorded here; not changed.

Not covered yet: attended transfer (Replaces), early media (183), and UPDATE. These are left for step 11’s media graph work, or later.

Step 7: P0-HA fencing

Design: grants are HMAC-SHA256 signatures from an ownership authority. The relay keeps the highest epoch per tenant/group, synced to disk. Every mutation must prove three things: the epoch, a running lease, and the owner’s token, a second signature issued to the owner alone. Each touched resource must belong to a proven group. See docs/native-api.md “Exclusive ownership”.

Requirement placed on Ferroswitch: one rising epoch sequence per tenant, across groups. That lets the relay prune old groups safely, through a per-tenant floor.

Bug found while testing: proofs carried only {group, epoch}. A stale controller could have guessed the next epoch. Proofs now carry the owner token.

Evidence:

  • control/ownership.rs unit tests:
    • epochs only rise;
    • same epoch for another owner: conflict;
    • a renewal never shortens the lease;
    • forged signature, unknown key, or another tenant’s signature: refused;
    • an expired lease is refused;
    • a guessed epoch without the token is refused;
    • claims survive a restart;
    • pruning raises the floor, and an old grant with a running lease cannot come back;
    • a corrupt file is an error, and the relay does not start.
  • tests/ha.rs fencing_by_authority_epochs, end to end:
    • with no claim, mutations are refused;
    • a forged grant is refused;
    • another group’s proof does not cover an endpoint;
    • after a handoff the stale controller is refused, even with a matching generation;
    • a guessed epoch is refused;
    • self-promotion is refused (an old grant, or the same epoch);
    • a bridge across calls needs peer_ownership at the current epoch;
    • another tenant cannot use a grant;
    • an ng delete on a native call is refused, while query works;
    • after a restart the stale controller is still refused and the current owner continues;
    • an expired lease fails closed until it is renewed;
    • a replayed expired grant is refused.

Residual gaps:

  • The async SDK knows fenced, but its typed requests have no ownership field yet; use MediaClient::call in HA mode.
  • Mixer and stream membership check only the ids named in a request. mixer.add names the endpoint, so it is covered; pending worker operations are covered by the control-thread ordering argument above.
  • Partition is modelled as a stale controller (an old epoch, or no token). There is no network-level partition test.

Step 8: PCM on shared shards; flush generations

  • PCM streams no longer have two OS threads each. A few shard threads ([runtime] pcm_shards; default one per CPU, at most 4) serve every stream. A stream stays on one shard, and every 20 ms the shard runs each stream once: the DSP towards the service, the service’s audio towards the worker, marks, and non-blocking writes.

  • Buffers are bounded:

    • a 240 ms write buffer per stream (overflow is dropped and counted, reported by a gap frame);
    • the worker’s 100 ms inject queue (when it is full, the shard stops reading that service);
    • at most 8 frames read per stream per tick (fairness).
  • The relay workers are untouched apart from flush handling.

  • The I/O design was chosen by measurement. tests/pcm.rs load (100 streams, both ways, 5 s, release build), share of one core:

    EngineThreadsCPU
    Baseline: threads per stream20012.6%, 11.6%
    Shards with an epoll loop on readability418.4%
    Shards driven by the 20 ms tick (kept)410.8%, 9.4%, 9.2%

    The epoll variant lost: its interest changed twice per tick for every stream whose service wrote ahead. The baseline also took about 250 s to shut down after the load run; the shards stop at once.

  • Flush generations, an opt-in protocol version 2 (stream.start protocol: 2; version 1 services keep working):

    • a flush starts a new generation and is acknowledged with a flush frame (the generation, and played_ms) and a stream.flushed event;
    • stale audio and marks are dropped and counted, and a late mark is answered as flushed;
    • every injected frame carries the flush count it was made under, and the worker drops it if a flush came since. This closes a race in which a frame encoded just before a flush was queued just after it.
    • marks carry generation, played_ms and boundary: "rtp_sent". RTP sent is stated explicitly not to be audible playout.
  • Bugs fixed on the way:

    • marks pending at a flush could wait forever: the worker drained its queue without counting, while mark positions counted every frame. The worker now counts frames consumed (played or dropped).
    • a gap frame was written only ahead of the next audio frame, so a service that fell behind at the end of speech was never told.

Evidence:

  • tests/pcm.rs flush_generations:
    • the hello says version 2;
    • a flush during a long answer: the old generation stops at once, the ack and stream.flushed agree on played_ms;
    • a mark that waited behind the answer is answered as flushed;
    • late generation-0 TTS plays nothing, and its mark is answered as flushed;
    • generation 1 plays, and its mark has rtp_sent and its generation;
    • a service flush racing a mark: the mark is flushed and the ack has generation 2.
  • tests/pcm.rs many_streams_share_two_threads, 8 streams on 2 threads:
    • while one service floods the relay, another’s mark is answered in under a second;
    • the services that read get their audio;
    • a service that does not read gets a gap frame;
    • a service that disconnects ends its stream, and a new stream on the same endpoint works;
    • there are still 2 threads.
  • The existing audio_streams_to_and_from_a_service passes unchanged.
  • frame.rs unit tests: version 2 round trips, and version 1 never carries a generation.

Residual gaps:

  • A shard serves its streams in turn within the tick; a stream’s DSP is not split further.
  • Mixers keep their own thread per mixer (not per participant).
  • A hung service cannot block a shard: every read and write is non-blocking. Only the hello is written blocking, at stream.start, with a 100 ms timeout.

Step 9: detectors, DTMF send, tones, playback queues, sensitive digits

  • control/ivr.rs composes what the relay already had:

    • the worker’s tone engine (RFC 4733 events or in-band tones; a sine code for cadenced tones);
    • file and blob playback;
    • recording pause;
    • the PCM shards’ VAD and in-band DTMF.
  • New operations:

    • dtmf.send, tone.start, tone.stop;
    • dtmf.policy (dedup by default, both, rfc4733, inband);
    • endpoint.sensitive;
    • stream.detect, with stream.start taking no socket for detectors only (no pcm_dir needed).
  • playback.start gains queue and stop_on (dtmf, speech). Interruption happens in the relay; digit collection and timeouts stay with the controller.

  • Sensitive digits. Every output path, and what covers it:

    PathCoverage
    LogsThe worker logged every key at info; it now logs that a key was pressed, at debug, without the digit, sensitive or not
    EventsSubscribers without sensitive: true get digit/code null and redacted: true, live and on cursor replay
    RecordingsPaused while sensitive, resumed after (only those it paused)
    Bridged peerNot covered (documented; ng block DTMF exists)
    PCM serviceNot covered: it hears the tones as audio (documented)
    Event journalIn memory only; holds the digit for entitled subscribers
  • Bug fixed: RFC 4733 keys from an endpoint not bridged to anyone (an IVR leg) were never reported, because the worker skipped every dropped packet. It now observes authentic packets dropped only for lack of a destination, and still ignores unknown legs and wrong sources.

Evidence (tests/ivr.rs):

  • keys_and_tones_to_an_endpoint:
    • events with telephone-event, tones with inband;
    • digits are not echoed;
    • bad digits are refused;
    • a cadenced tone plays and tone.stop silences it.
  • detectors_policies_and_sensitive_digits:
    • a detector with no service or pcm_dir, VAD off: no speech events;
    • one press, sent both in-band and as events, is reported once under dedup, twice under both, once (rfc4733) under rfc4733;
    • sensitive mode with a recording running: the recording pauses, the trusted subscriber sees the digit, the plain one sees it redacted, a cursor replay is redacted, and turning it off resumes;
    • stream.detect turns VAD on and speech is detected.
  • playback_queues_and_barge_in:
    • a queued playback starts after the first completes;
    • a key stops a stop_on: ["dtmf"] playback and drops the queue behind it.

Residual gaps:

  • The test checks a recording’s pause through the operation’s reply and the relay’s recording state, not by inspecting the pcap. A worker-confirmed pause boundary is step 10.
  • Tones and dtmf.send have no completion event; their reply gives the duration.

Step 10a: recording pause/resume with a confirmed boundary

  • recording.pause and recording.resume (control/rec.rs). The recording is paused only after a barrier confirms the media workers took the pause; the boundary time is recorded in pauses. Unconfirmed, the recording is pausing and the request fails (timeout). It is never reported paused while capture may go on.
  • endpoint.sensitive now pauses through the same confirmed path.
  • recording.query reports outcomes apart: finalized (the file is written), upload (pending, none, uploaded, failed), and failed with its detail.
  • Identity: a recording keeps its recording_id across pause, resume and a restart. A keyed recording.start lists it in the operation’s resources.

Evidence: tests/recpause.rs pauses_are_confirmed_and_hold_nothing:

  • pausing with no recording is refused;
  • a pause is confirmed with its boundary; pausing again changes nothing;
  • resume;
  • a second pause spans a restart of the relay, and the recording is still paused after it;
  • resume, then stop: completed, finalized, upload: none, two pauses;
  • the finished pcap is parsed: no packet inside either pause window, and audio before, between and after them.

The existing a_worker_failure_is_reported covers a recording whose file cannot be written (recording.failed).

Deviations and gaps found:

  • Only relayed media is recorded. An endpoint bridged to no one (an IVR leg talking to prompts) records nothing; the test had to bridge it. Recording an IVR leg needs the recorder to also take dropped authentic packets and injected audio. Recorded, not changed.
  • A failed upload is mapped (upload: failed) and covered by the store’s own tests, but there is no end-to-end test: S3 needs the s3 feature and credentials.
  • Disk full mid-recording is not simulated; an unwritable directory is.

Step 10b: access controls, rotation, rate limits, audit, ng isolation

  • Unix socket ACL. Bug fixed: the socket was always mode 0600, so the users configured in native_uids could not reach it, and the SO_PEERCRED check never ran for them. The mode is now 0600, 0666 when other users are listed (the credentials decide), or 0660 with native_socket_group.
  • Token rotation. native_tokens_file (several tokens per tenant) is re-read when it changes. A connection whose token was removed is refused at its next request and closed. An unreadable file keeps the last tokens.
  • Quotas. native_rate_limit: a per-tenant token bucket, refused with exhausted before anything runs. The existing per-tenant endpoint quota stays.
  • Protected transport. A non-loopback native_listen is refused unless native_allow_remote, and the TLS proxy setup is documented. This changes behaviour: it used to be a warning.
  • Audit. The rtpflux::audit log target gets one line per mutation, claim, authentication and refused connection: who, what and outcome, never a body.
  • No secrets in logs:
    • the audit line’s unit test feeds an SDP with a=crypto and checks no key reaches the line;
    • the logs were checked with grep: no log statement prints SDP or a request body;
    • digits stopped being logged in step 9.
  • ng isolation. ng_protect_native gives the [ha] guard without HA.

Evidence:

  • native.rs unit tests:
    • socket modes 0600, 0666 and 0660 (with the group set);
    • token rotation with overlap, revocation, and a short token left out;
    • an unreadable file keeps the tokens.
  • audit.rs unit tests: the audit line never holds SDP keys; per-tenant buckets.
  • tests/security.rs:
    • TCP rotation end to end: the old and new tokens overlap, then the revoked connection is refused and closed, and the old token can no longer connect;
    • the rate limit refuses a burst, another tenant is unaffected, and it recovers;
    • ng delete of a native call is refused while query answers;
    • a non-loopback native_listen is refused unless allowed.

Not covered:

  • A second Unix user connecting (the test runs as one user): the SO_PEERCRED path is the existing one, and the file modes are tested.
  • Native TLS: none; a TLS proxy is required.

Also in this step: two async SDK tests that failed only under a fully loaded test run were made tolerant of it. The slow-consumer test now waits for each event instead of stopping after 500 ms of quiet; the durable-mode test has a 30 s deadline. Neither showed a logic fault: both pass alone, and the events arrived complete and in order.

Step 11: composition and conference recovery

  • Mixer, per participant:

    • deafen (hears silence, still heard);
    • output gain, on what it hears, with input_gain_db as an alias of gain_db;
    • taps: PCM streams fed a copy of its packets by the mixer, at most 4. “Conference participants can also stream PCM”: speech recognition on a conference leg. A tap cannot inject, and it ends when its participant leaves.
  • A PCM stream now ends when nothing can send it packets any more (its call ended, or its participant left), instead of ticking silently.

  • Conference recovery (control/conference.rs):

    • each mixer’s plan (id, tenant, seats with role, whisper_to, mute, deafen, both gains) is kept by every mixer.* operation and saved;
    • after a restart, mixers are rebuilt with the same ids before any request is answered;
    • recovery.report gains restored_mixers, and participants whose endpoint did not return are listed as lost;
    • the mixing state starts afresh, and is documented as resumed, not transparently continued.
  • The media graph is documented (docs/native-api.md, “Media composition”):

    • nodes and where they run;
    • ownership, no cycles (one audio sink per endpoint, taps read-only);
    • atomic, worker-confirmed changes;
    • budgets and latency.

    No new graph engine was built: the graph is composed from the existing nodes, and endpoints without any keep the relay, transcode and XDP paths.

Evidence (tests/conference.rs):

  • composition_and_controls:
    • mixed codecs (PCMU, PCMA, G.722): B and C hear A, A does not hear itself (N − 1);
    • B’s output gain −20 dB is markedly quieter;
    • A deafened hears nothing of B;
    • A muted is heard by no one;
    • an injecting stream on a participant is refused;
    • a tap on A gets A’s voice while B still hears A;
    • removing A ends the tap.
  • attach_detach_and_a_restart:
    • three clients add and remove at once (15 rounds each), leaving three participants;
    • B deafened, C muted with +6 dB;
    • after a restart: restored_mixers holds the same id, nothing is lost, three participants; B still deafened and C still muted, by audio levels;
    • a new mixer gets a higher id.
  • tests/native.rs inventory_and_recovery_report now expects the mixer restored (it expected it lost).

Not covered (spec items left as gaps):

  • A conference recording: since done (see “Recording a conference mixer” below).
  • Mixer-to-mixer links (cascading) are not supported, by design (no cycles).
  • AEC, AGC, video and T.38 are optional later milestones, per the spec.

Step 12 finding: durable operations cost grew with history (fixed)

Found by the step 12 benchmark. With [sessions] ledger, every keyed operation rewrote and synced the whole state file, and the state file held every tombstone (up to 65 536). The cost of each operation grew with the number of endpoints ever destroyed. The rate fell from 122 pairs/s after 500 keyed pairs to 53 after 1500 and 37 after 2000, and over 1500 pairs the relay wrote 509 MB to a 330 KB state file.

Tombstones now have their own append-only file next to the state file (<state>.tombs.jsonl, control/tomblog.rs):

  • a destruction appends a line, synced before a durable reply;
  • the file is compacted at start-up and whenever it holds more than twice the tombstones kept;
  • a torn last line is skipped;
  • a state file of an older version still restores its tombstones, and they move to the new file.

Over 1500 keyed pairs: 8.7 MB written (58× less), a 354-octet state file, and a rate that no longer falls as history grows. The durable rate itself is bound by the disk’s sync latency (three to four syncs per operation), which on this machine varies from about 35 to 70 pairs a second from run to run.

Evidence:

  • tomblog.rs unit test: append, a later line replacing an earlier one, a torn line skipped, compaction;
  • the crash tests (SIGKILL at each boundary, keys and external ids durable) and the restart tests pass unchanged.

Step 12: benchmarks against the baseline

  • New tools:
    • bench/baseline.sh: HEAD against a pinned commit (default cac9411), built from a worktree, run alternately on identical configuration;
    • native-bench, a binary of rtpflux-bench: native create+destroy rate, per-operation p50/p95/p99, event throughput, RSS growth, and the recovery time after a restart.
  • Results (docs/benchmarks.md, “Against the integration baseline”):
    • ordinary relaying: no regression beyond the run-to-run spread, plain and SRTP;
    • native control: HEAD 7.8–8.9 k pairs/s against 5.9–6.8 k, lower p99, and no memory growth (the baseline grew 8.9 MB per 2000 pairs, a leak fixed earlier);
    • recovery of 500 endpoints: about 105–135 ms either way;
    • durable operations: 72 pairs/s, p50 2.6–3.1 ms, p99 about 30 ms, sync-bound. Their cost growing with history is fixed (see above).
  • Not measured: transcoding (no load mode), XDP (needs root; bench/fastpath.sh), the soak runs and tc netem (P1 acceptance table), and 500/1000 simultaneous PCM streams (the load test measured 100).
  • Memory note: the ledger keeps about 4.6 KB per keyed operation for its retention, bounded by ledger_quota.

Follow-up: gaps Ferroswitch found while integrating

Ferroswitch reported three gaps and worked around each on its side. Each is now fixed in the relay:

  • A recording never finished when its endpoint was destroyed. The call ended, but the outcome looked its endpoint up and found nothing, so recording.completed never came and the record stayed active. endpoint.destroy now stops the recording first (stop recording), and an outcome that arrives after the endpoint is gone goes to its tenant as the destroyed endpoint’s event (found by its tombstone, without seq). recording.query finds the record by the endpoint it was of. Test: recpause::destroying_the_endpoint_finishes_its_recording. Ferroswitch’s own stop before teardown is no longer needed, but does no harm.
  • Finished playbacks were not kept, so a controller that missed playback.completed while reconnecting could not tell completed from stopped. The relay now keeps how the latest 8192 playbacks ended (in memory) and answers playback.query (playing, queued, completed, stopped with its reason). A destroyed endpoint’s playback and queue now end with playback.stopped (reason: "endpoint_destroyed") before endpoint.destroyed. The async SDK has MediaClient::playback. Test: ivr::playback_ends_are_kept.
  • The SDK’s event filter could not ask for unredacted digits. The relay already honoured events.subscribe with sensitive: true, but EventFilter had no field for it. It now has sensitive.
  • No echo or loopback primitive. The media workers already had media echo for ng, but the native API had no way to use it. endpoint.echo (echo: true/false) now sends an endpoint its own RTP back, unchanged. The echo is kept through a renegotiation and a restart, endpoint.query reports it, and it is refused together with a bridge or a mixer, in either order. Async SDK: MediaClient::echo. Test: echo::an_endpoint_hears_itself.

Recording a conference mixer

Spec: “recording a conference mixer (rtpflux)”, proposed 2026-11-28 (Ferroswitch upstream issue rtpflux 9). recording.* take a mixer_id (see native-api.md, “Recording a mixer”).

How it runs:

  • The mixer thread computes what a listen participant hears and hands each 20 ms period to a 5 s queue (pcm::mixer::MixTap). It never waits: a full queue loses the period and counts it.
  • A writer thread spools the periods (raw 16 kHz PCM, one file per section). Lost periods are written as silence at their place.
  • At the end, the existing conversion thread turns each section into the chosen format and rate. The encoders now take any PCM source (recording::encode::Pcm).
  • Storage (local, S3, webhook) and the outcome events are the endpoint recordings’. The outcome is routed by Subject::Recording(id).

Covered by the spec’s acceptance list:

#StatusEvidence
1donemixrec::the_mix_a_listener_hears: tones per party (Goertzel), duration within 40 ms of start→stop
2donesame test: muted, listener and whisperer absent; include_whispers adds the whisperer (mutation-checked)
3donesame test: a participant leaving, silence in the middle, participants intervals
4done; the timeout branch is not testedmixrec::pauses_sensitivity_restart_and_keys: confirmed pause, the section shorter by the pauses (mutation-checked). A pause the mixer does not confirm in time is not provoked by any test
5donesame test: a sensitive participant pauses it; the controller’s pause survives sensitivity going away
6donefirst test: mixer.destroyed then recording.completed; recording.query answers
7donesame test: a restart goes on in section 2, listed in restored_mixer_recordings, a file per section; mixrec::a_mixer_not_restored_finishes_its_recording: its mixer’s plan removed from the state, it is finished with what it holds and reported lost
8unit levelpcm::mixer test: a full queue loses and counts, numbering goes on; recording::mixrec test: the writer fills lost periods with silence. No end-to-end run with a deliberately slow writer
9doneha::mixer_recordings_are_fenced: no proof, another group’s, and a stale epoch after a handoff are fenced; the new owner stops it
10donesame test: one recording for one key; operation.query lists its recording_id
11not testedsame storage code path as endpoint recordings
12donemixrec::a_track_per_participant: a file per participant, as long as the mix, its own tone only, silence before a latecomer joined, a muted one’s input kept
13donemixrec::load (ignored; by hand): see docs/benchmarks.md, “Recording conference mixers”

Also added:

  • mixer.destroyed event;
  • mixer events (with mixer_id, no endpoint_id) reach subscriptions that name no endpoints or sessions, filtered by mixer_ids;
  • the {mixer_id}, {recording_id} and {track} file-name placeholders;
  • [recording] max_mixer_recordings (64);
  • the async SDK has EventKind::MixerDestroyed, MediaEvent::mixer_id and EventFilter::mixer_ids.

Found while testing the restart path, and fixed: with no event subscriber connected, the control thread dropped media events (only an announcement’s end was kept). A recording’s outcome then never reached recording.query, endpoint and mixer recordings alike. A playback queue did not advance, playback.query missed the end, and nothing went to the journal for a later subscriber to replay. Media events are now always handled. Test: recpause::the_outcome_is_kept_without_subscribers (fails without the fix).

Ferroswitch’s requests R1–R5 (29 Nov 2026)

#RequestStatusEvidence
R1Video sections in the relay’s own offersdone (6a04ece)offers::video_offers_origins_and_local_sdp: an offer of audio and video (a port each), video both ways across a bridge with its payload types, a hold re-offering both sections (same ports, sendonly), limits refused
R2The relay’s own SDP origindone (6a04ece)same test: one session id, versions 1, 2, 3, 4 across a restart; an answer without the offerer’s o=; a keyed retry at the same version
R3Durable throughputdonethe state journal (docs/configuration.md, “The state journal”); tests/durable.rs: 63 → 2943 keyed operations/s with 10 live endpoints, 17 → 1677 with 1000 (p50 4.7 ms and 8.0 ms); crash tests at each boundary
R4endpoint.query with the local SDPdone (6a04ece)same test: the create reply’s SDP, then the committed one, absent without the flag
R5Typed external_id, replaces_generationdone (6a04ece)typed test: a typed create found by lookup

R3’s crash semantics changed for the better. An operation’s state and outcome are one record, so a crash leaves it wholly done or not done. There is no “pending, outcome unknown” left, except for a worker timeout. The crash tests were updated to that.

R3’s p99 at 1000 endpoints (about 100 ms) comes from compactions: the whole state is encoded on the control thread when the journal is full. That happens every few thousand operations; encoding it elsewhere is possible if the tail matters.

Bugs found by the tests after R3 (29 Nov 2026)

  • The journal lost restored mixers and video routers. At a start, the journal writes a full snapshot and removes the old files. Mixers and routers are rebuilt just after that, and the snapshot held only running ones. A second crash before the next snapshot lost the room. Snapshots now hold the plans still waiting to be rebuilt. Test: journal::a_kill_after_compactions_loses_nothing_acknowledged (thousands of keyed operations, compactions, SIGKILL twice).
  • A renegotiated video subscriber froze. See video-sfu.md.
  • An unanswered endpoint said “unknown call or tag”. Recording, bridging or playing to an endpoint the relay offered, before its answer, gave not_found, as if the endpoint were gone. It is now conflict, “not answered yet”. Test: offers::an_unanswered_offer_says_so.

Checked and found right: changes without a key (native and ng) survive a SIGKILL a second later (journal::a_kill_keeps_what_was_changed_a_second_before); an aborted re-offer keeps the committed SDP, and the next offer’s origin version goes above the rejected one’s, across a restart (offers::an_aborted_reoffer_keeps_the_sdp_and_moves_the_version_on).

  • A slow disk said “the relay is busy” for an operation that ran. Durable replies wait for the disk. When one took longer than the front’s 5 s, the client got exhausted (“busy”, documented as not run) without its operation_id, so the client could not match it. A late reply is now timeout, saying the outcome is unknown, with the operation_id. exhausted is kept for a full request queue, which really runs nothing. Test: crash::a_slow_disk_times_out_durable_replies_only (a fault that makes each sync take 6 s; a read meanwhile answers at once).
  • [ha] claims synced on the control thread. Under disk load, every client waited behind a claim’s two fsyncs. With a state file, claims are now written on the journal’s sync thread, before their reply. Test: ha::an_acknowledged_claim_is_on_the_disk.

Bugs found by coverage-guided tests (29 Nov 2026)

A coverage run (cargo llvm-cov, 81% of lines) pointed at what no test reached; tests there found:

  • connect / bridge.attach joined sections by position, not type. An audio endpoint bridged to a video-only one was accepted, its audio sent into the video section. An endpoint offering video then audio got the audio in its video. Sections are now joined by type; no type in common is refused. The refusal happens before anything changes, where before a refused attach had also dropped the bridge the endpoint had. Rejected sections now say they connect nothing. Test: bridges::sections_are_bridged_by_media_type.
  • A crafted WAVE header crashed the decoder. 32769 channels overflowed symphonia’s WAVE reader (a panic with overflow checks on). play media can carry the file in the request, and decodes on the control thread. Headers with no channels, or more than 8, are refused; a panic in the decoder now refuses the file instead of ending the thread. Test: robustness::media_files_never_panic (a new fuzz target, 900 000 cases clean).
  • A flaky relay test read counters before the worker had counted the packet it had just sent. It now waits for the counters, and for the worker to install each call.

Checked and found right: operation keys (expiry, quota, conflicts, failed outcomes replayed, across a restart; keys.rs), external_id lifecycle (keys.rs), video routers’ refusals and a router destroyed in use (video.rs).

Found by Ferroswitch’s soak (30 Nov 2026)

  • The ledger rewrote itself on every append past 50,000 live keys. After a compaction its line count was the live entries, already over the threshold, so each keyed operation rewrote and synced the whole file. Past about 28 minutes at 30 operations a second, operations took about 0.5 s and clients timed out. It now compacts only when the file also holds twice the live entries: each rewrite is followed by at least as many appends (amortised O(1)), and the file stays within twice what it holds. Test: ledger::tests::many_live_keys_do_not_rewrite_the_file_on_every_append (1990 rewrites for 2000 appends before, at most 10 now). Release binary: keyed operations hold their rate from 8,000 to 64,000 live keys.

  • Memory, measured: a live ledger key costs about 2.5 KB (its reply is kept as a parsed JSON tree; about 450 bytes on disk), so the default quota of 100,000 keys per tenant is about 250 MB. The event journal (65,536 events) adds about 66 MB, bounded. Keeping replies as text would cut the ledger’s share about fourfold; not done yet.

  • Native endpoints never timed out in practice. A created party’s hidden offerer is at 0.0.0.0 (“not advertised”); the hold check took that for RFC 3264 hold, so every native endpoint (and every created party) had silent_timeout (an hour by default) instead of timeout. A browser gone without a BYE stayed in its room for up to an hour. The hold check now reads only the real party’s SDP. And since a bridged endpoint is a call of its own, media sent to an endpoint now marks it active too: a listener bridged to a talker does not time out. Test: timeouts::one_sided_endpoints_time_out_and_live_ones_stay (not bridged and a room’s end with reason timeout; one that sends, a talker and its silent listener stay). Not counted yet: RTCP and STUN consent alone (an endpoint that sends no RTP at all, such as a browser with its microphone track removed).