Skip to content

ariadne: runtime channel-policy enforcement + drain fail-safe (§12, PR-D) - #467

Merged
transfix merged 1 commit into
masterfrom
design/ariadne-channel-runtime-policy
Sep 29, 2026
Merged

transfix merged 1 commit into
masterfrom
design/ariadne-channel-runtime-policy

Conversation

@transfix

Copy link
Copy Markdown
Owner

Final PR of the channel-scoping arc — the runtime enforcement backstop (catches dynamic channel names the load-time lint #465 can't see) plus a general fail-safety fix the enforcement exposed. Completes: #463 core resolver → #464 declaration → #465 load-lint → this runtime policy.

What lands

  • channel_policy on intrinsics_context (declared set + globals + strict/quiet), installed by the Runtime on every action/resident context. enforce_channel_policy refuses a strict-mode msg-* on a channel that is neither a #-runtime channel, a declared channel, a declared app-root-global (for a /-ref), nor granted via a planted transparent-link — called at msg-send/msg-recv/msg-pending entry.
  • Runtime::set_channel_policy(declared, global, strict, quiet) — plain args (no loader.h coupling); the generic .ari runner feeds it from LoadResult.channels/lint when a document declares channels: (strict unless lint.channels relaxed).
  • async_scheduler fail-safe (a real latent-bug fix): execute_process_step now catches a runtime step exception and kill_process()es it, instead of letting it escape sync_run() → the pump → drain() — which would crash the host frame loop. This gap affected any throwing intrinsic (a bad-arg builtin, now a channel refusal); the sync lane already handled it. The Runtime's sweep reports the killed action fail-safe (warn-once), so a refusal is visible, not silent.

Tests

6 AriadneChannelPolicy tests (strict-refuses / allows-declared / permissive-when-not-strict / allows-declared-global / refuses-undeclared-global / #-exempt), asserting the send's delivery outcome (pending_message_count). Full regression pass with the scheduler change: state_exec async 71 · scheduler 108 · integration 85 · intrinsics 151 · multiprocess 5 · advanced 40 · coordinator 61 · evaluator 39 · stackless 50 · ariadne_runtime 99 · loader 159 — all green.

Docs

Roadmap §12.6 documents the whole channel-scoping model: private-by-prefix + link-hole grants + the default-deny globals allowlist + the two enforcement layers (A load-lint, B runtime policy) driven by lint.channels.

…R-D)

The runtime backstop for channel enforcement — catches DYNAMIC channel names
the load-time lint (PR-C) can't see — plus a general fail-safety fix the
enforcement exposed. Completes the channel-scoping arc (#463 core → #464
declaration → #465 load-lint → this).

- channel_policy on intrinsics_context (declared set + globals + strict/quiet),
  installed by the Runtime on every action/resident ictx. enforce_channel_policy
  refuses a strict-mode msg-* on a channel that is neither a '#'-runtime channel,
  a declared channel, a declared app-root-global (for a '/'-ref), nor granted via
  a planted transparent-link. Called at the msg-send/recv/pending entry.
- Runtime::set_channel_policy(declared, global, strict, quiet) — plain args (no
  loader.h coupling); the generic .ari runner (ariadne_hello) feeds it from
  LoadResult.channels/lint when a doc declares channels: (strict unless relaxed).
- async_scheduler fail-safe: execute_process_step now CATCHES a runtime step
  exception and kill_process()es it instead of letting it escape sync_run() ->
  pump -> drain() (which would crash the host frame loop). This was a latent gap
  — any throwing intrinsic (bad-arg builtin, now a channel refusal) escaped the
  async lane; the sync lane already handled it. The sweep reports the killed
  action fail-safe (warn-once), so a refusal is visible, not silent.
- 6 AriadneChannelPolicy tests (strict-refuses/allows-declared/permissive-when-
  not-strict/declared-global/refuses-undeclared-global/#-exempt), asserting the
  send's delivery outcome. Roadmap §12.6 documents the whole channel-scoping
  model (private-by-prefix + link-hole grants + globals allowlist + A/B
  enforcement). Full state_exec + runtime + loader suites green, no regressions.
@transfix
transfix merged commit c42e945 into master Sep 29, 2026
13 checks passed
transfix added a commit that referenced this pull request Sep 30, 2026
state_exec is the substrate Ariadne apps run on (the demos are moving to
.ari apps), so forcing it OFF in the wasm builds only strips the program
lanes and leaves an OFF configuration nothing else exercises -- which is
how #467's unguarded channel_policy_ broke the gh-pages build. #438
already turned it ON for the wasm-mt libcvc/cvcgl publish; do the same
for the rest:

- src/cvcGL/examples/wasm/build-wasm-demo.sh (deploy-pages gh-pages
  gallery, both non-pthread and --pthread)
- cvcpkg/recipes/cvcgl-examples/build-wasm.sh (wasm-mt gallery bundle);
  cvc_revision 2 -> 3 so the change republishes over 3.4.0+cvc.2
- cvcpkg/recipes/pycvc-gl-cp312/build-wasm.{sh,ps1} (CPython-wasm host;
  no wasm variant published yet, so no revision bump needed)

The paths the demos use (stackless evaluator + async_scheduler) spawn no
threads, so this is safe on the non-pthread build; the compute pool
sizes itself to 0 workers there.
transfix added a commit that referenced this pull request Sep 30, 2026
state_exec is core: Ariadne's program + read lanes run on it and the demos
are moving to .ari apps. An OFF configuration only stripped those lanes
and left a build mode nothing tested -- the gh-pages wasm build was its
sole user, and #467's unguarded channel_policy_ broke it after merge.

- CMake: drop option(CVC_STATE_EXEC), the core/state_exec/ source filter,
  the PUBLIC compile definition, and the if(CVC_STATE_EXEC) test gating.
- Strip every #ifdef/#ifndef CVC_STATE_EXEC, keeping the ON code: ariadne
  (runtime, loader, app_runtime, net_intrinsics), core async_task, pycvc
  Exec. The OFF fallbacks (warn-and-show reactive slots, run_init error,
  throwing Exec stubs, no-op residents/verbs) are gone.
- Remove have_state_exec() (cvc::ariadne, AppRuntime, cvc::gl AriRuntime)
  and its callers: nav_compute's runtime check, net_intrinsics' early
  return, and the GTEST_SKIP / Python skip guards in the tests.
- Drop the now-meaningless -DCVC_STATE_EXEC=ON from the wasm build
  scripts and publish-cvcgl-wasm.yml; update docs.

This also fixes the native OFF build's executable links (app.cpp's
exec_scheduler() and nav_compute referenced state_exec unconditionally),
since there is no OFF build any more.
transfix added a commit that referenced this pull request Oct 25, 2026
)

* Bound writes: a relay client writes only its own participant, as itself

The relay applied and forwarded whatever a client sent: another
participant's intent, the server holon's poses, the scene, mutations or
media naming another origin, even a snapshot pushed at it.

state_inbound_gate (cvc/state), installed with
state_transport::set_inbound_gate on gRPC and WS, governs what a
transport takes from the connections it accepts. Dialed connections,
the bridge and the relay's own writes are not gated.

- Identity: a connection speaks only as the node id of its first Hello.
  One live connection holds a node id at a time. The first claim wins
  until it closes, or until it has been silent for 6 s (three missed
  link probes), when the next claim takes it over: a dropped network
  leaves the old stream open. The relay's own ids (its transport's and
  its shards') are never a client's.
- Origin: mutations, messages and media must name that id, and gRPC
  heartbeats must name it as their node. A client's SnapshotResponse is
  never applied, and a snapshot request is answered only for a
  connection speaking as itself.
- Departure: a close is that peer leaving only when the connection
  still held its id.
- Refused frames are not applied, forwarded or bridged; they are counted
  in total_inbound_rejected().

room_write_gate is the room's rule:
- a participant writes only inside conf.rooms.<room>.participants.<pid>,
  with value, touch or data ops;
- never the relay's keys there: pose, net.relay, and streams.<kind>.ready;
- only on canonical paths of at most 16 segments and 512 bytes (no empty
  or padded segment, which the tree would trim onto another key);
- and only for a pid that is one identifier.

Every client write today fits this rule.

arisrv --bind-writes on|off (default on; not an S7 switch) installs one
gate on both transports, and logs refusals as their count grows. The
bench mirrors it. The gate's holder map is file-local, so cvc.dll grows
only 71 names (65,198 of 65,535).

Tests:
- InboundGate{TakesOnlyWhatAPeerMayWriteAsItself, BindsANodeIdTo*,
  RefusesTheRelaysOwnId, HandsASilentHoldersIdOver} for gRPC and WS, and
  InboundGateSpansBothTransports;
- RoomWriteGate.* (the rule, binding, takeover);
- RoomRelayLoopbackTest.ClientWritesOnlyItsOwnParticipant: what the
  relay applies from a client that writes A's intent and pose, its own
  pose by normalising paths, the scene and the AOI, and A's intent as A.
  Mutants without the relay-id or canonical-path checks fail these.
- NoIntentOrUiDocsLeak now expects the echo refused by the write gate,
  and ControlPlaneEgressDrops's pre-S7 baseline turns bound writes off.

* Room token and default device identity (§5f), before usernames

Two credentials a peer can carry before there are accounts.

Room token -- who may join:
- arisrv takes it from --room-token-file PATH or CVC_ARISRV_ROOM_TOKEN,
  never from the command line. A token asked for must be a valid one: a
  flag with no path, an unreadable or blank file, or a set but empty
  variable is an error, not an open room.
- gRPC carries it as authorization: Bearer, now compared in constant
  time and counted in total_auth_rejected().
- WebSocket gains auth_config. A browser cannot set an Authorization
  header, so the client offers "cvc.v1,cvc-token.<token>" in
  Sec-WebSocket-Protocol. The server reads the upgrade request itself,
  refuses it with HTTP 401 unless the token is offered, and answers
  cvc.v1 (a browser requires the reply to name an offered subprotocol).
- Both checks run before admission, so a client without the token is
  sent nothing.
- arigl reads CVC_ARIADNE_ROOM_TOKEN. The browser page takes it from the
  invite link's URL fragment (#token=...), which never reaches a server
  or its logs.
- With no token configured the room is open, as before.

Each accepted WebSocket connection now does its handshake on its own
thread (10 s deadline, at most 64 at once). One client that connected
and sent nothing used to hold up every join, and stop().

Device id -- which device is this:
- Hello gains device_id (field 3), set with
  state_transport::set_device_id().
- default_device_id() is a salted SHA-256 of the OS machine id, the host
  name and the user. Under Emscripten it is "" unless CVC_DEVICE_ID is
  set; the page keeps a random id in localStorage, per page load where
  storage is blocked.
- A client sends scoped_device_id(base, relay URL), so two relays cannot
  match one device. A relay ignores an id that is not valid_device_id
  (1-64 of [A-Za-z0-9._-]).
- Link reports carry remote_device_id and holds_id.
- arisrv publishes participants.<pid>.device, a room-scoped 16-hex tag,
  from the link holding the pid (room_net write_link_devices).
  room_write_gate refuses a client's write to it.
- It is an identifier, not a credential: giving it authority needs a
  key the device keeps and the relay pins.

* ws: declare steady_ns before the accept loop uses it

The per-connection handshake stamps handshake_started_ns in accept_loop,
above steady_ns's definition: native builds with WebSocket failed to
compile (the wasm build skips accept_loop).

* Device keys: a device proves its id with a key the relay pins on first use (§5f)

The device id names a device; this gives it authority.

Keys (state_device_key.h, on OpenSSL's libcrypto):
- A device keeps one 32-byte seed: %LOCALAPPDATA%\cvc\device-key, or
  $XDG_CONFIG_HOME/cvc/device-key (~/.config/cvc/device-key), made on
  first use, owner-only on POSIX, and published in one step so two
  first launches agree on one seed. CVC_DEVICE_KEY_FILE names another
  file; CVC_DEVICE_KEY (64 hex) gives the seed itself, which is how the
  browser page passes the one it keeps in localStorage.
- For each relay it derives an Ed25519 key, HMAC-SHA256 of the seed and
  the relay URL, so two relays see unrelated keys.

The proof:
- A relay with a pin store puts a fresh 32-byte nonce in its Hello to
  each connection it accepts (Hello.nonce, field 4).
- The client answers with a DeviceProof (Frame field 12): its public
  key and a signature over the nonce, both node ids and its device id,
  each length-prefixed. One proof per challenge. A proof that arrives
  before the client's own Hello is held and checked when it comes.
- The relay verifies it and pins the key to the device id on first use
  (state_device_pins). A later proof under the pinned key verifies the
  link (state_link_report::device_verified); another key, or a bad
  signature, is refused and counted. A refused device stays in the
  room, without a tag. A store holds at most 65,536 pins.

The room:
- participants.<pid>.device is written only for a verified link that
  holds the pid, and cleared when the pid's holder proved no key, so a
  takeover does not keep the last device's tag.
- arisrv keeps one pin store for both transports, in memory or in a
  file with --device-pins PATH, and logs refused proofs.
- arigl loads the seed and signs for its relay; the page keeps the seed
  in localStorage (cvc.device_key) beside its device id.

Without OpenSSL nothing is derived or verified, and no device has a tag.

* Conference roster: a volume slider that holds still, and per-peer controls that follow the person

The Users window's volume slider sat in an auto-width table column. ImGui re-fits such a column to
its content every frame, and a slider in a cell took ~65% of it (ImGui's default item width), so
the column shrank by a third each frame until reserve_label_width's 48 px floor snapped it back: the
bar never held a width long enough to be dragged. The six fixed columns also already filled the
420 px window, which clipped the slider to a sliver.

- ImGuiBackend: a slider or int widget in a table cell now fills its cell, so an auto-width column
  settles at once (cvcgl_imgui_grid_slider: without this the column ends at 13 px, oscillating).
- conference_roster.ari: every roster column has a fixed width (vol 72 px), the window is 470 px,
  and the peer camera tiles move right with it. Each row's two name texts (plain and talking-green)
  are one group, so the cell exists on a frame where neither visibility check runs and the row no
  longer shifts left.
- Per-peer cam, mic and volume were keyed by roster ROW, and rows are sorted by pid, so a join or
  leave moved your settings onto someone else. on_tick now parks each row's controls under its pid
  (ctl.<pid>.*) before the rebuild and gives each row its own pid's back.

* Device keys: a device proves its id with a key the relay pins on first use (§5f) (#816)

The device id names a device; this gives it authority.

Keys (state_device_key.h, on OpenSSL's libcrypto):
- A device keeps one 32-byte seed: %LOCALAPPDATA%\cvc\device-key, or
  $XDG_CONFIG_HOME/cvc/device-key (~/.config/cvc/device-key), made on
  first use, owner-only on POSIX, and published in one step so two
  first launches agree on one seed. CVC_DEVICE_KEY_FILE names another
  file; CVC_DEVICE_KEY (64 hex) gives the seed itself, which is how the
  browser page passes the one it keeps in localStorage.
- For each relay it derives an Ed25519 key, HMAC-SHA256 of the seed and
  the relay URL, so two relays see unrelated keys.

The proof:
- A relay with a pin store puts a fresh 32-byte nonce in its Hello to
  each connection it accepts (Hello.nonce, field 4).
- The client answers with a DeviceProof (Frame field 12): its public
  key and a signature over the nonce, both node ids and its device id,
  each length-prefixed. One proof per challenge. A proof that arrives
  before the client's own Hello is held and checked when it comes.
- The relay verifies it and pins the key to the device id on first use
  (state_device_pins). A later proof under the pinned key verifies the
  link (state_link_report::device_verified); another key, or a bad
  signature, is refused and counted. A refused device stays in the
  room, without a tag. A store holds at most 65,536 pins.

The room:
- participants.<pid>.device is written only for a verified link that
  holds the pid, and cleared when the pid's holder proved no key, so a
  takeover does not keep the last device's tag.
- arisrv keeps one pin store for both transports, in memory or in a
  file with --device-pins PATH, and logs refused proofs.
- arigl loads the seed and signs for its relay; the page keeps the seed
  in localStorage (cvc.device_key) beside its device id.

Without OpenSSL nothing is derived or verified, and no device has a tag.

* Conference movement: the mover's own avatar stops jumping

Other people's view of a walking avatar was smooth, but the walker's own view jumped. arigl
predicts its avatar locally and replays its inputs on each server pose, so it was the only viewer
that saw the reconcile path, and three things fed that prediction the wrong history:

- The relay's ~1 Hz WebSocket re-broadcast sent a client its OWN intent back. The relay forgets a
  path when the client writes it, so the broadcast carried whatever the relay held; with the
  client's next write still in flight, that was the previous intent. The client applied it and
  predicted on it until the next key change or broadcast, while the server integrated the real one,
  so every 20 Hz pose snapped it back and the replay pushed it on again.
  - state_inbound_gate::sources (default false): whether a path is a peer's own. room_write_gate
    answers with its write rule, and broadcast_snapshot never sends such a path to its source.
  - arigl takes a tree intent only when it is not older than its last proposal
    (holon_sync read_current_intent; propose_intent now returns its stamp). A stamp of 0, the
    document's room-set-intent, is always taken.
- A clock realign wiped the input log. arigl moves its lead with the measured round trip, and any
  rise of ~50 ms seeked the clock and dropped the logged inputs, so the next pose snapped the
  avatar back by a round trip of walking. Within max_skew_ticks the client now slews its clock
  (holon_config::lead_slew, 5%) toward the target instead; the first alignment, joining, still
  seeks.
- The local avatar was drawn at its last whole 120 Hz quantum, so frames between quanta stood still
  and the rigidly following camera passed that judder to the whole view. display_pose now
  interpolates it between its last two quanta by the frame's alpha, as peers already are, and a
  reconcile shifts that interpolation with its correction.

Tests: RoomRelayLoopbackTest.ABroadcastNeverEchoesAClientsOwnIntent (the echo, end to end over WS;
fails without the broadcast skip), HolonTest.ALongerLeadIsSlewedIntoWithoutACorrection (a lead step
mid-walk: no correction slewing, one seeking), ClientSlewsTowardANewLead,
TheLocalAvatarIsShownBetweenQuanta, HolonSyncTest.ReadCurrentIntentRefusesAnEchoOfAnEarlierProposal
and RoomWriteGate.AParticipantSourcesWhatItWrites. Each fails with its fix removed.

* cvcgl_room_view: the local avatar's turn shows a quantum after it is taken

holon::display_pose now shows the local avatar between its last two quanta by the frame's alpha, so a turn taken on one quantum is drawn on the next. The visor check advances two quanta instead of one.

* Conference media: a fraction of the bandwidth, and an uplink that sheds instead of queueing

What each participant cost (the user's question; a 4-person room, every pair in view):
- Camera: 640x480 MJPEG at q70 and 30 fps, about 4-5 Mbit/s per receiver (17-22 KB a frame for a
  detailed scene with webcam-like noise), shown in ~300 px tiles.
- Mic: raw 32-bit float PCM at 48 kHz, 1.5 Mbit/s, sent even when muted or silent.
- So about 7.6 Mbit/s up and 23 Mbit/s down per client, and the link probe queued behind it.

Changes:
- The camera is captured at 320x240, 15 fps and q60: about 0.6 Mbit/s per receiver, ~8x less, for
  the same tiles. stream-capture-camera gains a `quality` option (1-100, default 70); it was always
  q70.
- arigl sends no mic chunk below -48 dBFS RMS more than 0.8 s after a louder one, so a silent or
  muted mic costs nothing (receivers already mix silence for a peer with no chunks, and its video
  runs free). A muted camera sends one frame a second instead of 15.
- A browser's send backlog is now WebSocket.bufferedAmount (it was always 0 there), so its uplink
  drops media at the 32 KB threshold instead of queueing it without bound behind every other frame,
  the link probe included.
- On every WebSocket link audio gets four times video's backlog allowance: a congested link sheds
  video first.

The roadmap records the new defaults (and the re-broadcast's no-echo rule from the movement fix).
Opus audio and per-receiver rungs are next.

* Per-viewer video rungs: the relay re-encodes each camera for each viewer's link

The user asked for per-viewer control of resolution and bitrate, adapted when a viewer's link
degrades, and asked whether senders must send several sizes. They need not: MJPEG frames stand
alone, so the relay makes the smaller sizes itself.

Rungs (cvc::media_rung_shaper, media_rungs.h):
- full (as sent), half and quarter (decoded at 1/2 or 1/4 size by libjpeg-turbo's DCT scaling and
  re-encoded), thumb (quarter at 2 fps) and off (no video; audio still flows).
- A variant is made once per frame and rung and shared by every viewer on it, across transports.
  Publishers upload one stream; old clients need no change.
- media_endpoint gains set_media_shaper, asked per receiver after the gate (the frame as sent, a
  variant, or nothing); the WS and gRPC fans encode each variant once per frame.
- cvc links libjpeg-turbo when the prefix has it (CVC_HAVE_TURBOJPEG); without it the smaller
  rungs send frames as is.

Adaptation (room_rung_controller, room_rungs.h), once a second over the link reports:
- per viewer, queueing (round trip above its minimum), the share of media frames dropped for it
  (new per-link media_sent / media_dropped counters) and what it was sent;
- down one rung after two bad seconds (queueing > 150 ms, > 5% dropped, or over budget), up one
  after ten good ones; a step up that fails early doubles the next wait (to 60 s).
- arisrv: --adapt on|off, --video-max RUNG, --video-floor RUNG, --viewer-kbps-max N; it logs each
  change and writes the rung to participants.<pid>.net.relay.video (relay-owned).

Camera off is a flag, not frames: a client whose camera is off sends no frames and publishes
participants.<pid>.video.off; viewers show "camera off" instead of the last frame they got.

The roster shows each person's rung as a dot before their name (green full, red reduced, black
none; hover for which) and "video in: ..." in My Camera. The dot is a new status_dot widget drawn
with ImGui's draw list, as the web build's font has no circle glyph.

Tests: MediaRungs.* (downscale sizes, shared variants, thumb pacing, audio untouched), RoomRungs.*
(down on queueing and drops, slow and wary up, the server's bounds), the WS shaper per receiver,
and RoomRelayLoopbackTest.AViewersVideoRungShapesWhatItGets on each transport.

* build(windows): cvc.dll stops exporting std:: symbols (63,073 -> 18,661 names) (#793)

cvc.dll's export table came from WINDOWS_EXPORT_ALL_SYMBOLS, which exports every external
symbol in cvc's objects, and a PE export table holds at most 65,535 names. The gRPC build
of master exported 63,073 and S7 (#789) 65,122; that limit is why the WebSocket transport
stays off on Windows. 44,412 of master's names were in namespace std: the members of
std::vector<cvc::...>, std::_Tree<...> and std::function's _Func_impl for cvc's lambdas,
the STL's inline functions, std RTTI. No consumer imports them. Each is an implicit
instantiation or an inline function that the consumer compiles from the same header, and
the linker resolves it from the consumer's own objects: of the 2,194 names S7's 286
binaries import from cvc.dll, none is in std.

Under MSVC, cvc_msvc_export_def (CMake/CvcMsvcExportDef.cmake) now builds the table as a
pre-link step. `cmake -E __create_def` over $<TARGET_OBJECTS:cvc> writes the same file
WINDOWS_EXPORT_ALL_SYMBOLS did, byte for byte. cvc_def_filter, a small host tool on
dbghelp's UnDecorateSymbolName, then leaves out every symbol whose undecorated name is in
namespace std, and cvc.dll links with /DEF: on the result. cvc_igl and cvc_physics_jolt
are still private static archives that are not scanned. Cross-compiles, CMake older than
3.18 and MinGW keep WINDOWS_EXPORT_ALL_SYMBOLS.

The gRPC RelWithDebInfo build of master now exports 18,661 names, and cvc.dll shrinks from
56.7 MB to 42.0 MB. S7's export list through the same filter is 18,946, and a CVC_ENABLE_WS=ON +
libigl build, which could not link before (66,726 names), exports 21,861. The cvc_igl_packaging
test also checks that the generated table names no igl:: or Eigen:: symbol.

(cherry picked from commit 1d0c87f)

* Video rungs: review fixes (bad JPEGs, variant cache, thumb pacing)

- jpeg_downscale refuses a JPEG over 4096 x 4096 before allocating for it:
  a frame's header names its own size, and one claiming 65535 x 65535 from
  any client would have the relay allocate gigabytes on a reader thread.
- A TurboJPEG handle a call failed on is replaced. A decompressor stopped
  partway through a bad header refuses every image after it ("two SOI
  markers"), so one malformed frame ended downscaling on that reader thread
  for good. The thread-local handles are now also destroyed at thread exit.
- write_media holds each variant's shared_ptr for the whole fan (WS and
  gRPC). Matched by address, a variant freed mid-fan could hand its address
  to another and a later receiver would get the wrong encoding.
- An unidentified receiver is shaped too, as "" (no rung: full).
- The thumb rung admits a frame a quarter of its interval early: the AOI
  tier may already pace that camera at the same 2 fps on its own schedule,
  and those frames arrive with a frame period of jitter, so a strict gap
  halved them.
- arisrv's room-debug report adds the shaper's totals.

Tests: the downscale test sends an oversized header and then a good frame
(which failed before the handle fix); the thumb test covers the early
frame; OnlyAViewersHoldingLinkCounts now checks a returning viewer starts
over at the best rung (it checked nothing); the WS shaper test claims only
what it checks, and asserts a shaped-out frame is not a link drop (the
controller would read its own off rung as congestion).

* Opus mics: 32 kbit/s instead of 1.5 Mbit/s

A mic sent as raw f32 at 48 kHz is 1.5 Mbit/s, the largest stream after
video. cvc::opus_encoder / opus_decoder (media_opus.h, over libopus) carry it
as Opus at 32 kbit/s: the sender re-chunks the mic's 1024-frame chunks into
20 ms (960-frame) packets, one media_frame each (codec "opus", a seq per
packet so a gap is a lost packet), and a new talk spurt resets the encoder.

A receiver decodes each peer with its own decoder (Opus is stateful),
conceals up to two lost packets, and cuts the result into mixer-sized
chunks: the mixer sums one chunk per peer, and a 960-frame packet in a
1024-frame mix would drift and click. A gap of over 0.4 s ends a peer's
talk spurt; a shorter delivery hitch keeps its samples.

The relay forwards a mic as sent, whatever its codec, and needs no libopus.
A client without libopus sends f32, which every client plays; it cannot
decode a peer's Opus, logs that once, and hears that peer as silence.
Older clients are not provided for.

libopus is optional. cvcpkg's autotools-built bundles ship no CMake config,
so it is found by header and library and linked through a synthesised
CvcOpus::opus, which cvcConfig.cmake recreates for a static consumer (as
PkgConfig::ZSTD). Under MSVC the search takes only the import library
(opus.lib, from cy-pca/cvcpkg#467, or libopus.dll.a): CMake would otherwise
take MinGW's libopus.a for `opus`, and its ___chkstk_ms calls do not link.
The libcvc recipe gains libopus on linux, macos and windows; wasm follows
once #467 publishes its bundle.

* conference_roster: ASCII status text (the browser's font draws a bullet or an em dash as ?)

The browser build's ImGui font is ASCII-only, so My Camera read "camera: ? on"
and a taken name "... is taken ? pick another". Plain "on" and a semicolon.

* recipe(libcvc): libopus for wasm too (cvcpkg libopus cvc.8)

cy-pca/cvcpkg#467 published a static wasm libopus, so the single-threaded
wasm libcvc gets Opus mics like the native ones. wasm-mt has no libopus
bundle, and Emscripten will not link a non-pthread archive into a -pthread
build, so it goes without (its mics stay f32).

* arigl: clang-format the video_off_ member comment

The Opus members inserted above it ended the aligned comment block, so
master's changed-lines check wants the single space back.
@transfix
transfix deleted the design/ariadne-channel-runtime-policy branch October 29, 2026 20:51
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.

1 participant