From 74c66e1cb6824015ad7c74e527b3b5072c336204 Mon Sep 17 00:00:00 2001 From: R Date: Sat, 14 Nov 2026 14:35:00 -0300 Subject: [PATCH 01/61] guidelines: webrtc is accepted, and its increment 1 is built The owner accepted webcpp::webrtc's proposal on 2026-11-14 (webcpporg/proposals#12), so its summary leaves chapter 18 for chapter 15, as the library its increment 1 builds natively: the decisions of the revised design, with what increment 1 measured. Reading a message through libdatachannel's C API costs four allocations and four copies inside libdatachannel, three to five times the C++ API's receive(), and under 2% of the time the message takes to arrive on the loopback; the design had estimated one copy and one allocation. The roadmap says which increments remain. Chapter 19 keeps the design's open questions O1 to O3 and adds two increment 1 found: dropping the size probe of the native receive, and a received message past the local maximum size, which libdatachannel truncates natively. --- CODING-GUIDELINES.md | 250 ++++++++++++++++++++++++------------------- 1 file changed, 139 insertions(+), 111 deletions(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index f6468085..8c09883a 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -7067,6 +7067,116 @@ facilities separately; a successful compile never proves runtime parity. controls accompany TLS application evidence. Documentation follows Diataxis in AsciiDoc with MrDocs API reference and executable examples. +### webrtc (WebRTC data channels in Asio's model; own; implementing, increment 1 of 3) + +webcpp::webrtc is a header-only C++20 library of webcpp's own (`kind: own`, +although it wraps libdatachannel natively) for peer connections and data +channels, shaped as the W3C WebRTC API in Asio's model, media out of scope. +The owner accepted its proposal on 2026-11-14 (webcpporg/proposals#12); its +`design.md` supersedes the specification of 2026-10-10 (`reference/spec.md`) +where they differ, and `reference/plan.md` holds three increments: the +interface, the runtime and the native implementation (built, in `libs/webrtc`, +from one import commit of `reference/source/`), the browser implementation +over webcpp::asio's bridge with an interop lane, and trystero on it. + +- **A library of its own on webcpp::asio, not a part of webcpp::beast.** The + owner's decision of 2026-11-14: beast is a source-compatible facade of + Boost.Beast and WebRTC has no Boost counterpart; libdatachannel and its + threads would burden every beast user; beast targets WASIp2/P3, where WebRTC + has no stack; and beast's D6 already foresees a WebRTC channel's byte stream + as an opt-in next layer, so beast would use webrtc, never the reverse. + Source: `libraries/webrtc/openspec/changes/genesis/design.md` D1 (proposals). +- **The interface carries the W3C names and shapes (`peer_connection`, + `data_channel`, `session_description`, `ice_candidate`, the `RTC*` + enumerations in snake case) in Asio's model: `async_*` operations with any + completion token, the executor (default `webcpp::asio::any_io_executor`) and + the allocator as template parameters, inputs as views and outputs owned.** + The owner's decision of 2026-10-10, so that a program, trystero first, is + written once and runs natively and in a browser; webcpp::asio's name is the + type the browser implementation shares with the program's io_context. + Source: `libraries/webrtc/openspec/changes/genesis/design.md` D2 (proposals). +- **Its targets are native and Emscripten, and its configuration stops with an + `#error` under WASI that names the reason.** libdatachannel has no WASI port + (its threads, and libjuice's and usrsctp's, need preemptive threads, and its + ICE and SCTP were never ported to WASI sockets), and no WASI host interface + offers WebRTC. A WASI stub was rejected because it would let a program + compile and fail at run time. Increment 1 declares native only; until + increment 2 the headers that need a backend stop with `#error` on + emscripten. + Source: `libraries/webrtc/openspec/changes/genesis/design.md` D3 (proposals). +- **The native backend calls libdatachannel's C API only, so the library works + with exceptions on and off.** The owner's decision of 2026-11-14: + libdatachannel throws and cannot be built without exceptions, but every + function of its C API catches them and returns a negative code, so a + program built with `-fno-exceptions` uses it: the native suite passes built + with `exception-handling=off` against archives built with exceptions. The + C++ API, which would leave a program without exceptions with no native + backend, was rejected. + Source: `libraries/webrtc/openspec/changes/genesis/design.md` D4 (proposals). +- **Reading a message through the C API costs four allocations and four + copies inside libdatachannel, and three to five times the time of the C++ + API's `receive()`, under 2% of the time the message takes to arrive.** + Measured on 2026-11-14 (`bench/receive_bench.cpp`, macOS arm64, Apple clang + 21, release, 100,000 messages): 4.37 million messages of 1 KiB a second + against 12.76 million, 131,000 of 64 KiB against 632,000, while the + loopback delivered 71 and 124 MB/s. The backend calls `rtcReceiveMessage` + twice, a size probe then the read, and each call copies the message twice + (`peek`, then a by-value visit); the design's estimate of one copy and one + allocation was low. The cost is libdatachannel's allocator's, not the + user's. + Source: `doc/native.adoc` (libs/webrtc). +- **Events are pending operations the caller re-arms + (`async_wait_ice_candidate`, `async_wait_state_change`, + `async_accept_data_channel`, `async_receive` and their kin), one wait of a + kind at a time, with a stated policy for an event that arrives while none is + pending.** This keeps every handler on the executor and every lifetime in + the caller's hands, as an acceptor's `async_accept`; callbacks, and one wait + returning a variant of events, were rejected. + Source: `libraries/webrtc/openspec/changes/genesis/design.md` D5 (proposals). +- **A `runtime` the program owns holds libdatachannel's process-wide state, + one at a time natively as a stated precondition, made before any connection + and destroyed after the last, and enforces `max_peer_connections` (default + 256) on both targets.** webcpp keeps no global or static mutable state, so a + second runtime cannot be detected; 256 is half of Chromium's 500 per page. + Source: `libraries/webrtc/openspec/changes/genesis/design.md` D6 (proposals). +- **libdatachannel's callbacks copy and post through a weak pointer, and + destruction calls `rtcDelete*`, which waits for the callbacks in flight.** + libdatachannel documents that wait; nothing of the user's allocator is + touched on its threads. The lifetime test runs 100 rounds of destruction + while the peer floods, clean under ThreadSanitizer. + Source: `libraries/webrtc/openspec/changes/genesis/design.md` D7 (proposals). +- **In the browser it will follow webcpp::beast's browser WebSocket as built: + one intrusive registration of the bridge per object, arrivals staged and + charged on arrival to the receive bound, one notification posted per batch, + JavaScript's exceptions caught in JavaScript, and the unsupported policy in + an inline namespace with a propagated b2 feature.** Those patterns are + proved; where webrtc differs (a send refused before the browser sees it + leaves the channel open; several event kinds; terminal cancellation only for + the description operations) the design says why. The b2 feature + `webcpp-webrtc-unsupported` exists from increment 1. + Source: `libraries/webrtc/openspec/changes/genesis/design.md` D8, D11, D12 + and D14 (proposals). +- **`async_receive` copies one whole message into the caller's dynamic + buffer; natively unread messages wait in libdatachannel's own queue of + 1,024, a flow control that never fails, and in the browser in a queue + bounded by `max_received_bytes`.** Measured on 2026-11-14 and pinned by + `test/stall_test.cpp`: a native channel never read, once its queue is full, + stalls its connection's other channels until it is read or destroyed; the + page tells a program to read or close every channel, and closing or + destroying a channel drains its queue. + Source: `libraries/webrtc/openspec/changes/genesis/design.md` D9 (proposals). +- **libdatachannel is the superproject's pinned, source-built copy, unmodified, + justified in the documentation, with nothing of it in a public header; its + MPL-2.0 is accepted for this library.** The owner's decision of 2026-11-14, + as trystero already distributes it; no WebRTC exists in webcpp, Boost, the + C++ Alliance or the standard library, and libdatachannel is the smallest + complete implementation. + Source: `libraries/webrtc/openspec/changes/genesis/design.md` D16 (proposals). +- **webcpp::webrtc knows nothing of xactor: an actor that needs a peer holds a + `peer_connection` made on the executor its driver runs on, and turns each + completion into a message to itself.** The two meet at the executor. + Source: `libraries/webrtc/openspec/changes/genesis/design.md` D17 (proposals). + ## 16. Roadmap What webcpp does not have yet, and the chapters that mention it: @@ -7094,9 +7204,12 @@ What webcpp does not have yet, and the chapters that mention it: migration. Their coexistence is required; dependency provenance must not be addressed by prohibiting a combined program. Actor-based libraries use xactor's scheduler through an application-owned loop. -- **webcpp::webrtc and webcpp::crypto.** WebRTC peer connections and data - channels, and authenticated encryption/randomness, remain separate proposals. - Trystero can then retain its protocol over those shared facilities. +- **webcpp::webrtc and webcpp::crypto.** webrtc's increment 1, the interface + and the native implementation, is built (chapter 15); its increment 2 brings + the browser implementation and the interop lane, and its increment 3 moves + trystero's WebRTC onto it. Authenticated encryption and randomness remain + crypto's (chapter 17). Trystero can then retain its protocol over those + shared facilities. - **The libraries web developers use most,** brought to C++: a JavaScript interpreter (QuickJS), libp2p, HTTP fetch. - **The site, increments 2 to 8.** Increment 1 is done: the site's @@ -8420,114 +8533,6 @@ The proposals not yet decided, each briefly, with the questions they leave for the owner. A draft decides nothing: it is here so that a contributor sees what is coming, and its proposal holds it in full. -### webrtc (draft, not decided) - -webcpp::webrtc would be a header-only C++20 library of webcpp's own -(`kind: own`, although it wraps libdatachannel natively) for peer connections -and data channels, shaped as the W3C WebRTC API in Asio's model, on native -(libdatachannel 0.24.6, through its C API) and Emscripten (the browser's -objects, through webcpp::asio's bridge), media out of scope, replacing the -WebRTC of trystero's `backend` in a later change. Its draft was revised on -2026-11-14: `design.md` supersedes the specification of 2026-10-10 -(`reference/spec.md`) where they differ; `reference/plan.md` holds three -increments, and `reference/source/` holds increment 1, the interface and the -native implementation, whose tests pass against the pinned libdatachannel, as -the build asks, without exceptions and under ThreadSanitizer. - -- **A library of its own on webcpp::asio, not a part of webcpp::beast.** The - owner's decision of 2026-11-14: beast is a source-compatible facade of - Boost.Beast and WebRTC has no Boost counterpart; libdatachannel and its - threads would burden every beast user; beast targets WASIp2/P3, where WebRTC - has no stack; and beast's D6 already foresees a WebRTC channel's byte stream - as an opt-in next layer, so beast would use webrtc, never the reverse. - Source: `libraries/webrtc/openspec/changes/genesis/design.md` D1 (proposals). -- **The interface carries the W3C names and shapes (`peer_connection`, - `data_channel`, `session_description`, `ice_candidate`, the `RTC*` - enumerations in snake case) in Asio's model: `async_*` operations with any - completion token, the executor (default `webcpp::asio::any_io_executor`) and - the allocator as template parameters, inputs as views and outputs owned.** - The owner's decision of 2026-10-10, so that a program, trystero first, is - written once and runs natively and in a browser; webcpp::asio's name is the - type the browser implementation shares with the program's io_context. - Source: `libraries/webrtc/openspec/changes/genesis/design.md` D2 (proposals). -- **Its targets are native and Emscripten, and its configuration stops with an - `#error` under WASI that names the reason.** libdatachannel has no WASI port - (its threads, and libjuice's and usrsctp's, need preemptive threads, and its - ICE and SCTP were never ported to WASI sockets), and no WASI host interface - offers WebRTC; Boost.Asio itself runs on WASIp2/P3 now, so that is no longer - a reason. A WASI stub was rejected because it would let a program compile and - fail at run time. - Source: `libraries/webrtc/openspec/changes/genesis/design.md` D3 (proposals). -- **The native backend calls libdatachannel's C API only, so the library works - with exceptions on and off on both targets.** The owner's decision of - 2026-11-14: libdatachannel throws and cannot be built without exceptions, but - every function of its C API catches them and returns a negative code, so a - program built with `-fno-exceptions` uses it (measured); the C++ API, which - would leave a program without exceptions with no native backend, was - rejected. The cost is a copy and an allocation per received message inside - libdatachannel, to be measured. - Source: `libraries/webrtc/openspec/changes/genesis/design.md` D4 (proposals). -- **Events are pending operations the caller re-arms - (`async_wait_ice_candidate`, `async_wait_state_change`, - `async_accept_data_channel`, `async_receive` and their kin), one wait of a - kind at a time, with a stated policy for an event that arrives while none is - pending.** This keeps every handler on the executor and every lifetime in - the caller's hands, as an acceptor's `async_accept`; callbacks, and one wait - returning a variant of events, were rejected. - Source: `libraries/webrtc/openspec/changes/genesis/design.md` D5 (proposals). -- **A `runtime` the program owns holds libdatachannel's process-wide state, - one at a time natively as a stated precondition, made before any connection - and destroyed after the last, and enforces `max_peer_connections` (default - 256) on both targets.** webcpp keeps no global or static mutable state, so a - second runtime cannot be detected; 256 is half of Chromium's 500 per page. - Source: `libraries/webrtc/openspec/changes/genesis/design.md` D6 (proposals). -- **libdatachannel's callbacks copy and post through a weak pointer, and - destruction calls `rtcDelete*`, which waits for the callbacks in flight.** - libdatachannel documents that wait; nothing of the user's allocator is - touched on its threads. - Source: `libraries/webrtc/openspec/changes/genesis/design.md` D7 (proposals). -- **In the browser it follows webcpp::beast's browser WebSocket as built: one - intrusive registration of the bridge per object, arrivals staged and charged - on arrival to the receive bound, one notification posted per batch, - JavaScript's exceptions caught in JavaScript, and the unsupported policy in - an inline namespace with a propagated b2 feature.** Those patterns are - proved; where webrtc differs (a send refused before the browser sees it - leaves the channel open; several event kinds; terminal cancellation only for - the description operations) the design says why. - Source: `libraries/webrtc/openspec/changes/genesis/design.md` D8, D11, D12 and - D14 (proposals). -- **`async_receive` copies one whole message into the caller's dynamic - buffer; natively unread messages wait in libdatachannel's own queue of 1,024, - a flow control that never fails, and in the browser in a queue bounded by - `max_received_bytes`.** Measured on 2026-11-14: a native channel never read, - once its queue is full, stalls its connection's other channels until it is - read or destroyed; the documentation tells a program to read or close every - channel, and closing or destroying a channel drains its queue. - Source: `libraries/webrtc/openspec/changes/genesis/design.md` D9 (proposals). -- **libdatachannel is the superproject's pinned, source-built copy, unmodified, - justified in the documentation, with nothing of it in a public header; its - MPL-2.0 is accepted for this library.** The owner's decision of 2026-11-14, - as trystero already distributes it; no WebRTC exists in webcpp, Boost, the - C++ Alliance or the standard library, and libdatachannel is the smallest - complete implementation. - Source: `libraries/webrtc/openspec/changes/genesis/design.md` D16 (proposals). -- **webcpp::webrtc knows nothing of xactor: an actor that needs a peer holds a - `peer_connection` made on the executor its driver runs on, and turns each - completion into a message to itself.** The two meet at the executor. - Source: `libraries/webrtc/openspec/changes/genesis/design.md` D17 (proposals). - -**Open questions for the owner.** - -- Whether a later version synthesises `negotiationneeded` natively (O1). -- Whether a later change adds a byte stream over a data channel, for - webcpp::beast's D6 (O2). -- Whether natively a channel keeps its own queue bounded in bytes, so that a - channel never read cannot stall its connection's others, at the price of the - flow control that slows the peer (O3). - -Source: `libraries/webrtc/openspec/changes/genesis/design.md` Open Questions -(proposals). - ### json_schema (draft, not decided) webcpp::json_schema would be a header-only C++20 JSON Schema validator of @@ -9077,3 +9082,26 @@ says what the tree does. CI tests predates the rule that makes them a subset of the lanes (`AGENTS.md` chapter 5), and its roadmap requirement repeats chapter 16's sentence on trystero's configuration. + +### webrtc: open questions + +- **Whether a later version synthesises `negotiationneeded` natively** (the + design's O1), and **whether a later change adds a byte stream over a data + channel**, for webcpp::beast's D6 (O2). +- **Whether natively a channel keeps its own queue bounded in bytes,** so that + a channel never read cannot stall its connection's others, at the price of + the flow control that slows the peer (O3). +- **Whether the native receive drops its size probe,** reading into the + caller's buffer with the last message's size as a guess and asking for the + size only when a message does not fit, which would halve the four + allocations and copies a message costs (chapter 15). As `src/capi.cpp` + reads, libdatachannel reports the size of a message too large for the + buffer given as 0, since it moves the message out before it reads its size, + so the probe would stay for that case. +- **A received message past the local maximum message size,** natively, is + truncated by libdatachannel to that size, with a warning in its log + (`src/impl/sctptransport.cpp`), and delivered; the page states it as a + difference. A peer that keeps to the size announced in the description never + sends one; whether the backend should detect the truncation and fail the + receive with `message_too_large`, as the browser implementation will, is + open. From aa0ea3a7b2bff9e96e9c658b2757495afa844cad Mon Sep 17 00:00:00 2001 From: R Date: Sat, 14 Nov 2026 14:35:00 -0300 Subject: [PATCH 02/61] build: register webrtc as a library of the superproject libs/webrtc is the submodule webcpporg/webrtc, by the relative URL ../webrtc.git as every library's, at its increment 1 (42509ec). AGENTS.md lists webrtc among the libraries, and its layout names every submodule of libs/, beast and cobalt included, which it had left out; the 0.1.0 release notes add webrtc under New Libraries. --- .gitmodules | 3 +++ AGENTS.md | 6 ++++-- doc/releases/0.1.0.adoc | 3 +++ libs/webrtc | 1 + 4 files changed, 11 insertions(+), 2 deletions(-) create mode 160000 libs/webrtc diff --git a/.gitmodules b/.gitmodules index 3762d051..5ad55389 100644 --- a/.gitmodules +++ b/.gitmodules @@ -49,3 +49,6 @@ [submodule "libs/cobalt"] path = libs/cobalt url = ../cobalt.git +[submodule "libs/webrtc"] + path = libs/webrtc + url = ../webrtc.git diff --git a/AGENTS.md b/AGENTS.md index 2f0a0d8e..3cb3ad5e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -85,6 +85,7 @@ for web developers and for AI developers (`CODING-GUIDELINES.md` chapter 16). | idna | internationalized domain names: Punycode, UTS 46's ToASCII and ToUnicode, conformant to IdnaTestV2, and IDNA2008's validity, over Unicode 17.0.0 tables generated into its headers; webcpp's own | native, wasip2, wasip3, emscripten; its own lane `tables` | a submodule at `libs/idna`; its errors are values, and its span forms allocate nothing | | lexical | the string formats JSON Schema names (date-time, email, hostname, ipv4/ipv6, uri, iri, uri-template, json-pointer, uuid, regex), each a validator that allocates nothing and a Boost.URL grammar rule; regex is an ECMA-262 syntax validator of its own, checked against V8; depends on idna and Boost.URL; webcpp's own | native, wasip2, wasip3, emscripten; its own lanes `generated` and `oracle` | a submodule at `libs/formats` | | trystero | a port of Trystero 0.26.0, serverless WebRTC rooms | native, emscripten; its own lanes `oracle` and `interop` | a submodule at `libs/trystero`; born with the allocation rule through `std::pmr` | +| webrtc | WebRTC peer connections and data channels with the W3C's names in Asio's model, natively over libdatachannel's C API, with exceptions on and off; webcpp's own | native; emscripten from its increment 2 | a submodule at `libs/webrtc`; increment 1 of 3 (`CODING-GUIDELINES.md` chapter 15) | ### The layout @@ -102,8 +103,9 @@ webcpp/ extend (below) .clang-tidy clang-tidy's checks, every repository's pyrightconfig.json Pyright's settings for every Python file - libs// a library: a repository of its own, a submodule here (asio, config, xactor, - xstate, pratt, wasi, trystero, document, idna, lexical) + libs// a library: a repository of its own, a submodule here (asio, beast, cobalt, + config, xactor, xstate, pratt, wasi, trystero, document, idna, lexical, + webrtc) third_party/ third-party code the libraries and their tests use, not webcpp's: each a submodule under third_party/libs/, pinned at a commit and keeping its own licence, and the Jamfile that declares it as diff --git a/doc/releases/0.1.0.adoc b/doc/releases/0.1.0.adoc index 4c1d1ed5..c046c03f 100644 --- a/doc/releases/0.1.0.adoc +++ b/doc/releases/0.1.0.adoc @@ -40,6 +40,9 @@ for {cpp}20, from R. * link:{library-pages}wasi/{library-page}[wasi]: a header-only HTTP handler for {cpp}20 programs built as WebAssembly components, covering WASI 0.2 and WASI 0.3, from R. +* link:{library-pages}webrtc/{library-page}[webrtc]: a header-only library of +WebRTC peer connections and data channels for {cpp}20, with the W3C's names in +Asio's model, natively over libdatachannel, from R. * link:{library-pages}xactor/{library-page}[xactor]: a header-only, deterministic actor system for {cpp}20, from R. * link:{library-pages}xstate/{library-page}[xstate]: a header-only port of diff --git a/libs/webrtc b/libs/webrtc new file mode 160000 index 00000000..42509ec0 --- /dev/null +++ b/libs/webrtc @@ -0,0 +1 @@ +Subproject commit 42509ec0cead625499c25b91d1dd7b716b056774 From 0af83cef346efd76194435d6843aaedd79cd6d09 Mon Sep 17 00:00:00 2001 From: R Date: Sat, 14 Nov 2026 14:56:29 -0300 Subject: [PATCH 03/61] webrtc: move to the commit that corrects its page after the review libs/webrtc moves to 6e96a83: the page no longer says that a channel added to a connection that is up needs a new offer and answer, it states its limits precisely, and the benchmark fails as a value on Windows too. Chapter 19 says, as the page now does, that libdatachannel truncates an oversized message silently, since webrtc installs no logger for it. --- CODING-GUIDELINES.md | 6 +++--- libs/webrtc | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index 47f54911..a48d41d5 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -9100,9 +9100,9 @@ says what the tree does. buffer given as 0, since it moves the message out before it reads its size, so the probe would stay for that case. - **A received message past the local maximum message size,** natively, is - truncated by libdatachannel to that size, with a warning in its log - (`src/impl/sctptransport.cpp`), and delivered; the page states it as a - difference. A peer that keeps to the size announced in the description never + truncated by libdatachannel to that size (`src/impl/sctptransport.cpp`), + silently, since webrtc installs no logger for it, and delivered; the page + states it as a difference. A peer that keeps to the size announced in the description never sends one; whether the backend should detect the truncation and fail the receive with `message_too_large`, as the browser implementation will, is open. diff --git a/libs/webrtc b/libs/webrtc index 42509ec0..6e96a830 160000 --- a/libs/webrtc +++ b/libs/webrtc @@ -1 +1 @@ -Subproject commit 42509ec0cead625499c25b91d1dd7b716b056774 +Subproject commit 6e96a8305bad91f9bbabdec86e04f8915da2538b From b43c08f04e9bcc78a8c9d4826e672b1be87a55e4 Mon Sep 17 00:00:00 2001 From: R Date: Sat, 14 Nov 2026 15:55:30 -0300 Subject: [PATCH 04/61] webrtc: increment 2, the browser implementation and its lanes libs/webrtc moves to 12de0a4: webrtc runs in the browser too, over the page's own RTCPeerConnection through webcpp::asio's bridge, in both suspension variants, with exceptions on and off, and its page says so. Its two own lanes meet a browser, so CHROME_LANES names them, as matrix_test.py now pins: browser, two peers in one page of headless Chrome, and interop, a native peer and a browser peer through a relay. The interop lane runs with exceptions on and off, and in the page under both unsupported policies (OWN_LANE_OPTIONS), and on emscripten its job first builds the native peer the driver starts, as beast's browser lane does. AGENTS.md lists the lanes and webrtc's targets, the 0.1.0 notes say it runs in the browser, and chapter 15 holds increment 2: the browser's design as built, its census, and the tests of both targets, with Chrome 156's default-route candidates and dropped last messages. --- .github/workflows/library.yml | 11 ++++++++++ AGENTS.md | 7 +++--- CODING-GUIDELINES.md | 40 +++++++++++++++++++++++------------ doc/releases/0.1.0.adoc | 2 +- libs/webrtc | 2 +- tools/ci/matrix.py | 9 +++++++- tools/ci/matrix_test.py | 6 +++--- 7 files changed, 54 insertions(+), 23 deletions(-) diff --git a/.github/workflows/library.yml b/.github/workflows/library.yml index b41a8b6f..a8f6fbba 100644 --- a/.github/workflows/library.yml +++ b/.github/workflows/library.yml @@ -332,6 +332,17 @@ jobs: libs/beast/test/browser/peer//native_peer-program \ toolset=clang-18 threading=multi -j2 + # webrtc's interop lane on emscripten drives the page against the native + # peer and relay, which its driver finds under bin/ (test/interop/run.mjs). + - name: Build the native webrtc interoperability peer + if: matrix.library == 'webrtc' && matrix.lane == 'interop' && matrix.platform == 'emscripten' + shell: bash + run: | + python3 tools/ci/matrix.py register clang-18 + b2 --user-config=.local/user-config.jam \ + libs/webrtc/test/interop//native-program \ + toolset=clang-18 threading=multi -j2 + # This embedding adds a private test CA through Wasmtime's supported host hook. # Stock Wasmtime uses its bundled public roots and has no CLI test-CA option. - name: Restore the isolated WASI HTTPS host fixture diff --git a/AGENTS.md b/AGENTS.md index 3cb3ad5e..9568a522 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -85,7 +85,7 @@ for web developers and for AI developers (`CODING-GUIDELINES.md` chapter 16). | idna | internationalized domain names: Punycode, UTS 46's ToASCII and ToUnicode, conformant to IdnaTestV2, and IDNA2008's validity, over Unicode 17.0.0 tables generated into its headers; webcpp's own | native, wasip2, wasip3, emscripten; its own lane `tables` | a submodule at `libs/idna`; its errors are values, and its span forms allocate nothing | | lexical | the string formats JSON Schema names (date-time, email, hostname, ipv4/ipv6, uri, iri, uri-template, json-pointer, uuid, regex), each a validator that allocates nothing and a Boost.URL grammar rule; regex is an ECMA-262 syntax validator of its own, checked against V8; depends on idna and Boost.URL; webcpp's own | native, wasip2, wasip3, emscripten; its own lanes `generated` and `oracle` | a submodule at `libs/formats` | | trystero | a port of Trystero 0.26.0, serverless WebRTC rooms | native, emscripten; its own lanes `oracle` and `interop` | a submodule at `libs/trystero`; born with the allocation rule through `std::pmr` | -| webrtc | WebRTC peer connections and data channels with the W3C's names in Asio's model, natively over libdatachannel's C API, with exceptions on and off; webcpp's own | native; emscripten from its increment 2 | a submodule at `libs/webrtc`; increment 1 of 3 (`CODING-GUIDELINES.md` chapter 15) | +| webrtc | WebRTC peer connections and data channels with the W3C's names in Asio's model, natively over libdatachannel's C API and in the browser over the page's own objects, with exceptions on and off; webcpp's own | native, emscripten; its own lanes `browser` and `interop` | a submodule at `libs/webrtc`; increments 1 and 2 of 3 (`CODING-GUIDELINES.md` chapter 15) | ### The layout @@ -1632,8 +1632,9 @@ jobs: kind `programs` on any other target, such as wasi's served lanes, has none. - An own lane whose driver meets a browser, one of `CHROME_LANES` in - `tools/ci/matrix.py` (trystero's `interop`, natively and on emscripten, - document's `js`, and asio's `browser`), + `tools/ci/matrix.py` (trystero's and webrtc's `interop`, natively and on + emscripten, document's `js`, webrtc's `browser`, and the browser lanes of + asio, beast and cobalt), has its entry's `chrome`, and its job runs the `chrome` action, which gives it `CHROME`, a pinned Chrome rather than the image's, which moves with the image, so that a red interop lane is never a browser nobody diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index a48d41d5..387bdb4d 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -7067,7 +7067,7 @@ facilities separately; a successful compile never proves runtime parity. controls accompany TLS application evidence. Documentation follows Diataxis in AsciiDoc with MrDocs API reference and executable examples. -### webrtc (WebRTC data channels in Asio's model; own; implementing, increment 1 of 3) +### webrtc (WebRTC data channels in Asio's model; own; implementing, increments 1 and 2 of 3) webcpp::webrtc is a header-only C++20 library of webcpp's own (`kind: own`, although it wraps libdatachannel natively) for peer connections and data @@ -7077,7 +7077,8 @@ The owner accepted its proposal on 2026-11-14 (webcpporg/proposals#12); its where they differ, and `reference/plan.md` holds three increments: the interface, the runtime and the native implementation (built, in `libs/webrtc`, from one import commit of `reference/source/`), the browser implementation -over webcpp::asio's bridge with an interop lane, and trystero on it. +over webcpp::asio's bridge with its `browser` and `interop` lanes (built), and +trystero on it. - **A library of its own on webcpp::asio, not a part of webcpp::beast.** The owner's decision of 2026-11-14: beast is a source-compatible facade of @@ -7100,9 +7101,7 @@ over webcpp::asio's bridge with an interop lane, and trystero on it. (its threads, and libjuice's and usrsctp's, need preemptive threads, and its ICE and SCTP were never ported to WASI sockets), and no WASI host interface offers WebRTC. A WASI stub was rejected because it would let a program - compile and fail at run time. Increment 1 declares native only; until - increment 2 the headers that need a backend stop with `#error` on - emscripten. + compile and fail at run time. Source: `libraries/webrtc/openspec/changes/genesis/design.md` D3 (proposals). - **The native backend calls libdatachannel's C API only, so the library works with exceptions on and off.** The owner's decision of 2026-11-14: @@ -7145,17 +7144,30 @@ over webcpp::asio's bridge with an interop lane, and trystero on it. touched on its threads. The lifetime test runs 100 rounds of destruction while the peer floods, clean under ThreadSanitizer. Source: `libraries/webrtc/openspec/changes/genesis/design.md` D7 (proposals). -- **In the browser it will follow webcpp::beast's browser WebSocket as built: +- **In the browser it follows webcpp::beast's browser WebSocket as built: one intrusive registration of the bridge per object, arrivals staged and charged on arrival to the receive bound, one notification posted per batch, - JavaScript's exceptions caught in JavaScript, and the unsupported policy in - an inline namespace with a propagated b2 feature.** Those patterns are - proved; where webrtc differs (a send refused before the browser sees it - leaves the channel open; several event kinds; terminal cancellation only for - the description operations) the design says why. The b2 feature - `webcpp-webrtc-unsupported` exists from increment 1. - Source: `libraries/webrtc/openspec/changes/genesis/design.md` D8, D11, D12 - and D14 (proposals). + JavaScript's exceptions caught in JavaScript and reported by DOMException + name, and the unsupported policy in an inline namespace with a propagated b2 + feature.** Those patterns are proved; where webrtc differs (a send refused + before the browser sees it leaves the channel open; several event kinds; + terminal cancellation only for the description operations, and in the + browser for adding a candidate, whose promise cannot be called back) the + design and the page say why. The page's census of `RTCPeerConnection`s, + kept in JavaScript until a `FinalizationRegistry` sees each collected, is + what `max_peer_connections` caps there. + Source: `libraries/webrtc/openspec/changes/genesis/design.md` D6, D8, D11, + D12 and D14 (proposals); `doc/browser.adoc` (libs/webrtc). +- **The tests run on both targets: natively, on emscripten under Node with a + fake connection where a real one is not needed, in headless Chrome with two + peers in one page (the `browser` lane), and native against Chrome through a + local relay over webcpp::beast's WebSocket (the `interop` lane).** Chrome + 156 offers a page with no media permission only its default-route address, + whatever `--allow-loopback-in-peer-connection` says, so the interop driver + grants the page's origin the microphone, which starts no capture, to keep + the exchange on 127.0.0.1; and Chrome 156 may drop messages sent just + before a channel is closed, which the page states as a difference. + Source: `doc/testing.adoc`, `test/interop/run.mjs` (libs/webrtc). - **`async_receive` copies one whole message into the caller's dynamic buffer; natively unread messages wait in libdatachannel's own queue of 1,024, a flow control that never fails, and in the browser in a queue diff --git a/doc/releases/0.1.0.adoc b/doc/releases/0.1.0.adoc index c046c03f..07f59a32 100644 --- a/doc/releases/0.1.0.adoc +++ b/doc/releases/0.1.0.adoc @@ -42,7 +42,7 @@ for {cpp}20 programs built as WebAssembly components, covering WASI 0.2 and WASI 0.3, from R. * link:{library-pages}webrtc/{library-page}[webrtc]: a header-only library of WebRTC peer connections and data channels for {cpp}20, with the W3C's names in -Asio's model, natively over libdatachannel, from R. +Asio's model, natively over libdatachannel and in the browser, from R. * link:{library-pages}xactor/{library-page}[xactor]: a header-only, deterministic actor system for {cpp}20, from R. * link:{library-pages}xstate/{library-page}[xstate]: a header-only port of diff --git a/libs/webrtc b/libs/webrtc index 6e96a830..12de0a45 160000 --- a/libs/webrtc +++ b/libs/webrtc @@ -1 +1 @@ -Subproject commit 6e96a8305bad91f9bbabdec86e04f8915da2538b +Subproject commit 12de0a4583f4785cc4b40d12ad3615c92651a2fa diff --git a/tools/ci/matrix.py b/tools/ci/matrix.py index 5e1f9a68..089bc8dd 100755 --- a/tools/ci/matrix.py +++ b/tools/ci/matrix.py @@ -181,7 +181,8 @@ ('cobalt', 'browser-workers'), ('cobalt', 'browser-runtime-probes'), ('cobalt', 'browser-pages'), ('cobalt', 'browser-worker-pages'), ('cobalt', 'browser-network-counterparts'), - ('document', 'js'), ('trystero', 'interop')} + ('document', 'js'), ('trystero', 'interop'), + ('webrtc', 'browser'), ('webrtc', 'interop')} # MSVC's lanes build 64-bit programs, embed their manifest with the linker and abbreviate b2's # paths against Windows's MAX_PATH, as xstate-cpp's green Windows jobs did. b2 abbreviates each @@ -525,6 +526,12 @@ def has_external(library: str | None) -> bool: ('exception-handling=on,off', 'webcpp-beast-unsupported=error,ignore'), ('beast', 'browser-node', 'emscripten'): ('exception-handling=on,off', 'webcpp-beast-unsupported=error,ignore'), + # webrtc's interop lane builds its programs as the request asks: both + # exception settings, and in the page both unsupported policies; its browser + # lane builds each program with exceptions on and off itself. + ('webrtc', 'interop', 'native'): ('exception-handling=on,off',), + ('webrtc', 'interop', 'emscripten'): + ('exception-handling=on,off', 'webcpp-webrtc-unsupported=error,ignore'), } diff --git a/tools/ci/matrix_test.py b/tools/ci/matrix_test.py index e65beaac..c9878414 100755 --- a/tools/ci/matrix_test.py +++ b/tools/ci/matrix_test.py @@ -1250,8 +1250,8 @@ def test_cobalt_browser_lanes_receive_chrome_and_all_profiles(root): def test_a_browser_lane_has_the_pinned_chrome(root): - # An own lane whose driver meets a browser, asio's browser, trystero's interop and document's js - # (CHROME_LANES), says chrome, on every target it runs on, and its job installs the pinned + # An own lane whose driver meets a browser, asio's browser, trystero's interop, document's js + # and webrtc's browser and interop (CHROME_LANES), says chrome, on every target it runs on, and its job installs the pinned # chrome-headless-shell, which gives CHROME; no other own lane does, and no job names the # image's Chrome. assert matrix.CHROME_LANES == { @@ -1262,7 +1262,7 @@ def test_a_browser_lane_has_the_pinned_chrome(root): ('cobalt', 'browser-workers'), ('cobalt', 'browser-runtime-probes'), ('cobalt', 'browser-pages'), ('cobalt', 'browser-worker-pages'), ('cobalt', 'browser-network-counterparts'), ('document', 'js'), - ('trystero', 'interop')}, matrix.CHROME_LANES + ('trystero', 'interop'), ('webrtc', 'browser'), ('webrtc', 'interop')}, matrix.CHROME_LANES boost_only(root) external_library(root) oracle_library(root, 'beta') From addc588672b197dc8d34c15c45af20c6063209e6 Mon Sep 17 00:00:00 2001 From: R Date: Sat, 14 Nov 2026 16:14:16 -0300 Subject: [PATCH 05/61] ci: keep matrix_test.py's comment within 100 columns, and move webrtc The comment that names the browser lanes ran past the Python line limit the lint keeps; libs/webrtc moves to the commit that keeps to the whole lint's format and run rules. --- libs/webrtc | 2 +- tools/ci/matrix_test.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/libs/webrtc b/libs/webrtc index 12de0a45..56dc3b8d 160000 --- a/libs/webrtc +++ b/libs/webrtc @@ -1 +1 @@ -Subproject commit 12de0a4583f4785cc4b40d12ad3615c92651a2fa +Subproject commit 56dc3b8d03541f4941986ecad5e60256bd59fe95 diff --git a/tools/ci/matrix_test.py b/tools/ci/matrix_test.py index c9878414..c62b820e 100755 --- a/tools/ci/matrix_test.py +++ b/tools/ci/matrix_test.py @@ -1251,9 +1251,9 @@ def test_cobalt_browser_lanes_receive_chrome_and_all_profiles(root): def test_a_browser_lane_has_the_pinned_chrome(root): # An own lane whose driver meets a browser, asio's browser, trystero's interop, document's js - # and webrtc's browser and interop (CHROME_LANES), says chrome, on every target it runs on, and its job installs the pinned - # chrome-headless-shell, which gives CHROME; no other own lane does, and no job names the - # image's Chrome. + # and webrtc's browser and interop (CHROME_LANES), says chrome, on every target it runs on, + # and its job installs the pinned chrome-headless-shell, which gives CHROME; no other own lane + # does, and no job names the image's Chrome. assert matrix.CHROME_LANES == { ('asio', 'browser'), ('asio', 'browser-workers'), ('asio', 'browser-worker-exceptions'), ('asio', 'browser-concurrency-hint'), @@ -1262,7 +1262,8 @@ def test_a_browser_lane_has_the_pinned_chrome(root): ('cobalt', 'browser-workers'), ('cobalt', 'browser-runtime-probes'), ('cobalt', 'browser-pages'), ('cobalt', 'browser-worker-pages'), ('cobalt', 'browser-network-counterparts'), ('document', 'js'), - ('trystero', 'interop'), ('webrtc', 'browser'), ('webrtc', 'interop')}, matrix.CHROME_LANES + ('trystero', 'interop'), ('webrtc', 'browser'), + ('webrtc', 'interop')}, matrix.CHROME_LANES boost_only(root) external_library(root) oracle_library(root, 'beta') From 44bc237814cc4dac1cbf598192894ba4e3f3285d Mon Sep 17 00:00:00 2001 From: R Date: Sat, 14 Nov 2026 16:21:18 -0300 Subject: [PATCH 06/61] ci: webrtc's interop lane on one unsupported policy, and AGENTS.md says what it meets The review of increment 2 found that the interop page sets nothing the unsupported policy decides, so running it under both policies doubled its job for no coverage; and AGENTS.md said webrtc's interop lane meets a browser natively, where its native run is two native peers. --- AGENTS.md | 6 ++++-- tools/ci/matrix.py | 10 +++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 9568a522..802011b8 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1632,8 +1632,10 @@ jobs: kind `programs` on any other target, such as wasi's served lanes, has none. - An own lane whose driver meets a browser, one of `CHROME_LANES` in - `tools/ci/matrix.py` (trystero's and webrtc's `interop`, natively and on - emscripten, document's `js`, webrtc's `browser`, and the browser lanes of + `tools/ci/matrix.py` (trystero's `interop`, natively and on emscripten, + webrtc's `interop`, whose page meets Chrome on emscripten while its native + run is two native peers, though `CHROME_LANES` names a lane on every + target, document's `js`, webrtc's `browser`, and the browser lanes of asio, beast and cobalt), has its entry's `chrome`, and its job runs the `chrome` action, which gives it `CHROME`, a pinned Chrome rather than the image's, which moves diff --git a/tools/ci/matrix.py b/tools/ci/matrix.py index 089bc8dd..3ff04ef5 100755 --- a/tools/ci/matrix.py +++ b/tools/ci/matrix.py @@ -526,12 +526,12 @@ def has_external(library: str | None) -> bool: ('exception-handling=on,off', 'webcpp-beast-unsupported=error,ignore'), ('beast', 'browser-node', 'emscripten'): ('exception-handling=on,off', 'webcpp-beast-unsupported=error,ignore'), - # webrtc's interop lane builds its programs as the request asks: both - # exception settings, and in the page both unsupported policies; its browser - # lane builds each program with exceptions on and off itself. + # webrtc's interop lane builds its programs as the request asks, with + # exceptions on and off; its page sets nothing the unsupported policy + # decides, so one policy is enough. Its browser lane builds each program + # with exceptions on and off itself. ('webrtc', 'interop', 'native'): ('exception-handling=on,off',), - ('webrtc', 'interop', 'emscripten'): - ('exception-handling=on,off', 'webcpp-webrtc-unsupported=error,ignore'), + ('webrtc', 'interop', 'emscripten'): ('exception-handling=on,off',), } From 8096f218f0fb8b9604e6d201140118bb1d6af95f Mon Sep 17 00:00:00 2001 From: R Date: Sat, 14 Nov 2026 16:59:32 -0300 Subject: [PATCH 07/61] guidelines: trystero on webcpp::webrtc and webcpp::asio, without exceptions Chapter 15's trystero entry records webrtc's increment 3: both backends' WebRTC is one implementation over webcpp::webrtc behind the abstract backend classes the memory relays implement; trystero's policies over it (the merged states, the candidates' JSON, texts and oversized binaries dropped on the executor, 64 frames for 10 s on both targets, the edge of onbufferedamountlow); the browser's cap as the runtime's over webcpp::webrtc's census; trystero's Asio named webcpp::asio, in both suspension variants, in place of BOOST_ASIO_DISABLE_THREADS; the native backend's runtime, its relay executor and its URLs libdatachannel cannot parse; and every part working with exceptions on and off. Chapter 16's webrtc bullet says increment 3 moved trystero; chapter 19 drops the comments a trystero commit corrected and narrows the remaining migration to the relays. AGENTS.md's trystero row and prerequisites drop the exceptions native trystero no longer needs. --- AGENTS.md | 5 +- CODING-GUIDELINES.md | 301 ++++++++++++++++++++++++++++--------------- 2 files changed, 197 insertions(+), 109 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 802011b8..de9ae559 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -84,7 +84,7 @@ for web developers and for AI developers (`CODING-GUIDELINES.md` chapter 16). | document | a JSON document that behaves as JavaScript does (key order, `JSON.stringify`'s bytes, the array methods), exact in decimal, in one relocatable image; webcpp's own; its parser is Boost.JSON's | native, wasip2, wasip3, emscripten; its oracle lane | a submodule at `libs/document`; its core never throws (`CODING-GUIDELINES.md` chapter 6) | | idna | internationalized domain names: Punycode, UTS 46's ToASCII and ToUnicode, conformant to IdnaTestV2, and IDNA2008's validity, over Unicode 17.0.0 tables generated into its headers; webcpp's own | native, wasip2, wasip3, emscripten; its own lane `tables` | a submodule at `libs/idna`; its errors are values, and its span forms allocate nothing | | lexical | the string formats JSON Schema names (date-time, email, hostname, ipv4/ipv6, uri, iri, uri-template, json-pointer, uuid, regex), each a validator that allocates nothing and a Boost.URL grammar rule; regex is an ECMA-262 syntax validator of its own, checked against V8; depends on idna and Boost.URL; webcpp's own | native, wasip2, wasip3, emscripten; its own lanes `generated` and `oracle` | a submodule at `libs/formats` | -| trystero | a port of Trystero 0.26.0, serverless WebRTC rooms | native, emscripten; its own lanes `oracle` and `interop` | a submodule at `libs/trystero`; born with the allocation rule through `std::pmr` | +| trystero | a port of Trystero 0.26.0, serverless WebRTC rooms; its backends' WebRTC is webrtc's, and its Asio is named `webcpp::asio` | native, emscripten (both suspension variants); its own lanes `oracle` and `interop` | a submodule at `libs/trystero`; born with the allocation rule through `std::pmr`; works with exceptions on and off on both targets | | webrtc | WebRTC peer connections and data channels with the W3C's names in Asio's model, natively over libdatachannel's C API and in the browser over the page's own objects, with exceptions on and off; webcpp's own | native, emscripten; its own lanes `browser` and `interop` | a submodule at `libs/webrtc`; increments 1 and 2 of 3 (`CODING-GUIDELINES.md` chapter 15) | ### The layout @@ -261,7 +261,8 @@ Jamroot is its build configuration, and `libs/` is its repository. nested dependencies with the consumer's compiler and runtime settings. Every consumer of `/webcpp/third_party//libdatachannel` requires `threading=multi`: a single-thread request is refused, since libdatachannel - runs worker threads of its own. Native Trystero also requires exceptions; + runs worker threads of its own. Native Trystero reaches it through + webrtc, which calls its C API, and works with exceptions on and off; - for native or WASIp2/P3 guest TLS: Python 3, Perl, Make (nmake on Windows), the selected compiler and `third_party/libs/openssl`, initialized with `git submodule update --init third_party/libs/openssl`. B2 builds the pinned diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index 387bdb4d..3f169c48 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -5271,11 +5271,13 @@ proposals is given relative to `libraries/document/openspec/`. trystero ports Trystero 0.26.0: the peers of a room meet over public Nostr relays and talk over WebRTC data channels, on Trystero's wire byte for byte, -natively over libdatachannel and in the browser over the page's own WebRTC. -The decisions are those of the tree the superproject records for webcpp 0.1.0 -(trystero `e9326e9`), which includes the change `shared-connection` (trystero -`2e2dcd4`, webcpp `1a0dcac` and `d9e5fa6`, 2026-10-14), implemented and -archived on 2026-11-14. +over webcpp::webrtc: natively libdatachannel's WebRTC and in the browser the +page's own. The decisions are those of the tree the superproject records for +webcpp 0.1.0 (trystero `e9326e9`), which includes the change +`shared-connection` (trystero `2e2dcd4`, webcpp `1a0dcac` and `d9e5fa6`, +2026-10-14), implemented and archived on 2026-11-14, and of webrtc's +increment 3 (trystero's branch `webrtc-backend`, 2026-11-14), which moved both +backends' WebRTC onto webcpp::webrtc and trystero's Asio onto webcpp::asio. **Scope and differences from Trystero JS.** @@ -5313,7 +5315,8 @@ archived on 2026-11-14. set later. Source: `doc/differences.adoc` (libs/trystero). - **`peers()` lists ids, not connections.** A connection is the backend's - object, a page's or libdatachannel's, and the room does not hand it out. + object, webcpp::webrtc's over a page's or libdatachannel's, and the room + does not hand it out. Source: `doc/differences.adoc` (libs/trystero). - **A send to a peer that has not joined completes with `error::no_such_peer`, where Trystero warns and resolves.** An operation that fails says so with @@ -5373,12 +5376,14 @@ archived on 2026-11-14. **Layers and the backend interface.** -- **The library is layered (protocol, backend interface, app, room, and the - browser and native backends), and the core above the interface never - includes a backend, libdatachannel, OpenSSL or Emscripten.** The same room - runs over the browser's APIs, over libdatachannel and over the tests' memory - relays, on both targets; `meta/include-boundaries.json` states the boundary - and the lint fails an include that crosses it. +- **The library is layered (protocol, backend interface, app, room, the + backend's WebRTC, and the browser and native backends), and the core above + the interface never includes a backend, the backend's WebRTC, + webcpp::webrtc, libdatachannel, OpenSSL or Emscripten.** The same room runs + over the browser's WebRTC and libdatachannel's, both through webcpp::webrtc, + and over the tests' memory relays, on both targets; + `meta/include-boundaries.json` states the boundary and the lint fails an + include that crosses it. Source: `doc/design.adoc` (libs/trystero). - **The backend is a handful of abstract classes, not template parameters.** Each operation is a call into JavaScript or a network stack, so a virtual @@ -5405,14 +5410,68 @@ archived on 2026-11-14. goes on with the others on every backend. Source: `include/webcpp/trystero/options.hpp` (libs/trystero). +**The backend's WebRTC.** + +- **Both backends make their peer connections and data channels the same way, + in `webrtc/`: `webrtc::peer_connection` and `webrtc::data_channel` hold + webcpp::webrtc's `basic_peer_connection` and `basic_data_channel` over a + `std::pmr::polymorphic_allocator` on the app's resource, and implement the + abstract `backend::peer_connection` and `backend::data_channel`.** + webcpp::webrtc gives both targets one interface, so trystero keeps only its + policies over WebRTC, the same on both. The abstract classes stay: the + tests' memory relays implement them for whole rooms on both targets, where + node has no WebRTC, and the interop's native peer wraps the native + backend's. + Source: `doc/design.adoc` (libs/trystero). +- **Each keeps a wait of every kind pending on webcpp::webrtc's object, + re-armed on the executor, and reports what it completes with through the + backend's handlers: one state that merges the connection's state and its + ICE state, failed, closed, disconnected, connected (or ICE completed), + connecting (or ICE checking) and new, as a page sees both.** A failure may + show in either state first, and the room acts on one: it ends a connection + failed or closed, and gives a disconnected one 5 s. The browser backend + merged them so already; natively the merge is new with webcpp::webrtc. + Source: `doc/design.adoc` (libs/trystero). +- **A local candidate leaves as the JSON of an `RTCIceCandidateInit`, and a + remote one is read from that JSON, on both targets; natively a TURN URL + with credentials is written `turn:user:credential@host` by webcpp::webrtc.** + The first is the form Trystero JS adds with `addIceCandidate`, the second + the form libdatachannel parses. + Source: `doc/design.adoc` (libs/trystero). +- **A channel reads every message as it comes, with `async_receive`, into a + vector of the app's resource, and drops a text message, or a binary one + larger than any room frame, on the executor.** Neither can be a frame. + webcpp::webrtc reads a text as the UTF-8 it holds, so the browser's old + faults (the text `1e300` threw a `RangeError` out of `new Uint8Array`, and + `300000000` made a 300 MB frame) cannot arise; and it bounds what it reads: + natively libdatachannel cuts a message to 256 KiB, and in the browser a + message past 256 KiB, or unread messages past 16 MiB, close the channel. + Source: `doc/design.adoc` (libs/trystero). +- **Valid frames received before the message handler is installed wait in a + FIFO bounded by 64 frames and 10 seconds, on both targets.** These are the + original Trystero peer's pending-data bounds. Overflow or expiry closes the + channel; a close releases the retained frames. Installing a handler + schedules delivery on the executor, preserving order with later arrivals and + rechecking the current handler and channel after each callback. It never + calls a message handler synchronously from `set_handlers`, where adoption + may still be initializing the shared connection. Queued frames use the + supplied resource, and the expiry is a timer of the factory's. + Source: `doc/design.adoc` (libs/trystero). +- **The channel reports the buffered amount falling to 64 KiB only after a + send left it above, as `onbufferedamountlow` does.** webcpp::webrtc's wait + completes whenever the amount is at or under the threshold, and the shared + connection gives the bindings waiting to send their turn at each fall, as + the browser's event did. + Source: `include/webcpp/trystero/webrtc/data_channel.hpp` (libs/trystero). + **The browser backend.** -- **In the browser the backend binds the page's own `RTCPeerConnection`, - `WebSocket`, `setTimeout` and `crypto.subtle` through `emscripten::val`, not - libdatachannel's WebAssembly port.** datachannel-wasm has no media and hides - the `RTCPeerConnection` it wraps; the direct binding is smaller, reports - every error, and leaves the browser's whole WebRTC stack within reach for - media. +- **In the browser the backend binds the page's own `WebSocket`, + `setTimeout` and `crypto.subtle` through `emscripten::val`, and its + `RTCPeerConnection` through webcpp::webrtc, not libdatachannel's WebAssembly + port.** webcpp::webrtc's browser implementation binds the page's objects + itself, so one peer connection and data channel serve both targets; + datachannel-wasm has no media and hides the `RTCPeerConnection` it wraps. Source: `doc/design.adoc` (libs/trystero). - **`browser::event_loop` drives the `io_context` without ever calling `run()`: each JavaScript event runs its handler and then `poll()`, and work @@ -5426,10 +5485,16 @@ archived on 2026-11-14. run.** A handler never runs inside the call that caused it, as when node's WebSocket fires `close` from inside `close()`. Source: `libraries/trystero/openspec/specs/trystero/spec.md` (proposals). -- **The browser has no threads: `/webcpp/trystero//trystero` defines - `BOOST_ASIO_DISABLE_THREADS` on emscripten.** Emscripten's threads need a - cross-origin isolated page. - Source: `doc/browser.adoc` (libs/trystero). +- **trystero names Asio as webcpp::asio wherever it builds on emscripten: + natively Boost.Asio itself, on emscripten the backend webcpp::asio ships, + without threads when the program has no pthread ABI.** webcpp::webrtc's + browser objects deliver their events through webcpp::asio's bridge, a + service of their executor's `io_context`, so the room's executor must be + webcpp::asio's; and Emscripten's threads need a cross-origin isolated page. + `/webcpp/trystero//trystero` brings `/webcpp/asio//asio`, so a program on + emscripten is built in one of its suspension variants, jspi by default or + asyncify, though the loop never runs the `io_context`. + Source: `doc/browser.adoc` and `AGENTS.md` (libs/trystero). - **JavaScript reaches C++ through one exported function, `trystero_dispatch`, and every object registers its callbacks with the loop by id and slot and removes them when it is destroyed.** A late event for a destroyed object @@ -5448,21 +5513,17 @@ archived on 2026-11-14. checked before any copy.** No `std::string` is made to carry it, and a string over its bound is never copied into WebAssembly. Source: `doc/browser.adoc` (libs/trystero). -- **A data channel message that is not an `ArrayBuffer`, or is larger than any - room frame, is dropped before it is read.** Neither can be a frame; - measured, the text `1e300` threw a `RangeError` out of `new Uint8Array`, and - `300000000` made a 300 MB frame. - Source: `libraries/trystero/openspec/specs/trystero/spec.md` (proposals). - **A page makes at most `browser::backend::max_peer_connections` (256) peer - connections across all its apps and rooms, counted, from construction until - the garbage collector frees them, by a census every program of the page - shares.** Chromium counts a connection against its 500 until a collection - (measured: the 501st throws "Cannot create so many PeerConnections"), and - the rest of its count stays free for what the page makes without a room. + connections across all its apps and rooms: the cap, + `runtime_options::max_peer_connections`, of the webcpp::webrtc runtime the + backend owns, over webcpp::webrtc's census of the page, which counts every + connection it makes, with any runtime, from construction until the garbage + collector frees it, and nothing without `FinalizationRegistry`.** Chromium + counts a connection against its 500 until a collection (measured: the 501st + throws "Cannot create so many PeerConnections"), the rest of its count stays + free for what the page makes without a room, and a count that never comes + down would stop the page for good. Source: `doc/browser.adoc` (libs/trystero). -- **Without `FinalizationRegistry` the census counts nothing.** The page never - stops making connections for a count that never comes down. - Source: `libraries/trystero/openspec/specs/trystero/spec.md` (proposals). - **A page's relay socket has no idle timeout.** A page's `WebSocket` cannot ping. Source: `doc/browser.adoc` (libs/trystero). @@ -5480,47 +5541,53 @@ archived on 2026-11-14. **The native backend.** -- **Natively WebRTC is libdatachannel's, the relays' WebSockets are - Boost.Beast's, and TLS and AES-GCM are OpenSSL's, with libdatachannel built - without its own WebSocket.** The relays then run on the room's executor like - everything else. +- **Natively WebRTC is webcpp::webrtc's over libdatachannel's C API, the + relays' WebSockets are Boost.Beast's, and TLS and AES-GCM are OpenSSL's, + with libdatachannel built without its own WebSocket.** The relays then run + on the room's executor like everything else, and the native peer + connections are the browser's in interface. Source: `doc/native.adoc` (libs/trystero). +- **The native backend names webcpp::asio's executor, and gives its relays' + WebSockets, which are Boost.Beast's over Boost.Asio, the same executor + through `relay_executor`.** Natively the two are one type. The guide's + reference reads every header for Emscripten's target, where webcpp::asio is + its own and the native backend is never built: `relay_executor` names no + executor there, and the native headers still parse. + Source: `AGENTS.md` and `include/webcpp/trystero/native/backend.hpp` + (libs/trystero). - **The sealer is asynchronous on both targets: the native one works synchronously and posts its completion.** Web Crypto is asynchronous, so the interface is, and a completion never runs inside the call that started it. Source: `libraries/trystero/openspec/changes/archive/2026-10-09-genesis/reference/research/TRYSTERO_CPP_SPIKE/FINDINGS.md` (proposals). -- **Every event of libdatachannel copies what it carries and is posted to the - executor through a `std::weak_ptr`; no handler runs on libdatachannel's - threads.** Its callbacks run on its own threads under a recursive mutex, and - an event that arrives after its object is gone must do nothing; an - application with several threads gives the app a strand. +- **webcpp::webrtc posts every event of libdatachannel to the executor, + through a weak reference; no handler runs on libdatachannel's threads.** Its + callbacks run on its own threads, and an event that arrives after its object + is gone must do nothing; an application with several threads gives the app + a strand. Source: `doc/native.adoc` (libs/trystero). -- **The backend holds every object libdatachannel hands out.** libdatachannel - keeps only weak references; the spike lost tracks and WebSockets it did not - retain. +- **What libdatachannel does is webcpp::webrtc's: its C API, its automatic + negotiation off, and every object it hands out held until its owner lets it + go.** An offer or an answer exists only when the signaling asks for one, as + in the browser; libdatachannel keeps only weak references, and the spike + lost tracks and WebSockets it did not retain. Source: `doc/native.adoc` (libs/trystero). -- **libdatachannel's automatic negotiation is off.** An offer or an answer - exists only when the signaling asks for one, as in the browser. - Source: `doc/native.adoc` (libs/trystero). -- **A local candidate leaves as the JSON of an `RTCIceCandidateInit`, and a - TURN URL with credentials is rewritten as `turn:user:credential@host`.** The - first is the form Trystero JS adds with `addIceCandidate`, the second the - form libdatachannel parses. - Source: `libraries/trystero/openspec/specs/trystero/spec.md` (proposals). -- **The native data channel drops a text message, or a binary one larger than - any room frame, on libdatachannel's thread, before it is posted.** Neither - can be a frame. - Source: `doc/native.adoc` (libs/trystero). -- **Valid native frames received before the message handler is installed wait - in a FIFO bounded by 64 frames and 10 seconds.** These are the original - Trystero peer's pending-data bounds. Overflow or expiry closes the channel; - a close releases the retained frames. Installing a handler schedules delivery - on the executor, preserving order with later arrivals and rechecking the - current handler and channel after each callback. It never calls a message - handler synchronously from `set_handlers`, where adoption may still be - initializing the shared connection. Queued frames use the supplied resource. +- **Natively a URL libdatachannel cannot parse, as a `stuns:` one, is left out + of the connection, each URL being tried alone; in the browser the page + refuses the whole connection for a server it cannot use.** webcpp::webrtc + refuses the whole configuration for one such URL, and a room has already + dropped every server WebRTC refuses; libdatachannel knows no STUN over TLS. + Source: `doc/native.adoc` and `include/webcpp/trystero/native/backend.hpp` + (libs/trystero). +- **A native backend owns a webcpp::webrtc runtime, made with + `backend_config::runtime`, at most 256 connections alive at once, or takes + the program's; each of its connections and channels keeps that runtime + alive.** A connection that outlives the backend in a handler the + `io_context` still holds must not outlive the runtime, and libdatachannel's + state is the process's: a process holds one runtime at a time, so a program + with several native backends, or with webcpp::webrtc beside trystero, gives + each the one it made. Source: `doc/native.adoc` (libs/trystero). - **A channel that closes during adoption before a room binds clears that room's negotiation and restarts its announcements.** No binding exists for @@ -5561,19 +5628,22 @@ archived on 2026-11-14. Source: `include/webcpp/trystero/native/backend.hpp` (libs/trystero). - **The constructor of `native::backend` is the one native function that throws, a `boost::system::system_error` when OpenSSL cannot make the TLS - context or load the system's certificate authorities.** (reason not - recorded) + context or load the system's certificate authorities; without exceptions, + Boost's `throw_exception`, which the program defines, is called instead.** + (reason not recorded) Source: `doc/native.adoc` (libs/trystero). -- **`native::data_channel`, `native::peer_connection` and `native::backend` - exist only with exceptions, and every program, test and headers-alone call - that uses them declares `on` itself.** libdatachannel - reports errors by throwing, and b2 ignores a non-free feature among usage - requirements, so `/webcpp/trystero//native` cannot declare it for them. - Source: `AGENTS.md` (libs/trystero). -- **The native timer, sealer and WebSockets are compiled alone in a - headers-alone call of their own, without exceptions.** The lint then - analyses them without exceptions too. +- **Every part of trystero, the native backend included, works with + exceptions and without them, and no program, test or headers-alone call + asks for `on`.** webcpp::webrtc calls libdatachannel's C + API, which catches what libdatachannel throws and returns a code; + `native_peer_connection` and `native_room` also run with + `exception-handling=off`, as the evidence. Source: `AGENTS.md` (libs/trystero). +- **The native headers and the backend's WebRTC are compiled alone in one + headers-alone call, natively, as the build asks.** None needs exceptions, so + the lint analyses them without exceptions too; on emscripten the backend's + WebRTC is compiled through the browser backend's header. + Source: `test/Jamfile` (libs/trystero). **Rooms, actions and errors.** @@ -5586,7 +5656,7 @@ archived on 2026-11-14. (proposals). - **An asynchronous operation owns its arguments: a value is taken by value, a view copied once at the call, a `boost::json::value` serialized at once, and - a peer id copied.** A token such as `boost::asio::deferred` starts the + a peer id copied.** A token such as `webcpp::asio::deferred` starts the operation after the call. Source: `doc/usage.adoc` (libs/trystero). - **Text is a view and a copy is a decision: digests are fed the parts of @@ -6004,7 +6074,7 @@ archived on 2026-11-14. temporaries beyond a stack buffer from the default resource. Source: `doc/allocation.adoc` (libs/trystero). - **A post goes through the `io_context`'s own executor when the room's - executor is one.** Through `boost::asio::any_io_executor`, Asio wraps a post + executor is one.** Through `webcpp::asio::any_io_executor`, Asio wraps a post in a function object allocated with `std::allocator` (measured: two `std::aligned_alloc` per post in every round of five, natively and on emscripten). @@ -6025,11 +6095,14 @@ archived on 2026-11-14. resource, and a verification allocates nothing. Source: `doc/allocation.adoc` (libs/trystero). - **The allocations outside the resources are listed on the page, not claimed: - libdatachannel's, OpenSSL's, `emscripten::val`'s, the JSON storage's - counter, Asio's once per context and its wrapper on a foreign executor, - Beast's stream state, and Emscripten's `select()`.** They belong to a - dependency or to Asio, and the posts from libdatachannel's threads may not - touch a resource used only on the executor. + libdatachannel's and OpenSSL's, with the copy libdatachannel's C API makes + of a message, `emscripten::val`'s, the JSON storage's counter, Asio's once + per context and its wrapper on a foreign executor, which webcpp::webrtc's + completions get through `any_io_executor`, Beast's stream state, + Emscripten's `select()`, and Asyncify's unwind data when a call + suspends.** They belong to a dependency or to Asio, and webcpp::webrtc's + posts from libdatachannel's threads may not touch a resource used only on + the executor. Source: `doc/allocation.adoc` (libs/trystero). - **No check catches a resource that ends too early: it is declared before the `io_context`, and its lifetime is the user's.** trystero holds a raw pointer @@ -6056,19 +6129,23 @@ archived on 2026-11-14. Source: `libraries/trystero/openspec/changes/archive/2026-10-09-genesis/reference/research/TRYSTERO_CPP_SPIKE/FINDINGS.md` (proposals). -- **libdatachannel (MPL 2.0) and OpenSSL (Apache 2.0) are needed by the native - backend only, through `/webcpp/trystero//native`.** A browser program never - includes the native backend, so `/webcpp/trystero//trystero` depends on - neither, as OpenSSL is optional for Asio. - Source: `doc/design.adoc` (libs/trystero). +- **trystero builds on webcpp::asio, and both backends' WebRTC on + webcpp::webrtc: `/webcpp/trystero//trystero` brings `/webcpp/asio//asio`, + and on emscripten `/webcpp/webrtc//webrtc`; `/webcpp/trystero//native` + brings `/webcpp/webrtc//webrtc` natively, with libdatachannel (MPL 2.0) and + OpenSSL (Apache 2.0).** A browser program never includes the native + backend, so neither libdatachannel nor OpenSSL is in it, as OpenSSL is + optional for Asio. + Source: `doc/design.adoc` and `build.jam` (libs/trystero). - **Only libsecp256k1 is externally provisioned, through command-line `SECP256K1_ROOT` / `SECP256K1_EMSCRIPTEN_ROOT`, then `.local/`, then native system paths outside Windows; the environment is never read.** Native - libdatachannel and its nested dependencies are now pinned source targets, - built statically against the same OpenSSL provider as Asio and Beast. - Native Trystero requires `threading=multi` and exceptions because its backend - uses worker threads. These dependency changes prepare the later migration; - they do not claim that Trystero already uses the webcpp facades. + libdatachannel and its nested dependencies are pinned source targets, built + statically against the same OpenSSL provider as Asio and Beast. Native + Trystero requires `threading=multi`, since libdatachannel runs worker + threads, and no exceptions. Its WebRTC is webcpp::webrtc's and its Asio is + named webcpp::asio; its relays' WebSockets are still Boost.Beast's, and its + sealer and randomness OpenSSL's, whose migration remains. Source: `doc/building.adoc` (libs/trystero). - **A library found nowhere leaves trystero out with one message, unless `webcpp-require-external=on`, as the CI builds, stops the build.** `b2 test` @@ -6179,14 +6256,22 @@ archived on 2026-11-14. the count is 8, not 2. Source: `doc/allocation.adoc` (libs/trystero). - **On Emscripten the allocation test replaces `select()` with one that keeps - its array on the stack.** Emscripten's `select()` callocs an array on every - call, and Asio's reactor calls it on every wait, so the count would see the - C library's wait rather than the rooms'. + its array on the stack, and under Asyncify counts Asyncify's unwind data + apart.** Emscripten's `select()` callocs an array on every call, and Asio's + reactor calls it on every wait, so the count would see the C library's wait + rather than the rooms'; the test's `run_for` suspends under Asyncify, whose + unwind data the C library allocates, as webcpp::asio's own allocation test + counts it. Source: `AGENTS.md` (libs/trystero). - **The browser tests run twice, with exceptions and without (`*_no_exceptions`).** No JavaScript exception may enter WebAssembly in either build (owner decision, 2026-10-10). Source: `libraries/trystero/openspec/specs/trystero/spec.md` (proposals). +- **Every emscripten suite runs in both of webcpp::asio's suspension variants, + jspi and asyncify, and a test whose `main` runs the `io_context` ends with + `webcpp::test::exit_status`.** trystero links webcpp::asio's runtime, and + under Asyncify a `main` that suspended loses what it returns. + Source: `AGENTS.md` (libs/trystero). - **`native_websocket`, the native interop peer and `shared_hardened` are built with the standard libraries' own checks (`_LIBCPP_HARDENING_MODE_EXTENSIVE`, `_GLIBCXX_ASSERTIONS`).** A completion @@ -7218,10 +7303,12 @@ What webcpp does not have yet, and the chapters that mention it: xactor's scheduler through an application-owned loop. - **webcpp::webrtc and webcpp::crypto.** webrtc's increment 1, the interface and the native implementation, is built (chapter 15); its increment 2 brings - the browser implementation and the interop lane, and its increment 3 moves - trystero's WebRTC onto it. Authenticated encryption and randomness remain - crypto's (chapter 17). Trystero can then retain its protocol over those - shared facilities. + the browser implementation and the interop lane; its increment 3 has moved + trystero's WebRTC onto it, both backends, with trystero's Asio named + webcpp::asio (chapter 15's trystero entry). Authenticated encryption and + randomness remain crypto's (chapter 17), and the relays' WebSockets + Beast's. Trystero can then retain its protocol over those shared + facilities. - **The libraries web developers use most,** brought to C++: a JavaScript interpreter (QuickJS), libp2p, HTTP fetch. - **The site, increments 2 to 8.** Increment 1 is done: the site's @@ -8905,8 +8992,9 @@ adopted. Chapter 5 rule 7's existing exact-archive exception stays in force. The global WASIp2/P3 launchers grant network/name lookup and default to 600 seconds for tests; it establishes no production capability policy. Native Trystero requires multiple threads and uses the same source-built OpenSSL through pinned -libdatachannel. Its later migration onto Asio/Beast remains roadmap work, and -coexistence is required now. +libdatachannel, which webcpp::webrtc now wraps for it, and names its Asio +webcpp::asio. Its relays' later migration onto Beast's facades remains roadmap +work, and coexistence is required now. ### The libraries against the rules @@ -9072,9 +9160,8 @@ says what the tree does. the change `shared-connection` (trystero `e9326e9`). The specification gives the interop driver's timeout as 900 where `test/oracle/Jamfile` gives 2400; the shared connection's delta has the roadmap list shared relay sockets, - which `doc/roadmap.adoc` leaves out; comments still say "the room's - resource" where it is the app's (`backend.hpp`, `native/data_channel.hpp`), - and `error.hpp` that `room::on_error` reports `invalid_configuration`; + which `doc/roadmap.adoc` leaves out; `error.hpp` says that `room::on_error` + reports `invalid_configuration`; `doc/differences.adoc` still says "as today"; comments use a private shorthand, `C/`, for Trystero's source files. The draft bounded parse (chapter 18) claims guarantee 9, which 9 to 11 now hold, rebases on From 308d8323396cb6ad33ac76822ed3c11c313b95a1 Mon Sep 17 00:00:00 2001 From: R Date: Sat, 14 Nov 2026 17:04:01 -0300 Subject: [PATCH 08/61] webrtc and trystero: move to the reviewed webrtc and to trystero on it libs/webrtc moves to 1dd2d82: the fixes of increment 2's review (a browser state that outlives its own shutdown, arrivals in their order, texts that cross whole, one runtime in the reference, the empty remote candidate) and of trystero's findings (clang-tidy, stuns: as a difference). libs/trystero moves to 528a4e6: its backends' WebRTC on webcpp::webrtc, native without exceptions, its page clean. AGENTS.md says why trystero's reference keeps BOOST_ASIO_DISABLE_THREADS: its native backend's Boost.Asio, read for a target with no threads. --- AGENTS.md | 13 +++++++------ libs/trystero | 2 +- libs/webrtc | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index de9ae559..8ee96348 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -521,12 +521,13 @@ single page, from the library's Doc Comments. `webcpp.reference ;` in library and Emscripten's give one function two (trystero's reference read as a native and an emscripten translation unit had 555 sections for 461). Such a library also gives the target of its native backend, if it has - one, which brings that backend's dependencies, and the defines its - browser build has, which a requirement conditioned on the emscripten - toolset does not give a reference built natively: `webcpp.reference - trystero : /webcpp/trystero//native - /webcpp//emscripten-reference BOOST_ASIO_DISABLE_THREADS - ;`. Read so, trystero's reference is the same on Linux and on macOS, byte + one, which brings that backend's dependencies, and the defines that parse + needs, which a requirement conditioned on the emscripten toolset does not + give a reference built natively; trystero's names Boost.Asio without + threads, as wasm32 has none, for its native backend's Beast and timers: + `webcpp.reference trystero : /webcpp/trystero//native + multi /webcpp//emscripten-reference + BOOST_ASIO_DISABLE_THREADS ;`. Read so, trystero's reference is the same on Linux and on macOS, byte for byte. The emsdk is `-sWEBCPP_EMSDK=`, read from b2's command line alone, else `.local/emsdk`, never the environment's `EMSDK`, which `emsdk_env.sh` exports and b2 would read as `-sEMSDK`; its diff --git a/libs/trystero b/libs/trystero index e9326e94..528a4e65 160000 --- a/libs/trystero +++ b/libs/trystero @@ -1 +1 @@ -Subproject commit e9326e94c06cfa9ffdbd0a8d3c8d72b80b3b9b59 +Subproject commit 528a4e6502052a12a884da4304fe067d0be8f913 diff --git a/libs/webrtc b/libs/webrtc index 56dc3b8d..1dd2d829 160000 --- a/libs/webrtc +++ b/libs/webrtc @@ -1 +1 @@ -Subproject commit 56dc3b8d03541f4941986ecad5e60256bd59fe95 +Subproject commit 1dd2d829b5abdb4ee67122cf9fbadcc7a8e02ef6 From df8f6a205efbfd2ca0767509161bde35c66f1663 Mon Sep 17 00:00:00 2001 From: R Date: Sat, 14 Nov 2026 18:00:29 -0300 Subject: [PATCH 09/61] tools/lint: analyse Boost.Unordered on arm64 hosts wasi-sdk's clang-tidy, which reads the native commands, ships x86's intrinsics headers alone, so on arm64 Boost.Unordered's open-addressing containers stopped it at , failing every native unit that includes one, as trystero's core now does. A native command is now told BOOST_UNORDERED_DISABLE_NEON on arm64 hosts, which reads Boost.Unordered's portable path; lint_test.py's clang_tidy_reads_boost_unordered_on_every_host failed on arm64 macOS before it and passes after, and the clean tree still passes. --- CODING-GUIDELINES.md | 2 +- tools/lint/lint.sh | 13 ++++++++++++- tools/lint/lint_test.py | 23 +++++++++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index 3f169c48..aab5c937 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -590,7 +590,7 @@ with `lint: failed: ` for each rule that failed. | Rule | What fails | | --- | --- | | clang-format | a C++ file not formatted as `.clang-format` says (Google-based, 4 spaces, 100 columns); `clang-format -i` fixes it | -| clang-tidy | a finding of `.clang-tidy` (every warning is an error) in the compilation database `tools/lint/compile_commands.py` writes from b2's dry runs, one per target the libraries declare: every test and example natively, with every program an own lane builds on that target, or on none (a served component, which only its own lane builds, among them; a served program in no own lane fails it, as it fails `b2 declared-lanes`), and each source that no native program compiles with the command of the first target that compiles it (wasip2, wasip3, else emscripten). A WebAssembly command names wasi-sdk's `clang++`, with that target's `--target`, to which the lint adds no host target or SDK, once the dry run of that target has generated the bindings its commands include (so the lint needs wit-bindgen and the WIT, `AGENTS.md` chapter 1); an emscripten command names Emscripten's `em++`, which clang-tidy cannot run, and is analysed with wasi-sdk's `clang++` in its place (the one beside the lint's clang-tidy), after the words `em++ --cflags` prints (the target `wasm32-unknown-emscripten`, the sysroot in Emscripten's cache, the `-iwithsysroot` directories compat and fakesdl, and the words of its exceptions), less the settings of em++ alone (`-sWASM_WORKERS`), which it reads and clang refuses, so the lint needs the emscripten toolset when a library declares emscripten. Plus each library's aggregate translation units, through which every public header is analysed, each compiled as a headers-alone translation unit of its target: a library whose public headers one target builds whole has one, of every header (`bin/aggregate/.cpp`), natively, or, for a library whose headers build only for WASI, on wasip2 and on wasip3, each reading its version's branch; a library whose headers no single target builds (a native backend against a dependency of the host's, a browser backend for emscripten) has one per target its headers-alone units run on, of the headers that target builds (`bin/aggregate/-native.cpp`, `-emscripten.cpp`). Every command, a program's and an aggregate's, on every target, has its twin: the same translation unit as b2 compiles it with `exception-handling=off` on the same target (natively with the handler `tools/throw_exception.cpp`), so that what only a user's build without exceptions compiles (`#ifdef BOOST_NO_EXCEPTIONS`) is analysed too, and a `throw`, `try` or `catch` outside it fails, in a template where a test or an example instantiates it; a program that declares `on` has none, and an aggregate's twin leaves out each header whose headers-alone call declares it (then a translation unit of its own, `-exception-handling-off.cpp`); the database names both. A public header without a headers-alone translation unit on any target, a declared target whose toolset is not configured, and a WebAssembly command whose compiler is neither wasi-sdk's `clang++` nor, on emscripten, Emscripten's `em++` (the lint would analyse it as a native command), fail it by name. Findings are reported in a library's public headers, in the headers of its tests and examples (`libs/xactor/test/require.hpp`) and in those of its JavaScript module (`libs/document/js/binding.hpp`), never in Boost's, the standard library's or a dependency's (`.clang-tidy`'s `HeaderFilterRegex`) | +| clang-tidy | a finding of `.clang-tidy` (every warning is an error) in the compilation database `tools/lint/compile_commands.py` writes from b2's dry runs, one per target the libraries declare: every test and example natively, with every program an own lane builds on that target, or on none (a served component, which only its own lane builds, among them; a served program in no own lane fails it, as it fails `b2 declared-lanes`), and each source that no native program compiles with the command of the first target that compiles it (wasip2, wasip3, else emscripten). A native command is told the host compiler's target and, on macOS, its SDK, and on arm64 `-DBOOST_UNORDERED_DISABLE_NEON`, since wasi-sdk's clang-tidy ships x86's intrinsics headers alone and Boost.Unordered includes `` there (`lint_test.py`). A WebAssembly command names wasi-sdk's `clang++`, with that target's `--target`, to which the lint adds no host target or SDK, once the dry run of that target has generated the bindings its commands include (so the lint needs wit-bindgen and the WIT, `AGENTS.md` chapter 1); an emscripten command names Emscripten's `em++`, which clang-tidy cannot run, and is analysed with wasi-sdk's `clang++` in its place (the one beside the lint's clang-tidy), after the words `em++ --cflags` prints (the target `wasm32-unknown-emscripten`, the sysroot in Emscripten's cache, the `-iwithsysroot` directories compat and fakesdl, and the words of its exceptions), less the settings of em++ alone (`-sWASM_WORKERS`), which it reads and clang refuses, so the lint needs the emscripten toolset when a library declares emscripten. Plus each library's aggregate translation units, through which every public header is analysed, each compiled as a headers-alone translation unit of its target: a library whose public headers one target builds whole has one, of every header (`bin/aggregate/.cpp`), natively, or, for a library whose headers build only for WASI, on wasip2 and on wasip3, each reading its version's branch; a library whose headers no single target builds (a native backend against a dependency of the host's, a browser backend for emscripten) has one per target its headers-alone units run on, of the headers that target builds (`bin/aggregate/-native.cpp`, `-emscripten.cpp`). Every command, a program's and an aggregate's, on every target, has its twin: the same translation unit as b2 compiles it with `exception-handling=off` on the same target (natively with the handler `tools/throw_exception.cpp`), so that what only a user's build without exceptions compiles (`#ifdef BOOST_NO_EXCEPTIONS`) is analysed too, and a `throw`, `try` or `catch` outside it fails, in a template where a test or an example instantiates it; a program that declares `on` has none, and an aggregate's twin leaves out each header whose headers-alone call declares it (then a translation unit of its own, `-exception-handling-off.cpp`); the database names both. A public header without a headers-alone translation unit on any target, a declared target whose toolset is not configured, and a WebAssembly command whose compiler is neither wasi-sdk's `clang++` nor, on emscripten, Emscripten's `em++` (the lint would analyse it as a native command), fail it by name. Findings are reported in a library's public headers, in the headers of its tests and examples (`libs/xactor/test/require.hpp`) and in those of its JavaScript module (`libs/document/js/binding.hpp`), never in Boost's, the standard library's or a dependency's (`.clang-tidy`'s `HeaderFilterRegex`) | | io_context::run | a call of Boost.Asio's `run`, `run_one` or `run_for`, which block, on an `io_context` however its type is qualified (`boost::asio::io_context`, `asio::io_context` through a namespace alias, `io_context` after a using); a driver drains with `poll` and `poll_one`. A program whose purpose is network I/O says why on the line, after `lint-run:` (`io.run_for(timeout); // lint-run: the memory relays post to it`); a library has no blanket exemption | | fluent chains | three calls chained in one expression | | returns `*this` | a function other than an assignment operator, a prefix `operator++` or `operator--` (the iterator requirements make them return `*this`), or a function whose head follows a line `// lint-std: ` naming the member of the standard it reproduces (`std::basic_regex::assign`), returning `*this`; the reason holds none of `;`, `{`, `}`, `#` or `@`, so that clang and MrDocs still attach the Doc Comment above the line to the function | diff --git a/tools/lint/lint.sh b/tools/lint/lint.sh index b4614a96..faa4cea4 100755 --- a/tools/lint/lint.sh +++ b/tools/lint/lint.sh @@ -293,13 +293,21 @@ PYTHON # names its own --target, and its sysroot is the one clang-tidy's wasi-sdk knows; one # that em++ compiles names em++'s target and sysroot, from em++ --cflags: it is told # neither. + # wasi-sdk's clang-tidy ships the x86 intrinsics headers alone: on arm64, Boost.Unordered's + # open-addressing containers include , which it does not have, so it is told to + # leave NEON out there and read Boost.Unordered's portable path, on which no analysis of + # webcpp's own code depends. host_target='' host_sysroot='' + host_define='' if [ -n "$(cat "${work_directory}/compiler")" ]; then host_target="$("$(cat "${work_directory}/compiler")" -dumpmachine)" if [ "$(uname -s)" = Darwin ] && command -v xcrun >/dev/null 2>&1; then host_sysroot="$(xcrun --show-sdk-path)" fi + case "${host_target}" in + arm64-* | aarch64-*) host_define='-DBOOST_UNORDERED_DISABLE_NEON' ;; + esac fi # clang-tidy reads one file per run and takes seconds on one that includes Boost, so the @@ -317,6 +325,9 @@ PYTHON if [ -n "${host_sysroot}" ]; then arguments+=(--extra-arg=-isysroot "--extra-arg=${host_sysroot}") fi + if [ -n "${host_define}" ]; then + arguments+=("--extra-arg=${host_define}") + fi fi local status=0 "${clang_tidy}" --quiet "${arguments[@]}" "${file}" \ @@ -324,7 +335,7 @@ PYTHON printf '%s\n' "${status}" > "${work_directory}/${index}.status" } export -f tidy_one - export clang_tidy host_target host_sysroot work_directory tidy_exclude + export clang_tidy host_target host_sysroot host_define work_directory tidy_exclude # This shard's slice: the files whose position in the sorted list is K modulo N. # Interleaving keeps the slices alike, since neighbours are alike (the examples of one diff --git a/tools/lint/lint_test.py b/tools/lint/lint_test.py index 5c2fa072..98f070e9 100755 --- a/tools/lint/lint_test.py +++ b/tools/lint/lint_test.py @@ -1023,6 +1023,28 @@ def test_a_dependency_s_warnings_are_not_ours(root): assert 'fake_dependency.hpp:' not in result.stdout, result.stdout[-6000:] +def test_clang_tidy_reads_boost_unordered_on_every_host(root): + # Boost.Unordered's open-addressing containers include on arm64, an intrinsics + # header of the host compiler's that wasi-sdk's clang-tidy, which reads a native command, does + # not ship: a library header that uses one analyses clean on every host, arm64 macOS included. + prepare(root) + write(root, 'libs/demo/include/webcpp/demo/seen.hpp', + '// Copyright (c) 2026 WebCpp.org\n//\n' + '// Distributed under the Boost Software License, Version 1.0. (See\n' + '// accompanying file LICENSE_1_0.txt or copy at\n' + '// https://www.boost.org/LICENSE_1_0.txt)\n\n' + '#ifndef WEBCPP_DEMO_SEEN_HPP\n#define WEBCPP_DEMO_SEEN_HPP\n\n' + '#include \n\n' + 'namespace webcpp::demo {\n\n' + '/**\n Whether `value` was seen before, recording it.\n\n' + ' @param seen The values seen so far.\n @param value The value.\n' + ' @return Whether it was there already.\n*/\n' + 'inline bool seen_before(boost::unordered_flat_set& seen, int value) {\n' + ' return !seen.insert(value).second;\n}\n\n' + '} // namespace webcpp::demo\n\n#endif // WEBCPP_DEMO_SEEN_HPP\n') + expect_clean(lint(root)) + + def test_a_compiled_boost_library_s_sources_are_not_analysed(root): # Boost.URL's sources, which /webcpp//boost_url compiles from Boost's tree outside the tree # the lint reads (.local/boost-source, or a CI runner's prefix), are Boost's: the database @@ -2488,6 +2510,7 @@ def test_wasip3_abi_snapshot_requires_integrity_before_style_exemption(root): test_clang_tidy_reads_what_only_one_target_builds, test_clang_tidy_reads_a_program_of_javascript_exceptions, test_a_dependency_s_warnings_are_not_ours, + test_clang_tidy_reads_boost_unordered_on_every_host, test_a_compiled_boost_library_s_sources_are_not_analysed, test_clang_tidy_uses_shipped_cobalt_sources_on_a_clean_tree, test_clang_tidy_refuses_a_throw_on_each_target_without_exceptions, From 3ce20accdfe78c671f19b9d5e2550045b3447043 Mon Sep 17 00:00:00 2001 From: R Date: Sat, 14 Nov 2026 18:00:43 -0300 Subject: [PATCH 10/61] doc: the 0.1.0 notes name the lint's arm64 fix Tools and build lists what changes for whoever lints, and the lint now analyses Boost.Unordered on arm64 hosts. --- doc/releases/0.1.0.adoc | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/releases/0.1.0.adoc b/doc/releases/0.1.0.adoc index 07f59a32..6cb9c37f 100644 --- a/doc/releases/0.1.0.adoc +++ b/doc/releases/0.1.0.adoc @@ -72,6 +72,7 @@ None. * Fixed Chrome provisioning and browser/TLS profile coverage in Asio CI lanes. * Added source-built OpenSSL and Cobalt SSL targets for WASIp2. * Added explicit browser pthread profiles with main-thread handoff tests. +* Fixed the lint's clang-tidy stopping at Boost.Unordered on arm64 hosts. * Changed lint to verify WASIp3 ABI snapshots before excluding upstream headers. * Fixed embedded CA headers using an unowned namespace and include path. * Added source-built Boost.Context for native stackful coroutine applications. From be22e44b5a6865a00f72e3fde80e36e04a5886c0 Mon Sep 17 00:00:00 2001 From: R Date: Sat, 14 Nov 2026 17:41:14 -0300 Subject: [PATCH 11/61] tools/openssl: the combined provider over trystero's backend as it is now trystero's native backend reaches libdatachannel through webcpp::webrtc's C API and no longer brings its C++ API, so rtc::PeerConnection no longer compiled here: the program makes its WebRTC state through the backend's own peer connection and data channel, and checks that the backend's relay TLS context, made without throwing over the system's authorities, comes from the same OpenSSL provider. --- tools/openssl/test/combined_provider.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/tools/openssl/test/combined_provider.cpp b/tools/openssl/test/combined_provider.cpp index 385c6ded..81537d7a 100644 --- a/tools/openssl/test/combined_provider.cpp +++ b/tools/openssl/test/combined_provider.cpp @@ -12,6 +12,7 @@ #include #include +#include int main() { if (OpenSSL_version_num() != OPENSSL_VERSION_NUMBER) { @@ -23,11 +24,18 @@ int main() { boost::asio::io_context context; boost::asio::ssl::context tls(boost::asio::ssl::context::tls_client); const boost::beast::tcp_stream stream(context); - const webcpp::trystero::native::backend backend(context.get_executor()); - rtc::PeerConnection peer(rtc::Configuration{}); - const auto channel = peer.createDataChannel("combined-provider"); - peer.close(); - if (!channel || tls.native_handle() == nullptr) { + // Trystero's relays verify against the system's authorities through the same provider, and + // its WebRTC is libdatachannel's, through webcpp::webrtc; its backend throws nothing, and + // holds an error in place of a TLS context OpenSSL could not make. + webcpp::trystero::native::backend backend(context.get_executor()); + const auto relays = backend.tls_context(); + const auto peer = backend.make_peer_connection({}, std::pmr::get_default_resource()); + const auto channel = peer ? peer->create_data_channel("combined-provider") : nullptr; + if (peer) { + peer->close(); + } + if (!channel || tls.native_handle() == nullptr || !relays || + relays->native_handle() == nullptr) { return 2; } std::puts("Asio, Beast and Trystero share the pinned OpenSSL provider"); From 4bbf9a17986dc54260030dfa17c885539abf045b Mon Sep 17 00:00:00 2001 From: R Date: Sat, 14 Nov 2026 19:34:40 -0300 Subject: [PATCH 12/61] tools/openssl: the combined provider over trystero's platform backend --- tools/openssl/test/Jamfile | 2 +- tools/openssl/test/combined_provider.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/openssl/test/Jamfile b/tools/openssl/test/Jamfile index 7b3b66aa..e7056847 100644 --- a/tools/openssl/test/Jamfile +++ b/tools/openssl/test/Jamfile @@ -27,6 +27,6 @@ explicit cobalt_ssl_cancel ; # The native WebRTC backend needs worker threads and exceptions. exe combined_provider : combined_provider.cpp /webcpp/asio//asio /webcpp/asio//openssl - /webcpp/beast//beast /webcpp/trystero//native + /webcpp/beast//beast /webcpp/trystero//platform : multi on ; explicit combined_provider ; diff --git a/tools/openssl/test/combined_provider.cpp b/tools/openssl/test/combined_provider.cpp index 81537d7a..7fd11a6c 100644 --- a/tools/openssl/test/combined_provider.cpp +++ b/tools/openssl/test/combined_provider.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include @@ -27,7 +27,7 @@ int main() { // Trystero's relays verify against the system's authorities through the same provider, and // its WebRTC is libdatachannel's, through webcpp::webrtc; its backend throws nothing, and // holds an error in place of a TLS context OpenSSL could not make. - webcpp::trystero::native::backend backend(context.get_executor()); + webcpp::trystero::platform::backend backend(context.get_executor()); const auto relays = backend.tls_context(); const auto peer = backend.make_peer_connection({}, std::pmr::get_default_resource()); const auto channel = peer ? peer->create_data_channel("combined-provider") : nullptr; From 83359cece3df1f5145a90ec06676fb61840a88fb Mon Sep 17 00:00:00 2001 From: R Date: Sat, 14 Nov 2026 19:42:43 -0300 Subject: [PATCH 13/61] guidelines and tools/openssl: trystero's refactor, phase 1 Chapter 15's trystero entry takes the first phase of trystero's refactor: the browser's main runs its io_context under a work guard and the page calls C++ through browser::page_call; page events and Web Crypto come through webcpp::asio's bridge and async_await; the native relays are one callback-composed session over webcpp::beast, their URLs read with Boost.URL, their trust the system's by default and their TLS context an error value rather than a throw; the event-id set is keyed SipHash in a boost::unordered_flat_set; an offer's size is a std::uint64_t. Chapter 19 drops the fixed trystero entries, corrects the relays' migration and the type lines' places, and records what the phase leaves to others: asio's citation of a removed trystero test and chapter 16's roadmap sentences. combined_provider no longer asks for exceptions: trystero's native backend throws nothing, and the program builds and runs with exception-handling=off, linking Boost's handler as the other programs of this Jamfile do. The superproject records trystero's refactor at its integration commit, with the interop scenario of a public app beside a protected one fixed. --- CODING-GUIDELINES.md | 242 +++++++++++++++++++++++-------------- libs/trystero | 2 +- tools/openssl/test/Jamfile | 6 +- 3 files changed, 159 insertions(+), 91 deletions(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index aab5c937..f7b209d5 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -5277,7 +5277,11 @@ webcpp 0.1.0 (trystero `e9326e9`), which includes the change `shared-connection` (trystero `2e2dcd4`, webcpp `1a0dcac` and `d9e5fa6`, 2026-10-14), implemented and archived on 2026-11-14, and of webrtc's increment 3 (trystero's branch `webrtc-backend`, 2026-11-14), which moved both -backends' WebRTC onto webcpp::webrtc and trystero's Asio onto webcpp::asio. +backends' WebRTC onto webcpp::webrtc and trystero's Asio onto webcpp::asio, +and of the first phase of trystero's refactor onto webcpp's libraries and +Boost (trystero's branch `refactor`, 2026-11-14), which moved the browser +onto webcpp::asio's run model, the native relays onto webcpp::beast and +Boost.URL, and what the core wrote itself onto Boost. **Scope and differences from Trystero JS.** @@ -5328,7 +5332,8 @@ backends' WebRTC onto webcpp::webrtc and trystero's Asio onto webcpp::asio. - **The wire is Trystero 0.26.0's, byte for byte, and never changes: the topic prefixes `"Trystero@"` and `"Trystero:"`, the handshake's `"__trystero_pw"`, every constant and layout under `protocol/`, the default relays in their - order, and the names embind exports.** A room joined from C++ and the same + order, and the names the chat's page calls (`joinRoom`, `sendText`) and the + interop page's `window.leave`.** A room joined from C++ and the same room joined from Trystero JS must be one room; the `oracle` lane fails when Trystero's own values differ from the committed ones. Source: @@ -5373,6 +5378,10 @@ backends' WebRTC onto webcpp::webrtc and trystero's Asio onto webcpp::asio. Trystero draws (`protocol::seal_iv_size`), so that each side opens what the other sealed. Source: `libraries/trystero/openspec/specs/trystero/spec.md` (proposals). +- **An offer's size is read as a `std::uint64_t` on every target and refused + beyond 2^53 - 1, as Trystero refuses it.** A float64 size does not fit a + 32-bit `std::size_t`: Emscripten read 2^53 - 1 as 4294967295 (measured). + Source: `doc/protocol.adoc` (libs/trystero). **Layers and the backend interface.** @@ -5466,20 +5475,22 @@ backends' WebRTC onto webcpp::webrtc and trystero's Asio onto webcpp::asio. **The browser backend.** -- **In the browser the backend binds the page's own `WebSocket`, - `setTimeout` and `crypto.subtle` through `emscripten::val`, and its - `RTCPeerConnection` through webcpp::webrtc, not libdatachannel's WebAssembly - port.** webcpp::webrtc's browser implementation binds the page's objects - itself, so one peer connection and data channel serve both targets; - datachannel-wasm has no media and hides the `RTCPeerConnection` it wraps. +- **In the browser the backend binds the page's own `WebSocket` and + `crypto.subtle` through webcpp::asio's bridge, its timers are webcpp::asio's, + and it binds the page's `RTCPeerConnection` through webcpp::webrtc, not + libdatachannel's WebAssembly port.** webcpp::webrtc's browser + implementation binds the page's objects itself, so one peer connection and + data channel serve both targets; datachannel-wasm has no media and hides the + `RTCPeerConnection` it wraps. Source: `doc/design.adoc` (libs/trystero). -- **`browser::event_loop` drives the `io_context` without ever calling - `run()`: each JavaScript event runs its handler and then `poll()`, and work - posted outside an event schedules one `poll()` in a microtask.** Nothing may - block in a page, and nothing runs while nothing happens. `poll()` from - `emscripten_set_main_loop` was rejected for its 60 wake-ups a second and its - stop in hidden tabs, and `poll()` on a fixed interval for its wake-ups and - latency. +- **A browser program's `main` runs its io_context under a work guard, as + webcpp::asio's model has it, and the page calls C++ only through + `browser::page_call`, which posts.** The owner's directive and decision of + 2026-11-14 on trystero's refactor (its decision 1): chapter 15 asio says + that nothing calls the run family from a JavaScript event and that use + without `run` is unsupported; and under Asyncify an embind call made while + `main` is suspended returns a promise that never settles, and its second + call aborts a debug build (measured with Emscripten 6.0.11). Source: `doc/browser.adoc` (libs/trystero). - **An event the page delivers while C++ is already running is posted, not run.** A handler never runs inside the call that caused it, as when node's @@ -5493,26 +5504,37 @@ backends' WebRTC onto webcpp::webrtc and trystero's Asio onto webcpp::asio. webcpp::asio's; and Emscripten's threads need a cross-origin isolated page. `/webcpp/trystero//trystero` brings `/webcpp/asio//asio`, so a program on emscripten is built in one of its suspension variants, jspi by default or - asyncify, though the loop never runs the `io_context`. + asyncify, and its `main` runs the `io_context`, which suspends there. Source: `doc/browser.adoc` and `AGENTS.md` (libs/trystero). -- **JavaScript reaches C++ through one exported function, `trystero_dispatch`, - and every object registers its callbacks with the loop by id and slot and - removes them when it is destroyed.** A late event for a destroyed object - finds nothing, and a destroyed loop marks every handler it made as dead. +- **Page events reach C++ through webcpp::asio's bridge, one intrusive + registration per WebSocket and per `page_call`, removed when its object is + destroyed; Web Crypto promises through `async_await`.** A late event for a + destroyed object finds nothing. Source: `doc/browser.adoc` (libs/trystero). -- **No JavaScript exception enters WebAssembly: every call that can throw runs - inside one `EM_JS` function that returns the exception as a value, and every - entry from the page restores the stack pointer and the loop's depth when - something escapes.** Measured before the fix, each escape left 128 bytes of - stack and the loop stopped after about 500; a C++ exception that reached - JavaScript kept its object for good, so `browser::dispatch` catches it - first. - Source: `libraries/trystero/openspec/specs/trystero/spec.md` (proposals). -- **Text crosses into JavaScript and back through the loop's `TextDecoder` and - `TextEncoder`, straight from and into WebAssembly memory, with its length - checked before any copy.** No `std::string` is made to carry it, and a - string over its bound is never copied into WebAssembly. +- **No JavaScript exception enters WebAssembly: calls that can throw are + caught in JavaScript (`EM_ASM` in inline functions; Web Crypto inside an + `async` function), and every event and page call enters C++ through + webcpp::asio's bridge, which restores the stack pointer, catches a C++ + exception in C++, and only posts.** Measured before the fix, each escape + left 128 bytes of stack and the loop stopped after about 500; a C++ + exception that reached JavaScript kept its object for good, so the bridge + catches it first. + Source: `libraries/trystero/openspec/specs/trystero/spec.md` (proposals) + and `doc/browser.adoc` (libs/trystero). +- **Text crosses into JavaScript through `browser::js_string`, straight from + WebAssembly memory, and back through a `TextEncoder`, its length checked + before any copy.** No `std::string` is made to carry it, and a string over + its bound is never copied into WebAssembly. Source: `doc/browser.adoc` (libs/trystero). +- **The browser's one timer, the core's `detail::timer`, over webcpp::asio's + steady timer, numbers its waits, so that a wait cancelled, restarted or + destroyed never fires.** Asio may already have queued its expiry as a + success; on emscripten the wait is in the reactor's timer queue, so it + fires only while the program runs its `io_context`. + Source: `include/webcpp/trystero/detail/timer.hpp` (libs/trystero). +- **`getentropy` is checked: a failure fails the seal, and aborts in + `random()`.** Without secure randomness nothing is safe, as natively. + Source: `include/webcpp/trystero/browser/backend.hpp` (libs/trystero). - **A page makes at most `browser::backend::max_peer_connections` (256) peer connections across all its apps and rooms: the cap, `runtime_options::max_peer_connections`, of the webcpp::webrtc runtime the @@ -5534,27 +5556,22 @@ backends' WebRTC onto webcpp::webrtc and trystero's Asio onto webcpp::asio. - **The browser sealer imports its key on its first operation and queues the operations that arrive while it imports.** (reason not recorded) Source: `libraries/trystero/openspec/specs/trystero/spec.md` (proposals). -- **A browser program lives as long as its page: the examples allocate their - application with `new`, and `main` returns at once.** The event loop must - outlive every room and object it serves. - Source: `doc/browser.adoc` (libs/trystero). **The native backend.** -- **Natively WebRTC is webcpp::webrtc's over libdatachannel's C API, the - relays' WebSockets are Boost.Beast's, and TLS and AES-GCM are OpenSSL's, - with libdatachannel built without its own WebSocket.** The relays then run - on the room's executor like everything else, and the native peer - connections are the browser's in interface. +- **Natively WebRTC is libdatachannel's, through webcpp::webrtc over its C + API, the relays' WebSockets are webcpp::beast's, natively Boost.Beast's + own, and TLS and AES-GCM are OpenSSL's, with libdatachannel built without + its own WebSocket.** The relays then run on the room's executor like + everything else, and the native peer connections are the browser's in + interface. Source: `doc/native.adoc` (libs/trystero). -- **The native backend names webcpp::asio's executor, and gives its relays' - WebSockets, which are Boost.Beast's over Boost.Asio, the same executor - through `relay_executor`.** Natively the two are one type. The guide's - reference reads every header for Emscripten's target, where webcpp::asio is - its own and the native backend is never built: `relay_executor` names no - executor there, and the native headers still parse. - Source: `AGENTS.md` and `include/webcpp/trystero/native/backend.hpp` - (libs/trystero). +- **The native backend names webcpp::asio and webcpp::beast everywhere, its + relays included.** The guide's reference reads every header for + Emscripten's target, where both are their browser implementations, and the + native headers parse there as they are, with no configuration of + Boost.Asio's. + Source: `AGENTS.md` and `doc/Jamfile` (libs/trystero). - **The sealer is asynchronous on both targets: the native one works synchronously and posts its completion.** Web Crypto is asynchronous, so the interface is, and a completion never runs inside the call that started it. @@ -5599,15 +5616,38 @@ backends' WebRTC onto webcpp::webrtc and trystero's Asio onto webcpp::asio. destroyed never fires.** Asio may already have queued its expiry as a success. Source: `libraries/trystero/openspec/specs/trystero/spec.md` (proposals). -- **The native WebSocket writes one text at a time, and a connection that ends - during a write clears its queue while the write finishes on the frame it - moved out of it.** Beast allows one write at a time, and the write's - completion must never touch the cleared container. - Source: `libraries/trystero/openspec/specs/trystero/spec.md` (proposals). -- **Relays are verified against the system's certificate authorities, and - `tls_context()` hands the TLS context to an application with authorities of - its own.** A relay whose certificate does not verify is unreachable, and the - room retries it later as it would any other. +- **The relay WebSocket is one session of Asio operations composed by + callbacks (resolve, connect, TLS, handshake, a read loop, one write at a + time), each handler bound to the room's allocator, and a connection that + ends during a write clears its queue while the write finishes on the text + it moved out of it.** Beast allows one write at a time, and the write's + completion must never touch the cleared container; callbacks rather than + coroutines, so that no coroutine frame, and no read buffer, is allocated + outside the room's resource. The session names webcpp::asio and + webcpp::beast only and compiles for Emscripten too. + Source: `include/webcpp/trystero/native/websocket.hpp` (libs/trystero). +- **A relay's URL is read with Boost.URL as a page's `WebSocket` reads it: an + IPv6 address in brackets reaches the resolver without them, the scheme in + any case, a host name decoded and in lower case, the scheme's port by + default; userinfo, a fragment, a port beyond 65535 and an IPvFuture host are + refused, and report a close.** Boost before one's own (chapter 4); the + hand-written parser kept the brackets, so a relay at an IPv6 address was + unreachable. + Source: `doc/native.adoc` (libs/trystero). +- **Over TLS the connection names the host (SNI) through + `webcpp::beast::set_server_name` only when it is a name, never an address, + and checks the certificate against the URL's host, a name or an address, + with Asio's `host_name_verification`.** RFC 6066 allows no address in SNI. + Source: `doc/native.adoc` (libs/trystero). +- **Relays are verified against the system's certificate authorities, through + `native::make_tls_context()` (TLS 1.2 or newer, peer verification, + OpenSSL's default verify paths, the call Asio's non-throwing + `set_default_verify_paths(ec)` makes), and a backend takes a program's own + context instead: webcpp's embedded Mozilla roots + (`webcpp::asio::make_tls_client_context()`), or a private authority.** The + owner's decision of 2026-11-14 on trystero's refactor (its decision 2): no + relay's trust changes. A relay whose certificate does not verify is + unreachable, and the room retries it later as it would any other. Source: `doc/native.adoc` (libs/trystero). - **A native relay that stops answering is dropped once `websocket_limits::idle_timeout` (30 s) passes with its keep-alive ping, @@ -5626,11 +5666,14 @@ backends' WebRTC onto webcpp::webrtc and trystero's Asio onto webcpp::asio. - **`native::backend::random` aborts the program when OpenSSL has no secure randomness.** Without secure randomness nothing is safe. Source: `include/webcpp/trystero/native/backend.hpp` (libs/trystero). -- **The constructor of `native::backend` is the one native function that - throws, a `boost::system::system_error` when OpenSSL cannot make the TLS - context or load the system's certificate authorities; without exceptions, - Boost's `throw_exception`, which the program defines, is called instead.** - (reason not recorded) +- **No function of the native backend throws, its constructors included: a + TLS context OpenSSL cannot make, or a program's `result` that holds an + error, is kept as that error, `tls_context()` returns it as a + `boost::system::result`, and every `wss://` + relay reports a close while `ws://` ones are still reached.** Chapter 6 (an + API that throws sits behind `WEBCPP_TRYSTERO_NO_EXCEPTIONS`) and chapter 4 + (errors as values); `config.hpp`'s Doc Comment says trystero raises no + exception of its own. Source: `doc/native.adoc` (libs/trystero). - **Every part of trystero, the native backend included, works with exceptions and without them, and no program, test or headers-alone call @@ -5639,10 +5682,12 @@ backends' WebRTC onto webcpp::webrtc and trystero's Asio onto webcpp::asio. `native_peer_connection` and `native_room` also run with `exception-handling=off`, as the evidence. Source: `AGENTS.md` (libs/trystero). -- **The native headers and the backend's WebRTC are compiled alone in one - headers-alone call, natively, as the build asks.** None needs exceptions, so - the lint analyses them without exceptions too; on emscripten the backend's - WebRTC is compiled through the browser backend's header. +- **The native headers and the backend's WebRTC are compiled alone natively, + as the build asks, and the relay session on emscripten too.** None needs + exceptions, so the lint analyses them without exceptions too; on emscripten + the backend's WebRTC is compiled through the browser backend's header, and + the relay session alone, so that the lanes, not only the reference's + parse, prove it compiles there. Source: `test/Jamfile` (libs/trystero). **Rooms, actions and errors.** @@ -5990,10 +6035,14 @@ backends' WebRTC onto webcpp::webrtc and trystero's Asio onto webcpp::asio. relay, and once in 5.3 s, Trystero's announce interval, per relay.** A flood of low ids must not have the relays rate-limit the room. Source: `doc/protocol.adoc` (libs/trystero). -- **The strategy remembers the last 4096 event ids and drops a repeated one.** - A signal reaches the room on several relays and must reach the signaling - once. - Source: `libraries/trystero/openspec/specs/trystero/spec.md` (proposals). +- **The strategy remembers the last 4096 event ids and drops a repeated one, + in a `boost::unordered_flat_set` hashed with SipHash under a key it draws + when it is made.** A signal reaches the room on several relays and must + reach the signaling once; an id is a relay's choice, and ids chosen to + share a bucket of the standard library's unseeded hash cost 26.7 us an + event against 0.12 us (measured). + Source: `libraries/trystero/openspec/specs/trystero/spec.md` (proposals) + and `include/webcpp/trystero/detail/nostr_strategy.hpp` (libs/trystero). - **A lost relay is retried after a random share of a bound that starts at 3.3 s and doubles to 60 s, and comes back down only after a connection lasted 60 s.** A relay that closes the room at once after each open is then @@ -6086,7 +6135,8 @@ backends' WebRTC onto webcpp::webrtc and trystero's Asio onto webcpp::asio. type cost two `operator new` calls per completion (measured). Source: `AGENTS.md` (libs/trystero). - **`trystero::bytes` and `trystero::payload` keep `std::allocator`; every - other container trystero declares is a `std::pmr` one.** Those two are the + other container trystero declares is a `std::pmr` one or a Boost container + over `std::pmr::polymorphic_allocator`.** Those two are the user's choice; `std::pmr::string` and `pmr_bytes` are the types that receive in the room's resource. Source: `doc/allocation.adoc` (libs/trystero). @@ -6099,8 +6149,9 @@ backends' WebRTC onto webcpp::webrtc and trystero's Asio onto webcpp::asio. of a message, `emscripten::val`'s, the JSON storage's counter, Asio's once per context and its wrapper on a foreign executor, which webcpp::webrtc's completions get through `any_io_executor`, Beast's stream state, - Emscripten's `select()`, and Asyncify's unwind data when a call - suspends.** They belong to a dependency or to Asio, and webcpp::webrtc's + Emscripten's `select()`, Asyncify's unwind data when the run suspends, and + the entry of each pending Web Crypto promise in the map of webcpp::asio's + bridge.** They belong to a dependency or to Asio, and webcpp::webrtc's posts from libdatachannel's threads may not touch a resource used only on the executor. Source: `doc/allocation.adoc` (libs/trystero). @@ -6114,9 +6165,8 @@ backends' WebRTC onto webcpp::webrtc and trystero's Asio onto webcpp::asio. short-lived one or a test.** A room allocates and frees on every event: a frame, a parsed text, a post, a log line. Source: `doc/allocation.adoc` (libs/trystero). -- **The browser's `event_loop` and the tests' `memory_network` allocate their - registrations in their own resource, while each registered callback stays in - its own.** They are shared by every room of a page or of a test. +- **The tests' `memory_network` allocates its relays in its own resource.** + It is shared by every room of a test. Source: `doc/allocation.adoc` (libs/trystero). **Build and dependencies.** @@ -6133,7 +6183,9 @@ backends' WebRTC onto webcpp::webrtc and trystero's Asio onto webcpp::asio. webcpp::webrtc: `/webcpp/trystero//trystero` brings `/webcpp/asio//asio`, and on emscripten `/webcpp/webrtc//webrtc`; `/webcpp/trystero//native` brings `/webcpp/webrtc//webrtc` natively, with libdatachannel (MPL 2.0) and - OpenSSL (Apache 2.0).** A browser program never includes the native + OpenSSL (Apache 2.0), and for the relays `/webcpp/beast//tls`, + `/webcpp//boost_url` and `/webcpp/asio//tls`, whose embedded authorities a + program may choose.** A browser program never includes the native backend, so neither libdatachannel nor OpenSSL is in it, as OpenSSL is optional for Asio. Source: `doc/design.adoc` and `build.jam` (libs/trystero). @@ -6143,9 +6195,9 @@ backends' WebRTC onto webcpp::webrtc and trystero's Asio onto webcpp::asio. libdatachannel and its nested dependencies are pinned source targets, built statically against the same OpenSSL provider as Asio and Beast. Native Trystero requires `threading=multi`, since libdatachannel runs worker - threads, and no exceptions. Its WebRTC is webcpp::webrtc's and its Asio is - named webcpp::asio; its relays' WebSockets are still Boost.Beast's, and its - sealer and randomness OpenSSL's, whose migration remains. + threads, and no exceptions. Its WebRTC is webcpp::webrtc's, its Asio is + named webcpp::asio and its relays' WebSockets are webcpp::beast's; its + sealer and randomness are still OpenSSL's, whose migration remains. Source: `doc/building.adoc` (libs/trystero). - **A library found nowhere leaves trystero out with one message, unless `webcpp-require-external=on`, as the CI builds, stops the build.** `b2 test` @@ -8993,8 +9045,9 @@ The global WASIp2/P3 launchers grant network/name lookup and default to 600 seco for tests; it establishes no production capability policy. Native Trystero requires multiple threads and uses the same source-built OpenSSL through pinned libdatachannel, which webcpp::webrtc now wraps for it, and names its Asio -webcpp::asio. Its relays' later migration onto Beast's facades remains roadmap -work, and coexistence is required now. +webcpp::asio. Its relays now run on webcpp::beast's facade, natively Boost.Beast +over that same OpenSSL (trystero's branch `refactor`), and coexistence is +required. ### The libraries against the rules @@ -9015,7 +9068,7 @@ it says. (`parser.hpp:54,175,199,309`, `calculator.hpp:988-1017`), wasi's `response.hpp:45` and `entrypoint.hpp:101,122,200,234` (with unqualified `uintN_t`), idna's `detail/nfc.hpp:229,233`, trystero's - `detail/nostr_strategy.hpp:139-140`, `detail/signaling.hpp:232` and + `detail/nostr_strategy.hpp:222-223`, `detail/signaling.hpp:233` and `protocol/nostr.hpp:49`, lexical's `date_time.hpp:54-144`, `detail/regex_validator.hpp:71` and `detail/regex_unicode.hpp:35`, and document's sizes as `std::uint64_t`. The roadmap's review covers it. @@ -9160,10 +9213,9 @@ says what the tree does. the change `shared-connection` (trystero `e9326e9`). The specification gives the interop driver's timeout as 900 where `test/oracle/Jamfile` gives 2400; the shared connection's delta has the roadmap list shared relay sockets, - which `doc/roadmap.adoc` leaves out; `error.hpp` says that `room::on_error` - reports `invalid_configuration`; - `doc/differences.adoc` still says "as today"; comments use a private - shorthand, `C/`, for Trystero's source files. The draft bounded parse + which `doc/roadmap.adoc` leaves out; `test/oracle/interop/js.html:149` + still cites Trystero's source with a private shorthand, `C/`, where every + other comment writes `dist/`. The draft bounded parse (chapter 18) claims guarantee 9, which 9 to 11 now hold, rebases on `160f431`, and says "about sixty times" where its own figures give 87. - **asio.** The 2026-11-03 amendment reconciles default turn limit 100, @@ -9183,6 +9235,20 @@ says what the tree does. (`AGENTS.md` chapter 5), and its roadmap requirement repeats chapter 16's sentence on trystero's configuration. +### trystero's refactor: open items + +The first phase of trystero's refactor onto webcpp's libraries and Boost +(trystero's branch `refactor`, 2026-11-14) leaves these to their owners. + +- **asio.** `libs/asio/include/webcpp/asio/browser/src.hpp:189` cites a + measurement made "in trystero's browser_event_loop_test.cpp", which the + browser's move onto webcpp::asio's run model removed; the citation names a + file that no longer exists. +- **Chapter 16.** Its "webcpp::webrtc and webcpp::crypto" still leaves the + relays' WebSockets to Beast, and its "Trystero on Asio and Beast" calls Asio + and Beast foundations for Trystero's later migration, which this phase made + for the relays (chapter 15's trystero entry). + ### webrtc: open questions - **Whether a later version synthesises `negotiationneeded` natively** (the diff --git a/libs/trystero b/libs/trystero index 528a4e65..dbf78dfd 160000 --- a/libs/trystero +++ b/libs/trystero @@ -1 +1 @@ -Subproject commit 528a4e6502052a12a884da4304fe067d0be8f913 +Subproject commit dbf78dfd8b20b21984fabc5be8d586ed46377631 diff --git a/tools/openssl/test/Jamfile b/tools/openssl/test/Jamfile index 7b3b66aa..0c8d47b3 100644 --- a/tools/openssl/test/Jamfile +++ b/tools/openssl/test/Jamfile @@ -25,8 +25,10 @@ explicit cobalt_ssl_state ; alias cobalt_ssl_cancel : ../../../libs/cobalt/test/tls//cobalt_ssl_cancel-program ; explicit cobalt_ssl_cancel ; -# The native WebRTC backend needs worker threads and exceptions. +# Trystero's native backend needs worker threads, libdatachannel's; it works +# with exceptions and without them, as the program does, which links the +# handler Boost calls in place of a throw when it is built without them. exe combined_provider : combined_provider.cpp /webcpp/asio//asio /webcpp/asio//openssl /webcpp/beast//beast /webcpp/trystero//native - : multi on ; + : multi off:/webcpp//throw_exception ; explicit combined_provider ; From 2b5b6b94795f2355f18b36632654b15657223b27 Mon Sep 17 00:00:00 2001 From: R Date: Sat, 14 Nov 2026 20:24:39 -0300 Subject: [PATCH 14/61] webrtc and trystero: the lint's findings on the phase 1 integration webrtc wraps a comment of its browser lane within 80 columns; trystero's relay session erases its reads' and writes' handlers' types, so that the analysis of its Emscripten compile sees no cycle through Asio's post. --- libs/trystero | 2 +- libs/webrtc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/trystero b/libs/trystero index dbf78dfd..44b5f103 160000 --- a/libs/trystero +++ b/libs/trystero @@ -1 +1 @@ -Subproject commit dbf78dfd8b20b21984fabc5be8d586ed46377631 +Subproject commit 44b5f1038f611b7cc195ccdef34cab3cb3819bb1 diff --git a/libs/webrtc b/libs/webrtc index 1dd2d829..f6b8eed0 160000 --- a/libs/webrtc +++ b/libs/webrtc @@ -1 +1 @@ -Subproject commit 1dd2d829b5abdb4ee67122cf9fbadcc7a8e02ef6 +Subproject commit f6b8eed0a63a5baf484674943ddaad3f81370e33 From 35743216ec3dd05bbe2df2bfe11adb6e2070deb8 Mon Sep 17 00:00:00 2001 From: R Date: Sat, 14 Nov 2026 20:44:20 -0300 Subject: [PATCH 15/61] trystero: the allocation test proportionate under Asyncify The superproject records trystero's refactor with the allocation test's arenas left uninitialized, which took it from 105 s to 0.8 s under Asyncify. --- libs/trystero | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/trystero b/libs/trystero index 44b5f103..1965443e 160000 --- a/libs/trystero +++ b/libs/trystero @@ -1 +1 @@ -Subproject commit 44b5f1038f611b7cc195ccdef34cab3cb3819bb1 +Subproject commit 1965443ecdef5af13d0d374c69e0e6f7153b1921 From 8756479248b7f9d790893c166dafc19361ebbbd8 Mon Sep 17 00:00:00 2001 From: R Date: Sat, 14 Nov 2026 20:50:17 -0300 Subject: [PATCH 16/61] trystero: the allocation test's arenas to clang-tidy The superproject records trystero's refactor with the allocation test's arenas held as std::arrays, which the lint's clang-tidy accepts. --- libs/trystero | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/trystero b/libs/trystero index 1965443e..47412f49 160000 --- a/libs/trystero +++ b/libs/trystero @@ -1 +1 @@ -Subproject commit 1965443ecdef5af13d0d374c69e0e6f7153b1921 +Subproject commit 47412f494e593e421dd9f60f51f43c24f1618a66 From 3de25779e87243074461e89348dbe70797113ac2 Mon Sep 17 00:00:00 2001 From: R Date: Sat, 14 Nov 2026 21:08:24 -0300 Subject: [PATCH 17/61] AGENTS.md: trystero's reference names its platform backend's target --- AGENTS.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 8ee96348..215d17f2 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -520,14 +520,14 @@ single page, from the library's Doc Comments. `webcpp.reference ;` in that holds the types of a function's parameters, and the host's standard library and Emscripten's give one function two (trystero's reference read as a native and an emscripten translation unit had 555 sections for 461). - Such a library also gives the target of its native backend, if it has - one, which brings that backend's dependencies, and the defines that parse + Such a library also gives the target of its backend, if it has one, + which brings that backend's dependencies, and the defines that parse needs, which a requirement conditioned on the emscripten toolset does not - give a reference built natively; trystero's names Boost.Asio without - threads, as wasm32 has none, for its native backend's Beast and timers: - `webcpp.reference trystero : /webcpp/trystero//native - multi /webcpp//emscripten-reference - BOOST_ASIO_DISABLE_THREADS ;`. Read so, trystero's reference is the same on Linux and on macOS, byte + give a reference built natively; trystero's gives its platform backend's, + whose Asio and Beast are webcpp::asio and webcpp::beast, their browser + implementations for that target, so that no define of Boost.Asio's is + needed: `webcpp.reference trystero : /webcpp/trystero//platform + multi /webcpp//emscripten-reference ;`. Read so, trystero's reference is the same on Linux and on macOS, byte for byte. The emsdk is `-sWEBCPP_EMSDK=`, read from b2's command line alone, else `.local/emsdk`, never the environment's `EMSDK`, which `emsdk_env.sh` exports and b2 would read as `-sEMSDK`; its From 86d9315a14b687f7095cb7f658c3d71ab96d33dd Mon Sep 17 00:00:00 2001 From: R Date: Sat, 14 Nov 2026 21:26:59 -0300 Subject: [PATCH 18/61] trystero: one platform backend (WP4) --- libs/trystero | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/trystero b/libs/trystero index dbf78dfd..71fc7514 160000 --- a/libs/trystero +++ b/libs/trystero @@ -1 +1 @@ -Subproject commit dbf78dfd8b20b21984fabc5be8d586ed46377631 +Subproject commit 71fc751441bd8d4fa9a0510195a01b0cebdbff9c From 30fde84ce624424d76c7e189032c0a953941cb55 Mon Sep 17 00:00:00 2001 From: R Date: Sat, 14 Nov 2026 21:44:55 -0300 Subject: [PATCH 19/61] guidelines: trystero's one platform backend (WP4) and the core's std::chrono (WP5) Chapter 15's trystero entry takes the two work packages at trystero 71fc751. The browser and native backends become one platform::backend, in sections for both targets, a page and natively: only the sealer and the randomness are the target's own, by WEBCPP_TARGET_EMSCRIPTEN; the randomness is checked wherever it is drawn; the window and the runtime hold on both targets; the relays are one webcpp::beast session whose failed write reports one close, whose URLs a page would read otherwise fail closed, and whose TLS verifies the peer whatever the context's mode; page_call checks the page's value and its resource outlives the io_context. The core keeps its times as std::chrono and its integers at a fixed meaning, and acts once only on NIP-01 event ids. Memory, the build, the evidence and every source follow the new names and pages. Chapter 6's example of a header that declares nothing without exceptions named the removed webcpp::trystero::native: no library has one now, so the fixture's error is given, as clang reports it. Chapter 4's and chapter 17's sentences on trystero's two backends follow. Chapter 19 drops trystero's resolved type and shareability lines, records the draft parse's outdated question, asio's building page on //native, the allocation test's compiler macro, the quick starts, what is deferred, and the seam's clocks, in progress. --- CODING-GUIDELINES.md | 648 +++++++++++++++++++++++++++---------------- 1 file changed, 414 insertions(+), 234 deletions(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index f7b209d5..5a1a6c71 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -260,9 +260,9 @@ A test's helpers that are shared between tests go in `webcpp::test` - **A library from outside is wrapped,** behind an interface that follows its counterpart in the standard library or in Boost as closely as it can, so that the outside library is an implementation detail the user never names - and another implementation can replace it: as webcpp::trystero hides - libdatachannel behind its backend interface, with the browser's WebRTC as - the other backend. + and another implementation can replace it: as webcpp::webrtc hides + libdatachannel behind the W3C's WebRTC API, with the page's own WebRTC as + its other implementation. - **Types of a fixed meaning.** An integer whose width matters is one of the fixed-width types of `` (`std::uint8_t`, `std::int64_t`, `std::uint32_t`), as Boost.Config's `` guidelines give @@ -422,7 +422,7 @@ exactly its authors' and the program carries only what it calls. alone: every library supports both (below), the lint analyses every program both ways, and a library proves what behaves otherwise without exceptions by tests of its own that declare `off` - (trystero's `browser_*_no_exceptions`). + (trystero's `platform_*_no_exceptions`). - **Each library has its own configuration macro,** `WEBCPP__NO_EXCEPTIONS`, as Boost.Asio has `BOOST_ASIO_NO_EXCEPTIONS`, in `/config.hpp>`, which the convenience header and every @@ -473,12 +473,13 @@ exactly its authors' and the program carries only what it calls. and the header declares nothing without exceptions: what follows its `config.hpp` sits inside `#ifndef WEBCPP__NO_EXCEPTIONS`, with a comment that names the dependency, so that a program built without - exceptions that uses it fails on the first name it uses (trystero's: - `no member named 'backend' in namespace 'webcpp::trystero::native'`), and - one that only includes it compiles. The - fixture browser_demo's `native.hpp` is one, against the fake dependency of - its `deps/include` (a fixture without `config.hpp`, it tests - `BOOST_NO_EXCEPTIONS`). + exceptions that uses it fails on the first name it uses, and one that only + includes it compiles. No library has such a header today; the fixture + browser_demo's `native.hpp` is one, against the fake dependency of its + `deps/include` (a fixture without `config.hpp`, it tests + `BOOST_NO_EXCEPTIONS`): a program built without exceptions that includes + `` beside it and calls `native_answer` fails with + `no member named 'native_answer' in namespace 'webcpp::browser_demo'`. - **A program that needs exceptions says so.** A test or an example that throws, tries or catches on purpose declares `on` in its requirements, as the fixture demo's @@ -5281,7 +5282,10 @@ backends' WebRTC onto webcpp::webrtc and trystero's Asio onto webcpp::asio, and of the first phase of trystero's refactor onto webcpp's libraries and Boost (trystero's branch `refactor`, 2026-11-14), which moved the browser onto webcpp::asio's run model, the native relays onto webcpp::beast and -Boost.URL, and what the core wrote itself onto Boost. +Boost.URL, and what the core wrote itself onto Boost, replaced its two +backends by one platform backend (trystero's branch `wp4`), and moved the +core's times onto `std::chrono` and its integers to a fixed meaning +(trystero's branch `wp5`), both merged into `refactor`. **Scope and differences from Trystero JS.** @@ -5386,8 +5390,8 @@ Boost.URL, and what the core wrote itself onto Boost. **Layers and the backend interface.** - **The library is layered (protocol, backend interface, app, room, the - backend's WebRTC, and the browser and native backends), and the core above - the interface never includes a backend, the backend's WebRTC, + backend's WebRTC, and the platform backend), and the core above the + interface never includes the platform backend, the backend's WebRTC, webcpp::webrtc, libdatachannel, OpenSSL or Emscripten.** The same room runs over the browser's WebRTC and libdatachannel's, both through webcpp::webrtc, and over the tests' memory relays, on both targets; @@ -5397,8 +5401,8 @@ Boost.URL, and what the core wrote itself onto Boost. - **The backend is a handful of abstract classes, not template parameters.** Each operation is a call into JavaScript or a network stack, so a virtual call costs nothing measurable, while the room stays free of templates over - the platform and of `#ifdef`, and the test and browser backends are - interchangeable at run time. + the platform and of `#ifdef`, and the tests' memory relays and the platform + backend are interchangeable at run time. Source: `doc/design.adoc` (libs/trystero). - **Every handler a backend invokes, and every completion of the library, runs on the executor after the call that caused it has returned, even when its @@ -5413,6 +5417,23 @@ Boost.URL, and what the core wrote itself onto Boost. `random` fills from a cryptographically secure source.** The bytes become secret keys and nonces. Source: `libraries/trystero/openspec/specs/trystero/spec.md` (proposals). +- **The core keeps its times as `std::chrono` and its integers at a fixed + meaning: a time of the backend's monotonic clock is a + `std::chrono::steady_clock::time_point` (`detail::time_point`) and a delay + a `std::chrono::milliseconds`; a Nostr event's `created_at` and a + subscription's `since` are `std::chrono::sys_seconds`; a Nostr kind and a + counter are `std::uint32_t`, an index or a count a `std::size_t`; and the + backend's clocks reach the core only through `detail::steady_now` and + `detail::unix_now`.** Chapter 4's types of a fixed meaning. Every value is + Trystero's number, truncated where Trystero's is, so nothing a peer sees + changes. `double` stays where it is JavaScript's Number on Trystero's side, + which the oracle's fixtures pin: `str_to_num` and the sum of UTF-16 code + units it takes, the relay shuffle, and the action wire's float64 sizes and + offsets. The backend interface itself still gives its clocks as a `double` + of milliseconds (`now_ms`) and an `std::int64_t` of seconds + (`unix_seconds`), which those two functions convert (chapter 19). + Source: `include/webcpp/trystero/detail/clock.hpp` and + `include/webcpp/trystero/protocol/nostr.hpp` (libs/trystero). - **ICE servers are checked in the core: an unusable URL, or a TURN server without credentials, is dropped when the app is made and reported, and every scheme is lowercased.** WebRTC would refuse them; dropped at once, the app @@ -5421,16 +5442,16 @@ Boost.URL, and what the core wrote itself onto Boost. **The backend's WebRTC.** -- **Both backends make their peer connections and data channels the same way, - in `webrtc/`: `webrtc::peer_connection` and `webrtc::data_channel` hold - webcpp::webrtc's `basic_peer_connection` and `basic_data_channel` over a - `std::pmr::polymorphic_allocator` on the app's resource, and implement the - abstract `backend::peer_connection` and `backend::data_channel`.** - webcpp::webrtc gives both targets one interface, so trystero keeps only its - policies over WebRTC, the same on both. The abstract classes stay: the - tests' memory relays implement them for whole rooms on both targets, where - node has no WebRTC, and the interop's native peer wraps the native - backend's. +- **The platform backend makes its peer connections and data channels in + `webrtc/`, on both targets: `webrtc::peer_connection` and + `webrtc::data_channel` hold webcpp::webrtc's `basic_peer_connection` and + `basic_data_channel` over a `std::pmr::polymorphic_allocator` on the app's + resource, and implement the abstract `backend::peer_connection` and + `backend::data_channel`.** webcpp::webrtc gives both targets one interface, + so trystero keeps only its policies over WebRTC, the same on both. The + abstract classes stay: the tests' memory relays implement them for whole + rooms on both targets, where node has no WebRTC, and the interop's native + peer wraps the platform backend's. Source: `doc/design.adoc` (libs/trystero). - **Each keeps a wait of every kind pending on webcpp::webrtc's object, re-armed on the executor, and reports what it completes with through the @@ -5473,25 +5494,158 @@ Boost.URL, and what the core wrote itself onto Boost. the browser's event did. Source: `include/webcpp/trystero/webrtc/data_channel.hpp` (libs/trystero). -**The browser backend.** +**The platform backend.** + +- **One class, `platform::backend` (`include/webcpp/trystero/platform/`), + implements the backend interface on both targets, in place of + `native::backend` and `browser::backend`, with no alias; the abstract + classes of `backend.hpp` stay, for the memory relays and the interop's + native peer (above).** The owner's decision 3 of trystero's refactor + (2026-11-14): everything but WebRTC was written twice, and webcpp::asio, + webcpp::beast and webcpp::webrtc now give both targets one interface. No + version is released yet (0.1.0 is in preparation, chapter 19), so the + rename costs no release. + Source: `doc/design.adoc` and `doc/platform.adoc` (libs/trystero). +- **Two parts are the target's own, chosen by `WEBCPP_TARGET_EMSCRIPTEN`: the + sealer, natively OpenSSL's AES-256-GCM and in a page `crypto.subtle`, and + the source of randomness, natively OpenSSL's `RAND_bytes` and in a page + `getentropy`; the WebRTC, the relays' session, the timer + (`detail::timer`) and the clocks (`std::chrono::system_clock` and + `std::chrono::steady_clock`) are one code on both.** Until webcpp::crypto + is built (chapter 17), the platform's crypto is the target's own; + Emscripten reads the standard clocks from the page's `Date.now()` and + `performance.now()`, as the browser backend did through embind. A library + chooses its code by config's target macro, not the compiler's (chapter 15, + config). + Source: `doc/platform.adoc` and `doc/design.adoc` (libs/trystero). +- **The platform's one source of randomness is checked wherever it is drawn: + `random()` aborts the program without it, and a seal fails with + `error::backend_failure`.** Without secure randomness nothing is safe; the + browser backend ignored a failed `getentropy` before trystero's refactor, + as chapter 17 recalls, and that is not repeated. + Source: `include/webcpp/trystero/platform/entropy.hpp` and + `include/webcpp/trystero/platform/backend.hpp` (libs/trystero). +- **The window of `backend_config::max_peer_connections_per_minute` (256) + bounds the connections the backend makes for every app and room it serves, + on both targets, beside its runtime's cap.** A room makes at most 64 in any + 57 s, so the default lets four rooms do so at once; and the window is a + policy, not a platform's: in a page a collection frees closed connections + from the census, after which only the window bounds how fast a flood makes + new ones. + Source: `doc/platform.adoc` and `doc/design.adoc` (libs/trystero). +- **The platform backend owns a webcpp::webrtc runtime, made with + `backend_config::runtime` in `backend_config::memory`, at most 256 + connections alive at once, or takes the program's; each of its connections + and channels keeps that runtime alive.** A connection that outlives the + backend in a handler the `io_context` still holds must not outlive the + runtime; and natively libdatachannel's state is the process's, which holds + one runtime at a time, so a program with several backends, or with + webcpp::webrtc beside trystero, gives each the one it made. + Source: `doc/platform.adoc` (libs/trystero). +- **The platform backend's one timer, the core's `detail::timer`, over + webcpp::asio's steady timer, on both targets, numbers its waits, so that a + wait cancelled, restarted or destroyed never fires.** Asio may already have + queued its expiry as a success; on emscripten the wait is in the reactor's + timer queue, so it fires only while the program runs its `io_context`. + Source: `include/webcpp/trystero/detail/timer.hpp` (libs/trystero). +- **The sealer is asynchronous on both targets: natively it works + synchronously and posts its completion.** Web Crypto is asynchronous, so + the interface is, and a completion never runs inside the call that started + it. + Source: `doc/platform.adoc` (libs/trystero) and + `libraries/trystero/openspec/changes/archive/2026-10-09-genesis/reference/research/TRYSTERO_CPP_SPIKE/FINDINGS.md` + (proposals). +- **The relays' WebSocket is one session of webcpp::beast on both targets, + natively over Boost.Beast's own stream and in a page over webcpp::beast's + page `WebSocket`: Asio operations composed by callbacks (resolve, connect, + TLS, handshake, a read loop, one write at a time), each handler bound to + the room's allocator, and a connection that ends during a write clears its + queue while the write finishes on the text it moved out of it.** Beast + allows one write at a time, and the write's completion must never touch + the cleared container; callbacks rather than coroutines, so that no + coroutine frame, and no read buffer, is allocated outside the room's + resource. The session names webcpp::asio and webcpp::beast only, and + serves both targets. + Source: `include/webcpp/trystero/platform/websocket.hpp` (libs/trystero). +- **A write that fails ends the connection at once, reporting one close, + unless the session is already closing; and in a page + `websocket_limits::max_queued_bytes` also bounds the page's + `bufferedAmount`, through webcpp::beast's `queue_limits::send`.** A page's + `WebSocket` writes at once, so what a relay does not read piles up there, + not in the session's queue; webcpp::beast closes past its send limit, and + the close event of a stalled socket may never come, as with the stand-in + of `platform_page_websocket_bound`, whose close never completes. Writes + that fail while the session closes are expected and change nothing, so a + socket reports one close (`platform_page_websocket_late_events`). + Source: `include/webcpp/trystero/platform/websocket.hpp` (libs/trystero). +- **A relay's URL is read with Boost.URL on both targets, by the same rules, + as a page's `WebSocket` reads a `ws://` or `wss://` one: an IPv6 address in + brackets reaches the resolver without them, the scheme in any case, a host + name decoded and in lower case, the scheme's port by default; userinfo, a + fragment, a port beyond 65535, an IPvFuture host, and `http://` and + `https://`, which a page's `WebSocket` alone takes as `ws://` and `wss://`, + are refused, and report a close.** Boost before one's own (chapter 4), and + one reading of a relay URL on both targets, which refuses none of + Trystero's default relays, all `wss://`; the hand-written parser kept the + brackets, so a relay at an IPv6 address was unreachable. + Source: `doc/platform.adoc` (libs/trystero). +- **A relay URL that a page's URL parser reads otherwise fails closed: an + IPv4 address in another form than a dotted quad (`127.1`), and so any host + whose last label is a number; an international name, which a page turns + into its A-label and Boost.URL does not; and a tab, a newline or a + backslash anywhere in it.** `ws://127.1/` reached 127.0.0.1 through the + system's resolver, and an international name went to it as raw UTF-8. + Source: `doc/platform.adoc` (libs/trystero). +- **No function of the platform backend throws, its constructors included: a + TLS context OpenSSL cannot make, or a program's `result` that holds an + error, is kept as that error, `tls_context()` returns it as a + `boost::system::result`, and every `wss://` + relay reports a close while `ws://` ones are still reached.** Chapter 6 (an + API that throws sits behind `WEBCPP_TRYSTERO_NO_EXCEPTIONS`) and chapter 4 + (errors as values); `config.hpp`'s Doc Comment says trystero raises no + exception of its own. + Source: `doc/platform.adoc` (libs/trystero). +- **Every part of trystero, the platform backend included, works with + exceptions and without them on both targets, and no program, test or + headers-alone call asks for `on`.** webcpp::webrtc + calls libdatachannel's C API, which catches what libdatachannel throws and + returns a code; every `platform_*` test but `platform_websocket` also runs + with `exception-handling=off`, as the evidence. + Source: `AGENTS.md` and `test/Jamfile` (libs/trystero). +- **The platform backend's headers and its WebRTC are compiled alone on both + targets, and `platform/page.hpp` on emscripten only, which it refuses + elsewhere with `#error`.** None needs exceptions, so the lint analyses them + without exceptions too, and the lanes, not only the reference's parse, + prove that each compiles on the targets that build it. + Source: `test/Jamfile` (libs/trystero). +- **The platform backend names webcpp::asio and webcpp::beast everywhere.** + The guide's reference reads every header for Emscripten's target, where + both are their browser implementations, with the platform backend's target + built natively, and the headers parse there with no configuration of + Boost.Asio's. + Source: `AGENTS.md` and `doc/Jamfile` (libs/trystero). -- **In the browser the backend binds the page's own `WebSocket` and - `crypto.subtle` through webcpp::asio's bridge, its timers are webcpp::asio's, - and it binds the page's `RTCPeerConnection` through webcpp::webrtc, not - libdatachannel's WebAssembly port.** webcpp::webrtc's browser - implementation binds the page's objects itself, so one peer connection and - data channel serve both targets; datachannel-wasm has no media and hides the - `RTCPeerConnection` it wraps. - Source: `doc/design.adoc` (libs/trystero). -- **A browser program's `main` runs its io_context under a work guard, as +**The platform backend in a page.** + +- **In a page the platform backend reaches the page's own `WebSocket` through + webcpp::beast's page stream and `crypto.subtle` through webcpp::asio's + `async_await`, its timers are webcpp::asio's, and it binds the page's + `RTCPeerConnection` through webcpp::webrtc, not libdatachannel's + WebAssembly port.** webcpp::webrtc's browser implementation binds the + page's objects itself, so one peer connection and data channel serve both + targets; datachannel-wasm has no media and hides the `RTCPeerConnection` + it wraps. + Source: `doc/platform.adoc` and `doc/design.adoc` (libs/trystero). +- **A page's program runs its io_context from `main` under a work guard, as webcpp::asio's model has it, and the page calls C++ only through - `browser::page_call`, which posts.** The owner's directive and decision of - 2026-11-14 on trystero's refactor (its decision 1): chapter 15 asio says - that nothing calls the run family from a JavaScript event and that use - without `run` is unsupported; and under Asyncify an embind call made while - `main` is suspended returns a promise that never settles, and its second - call aborts a debug build (measured with Emscripten 6.0.11). - Source: `doc/browser.adoc` (libs/trystero). + `platform::page_call` (`platform/page.hpp`, emscripten only), which + posts.** The owner's directive and decision of 2026-11-14 on trystero's + refactor (its decision 1): chapter 15 asio says that nothing calls the run + family from a JavaScript event and that use without `run` is unsupported; + and under Asyncify an embind call made while `main` is suspended returns a + promise that never settles, and its second call aborts a debug build + (measured with Emscripten 6.0.11). + Source: `doc/platform.adoc` (libs/trystero). - **An event the page delivers while C++ is already running is posted, not run.** A handler never runs inside the call that caused it, as when node's WebSocket fires `close` from inside `close()`. @@ -5505,190 +5659,151 @@ Boost.URL, and what the core wrote itself onto Boost. `/webcpp/trystero//trystero` brings `/webcpp/asio//asio`, so a program on emscripten is built in one of its suspension variants, jspi by default or asyncify, and its `main` runs the `io_context`, which suspends there. - Source: `doc/browser.adoc` and `AGENTS.md` (libs/trystero). -- **Page events reach C++ through webcpp::asio's bridge, one intrusive - registration per WebSocket and per `page_call`, removed when its object is - destroyed; Web Crypto promises through `async_await`.** A late event for a - destroyed object finds nothing. - Source: `doc/browser.adoc` (libs/trystero). + Source: `doc/platform.adoc` and `AGENTS.md` (libs/trystero). +- **Page events reach C++ through webcpp::asio's bridge: a relay socket's + through webcpp::beast's page stream, which also scopes each event to its + connection, a `page_call`'s through one intrusive registration, removed + when its object is destroyed, and Web Crypto promises through + `async_await`.** A late event for a destroyed object finds nothing. + Source: `doc/platform.adoc` (libs/trystero). - **No JavaScript exception enters WebAssembly: calls that can throw are - caught in JavaScript (`EM_ASM` in inline functions; Web Crypto inside an - `async` function), and every event and page call enters C++ through - webcpp::asio's bridge, which restores the stack pointer, catches a C++ - exception in C++, and only posts.** Measured before the fix, each escape - left 128 bytes of stack and the loop stopped after about 500; a C++ - exception that reached JavaScript kept its object for good, so the bridge - catches it first. + caught in JavaScript (`EM_ASM` in inline functions, trystero's and + webcpp::beast's; Web Crypto inside an `async` function), and every event + and page call enters C++ through webcpp::asio's bridge, which restores the + stack pointer, catches a C++ exception in C++, and only posts.** Measured + before the fix, each escape left 128 bytes of stack and the loop stopped + after about 500; a C++ exception that reached JavaScript kept its object + for good, so the bridge catches it first. Source: `libraries/trystero/openspec/specs/trystero/spec.md` (proposals) - and `doc/browser.adoc` (libs/trystero). -- **Text crosses into JavaScript through `browser::js_string`, straight from - WebAssembly memory, and back through a `TextEncoder`, its length checked - before any copy.** No `std::string` is made to carry it, and a string over - its bound is never copied into WebAssembly. - Source: `doc/browser.adoc` (libs/trystero). -- **The browser's one timer, the core's `detail::timer`, over webcpp::asio's - steady timer, numbers its waits, so that a wait cancelled, restarted or - destroyed never fires.** Asio may already have queued its expiry as a - success; on emscripten the wait is in the reactor's timer queue, so it - fires only while the program runs its `io_context`. - Source: `include/webcpp/trystero/detail/timer.hpp` (libs/trystero). -- **`getentropy` is checked: a failure fails the seal, and aborts in - `random()`.** Without secure randomness nothing is safe, as natively. - Source: `include/webcpp/trystero/browser/backend.hpp` (libs/trystero). -- **A page makes at most `browser::backend::max_peer_connections` (256) peer - connections across all its apps and rooms: the cap, - `runtime_options::max_peer_connections`, of the webcpp::webrtc runtime the - backend owns, over webcpp::webrtc's census of the page, which counts every - connection it makes, with any runtime, from construction until the garbage - collector frees it, and nothing without `FinalizationRegistry`.** Chromium - counts a connection against its 500 until a collection (measured: the 501st - throws "Cannot create so many PeerConnections"), the rest of its count stays - free for what the page makes without a room, and a count that never comes - down would stop the page for good. - Source: `doc/browser.adoc` (libs/trystero). + and `doc/platform.adoc` (libs/trystero). +- **Text crosses into JavaScript through `platform::js_string`, straight from + WebAssembly memory, and a relay's text back through webcpp::beast's page + stream, its UTF-8 length checked against `read_message_max` (1 MiB) before + any copy.** No `std::string` is made to carry it, and a string over its + bound is never copied into WebAssembly. + Source: `doc/platform.adoc` (libs/trystero). +- **A page makes at most `runtime_options::max_peer_connections` (256 by + default) peer connections across all its apps and rooms, the cap of the + backend's webcpp::webrtc runtime over webcpp::webrtc's census of the page, + which counts every connection it makes, with any runtime, from + construction until the garbage collector frees it, and nothing without + `FinalizationRegistry`; and at most 256 a minute, the backend's window.** + Chromium counts a connection against its 500 until a collection (measured: + the 501st throws "Cannot create so many PeerConnections"), the rest of its + count stays free for what the page makes without a room, and a count that + never comes down would stop the page for good. + Source: `doc/platform.adoc` (libs/trystero). - **A page's relay socket has no idle timeout.** A page's `WebSocket` cannot - ping. - Source: `doc/browser.adoc` (libs/trystero). -- **The browser backend requires a secure context.** `crypto.subtle`, which - seals the signaling, exists only there; elsewhere every sealing operation - fails with `error::backend_failure`. - Source: `doc/browser.adoc` (libs/trystero). -- **The browser sealer imports its key on its first operation and queues the - operations that arrive while it imports.** (reason not recorded) + ping, and webcpp::beast's page stream refuses keep-alive pings, so the + session sets none there. + Source: `doc/platform.adoc` (libs/trystero). +- **A page's platform backend requires a secure context for its sealer.** + `crypto.subtle`, which seals the signaling, exists only there; elsewhere + every sealing operation fails with `error::backend_failure`. + Source: `doc/platform.adoc` (libs/trystero). +- **In a page the sealer imports its key on its first operation and queues + the operations that arrive while it imports.** (reason not recorded) Source: `libraries/trystero/openspec/specs/trystero/spec.md` (proposals). - -**The native backend.** +- **A `page_call`'s handler lets no JavaScript error out: it checks the type + of the page's value before converting it.** A `BindingError` or a + `TypeError` out of a handler leaves `run` with it, and the program's run + never resumes (measured with Emscripten 6.0.11 under node, in either + suspension variant), as webcpp::asio's guide says; before `page_call`, + embind's typed functions refused a wrong type outside WebAssembly. + Source: `doc/platform.adoc` (libs/trystero). +- **A `page_call`'s resource holds each call the page made until the + `io_context` runs it or is destroyed, so it outlives the `io_context`; and + the handler reads the page's value as it is when the handler runs.** A + call is an operation the `io_context` holds, which only its run or its + destruction frees, and it carries a handle of the page's value, not a + copy, so a JavaScript object the page changes meanwhile is seen changed + (`platform_page_call`). + Source: `include/webcpp/trystero/platform/page.hpp` (libs/trystero). + +**The platform backend natively.** - **Natively WebRTC is libdatachannel's, through webcpp::webrtc over its C - API, the relays' WebSockets are webcpp::beast's, natively Boost.Beast's - own, and TLS and AES-GCM are OpenSSL's, with libdatachannel built without - its own WebSocket.** The relays then run on the room's executor like - everything else, and the native peer connections are the browser's in + API, the relays' WebSockets are Boost.Beast's own, through webcpp::beast, + and TLS, AES-GCM and randomness are OpenSSL's, with libdatachannel built + without its own WebSocket.** The relays then run on the room's executor + like everything else, and the native peer connections are the browser's in interface. - Source: `doc/native.adoc` (libs/trystero). -- **The native backend names webcpp::asio and webcpp::beast everywhere, its - relays included.** The guide's reference reads every header for - Emscripten's target, where both are their browser implementations, and the - native headers parse there as they are, with no configuration of - Boost.Asio's. - Source: `AGENTS.md` and `doc/Jamfile` (libs/trystero). -- **The sealer is asynchronous on both targets: the native one works - synchronously and posts its completion.** Web Crypto is asynchronous, so the - interface is, and a completion never runs inside the call that started it. - Source: - `libraries/trystero/openspec/changes/archive/2026-10-09-genesis/reference/research/TRYSTERO_CPP_SPIKE/FINDINGS.md` - (proposals). + Source: `doc/platform.adoc` and `doc/building.adoc` (libs/trystero). - **webcpp::webrtc posts every event of libdatachannel to the executor, through a weak reference; no handler runs on libdatachannel's threads.** Its callbacks run on its own threads, and an event that arrives after its object is gone must do nothing; an application with several threads gives the app a strand. - Source: `doc/native.adoc` (libs/trystero). + Source: `doc/platform.adoc` (libs/trystero). - **What libdatachannel does is webcpp::webrtc's: its C API, its automatic negotiation off, and every object it hands out held until its owner lets it go.** An offer or an answer exists only when the signaling asks for one, as in the browser; libdatachannel keeps only weak references, and the spike lost tracks and WebSockets it did not retain. - Source: `doc/native.adoc` (libs/trystero). + Source: `doc/platform.adoc` (libs/trystero). - **Natively a URL libdatachannel cannot parse, as a `stuns:` one, is left out of the connection, each URL being tried alone; in the browser the page refuses the whole connection for a server it cannot use.** webcpp::webrtc refuses the whole configuration for one such URL, and a room has already dropped every server WebRTC refuses; libdatachannel knows no STUN over TLS. - Source: `doc/native.adoc` and `include/webcpp/trystero/native/backend.hpp` - (libs/trystero). -- **A native backend owns a webcpp::webrtc runtime, made with - `backend_config::runtime`, at most 256 connections alive at once, or takes - the program's; each of its connections and channels keeps that runtime - alive.** A connection that outlives the backend in a handler the - `io_context` still holds must not outlive the runtime, and libdatachannel's - state is the process's: a process holds one runtime at a time, so a program - with several native backends, or with webcpp::webrtc beside trystero, gives - each the one it made. - Source: `doc/native.adoc` (libs/trystero). + Natively only: in a page each probe would be a connection the census + counts until a collection. + Source: `doc/platform.adoc` and + `include/webcpp/trystero/platform/backend.hpp` (libs/trystero). - **A channel that closes during adoption before a room binds clears that room's negotiation and restarts its announcements.** No binding exists for the later connection-end callback to remove. Keeping the negotiation marked connected would prevent the room from ever reconnecting. Source: `include/webcpp/trystero/room.hpp` and `test/shared_test.cpp` (libs/trystero). -- **The native timer numbers its waits, so that a wait cancelled, restarted or - destroyed never fires.** Asio may already have queued its expiry as a - success. - Source: `libraries/trystero/openspec/specs/trystero/spec.md` (proposals). -- **The relay WebSocket is one session of Asio operations composed by - callbacks (resolve, connect, TLS, handshake, a read loop, one write at a - time), each handler bound to the room's allocator, and a connection that - ends during a write clears its queue while the write finishes on the text - it moved out of it.** Beast allows one write at a time, and the write's - completion must never touch the cleared container; callbacks rather than - coroutines, so that no coroutine frame, and no read buffer, is allocated - outside the room's resource. The session names webcpp::asio and - webcpp::beast only and compiles for Emscripten too. - Source: `include/webcpp/trystero/native/websocket.hpp` (libs/trystero). -- **A relay's URL is read with Boost.URL as a page's `WebSocket` reads it: an - IPv6 address in brackets reaches the resolver without them, the scheme in - any case, a host name decoded and in lower case, the scheme's port by - default; userinfo, a fragment, a port beyond 65535 and an IPvFuture host are - refused, and report a close.** Boost before one's own (chapter 4); the - hand-written parser kept the brackets, so a relay at an IPv6 address was - unreachable. - Source: `doc/native.adoc` (libs/trystero). +- **`backend_config::bind_address` binds every peer connection to one address; + empty means every interface but the loopback.** Bound to 127.0.0.1, the + peers of one machine connect with no other network, which a test wants. + Natively only: a page cannot bind, and webcpp::webrtc refuses every + connection a page asks it to bind. + Source: `doc/platform.adoc` (libs/trystero). +- **Natively a relay over TLS is verified whatever the verify mode of the + context: the session sets `verify_peer` on its stream before the + handshake.** Asio's `ssl::context(tls_client)` is `verify_none`, and + `set_verify_callback` does not change the mode, so a program's context + made with `load_verify_file` alone accepted any certificate for any name; + a page's `WebSocket` always verifies. + Source: `doc/platform.adoc` (libs/trystero). - **Over TLS the connection names the host (SNI) through - `webcpp::beast::set_server_name` only when it is a name, never an address, - and checks the certificate against the URL's host, a name or an address, - with Asio's `host_name_verification`.** RFC 6066 allows no address in SNI. - Source: `doc/native.adoc` (libs/trystero). + `webcpp::beast::set_server_name` only when it is a name once decoded, never + an address, an escaped dotted quad among them, and checks the certificate + against the URL's host, a name or an address, with Asio's + `host_name_verification`.** RFC 6066 allows no address in SNI; + `wss://%31%32%37.0.0.1/` sent `127.0.0.1` as one. + Source: `doc/platform.adoc` (libs/trystero). - **Relays are verified against the system's certificate authorities, through - `native::make_tls_context()` (TLS 1.2 or newer, peer verification, + `platform::make_tls_context()` (TLS 1.2 or newer, peer verification, OpenSSL's default verify paths, the call Asio's non-throwing `set_default_verify_paths(ec)` makes), and a backend takes a program's own context instead: webcpp's embedded Mozilla roots (`webcpp::asio::make_tls_client_context()`), or a private authority.** The owner's decision of 2026-11-14 on trystero's refactor (its decision 2): no relay's trust changes. A relay whose certificate does not verify is - unreachable, and the room retries it later as it would any other. - Source: `doc/native.adoc` (libs/trystero). -- **A native relay that stops answering is dropped once + unreachable, and the room retries it later as it would any other. In a + page the context records the policy, a client that verifies its peer, and + the browser verifies against its own authorities. + Source: `doc/platform.adoc` (libs/trystero). +- **`platform::detail::openssl_error()` reports the error OpenSSL queued + last, and `make_tls_context()` starts from an empty queue.** The queue's + first error may be one an earlier call left behind; the last is the + failure's. + Source: `include/webcpp/trystero/platform/websocket.hpp` (libs/trystero). +- **On Windows the system's authorities are none unless `SSL_CERT_FILE` or + `SSL_CERT_DIR` names some, so a Windows program gives the backend its own + context.** OpenSSL's default verify paths there are under its build-time + `SSL` directory, which neither Windows nor webcpp fills, and it reads no + Windows certificate store. + Source: `doc/platform.adoc` (libs/trystero). +- **Natively a relay that stops answering is dropped once `websocket_limits::idle_timeout` (30 s) passes with its keep-alive ping, sent halfway, unanswered.** Signaling texts are 2 to 4 KB, so a real room meets the cut only with a relay slower than about 200 B/s. - Source: `doc/native.adoc` (libs/trystero). -- **`backend_config::bind_address` binds every peer connection to one address; - empty means every interface but the loopback.** Bound to 127.0.0.1, the - peers of one machine connect with no other network, which a test wants. - Source: `doc/native.adoc` (libs/trystero). -- **`backend_config::max_peer_connections_per_minute` (256) bounds the - connections a native backend makes for every app and room it serves.** A - room makes at most 64 in any 57 s, so the default lets four rooms do so at - once. - Source: `doc/native.adoc` (libs/trystero). -- **`native::backend::random` aborts the program when OpenSSL has no secure - randomness.** Without secure randomness nothing is safe. - Source: `include/webcpp/trystero/native/backend.hpp` (libs/trystero). -- **No function of the native backend throws, its constructors included: a - TLS context OpenSSL cannot make, or a program's `result` that holds an - error, is kept as that error, `tls_context()` returns it as a - `boost::system::result`, and every `wss://` - relay reports a close while `ws://` ones are still reached.** Chapter 6 (an - API that throws sits behind `WEBCPP_TRYSTERO_NO_EXCEPTIONS`) and chapter 4 - (errors as values); `config.hpp`'s Doc Comment says trystero raises no - exception of its own. - Source: `doc/native.adoc` (libs/trystero). -- **Every part of trystero, the native backend included, works with - exceptions and without them, and no program, test or headers-alone call - asks for `on`.** webcpp::webrtc calls libdatachannel's C - API, which catches what libdatachannel throws and returns a code; - `native_peer_connection` and `native_room` also run with - `exception-handling=off`, as the evidence. - Source: `AGENTS.md` (libs/trystero). -- **The native headers and the backend's WebRTC are compiled alone natively, - as the build asks, and the relay session on emscripten too.** None needs - exceptions, so the lint analyses them without exceptions too; on emscripten - the backend's WebRTC is compiled through the browser backend's header, and - the relay session alone, so that the lanes, not only the reference's - parse, prove it compiles there. - Source: `test/Jamfile` (libs/trystero). + Source: `doc/platform.adoc` (libs/trystero). **Rooms, actions and errors.** @@ -6043,6 +6158,12 @@ Boost.URL, and what the core wrote itself onto Boost. event against 0.12 us (measured). Source: `libraries/trystero/openspec/specs/trystero/spec.md` (proposals) and `include/webcpp/trystero/detail/nostr_strategy.hpp` (libs/trystero). +- **A Nostr event is acted on once only when its id is NIP-01's, 64 lowercase + hexadecimal digits, among the 4096 newest; any other id is acted on each + time and never stored.** Trystero remembers no id and acts on every event; + storing any id, a relay could fill the room's resource with ids of nearly + 1 MiB each. + Source: `include/webcpp/trystero/detail/nostr_strategy.hpp` (libs/trystero). - **A lost relay is retried after a random share of a bound that starts at 3.3 s and doubles to 60 s, and comes back down only after a connection lasted 60 s.** A relay that closes the room at once after each open is then @@ -6080,6 +6201,14 @@ Boost.URL, and what the core wrote itself onto Boost. Source: `libraries/trystero/openspec/changes/archive/2026-11-14-shared-connection/reference/spec.md` (proposals). +- **The platform backend's own state, its copy of `bind_address`, its window + of constructions and its own webcpp::webrtc runtime, is in + `backend_config::memory`, the default resource unless the program gives + one.** Chapter 4's allocation rule; both backends made their window and + their runtime in the default resource. The test `platform_backend`, on both + targets, makes a backend while a counting resource is the default one, + which sees none of it. + Source: `doc/platform.adoc` and `doc/allocation.adoc` (libs/trystero). - **Peer connections, data channels and the frames received on them use the app's resource even while a room negotiates them; relay sockets, sealers and room timers use the room's.** A connection belongs to the app once adopted, @@ -6123,11 +6252,19 @@ Boost.URL, and what the core wrote itself onto Boost. temporaries beyond a stack buffer from the default resource. Source: `doc/allocation.adoc` (libs/trystero). - **A post goes through the `io_context`'s own executor when the room's - executor is one.** Through `webcpp::asio::any_io_executor`, Asio wraps a post - in a function object allocated with `std::allocator` (measured: two - `std::aligned_alloc` per post in every round of five, natively and on - emscripten). - Source: `doc/allocation.adoc` (libs/trystero). + executor is one, and in a page the sealer awaits each Web Crypto promise + through it too, so that after a first seal and open a seal or an open + allocates nothing outside the room's resource.** Through + `webcpp::asio::any_io_executor`, Asio wraps a post in a function object + allocated with `std::allocator` (measured: two `std::aligned_alloc` per + post in every round of five, natively and on emscripten, and two for each + seal and each open of a page's sealer); `platform_page_sealer_allocation` + counts `operator new` and the C library's functions from the start of a + seal or an open to its completion and sees none. The executor is the + program's: on a strand over the `io_context` the wrapper stays Asio's, as + the page lists. + Source: `doc/allocation.adoc` and + `include/webcpp/trystero/platform/sealer.hpp` (libs/trystero). - **The room never binds its allocator over a user's completion handler, and records, when it erases the handler's type, whether its executor is the room's.** A completion handler is the user's, allocated as its own @@ -6147,11 +6284,19 @@ Boost.URL, and what the core wrote itself onto Boost. - **The allocations outside the resources are listed on the page, not claimed: libdatachannel's and OpenSSL's, with the copy libdatachannel's C API makes of a message, `emscripten::val`'s, the JSON storage's counter, Asio's once - per context and its wrapper on a foreign executor, which webcpp::webrtc's - completions get through `any_io_executor`, Beast's stream state, - Emscripten's `select()`, Asyncify's unwind data when the run suspends, and - the entry of each pending Web Crypto promise in the map of webcpp::asio's - bridge.** They belong to a dependency or to Asio, and webcpp::webrtc's + per context and its wrapper on an executor that is not an `io_context`'s, + a strand for one, which webcpp::webrtc's completions get through + `any_io_executor`; natively, for each relay connection, what Boost.Beast + and Asio allocate of their own (the WebSocket's and the TCP stream's + state, the WebSocket's write buffer, the TLS stream's two buffers, the + resolver's state and results, the handshake's request and response and, + for a response that is not 101, its body up to Beast's 8 MiB, which no + option of its stream lowers, the verify callback and its copy of the host, + the waits of Beast's timers and each keep-alive ping's frame), where in a + page the stream's state is in the room's resource; Emscripten's + `select()`, Asyncify's unwind data when the run suspends, and the storage + of the map in which webcpp::asio's bridge finds each pending Web Crypto + promise.** They belong to a dependency or to Asio, and webcpp::webrtc's posts from libdatachannel's threads may not touch a resource used only on the executor. Source: `doc/allocation.adoc` (libs/trystero). @@ -6179,25 +6324,29 @@ Boost.URL, and what the core wrote itself onto Boost. Source: `libraries/trystero/openspec/changes/archive/2026-10-09-genesis/reference/research/TRYSTERO_CPP_SPIKE/FINDINGS.md` (proposals). -- **trystero builds on webcpp::asio, and both backends' WebRTC on - webcpp::webrtc: `/webcpp/trystero//trystero` brings `/webcpp/asio//asio`, - and on emscripten `/webcpp/webrtc//webrtc`; `/webcpp/trystero//native` - brings `/webcpp/webrtc//webrtc` natively, with libdatachannel (MPL 2.0) and - OpenSSL (Apache 2.0), and for the relays `/webcpp/beast//tls`, - `/webcpp//boost_url` and `/webcpp/asio//tls`, whose embedded authorities a - program may choose.** A browser program never includes the native - backend, so neither libdatachannel nor OpenSSL is in it, as OpenSSL is +- **trystero builds on webcpp::asio, and its platform backend on + webcpp::webrtc, webcpp::beast and Boost.URL: `/webcpp/trystero//trystero` + is the rooms alone, which bring `/webcpp/asio//asio` and on no target + webcpp::webrtc; `/webcpp/trystero//platform`, the backend's one target on + both targets in place of `/webcpp/trystero//native`, adds + `/webcpp/webrtc//webrtc` and `/webcpp//boost_url` on both, natively with + libdatachannel (MPL 2.0) and OpenSSL (Apache 2.0) and, for the relays, + `/webcpp/beast//tls` and `/webcpp/asio//tls`, whose embedded authorities a + program may choose, and on emscripten `/webcpp/beast//browser`.** One + target for one class, which a native program and a page's both name; a + page's program links neither libdatachannel nor OpenSSL, as OpenSSL is optional for Asio. Source: `doc/design.adoc` and `build.jam` (libs/trystero). - **Only libsecp256k1 is externally provisioned, through command-line `SECP256K1_ROOT` / `SECP256K1_EMSCRIPTEN_ROOT`, then `.local/`, then native system paths outside Windows; the environment is never read.** Native libdatachannel and its nested dependencies are pinned source targets, built - statically against the same OpenSSL provider as Asio and Beast. Native - Trystero requires `threading=multi`, since libdatachannel runs worker - threads, and no exceptions. Its WebRTC is webcpp::webrtc's, its Asio is - named webcpp::asio and its relays' WebSockets are webcpp::beast's; its - sealer and randomness are still OpenSSL's, whose migration remains. + statically against the same OpenSSL provider as Asio and Beast. The + platform backend natively requires `threading=multi`, since libdatachannel + runs worker threads, and no exceptions. Its WebRTC is webcpp::webrtc's, its + Asio is named webcpp::asio and its relays' WebSockets are webcpp::beast's; + natively its sealer and randomness are still OpenSSL's, whose migration + remains. Source: `doc/building.adoc` (libs/trystero). - **A library found nowhere leaves trystero out with one message, unless `webcpp-require-external=on`, as the CI builds, stops the build.** `b2 test` @@ -6207,11 +6356,12 @@ Boost.URL, and what the core wrote itself onto Boost. superproject's root, their alternatives would be matched against a request without `20`, and none chosen. Source: `build.jam` (libs/trystero). -- **embind is linked as the flag `-lembind`, not with b2's `on`.** - `on` is not a free feature, and b2 ignores one among usage - requirements (measured: a program then fails to link, - `_embind_register_function` undefined). - Source: `build.jam` (libs/trystero). +- **embind is linked as the flag `-lembind`, which `/webcpp/asio//asio` + adds, not with b2's `on`.** `on` is not a free feature, + and b2 ignores one among usage requirements (measured when trystero linked + embind itself: a program then fails to link, `_embind_register_function` + undefined). + Source: `doc/building.adoc` and `AGENTS.md` (libs/trystero). - **On MSVC the external library is `libsecp256k1` with `SECP256K1_STATIC`, the source providers export their static `.lib` archives with the consumer's runtime settings, and tests and examples add `/bigobj`.** A static @@ -6221,8 +6371,8 @@ Boost.URL, and what the core wrote itself onto Boost. Source: `libraries/trystero/openspec/specs/trystero/spec.md` (proposals). - **libdatachannel is built with the compiler and standard library of the programs that link it.** A program built with GCC and libstdc++ does not - link against a libdatachannel built with libc++, though the native headers - still compile alone. + link against a libdatachannel built with libc++, though the platform + backend's headers still compile alone. Source: `doc/building.adoc` (libs/trystero). **Licensing.** @@ -6315,16 +6465,17 @@ Boost.URL, and what the core wrote itself onto Boost. unwind data the C library allocates, as webcpp::asio's own allocation test counts it. Source: `AGENTS.md` (libs/trystero). -- **The browser tests run twice, with exceptions and without - (`*_no_exceptions`).** No JavaScript exception may enter WebAssembly in - either build (owner decision, 2026-10-10). - Source: `libraries/trystero/openspec/specs/trystero/spec.md` (proposals). +- **On emscripten every test of the platform backend runs twice, with + exceptions and without (`*_no_exceptions`).** No JavaScript exception may + enter WebAssembly in either build (owner decision, 2026-10-10). + Source: `libraries/trystero/openspec/specs/trystero/spec.md` (proposals) + and `test/Jamfile` (libs/trystero). - **Every emscripten suite runs in both of webcpp::asio's suspension variants, jspi and asyncify, and a test whose `main` runs the `io_context` ends with `webcpp::test::exit_status`.** trystero links webcpp::asio's runtime, and under Asyncify a `main` that suspended loses what it returns. Source: `AGENTS.md` (libs/trystero). -- **`native_websocket`, the native interop peer and `shared_hardened` are +- **`platform_websocket`, the native interop peer and `shared_hardened` are built with the standard libraries' own checks (`_LIBCPP_HARDENING_MODE_EXTENSIVE`, `_GLIBCXX_ASSERTIONS`).** A completion that touches a container its socket cleared, or a resource past its @@ -7848,7 +7999,7 @@ are unchanged. No crypto implementation or new backend coverage is claimed. contract it relies on, and on failure zeroes the buffer and returns `entropy_unavailable`, or `errc::not_supported` where the environment has no generator.** 256 bytes is the limit of `getentropy`; trystero's browser - backend ignores the result today, which is not repeated; an Emscripten audio + backend ignored the result, which is not repeated; an Emscripten audio worklet has no `crypto`. Source: `libraries/crypto/openspec/changes/genesis/reference/spec.md` section 6 (proposals). @@ -8180,7 +8331,7 @@ are unchanged. No crypto implementation or new backend coverage is claimed. **Migration.** - **Increment 3 moves webcpp::trystero onto the library: `aes256_gcm` with its - 16-byte IVs replaces its native and browser sealers, `random_device::fill` + 16-byte IVs replaces its sealer on both targets, `random_device::fill` its `random`, `secp256k1::keypair` and `/third_party//secp256k1` its signer and external libsecp256k1, and its direct use of OpenSSL goes.** Errors are values, so a system without entropy fails the operation that needed the @@ -9061,17 +9212,16 @@ it says. (`machine.hpp:1322-1328`, `implementations.hpp:81-145`); wasi's response holds its body as a `std::string`; these three are on the roadmap. document has no `Allocator` parameter either, and is not on it. The pages of pratt, - idna, trystero and document do not say which of their types are shareable - (each library's `doc/allocation.adoc`). + idna and document do not say which of their types are shareable (each + library's `doc/allocation.adoc`). - **Types of a fixed meaning (chapter 4).** Plain `int` or `unsigned` where no interface asks for it: pratt's binding powers and `max_depth` (`parser.hpp:54,175,199,309`, `calculator.hpp:988-1017`), wasi's `response.hpp:45` and `entrypoint.hpp:101,122,200,234` (with unqualified - `uintN_t`), idna's `detail/nfc.hpp:229,233`, trystero's - `detail/nostr_strategy.hpp:222-223`, `detail/signaling.hpp:233` and - `protocol/nostr.hpp:49`, lexical's `date_time.hpp:54-144`, - `detail/regex_validator.hpp:71` and `detail/regex_unicode.hpp:35`, and - document's sizes as `std::uint64_t`. The roadmap's review covers it. + `uintN_t`), idna's `detail/nfc.hpp:229,233`, lexical's + `date_time.hpp:54-144`, `detail/regex_validator.hpp:71` and + `detail/regex_unicode.hpp:35`, and document's sizes as `std::uint64_t`. The + roadmap's review covers it. - **What a library builds on (chapter 4).** document hashes with an FNV-1a of its own rather than Boost.Hash2's; lexical has a UTF-8 decoder of its own in `detail`, the third in webcpp. @@ -9217,7 +9367,11 @@ says what the tree does. still cites Trystero's source with a private shorthand, `C/`, where every other comment writes `dist/`. The draft bounded parse (chapter 18) claims guarantee 9, which 9 to 11 now hold, rebases on - `160f431`, and says "about sixty times" where its own figures give 87. + `160f431`, and says "about sixty times" where its own figures give 87; its + question 4 has the browser backend hand a candidate to the page's + `JSON.parse`, where the platform backend's `webrtc::peer_connection` now + parses it with Boost.JSON on both targets + (`include/webcpp/trystero/webrtc/peer_connection.hpp`). - **asio.** The 2026-11-03 amendment reconciles default turn limit 100, supported targets, source-built TLS, private configuration/allocation fixes and guide order. Proposal source snapshots must name the final committed @@ -9238,16 +9392,42 @@ says what the tree does. ### trystero's refactor: open items The first phase of trystero's refactor onto webcpp's libraries and Boost -(trystero's branch `refactor`, 2026-11-14) leaves these to their owners. +(trystero's branch `refactor`, 2026-11-14), with its one platform backend +and the core's `std::chrono` since, leaves these to their owners. - **asio.** `libs/asio/include/webcpp/asio/browser/src.hpp:189` cites a measurement made "in trystero's browser_event_loop_test.cpp", which the browser's move onto webcpp::asio's run model removed; the citation names a - file that no longer exists. + file that no longer exists. `libs/asio/doc/building.adoc:415` names + `/webcpp/trystero//native`, which is now `/webcpp/trystero//platform`, and + says such a program selects exceptions for Trystero's worker-thread + backend, which needs none since webcpp::webrtc's move. - **Chapter 16.** Its "webcpp::webrtc and webcpp::crypto" still leaves the relays' WebSockets to Beast, and its "Trystero on Asio and Beast" calls Asio and Beast foundations for Trystero's later migration, which this phase made for the relays (chapter 15's trystero entry). +- **trystero, its tests and examples.** `test/allocation_test.cpp` still + selects its target by the compiler's `__EMSCRIPTEN__`, where the library + uses config's `WEBCPP_TARGET_EMSCRIPTEN`, the condition chapter 8 asks a + program to share with its library; and the two quick starts, + `example/quick_start.cpp` and `example/native_quick_start.cpp`, are one + program over one backend now, which a later change may make one example on + both targets. +- **trystero, deferred.** Reaching a relay whose host is an international + name, through webcpp::idna, or one written with a WHATWG IPv4 shorthand, + both failing closed today; natively, a deadline on the resolution of a + relay's name, which has none (the system's resolver on Asio's resolver + thread); and a bound on the body of a handshake response that is not 101, + which Boost.Beast reads up to 8 MiB outside the room's resource, and which + no option of its WebSocket stream lowers: it needs a change to Beast, or a + next layer that caps the bytes, which would change the native stream's + type. +- **trystero, the seam's clocks (in progress).** The backend interface still + gives its clocks as `now_ms()`, a `double`, and `unix_seconds()`, an + `std::int64_t`, which `detail/clock.hpp` converts, and making it return + `std::chrono::steady_clock::time_point` and `std::chrono::sys_seconds`, + with the memory backend's virtual clock, is under way in trystero's + refactor. ### webrtc: open questions From b1bc9fdae102273004444df3368d05cdd60df6e8 Mon Sep 17 00:00:00 2001 From: R Date: Sat, 14 Nov 2026 21:45:55 -0300 Subject: [PATCH 20/61] trystero: JSON on webcpp::document (WP7), and document's quote libs/trystero records refactor at a0cfac5: every JSON text trystero reads or writes goes through webcpp::document, read into an external document in a buffer of the room's resource and written field by field with document's quote. libs/document records its quote branch at d6a6d07, the public JSON.stringify quoting trystero writes with. --- libs/document | 2 +- libs/trystero | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/document b/libs/document index 5a239305..d6a6d073 160000 --- a/libs/document +++ b/libs/document @@ -1 +1 @@ -Subproject commit 5a239305e3fb152135369d5ae5789318b17cc790 +Subproject commit d6a6d0732cb638cb4fa5bc95663c0cc2e7bb1c02 diff --git a/libs/trystero b/libs/trystero index 71fc7514..a0cfac5e 160000 --- a/libs/trystero +++ b/libs/trystero @@ -1 +1 @@ -Subproject commit 71fc751441bd8d4fa9a0510195a01b0cebdbff9c +Subproject commit a0cfac5ed745213448f00b47d34511f36e02b950 From 77c9c21499333d7c4b696112ecc2f56960fb7c07 Mon Sep 17 00:00:00 2001 From: R Date: Sat, 14 Nov 2026 21:53:30 -0300 Subject: [PATCH 21/61] guidelines: trystero's JSON on webcpp::document (WP7), and document's quote Chapter 15's trystero entry takes WP7 at trystero a0cfac5: the protocol's texts are written field by field with webcpp::document's quote and read into an external document in a buffer of the room's resource, twice the text and 4 KiB, doubled up to twice the caller's bound and 64 KiB; each caller bounds its text (68,608, 66,560, 1,024 bytes and 16 KiB); the JSON payload is webcpp::document::document or pmr_document; a self id that is not UTF-8 becomes a random one. json_resource and the rooms' JSON storage leave, the outside list names document's working state, and the allocation test's bullet says what it now tracks. document's entry gains quote. Chapter 18 closes the bounded-parse draft as superseded, keeping its record, and says how such a draft stays until its proposal is archived. Chapter 19 drops that draft's discrepancies and records document's working state as an open decision of the owner, document's measured cost, and the inventory's understatement of that working state. AGENTS.md's table names trystero's one platform backend. --- AGENTS.md | 2 +- CODING-GUIDELINES.md | 220 ++++++++++++++++++++++++++++++------------- 2 files changed, 154 insertions(+), 68 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 215d17f2..0b6db94f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -84,7 +84,7 @@ for web developers and for AI developers (`CODING-GUIDELINES.md` chapter 16). | document | a JSON document that behaves as JavaScript does (key order, `JSON.stringify`'s bytes, the array methods), exact in decimal, in one relocatable image; webcpp's own; its parser is Boost.JSON's | native, wasip2, wasip3, emscripten; its oracle lane | a submodule at `libs/document`; its core never throws (`CODING-GUIDELINES.md` chapter 6) | | idna | internationalized domain names: Punycode, UTS 46's ToASCII and ToUnicode, conformant to IdnaTestV2, and IDNA2008's validity, over Unicode 17.0.0 tables generated into its headers; webcpp's own | native, wasip2, wasip3, emscripten; its own lane `tables` | a submodule at `libs/idna`; its errors are values, and its span forms allocate nothing | | lexical | the string formats JSON Schema names (date-time, email, hostname, ipv4/ipv6, uri, iri, uri-template, json-pointer, uuid, regex), each a validator that allocates nothing and a Boost.URL grammar rule; regex is an ECMA-262 syntax validator of its own, checked against V8; depends on idna and Boost.URL; webcpp's own | native, wasip2, wasip3, emscripten; its own lanes `generated` and `oracle` | a submodule at `libs/formats` | -| trystero | a port of Trystero 0.26.0, serverless WebRTC rooms; its backends' WebRTC is webrtc's, and its Asio is named `webcpp::asio` | native, emscripten (both suspension variants); its own lanes `oracle` and `interop` | a submodule at `libs/trystero`; born with the allocation rule through `std::pmr`; works with exceptions on and off on both targets | +| trystero | a port of Trystero 0.26.0, serverless WebRTC rooms; its one platform backend's WebRTC, on both targets, is webrtc's, and its Asio is named `webcpp::asio` | native, emscripten (both suspension variants); its own lanes `oracle` and `interop` | a submodule at `libs/trystero`; born with the allocation rule through `std::pmr`; works with exceptions on and off on both targets | | webrtc | WebRTC peer connections and data channels with the W3C's names in Asio's model, natively over libdatachannel's C API and in the browser over the page's own objects, with exceptions on and off; webcpp's own | native, emscripten; its own lanes `browser` and `interop` | a submodule at `libs/webrtc`; increments 1 and 2 of 3 (`CODING-GUIDELINES.md` chapter 15) | ### The layout diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index 5a1a6c71..a48d3606 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -5034,6 +5034,18 @@ proposals is given relative to `libraries/document/openspec/`. sink's failure stops the writing and is returned unchanged (the 4096 default is a ruling, reason not recorded). Source: `include/webcpp/document/stringify.hpp` (libs/document). +- **`quote` is `JSON.stringify` of a string alone: it appends the string as a + JSON string literal, its quotes included, to any string the caller gives + (`std::string`, `std::pmr::string`, or any type with + `append(const char*, std::size_t)`), with the bytes `stringify` writes of + the same string, from the same code, and that string is the only thing + that allocates.** A JSON text of a fixed shape is then written field by + field into memory the program chooses, without a document, as trystero + writes its protocol's texts. UTF-8 text that is not valid, which no + JavaScript string is, returns `errc::type` and leaves the string as it + was; UTF-16 text writes a lone surrogate as `\u` and four lowercase hex + digits, as JavaScript does since ES2019. + Source: `doc/stringify.adoc` (libs/document). - **The writer walks with a stack of its own that holds node ids, never recursion and never nodes.** A document's depth is then bounded by memory, not by the thread's stack, and nothing the walk holds is stale when the @@ -5356,12 +5368,20 @@ core's times onto `std::chrono` and its integers to a fixed meaning with those Trystero JS computed from the same inputs. Source: `doc/protocol.adoc` (libs/trystero). - **Every text the protocol writes is appended field by field into one - reserved buffer, escaped by Boost.JSON's serializer, never built as a - `boost::json::value`, and a Nostr event's id is hashed over those same - bytes.** The texts are fixed shapes of a few strings and numbers, the - escaping equals what `JSON.stringify` writes, and hashing the written bytes - keeps the id and the text from ever disagreeing. - Source: `libraries/trystero/openspec/specs/trystero/spec.md` (proposals). + reserved buffer, its strings quoted by `webcpp::document::quote`, never + built as a document, and a Nostr event's id is hashed over those same + bytes.** The texts are fixed shapes of a few strings and numbers; `quote` + is `JSON.stringify`'s own quoting, from document's writer, where a document + would copy every string into a node of some 200 bytes and write it again; + and hashing the written bytes keeps the id and the text from ever + disagreeing. + Source: `doc/design.adoc` (libs/trystero). +- **A self id that is not UTF-8 is set aside for a random one when the app is + made, with a configuration report to `app::on_error`, and a local + candidate that is not UTF-8 is not reported.** `quote` refuses invalid + UTF-8, which no JavaScript string holds, and the self id is the only string + a program gives that a signal writes. + Source: `doc/protocol.adoc` (libs/trystero). - **The relay shuffle computes `sin(seed++) * 10000` with `std::sin`.** Every peer of an app, Trystero JS included, must pick the same relays; this relies on `std::sin` and V8's `Math.sin` agreeing on these inputs, which the @@ -5815,8 +5835,8 @@ core's times onto `std::chrono` and its integers to a fixed meaning `libraries/trystero/openspec/changes/archive/2026-10-09-genesis/reference/research/TRYSTERO_CPP_SPIKE/FINDINGS.md` (proposals). - **An asynchronous operation owns its arguments: a value is taken by value, a - view copied once at the call, a `boost::json::value` serialized at once, and - a peer id copied.** A token such as `webcpp::asio::deferred` starts the + view copied once at the call, a JSON document written at once, and a peer + id copied.** A token such as `webcpp::asio::deferred` starts the operation after the call. Source: `doc/usage.adoc` (libs/trystero). - **Text is a view and a copy is a decision: digests are fed the parts of @@ -5842,6 +5862,16 @@ core's times onto `std::chrono` and its integers to a fixed meaning - **`async_receive` refuses a view type at compile time.** A received view would outlive the message. Source: `libraries/trystero/openspec/specs/trystero/spec.md` (proposals). +- **The JSON payload is webcpp::document's: `webcpp::document::document`, the + user's choice of document's own allocation, and `pmr_document`, received + into a buffer of the room's resource; a C++ peer sends what + `JSON.stringify` writes of the document.** The owner's decision 5 of + trystero's refactor keeps no specialization for `boost::json::value`; the + pair mirrors `std::string` and `std::pmr::string`, and a sent document is + written into a string of the room's resource in pieces of 8 bytes, which + no standard library's string keeps outside its own object. + Source: `doc/usage.adoc` and `include/webcpp/trystero/protocol/json.hpp` + (libs/trystero). - **Actions of different types may share a name, which has one receiver slot.** One may receive as views while another sends by moving strings, as the chat example does. @@ -6180,6 +6210,17 @@ core's times onto `std::chrono` and its integers to a fixed meaning before it is copied, and what the room holds unsent for a relay at 4 MiB.** A relay is a third party too. Source: `AGENTS.md` (libs/trystero). +- **Each caller bounds the JSON text it reads, as `parse_options::max_bytes`: + 68,608 bytes for a relay's text, 66,560 for a signal, 1,024 for a + handshake message, 16 KiB for a remote candidate; a longer text is refused + before it is read, as a malformed one is: a relay's text or a signal + dropped, a handshake failed, a candidate not added.** The bounds come from + the fields' own bounds (a sealed offer or answer of 64 KiB with the + longest ids, ten times Trystero's longest handshake message, the bound of a + sealed candidate), as chapter 18's draft had them, so no text a Trystero + peer writes is refused; document keeps no hashed index, so no key set, + read twice or chosen to collide, makes a parse quadratic. + Source: `doc/protocol.adoc` (libs/trystero). - **A signal's fields are bounded: the peer id and the offer id at 64 bytes, a sealed offer or answer at 64 KiB, a sealed candidate at 16 KiB.** Trystero JS bounds none; the bounds refuse nothing a browser writes for a data @@ -6240,17 +6281,16 @@ core's times onto `std::chrono` and its integers to a fixed meaning no allocator since C++17; the app moves `app_config::log` into its resource, which makes `app_config` move-only. Source: `doc/allocation.adoc` (libs/trystero). -- **`json_resource` adapts a `std::pmr::memory_resource` to Boost.JSON over - Boost.Container's header-only base, and equals only itself.** - `boost::container::pmr`'s global resources are compiled, and the CI installs - Boost's headers alone; telling two adapters over one upstream apart would - need RTTI, which a user may build without. - Source: `libraries/trystero/openspec/specs/trystero/spec.md` (proposals). -- **A room makes its JSON storage once, at its construction, and parses with a - `boost::json::parser` over it, never with `boost::json::parse`.** A value a - handler keeps may outlive the room, and `boost::json::parse` takes its - temporaries beyond a stack buffer from the default resource. - Source: `doc/allocation.adoc` (libs/trystero). +- **Every JSON text a room reads is parsed by webcpp::document into a buffer + of the room's resource (of the app's for a remote candidate), an external + document that its owner, `protocol::json::document`, frees with the + buffer: twice the text and 4 KiB, made again twice as large when the parse + fills it, up to twice the caller's bound and 64 KiB.** document's external + storage allocates every value inside the buffer, so the values are in the + resource without a storage of the room's; and the image's bound refuses a + text of thousands of values once it has cost that bound. + Source: `doc/allocation.adoc` and + `include/webcpp/trystero/protocol/json.hpp` (libs/trystero). - **A post goes through the `io_context`'s own executor when the room's executor is one, and in a page the sealer awaits each Web Crypto promise through it too, so that after a first seal and open a seal or an open @@ -6273,9 +6313,11 @@ core's times onto `std::chrono` and its integers to a fixed meaning Source: `AGENTS.md` (libs/trystero). - **`trystero::bytes` and `trystero::payload` keep `std::allocator`; every other container trystero declares is a `std::pmr` one or a Boost container - over `std::pmr::polymorphic_allocator`.** Those two are the - user's choice; `std::pmr::string` and `pmr_bytes` are the types that receive - in the room's resource. + over `std::pmr::polymorphic_allocator`.** Those two are the user's choice, + as `webcpp::document::document` is, whose image a received one takes from + the global `operator new`, as document's owned documents do; + `std::pmr::string`, `pmr_bytes` and `pmr_document` are the types that + receive in the room's resource. Source: `doc/allocation.adoc` (libs/trystero). - **libsecp256k1 signs with a context preallocated in the room's resource, and verifies with its static context.** No allocation of a room escapes its @@ -6283,22 +6325,25 @@ core's times onto `std::chrono` and its integers to a fixed meaning Source: `doc/allocation.adoc` (libs/trystero). - **The allocations outside the resources are listed on the page, not claimed: libdatachannel's and OpenSSL's, with the copy libdatachannel's C API makes - of a message, `emscripten::val`'s, the JSON storage's counter, Asio's once - per context and its wrapper on an executor that is not an `io_context`'s, - a strand for one, which webcpp::webrtc's completions get through - `any_io_executor`; natively, for each relay connection, what Boost.Beast - and Asio allocate of their own (the WebSocket's and the TCP stream's - state, the WebSocket's write buffer, the TLS stream's two buffers, the - resolver's state and results, the handshake's request and response and, - for a response that is not 101, its body up to Beast's 8 MiB, which no - option of its stream lowers, the verify callback and its copy of the host, - the waits of Beast's timers and each keep-alive ping's frame), where in a - page the stream's state is in the room's resource; Emscripten's - `select()`, Asyncify's unwind data when the run suspends, and the storage - of the map in which webcpp::asio's bridge finds each pending Web Crypto - promise.** They belong to a dependency or to Asio, and webcpp::webrtc's - posts from libdatachannel's threads may not touch a resource used only on - the executor. + of a message, `emscripten::val`'s, webcpp::document's working state while + it reads or writes a JSON text (its parser's stack, path and pending text, + its tree's record of each change, its writer's stack), each piece freed + before the call returns, Asio's once per context and its wrapper on an + executor that is not an `io_context`'s, a strand for one, which + webcpp::webrtc's completions get through `any_io_executor`; natively, for + each relay connection, what Boost.Beast and Asio allocate of their own + (the WebSocket's and the TCP stream's state, the WebSocket's write buffer, + the TLS stream's two buffers, the resolver's state and results, the + handshake's request and response and, for a response that is not 101, its + body up to Beast's 8 MiB, which no option of its stream lowers, the verify + callback and its copy of the host, the waits of Beast's timers and each + keep-alive ping's frame), where in a page the stream's state is in the + room's resource; Emscripten's `select()`, Asyncify's unwind data when the + run suspends, and the storage of the map in which webcpp::asio's bridge + finds each pending Web Crypto promise.** They belong to a dependency or to + Asio, and webcpp::webrtc's posts from libdatachannel's threads may not + touch a resource used only on the executor; document's working state waits + for the owner's decision (chapter 19). Source: `doc/allocation.adoc` (libs/trystero). - **No check catches a resource that ends too early: it is declared before the `io_context`, and its lifetime is the user's.** trystero holds a raw pointer @@ -6324,18 +6369,19 @@ core's times onto `std::chrono` and its integers to a fixed meaning Source: `libraries/trystero/openspec/changes/archive/2026-10-09-genesis/reference/research/TRYSTERO_CPP_SPIKE/FINDINGS.md` (proposals). -- **trystero builds on webcpp::asio, and its platform backend on - webcpp::webrtc, webcpp::beast and Boost.URL: `/webcpp/trystero//trystero` - is the rooms alone, which bring `/webcpp/asio//asio` and on no target - webcpp::webrtc; `/webcpp/trystero//platform`, the backend's one target on - both targets in place of `/webcpp/trystero//native`, adds - `/webcpp/webrtc//webrtc` and `/webcpp//boost_url` on both, natively with - libdatachannel (MPL 2.0) and OpenSSL (Apache 2.0) and, for the relays, - `/webcpp/beast//tls` and `/webcpp/asio//tls`, whose embedded authorities a - program may choose, and on emscripten `/webcpp/beast//browser`.** One - target for one class, which a native program and a page's both name; a - page's program links neither libdatachannel nor OpenSSL, as OpenSSL is - optional for Asio. +- **trystero builds on webcpp::asio and webcpp::document, and its platform + backend on webcpp::webrtc, webcpp::beast and Boost.URL: + `/webcpp/trystero//trystero` is the rooms alone, which bring + `/webcpp/asio//asio` and `/webcpp/document//document`, with Boost.JSON's + and Boost.Charconv's definitions, and on no target webcpp::webrtc; + `/webcpp/trystero//platform`, the backend's one target on both targets in + place of `/webcpp/trystero//native`, adds `/webcpp/webrtc//webrtc` and + `/webcpp//boost_url` on both, natively with libdatachannel (MPL 2.0) and + OpenSSL (Apache 2.0) and, for the relays, `/webcpp/beast//tls` and + `/webcpp/asio//tls`, whose embedded authorities a program may choose, and + on emscripten `/webcpp/beast//browser`.** One target for one class, which + a native program and a page's both name; a page's program links neither + libdatachannel nor OpenSSL, as OpenSSL is optional for Asio. Source: `doc/design.adoc` and `build.jam` (libs/trystero). - **Only libsecp256k1 is externally provisioned, through command-line `SECP256K1_ROOT` / `SECP256K1_EMSCRIPTEN_ROOT`, then `.local/`, then native @@ -6451,12 +6497,18 @@ core's times onto `std::chrono` and its integers to a fixed meaning Source: `libraries/trystero/openspec/changes/archive/2026-11-14-shared-connection/reference/spec.md` (proposals). -- **The allocation test replaces the global `operator new`, counts the C - library's allocation functions where the platform shows them, and makes - Asio's once-per-context allocations before it counts.** From construction to - drain it must see only the rooms' JSON storage counters; without the warm-up - the count is 8, not 2. - Source: `doc/allocation.adoc` (libs/trystero). +- **The allocation test tracks every global allocation until it is freed: + exchanging a `std::pmr::string` or a `pmr_bytes` sees none, a + `pmr_document` exactly what its write and read cost webcpp::document, + counted apart; each protocol text costs at most 8 allocations a value and + 16 more; nothing is left at a drain.** webcpp::document's working state + comes and goes inside each parse and write, so the test keeps each global + allocation by its address until it is freed. It replaces the global + `operator new`, counts the C library's allocation functions where the + platform shows them, and makes Asio's once-per-context allocations before + it counts: without them, the 6 they make would still be out at the drain. + Source: `doc/allocation.adoc` and `test/allocation_test.cpp` + (libs/trystero). - **On Emscripten the allocation test replaces `select()` with one that keeps its array on the stack, and under Asyncify counts Asyncify's unwind data apart.** Emscripten's `select()` callocs an array on every call, and Asio's @@ -8834,7 +8886,9 @@ summary. The proposals not yet decided, each briefly, with the questions they leave for the owner. Neither a draft nor a proposal under discussion decides anything: each is here so that a contributor sees what is coming, and its -proposal holds it in full. +proposal holds it in full. A draft that a built change superseded stays, +marked so, with what superseded it, until its proposal is archived with its +status (chapter 14), so that its reasons stay readable. ### json_schema (draft, not decided) @@ -9042,7 +9096,22 @@ Open questions for the owner: - **O6.** The matching interface (D4) in lexical, as json_schema's proposal assumes, or in json_schema itself? -### trystero: bounded JSON parse (draft, not decided) +### trystero: bounded JSON parse (draft, superseded) + +**Superseded** by trystero's JSON on webcpp::document (trystero `a0cfac5`; +chapter 15's trystero entry). document's objects are ordered indices, not +hashed, so the quadratic parse this draft answers is gone, and with it the +bound of 18 members, its `static_assert`, the colliding keys' generator +(question 7) and `parse_payload`; the draft's byte bound for each caller is +adopted as `parse_options::max_bytes`, with an image bound of twice that +bound and 64 KiB. Of its questions, 1 is moot, since no numbered guarantee is +added; 2 no longer matters, since no object's size is bounded; 3 is +answered, the page's differences listing the bounds; 4 is answered, the +platform backend reading a remote candidate, at most 16 KiB of it, on both +targets; 5 and 6 are moot, the allocation test measuring document's cost per +text. Its proposal is still marked `draft` (`.openspec.yaml`, proposals); +archiving it as withdrawn is the owner's (chapter 14). The draft's record +follows as it was. A relay or a peer can stall a room with a text well under the 1 MiB bound: keys that collide in Boost.JSON's object hash, seeded with the object's @@ -9365,13 +9434,7 @@ says what the tree does. the shared connection's delta has the roadmap list shared relay sockets, which `doc/roadmap.adoc` leaves out; `test/oracle/interop/js.html:149` still cites Trystero's source with a private shorthand, `C/`, where every - other comment writes `dist/`. The draft bounded parse - (chapter 18) claims guarantee 9, which 9 to 11 now hold, rebases on - `160f431`, and says "about sixty times" where its own figures give 87; its - question 4 has the browser backend hand a candidate to the page's - `JSON.parse`, where the platform backend's `webrtc::peer_connection` now - parses it with Boost.JSON on both targets - (`include/webcpp/trystero/webrtc/peer_connection.hpp`). + other comment writes `dist/`. - **asio.** The 2026-11-03 amendment reconciles default turn limit 100, supported targets, source-built TLS, private configuration/allocation fixes and guide order. Proposal source snapshots must name the final committed @@ -9392,8 +9455,9 @@ says what the tree does. ### trystero's refactor: open items The first phase of trystero's refactor onto webcpp's libraries and Boost -(trystero's branch `refactor`, 2026-11-14), with its one platform backend -and the core's `std::chrono` since, leaves these to their owners. +(trystero's branch `refactor`, 2026-11-14), with its one platform backend, +the core's `std::chrono` and its JSON on webcpp::document since, leaves +these to their owners. - **asio.** `libs/asio/include/webcpp/asio/browser/src.hpp:189` cites a measurement made "in trystero's browser_event_loop_test.cpp", which the @@ -9428,6 +9492,28 @@ and the core's `std::chrono` since, leaves these to their owners. `std::chrono::steady_clock::time_point` and `std::chrono::sys_seconds`, with the memory backend's virtual clock, is under way in trystero's refactor. +- **trystero, document's working state: an open decision of the owner.** + webcpp::document's parser and writer keep their working state (Boost.JSON's + parser stack, the path and the pending text, the tree's record of each + change, the writer's stack) in the standard allocator, about seven + allocations a value for each text a room reads, each freed before the call + returns. trystero's guarantee 5 and its allocation page + (`doc/guarantees.adoc`, `doc/allocation.adoc`) name it outside the + resources, and measure it; chapter 4 admits such storage only as an + approved exception, and none is approved. Whether the owner approves it, + or document takes a scratch resource for it, is open. +- **trystero, document's cost.** As WP7 measured it, natively at `-O2`, + document reads a relay's event in about 12 us, where Boost.JSON took + 1.6 us, and the chat's debug WebAssembly grew from 29.2 MB to 33.7 MB; the + release size is not measured. Neither figure is recorded in trystero's + tree. +- **The refactor's inventory understated document's working state.** Its + correction of the owner's decision 4 named, outside a document's buffer, + Boost.JSON's parser stack and `stringify`'s string alone; what document + allocates while it reads a text grows with its values, about seven + allocations a value, the tree recording each change. The inventory is the + integrator's working file, outside the tree; trystero's + `doc/allocation.adoc` has the measured list. ### webrtc: open questions From 637cb5c04db271431831d62e61d7e27bbf819a73 Mon Sep 17 00:00:00 2001 From: R Date: Sat, 14 Nov 2026 21:55:26 -0300 Subject: [PATCH 22/61] trystero: AGENTS.md on webcpp::document's JSON --- libs/trystero | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/trystero b/libs/trystero index a0cfac5e..f583207d 160000 --- a/libs/trystero +++ b/libs/trystero @@ -1 +1 @@ -Subproject commit a0cfac5ed745213448f00b47d34511f36e02b950 +Subproject commit f583207dc1978089e827f4c7f24efa7dabaac41f From 6a10a7690fe53e3a33700aff239b904c8e88849a Mon Sep 17 00:00:00 2001 From: R Date: Sat, 14 Nov 2026 22:09:35 -0300 Subject: [PATCH 23/61] trystero: the backend's clocks as std::chrono --- libs/trystero | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/trystero b/libs/trystero index f583207d..aaf67b80 160000 --- a/libs/trystero +++ b/libs/trystero @@ -1 +1 @@ -Subproject commit f583207dc1978089e827f4c7f24efa7dabaac41f +Subproject commit aaf67b80d956f31afaf7b58ade6561e68689deb4 From a9aa83fce1ab1eda0b66232728a514cd2d8142eb Mon Sep 17 00:00:00 2001 From: R Date: Sat, 14 Nov 2026 22:24:37 -0300 Subject: [PATCH 24/61] tools/oracle: a program without twin needs no .expected, as a linked one has none --- CODING-GUIDELINES.md | 4 +++- tools/oracle/twins.py | 9 ++++++--- tools/oracle/twins_test.py | 24 +++++++++++++++++------- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index f7b209d5..8c24f6c2 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -988,7 +988,9 @@ its first user, and the model: what the C++ example prints), or diverges, with the original's output recorded as its own `.expected` and the difference in the appendix (chapter 11), or is listed as without a twin, with the reason, as a line - `: ` of the twin directory's `without-twin.txt`. + `: ` of the twin directory's `without-twin.txt`. A program + with a twin has its `.expected`; one without may have none, as a program + `webcpp.link` links and never runs prints nothing to compare. - **Nothing expected is written by hand.** Only `update-expected` writes an expected result, and it refuses to write a twin's output for a twin that agrees, since that output must be the C++ example's. Nor is a generated diff --git a/tools/oracle/twins.py b/tools/oracle/twins.py index c0b4d4d0..8cc8960b 100755 --- a/tools/oracle/twins.py +++ b/tools/oracle/twins.py @@ -14,7 +14,10 @@ (xstate/actions_order, or a name alone at the top). It has a twin, /, which does on the original what the program does on the port, or a line `: ` in /without-twin.txt, which says -why the original has none. A twin runs as the words after `--` followed by +why it has none. A program with a twin has its output beside it, +/.expected; one without may have none, as a program that is +linked and never run prints nothing to compare (webcpp.link, whose .expected +the page's check refuses). A twin runs as the words after `--` followed by its path (node --conditions=development, for a JavaScript original), in a process group of its own that is killed when it outlives --timeout, colour off whatever the shell asks for. What it prints on the standard output, every @@ -118,7 +121,7 @@ def exemptions(path: Path) -> tuple[dict[str, str], list[str]]: def survey(arguments: Arguments) -> tuple[Tree, list[str]]: """The tree, and every fault that needs no twin to run: the bookkeeping of the programs, the - twins, the outputs and the exemptions, and each program's .expected.""" + twins, the outputs and the exemptions, and the .expected of each program with a twin.""" exemption_file = arguments.twins / EXEMPTIONS exempt, faults = exemptions(exemption_file) tree = Tree(programs=files(arguments.examples, PROGRAM), @@ -135,7 +138,7 @@ def survey(arguments: Arguments) -> tuple[Tree, list[str]]: faults.append(f'{name}: {EXEMPTIONS} names no example') for name in sorted(tree.outputs - tree.twins): faults.append(f'{name}: an output of no twin') - for name in sorted(tree.programs): + for name in sorted(tree.programs & tree.twins): expected = arguments.examples / f'{name}{OUTPUT}' if not expected.is_file(): faults.append(f"{name}: the program's output {expected} does not exist") diff --git a/tools/oracle/twins_test.py b/tools/oracle/twins_test.py index 618beeb6..52b91e69 100755 --- a/tools/oracle/twins_test.py +++ b/tools/oracle/twins_test.py @@ -10,8 +10,9 @@ passes, colour off whatever the shell asks; each fault is named and fails: a difference, a twin that exits non-zero or hangs, an own output equal to the program's, a program without twin and without line, a malformed line, a line or a twin or an output of no program, a twin and a line -for one program, a program without its .expected; --update rewrites a divergent twin's own output -and refuses to make it the program's; a program is found at any depth, and at the top; --list +for one program, a program with a twin and without its .expected, while one without twin needs +none; --update rewrites a divergent twin's own output and refuses to make it the program's; a +program is found at any depth, and at the top; --list runs nothing and accounts for every program; a missing directory, a tree without program, a command not on PATH and a usage error exit 2. Run with the names of some cases to run only those.""" @@ -183,18 +184,26 @@ def test_an_output_of_no_twin_fails(root: Path) -> None: def test_missing_expected_is_a_fault(root: Path) -> None: - # A program without its .expected, with a twin or without one, is named; the others run. + # A program with a twin and without its .expected is named; the others run. tree(root) (root / 'example/xstate/agrees.expected').unlink() - (root / 'example/actors/alone.expected').unlink() write(root / 'twins/xstate/differs.mjs', "console.log('changed');\n") result = runner(root) - for name in ('xstate/agrees', 'actors/alone'): - missing = root / f'example/{name}.expected' - expect(result, 1, f"twins: {name}: the program's output {missing} does not exist") + missing = root / 'example/xstate/agrees.expected' + expect(result, 1, f"twins: xstate/agrees: the program's output {missing} does not exist") assert 'xstate/differs: differs' in result.stderr, result.stderr +def test_a_program_without_twin_needs_no_expected(root: Path) -> None: + # A program linked and never run prints nothing to compare: without twin, it has no output. + tree(root) + (root / 'example/actors/alone.expected').unlink() + expect(runner(root), 0, '') + result = runner(root, '--list', command=()) + expect(result, 0, '') + assert 'without-twin actors/alone\n' in result.stdout, result.stdout + + def test_nested_paths_are_programs(root: Path) -> None: # A program is found at any depth and named by its path; one at the top has no group. tree(root) @@ -292,6 +301,7 @@ def test_usage_errors_exit_2(root: Path) -> None: test_a_twin_of_no_example_fails, test_an_output_of_no_twin_fails, test_missing_expected_is_a_fault, + test_a_program_without_twin_needs_no_expected, test_nested_paths_are_programs, test_another_suffix_and_language, test_list_counts_every_program, From 8994a0de65e4fc8766a90c35ca30182792723e50 Mon Sep 17 00:00:00 2001 From: R Date: Sat, 14 Nov 2026 22:24:37 -0300 Subject: [PATCH 25/61] AGENTS.md: trystero's own lanes, relayed and provider-integration among them --- AGENTS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AGENTS.md b/AGENTS.md index 8ee96348..013f621c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -84,7 +84,7 @@ for web developers and for AI developers (`CODING-GUIDELINES.md` chapter 16). | document | a JSON document that behaves as JavaScript does (key order, `JSON.stringify`'s bytes, the array methods), exact in decimal, in one relocatable image; webcpp's own; its parser is Boost.JSON's | native, wasip2, wasip3, emscripten; its oracle lane | a submodule at `libs/document`; its core never throws (`CODING-GUIDELINES.md` chapter 6) | | idna | internationalized domain names: Punycode, UTS 46's ToASCII and ToUnicode, conformant to IdnaTestV2, and IDNA2008's validity, over Unicode 17.0.0 tables generated into its headers; webcpp's own | native, wasip2, wasip3, emscripten; its own lane `tables` | a submodule at `libs/idna`; its errors are values, and its span forms allocate nothing | | lexical | the string formats JSON Schema names (date-time, email, hostname, ipv4/ipv6, uri, iri, uri-template, json-pointer, uuid, regex), each a validator that allocates nothing and a Boost.URL grammar rule; regex is an ECMA-262 syntax validator of its own, checked against V8; depends on idna and Boost.URL; webcpp's own | native, wasip2, wasip3, emscripten; its own lanes `generated` and `oracle` | a submodule at `libs/formats` | -| trystero | a port of Trystero 0.26.0, serverless WebRTC rooms; its backends' WebRTC is webrtc's, and its Asio is named `webcpp::asio` | native, emscripten (both suspension variants); its own lanes `oracle` and `interop` | a submodule at `libs/trystero`; born with the allocation rule through `std::pmr`; works with exceptions on and off on both targets | +| trystero | a port of Trystero 0.26.0, serverless WebRTC rooms; its backends' WebRTC is webrtc's, and its Asio is named `webcpp::asio` | native, emscripten (both suspension variants); its own lanes `oracle`, `relayed` (its examples over a local relay, natively), `interop` and `provider-integration` | a submodule at `libs/trystero`; born with the allocation rule through `std::pmr`; works with exceptions on and off on both targets | | webrtc | WebRTC peer connections and data channels with the W3C's names in Asio's model, natively over libdatachannel's C API and in the browser over the page's own objects, with exceptions on and off; webcpp's own | native, emscripten; its own lanes `browser` and `interop` | a submodule at `libs/webrtc`; increments 1 and 2 of 3 (`CODING-GUIDELINES.md` chapter 15) | ### The layout From df4f49e0143a2511116ac208c7ee5adbb93d0461 Mon Sep 17 00:00:00 2001 From: R Date: Sat, 14 Nov 2026 22:28:41 -0300 Subject: [PATCH 26/61] trystero: remember a Nostr event id only once it is the event's own --- libs/trystero | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/trystero b/libs/trystero index aaf67b80..4128cc10 160000 --- a/libs/trystero +++ b/libs/trystero @@ -1 +1 @@ -Subproject commit aaf67b80d956f31afaf7b58ade6561e68689deb4 +Subproject commit 4128cc1080f56dcab82d944be0375a76b9fa1ce2 From f0727783cbcc6cbf6455ee993814f843fd571e96 Mon Sep 17 00:00:00 2001 From: R Date: Sat, 14 Nov 2026 23:07:23 -0300 Subject: [PATCH 27/61] trystero: the answerer's signals and the parse bounds tested where they apply --- libs/trystero | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/trystero b/libs/trystero index 62cb27a5..bf631da1 160000 --- a/libs/trystero +++ b/libs/trystero @@ -1 +1 @@ -Subproject commit 62cb27a583bc71d1e41dfa137bfbeb97b9f73e1b +Subproject commit bf631da14ff7d21ff6056906d5baed6ff1cfa4da From 57c16104a11b245f6f49ebd199fc9b5870e56953 Mon Sep 17 00:00:00 2001 From: R Date: Sat, 14 Nov 2026 23:23:41 -0300 Subject: [PATCH 28/61] beast: a WebSocket client layer that bounds the handshake response it reads --- libs/beast | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/beast b/libs/beast index 6c53f854..40e5f3d2 160000 --- a/libs/beast +++ b/libs/beast @@ -1 +1 @@ -Subproject commit 6c53f854070a4eebd844f21c29692e938181f8f6 +Subproject commit 40e5f3d2e311dfbdd3fa710822e7a34a34208f01 From 845295a759696fb92d41e2c633814c952f9d47fb Mon Sep 17 00:00:00 2001 From: R Date: Sat, 14 Nov 2026 23:36:19 -0300 Subject: [PATCH 29/61] trystero: programs show a JSON payload's exact numbers and the payloads a room refuses --- libs/trystero | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/trystero b/libs/trystero index bf631da1..644d2657 160000 --- a/libs/trystero +++ b/libs/trystero @@ -1 +1 @@ -Subproject commit bf631da14ff7d21ff6056906d5baed6ff1cfa4da +Subproject commit 644d265777a9b4901a42c10475072f24206ae648 From ee5a540bd3318485d80f4ff307eafe39ac45584d Mon Sep 17 00:00:00 2001 From: R Date: Sun, 15 Nov 2026 00:07:55 -0300 Subject: [PATCH 30/61] trystero: the WP4 review's fixes to the platform backend --- libs/trystero | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/trystero b/libs/trystero index 644d2657..81fa1bdf 160000 --- a/libs/trystero +++ b/libs/trystero @@ -1 +1 @@ -Subproject commit 644d265777a9b4901a42c10475072f24206ae648 +Subproject commit 81fa1bdf152040c08b25a855812920905cf2e6eb From 13c1d017774b19dd742fc88335025eff064621d5 Mon Sep 17 00:00:00 2001 From: R Date: Sun, 15 Nov 2026 00:25:47 -0300 Subject: [PATCH 31/61] trystero: the flood test on the virtual clock --- libs/trystero | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/trystero b/libs/trystero index 81fa1bdf..7bf2d730 160000 --- a/libs/trystero +++ b/libs/trystero @@ -1 +1 @@ -Subproject commit 81fa1bdf152040c08b25a855812920905cf2e6eb +Subproject commit 7bf2d7302e29da28817ae5e9f91c632a9da72d3d From 85ca12430b68343171250e36a7b0204f5752027c Mon Sep 17 00:00:00 2001 From: R Date: Sun, 15 Nov 2026 01:05:45 -0300 Subject: [PATCH 32/61] trystero: a relay's refusal has its header read alone, through beast's bounded handshake --- libs/trystero | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/trystero b/libs/trystero index 7bf2d730..ab565811 160000 --- a/libs/trystero +++ b/libs/trystero @@ -1 +1 @@ -Subproject commit 7bf2d7302e29da28817ae5e9f91c632a9da72d3d +Subproject commit ab5658115691c2146d0f0b07a6d38056756b3d09 From a5f14eaeab2576e511a5dfcf3b73d6b331c5ca12 Mon Sep 17 00:00:00 2001 From: R Date: Sun, 15 Nov 2026 01:10:10 -0300 Subject: [PATCH 33/61] document: allocators in its storages, every operation's working state among them --- libs/document | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/document b/libs/document index d6a6d073..cc9c9173 160000 --- a/libs/document +++ b/libs/document @@ -1 +1 @@ -Subproject commit d6a6d0732cb638cb4fa5bc95663c0cc2e7bb1c02 +Subproject commit cc9c91739920b7b624888f31e2b6930678e2567c From d67808f01ad307a0cb8d1d01d4dd0329dea3910e Mon Sep 17 00:00:00 2001 From: R Date: Sun, 15 Nov 2026 01:12:47 -0300 Subject: [PATCH 34/61] trystero: the room test's timing cases on the virtual clock --- libs/trystero | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/trystero b/libs/trystero index ab565811..0c19c598 160000 --- a/libs/trystero +++ b/libs/trystero @@ -1 +1 @@ -Subproject commit ab5658115691c2146d0f0b07a6d38056756b3d09 +Subproject commit 0c19c598cb498bb9c686bf68ef9445f2ae5dd2d8 From 6bcae343579e63604525dc28b660bb0ff5ed76d4 Mon Sep 17 00:00:00 2001 From: R Date: Sun, 15 Nov 2026 01:39:06 -0300 Subject: [PATCH 35/61] trystero: every JSON text in a webcpp::document::pmr::document of the room's resource --- libs/trystero | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/trystero b/libs/trystero index 0c19c598..2af79065 160000 --- a/libs/trystero +++ b/libs/trystero @@ -1 +1 @@ -Subproject commit 0c19c598cb498bb9c686bf68ef9445f2ae5dd2d8 +Subproject commit 2af790654aa661162cbb855b5cc8e7eaff341a06 From 6e920146f16359b04560e3b598756b16a58a041b Mon Sep 17 00:00:00 2001 From: R Date: Sun, 15 Nov 2026 01:41:40 -0300 Subject: [PATCH 36/61] trystero: three room cases wait for what they check --- libs/trystero | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/trystero b/libs/trystero index 2af79065..837c6dfa 160000 --- a/libs/trystero +++ b/libs/trystero @@ -1 +1 @@ -Subproject commit 2af790654aa661162cbb855b5cc8e7eaff341a06 +Subproject commit 837c6dfa69ebb6eb34ce44d4c8b2a4279752aff4 From d09d9b128cda0d2b9323f388a2f82c6bb32b4fdc Mon Sep 17 00:00:00 2001 From: R Date: Sun, 15 Nov 2026 02:27:21 -0300 Subject: [PATCH 37/61] trystero: an offer being opened keeps its negotiation's place --- libs/trystero | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/trystero b/libs/trystero index 837c6dfa..ff40d046 160000 --- a/libs/trystero +++ b/libs/trystero @@ -1 +1 @@ -Subproject commit 837c6dfa69ebb6eb34ce44d4c8b2a4279752aff4 +Subproject commit ff40d04635ad4c8a7c0b527fe57691940e5aef83 From a67b3fc56494a96c932f750cfef9179ab77b49a5 Mon Sep 17 00:00:00 2001 From: R Date: Sun, 15 Nov 2026 02:51:57 -0300 Subject: [PATCH 38/61] trystero: each test case in a frame of its own, and the deepest in release under Asyncify --- libs/trystero | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/trystero b/libs/trystero index ff40d046..12588ea7 160000 --- a/libs/trystero +++ b/libs/trystero @@ -1 +1 @@ -Subproject commit ff40d04635ad4c8a7c0b527fe57691940e5aef83 +Subproject commit 12588ea7672e9d2c0f1d0fe9477b5977f45b70d2 From af015eab27e065a5f26134cd6a276c43fad4676d Mon Sep 17 00:00:00 2001 From: R Date: Sun, 15 Nov 2026 02:59:56 -0300 Subject: [PATCH 39/61] webrtc: a data channel's ordered, max_packet_life_time, max_retransmits, protocol and negotiated --- libs/webrtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/webrtc b/libs/webrtc index f6b8eed0..b89d5ce5 160000 --- a/libs/webrtc +++ b/libs/webrtc @@ -1 +1 @@ -Subproject commit f6b8eed0a63a5baf484674943ddaad3f81370e33 +Subproject commit b89d5ce5fb59e6af78841ecabf04effe5b10c472 From 4e3c5378252b34af95b4608bd1d3fc2d96ecf7ae Mon Sep 17 00:00:00 2001 From: R Date: Sun, 15 Nov 2026 03:13:39 -0300 Subject: [PATCH 40/61] trystero: a negotiation opens one offer of its peer at a time --- libs/trystero | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/trystero b/libs/trystero index 12588ea7..459b08c8 160000 --- a/libs/trystero +++ b/libs/trystero @@ -1 +1 @@ -Subproject commit 12588ea7672e9d2c0f1d0fe9477b5977f45b70d2 +Subproject commit 459b08c812c17c90809b9a5c641f265a9cc43bde From 73590277a780afa778f8171a222762cb39bdf247 Mon Sep 17 00:00:00 2001 From: R Date: Sun, 15 Nov 2026 03:22:55 -0300 Subject: [PATCH 41/61] webrtc: natively a channel's max_packet_life_time of 0 follows the unsupported policy --- libs/webrtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/webrtc b/libs/webrtc index b89d5ce5..871a4efd 160000 --- a/libs/webrtc +++ b/libs/webrtc @@ -1 +1 @@ -Subproject commit b89d5ce5fb59e6af78841ecabf04effe5b10c472 +Subproject commit 871a4efdc4feda2b79303eb58488ce13839a339d From 59ec8a0a1a407a5806d9f081e40ed170867ab65c Mon Sep 17 00:00:00 2001 From: R Date: Sun, 15 Nov 2026 03:35:54 -0300 Subject: [PATCH 42/61] guidelines: trystero's refactor at 459b08c, beast's bounded handshake, webrtc's native policy Chapter 15's trystero entry takes the refactor's later work, each bullet checked against trystero 459b08c. The backend interface's clocks are std::chrono (steady_now, unix_now). The relays' session completes into a handler of its own rather than any_completion_handler, drops binary messages, verifies TLS whatever the context's mode on both targets, sets read_message_max before the handshake, refuses a URL whose path RFC 3986 refuses, and natively runs over webcpp::beast's bounded handshake layer; a page's randomness is crypto.getRandomValues behind a JavaScript catch, its sealer reads only an ArrayBuffer, its page_call checks a number's range, and its stream refuses a TLS context the page cannot honour. Every JSON text is a webcpp::document::pmr::document of the room's resource, 16 deep at most for the protocol; a payload's image is bounded by 96 times its text and room_options::max_json_document_bytes, a rejected receive is nothing(), and Asyncify leaves Boost.JSON's parse_* uninstrumented. A room keeps an offer being opened in its place and opens one offer of a peer at a time, and drops a repeated Nostr event only under an id it checked to be the event's own. The evidence: the allocation test sees no global allocation at all, the timing cases run on the virtual clock, the release Asyncify tests run each case in a frame of its own, and the examples run over a relay of their own beside their twins. Chapter 15's beast entry gains the bounded handshake layer; its webrtc entry has its three increments built, and the unsupported policy, with its inline namespace, on both targets since webrtc 871a4ef. Chapter 18's superseded draft names the move onto pmr::document. Chapter 19 closes the seam's clocks, document's working state and the inventory's understatement, the allocation test's macro, the handshake body and trystero's fidelity gap; it records the quick start's single target, a page relay's allocations outside the room's resource, b2's unoptimized emscripten release link, which a separate pull request fixes, and webrtc's D14 against its tree. --- CODING-GUIDELINES.md | 587 ++++++++++++++++++++++++++++--------------- 1 file changed, 391 insertions(+), 196 deletions(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index 13f0a0ec..cea30b5d 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -5293,13 +5293,16 @@ webcpp 0.1.0 (trystero `e9326e9`), which includes the change 2026-10-14), implemented and archived on 2026-11-14, and of webrtc's increment 3 (trystero's branch `webrtc-backend`, 2026-11-14), which moved both backends' WebRTC onto webcpp::webrtc and trystero's Asio onto webcpp::asio, -and of the first phase of trystero's refactor onto webcpp's libraries and -Boost (trystero's branch `refactor`, 2026-11-14), which moved the browser -onto webcpp::asio's run model, the native relays onto webcpp::beast and -Boost.URL, and what the core wrote itself onto Boost, replaced its two -backends by one platform backend (trystero's branch `wp4`), and moved the -core's times onto `std::chrono` and its integers to a fixed meaning -(trystero's branch `wp5`), both merged into `refactor`. +and of trystero's refactor onto webcpp's libraries and Boost (trystero's +branch `refactor`, at `459b08c` on 2026-11-15). The refactor moved the +browser onto webcpp::asio's run model, the native relays onto webcpp::beast +and Boost.URL, and what the core wrote itself onto Boost; replaced the two +backends by one platform backend; moved the core's times, then the backend +interface's clocks, onto `std::chrono` and its integers to a fixed meaning; +gave the examples a relay of their own and twins on Trystero JS; read and +wrote every JSON text with webcpp::document, in the room's resource since +document took an allocator; and bounded what a relay's refused handshake +makes a room read, through webcpp::beast's bounded handshake layer. **Scope and differences from Trystero JS.** @@ -5439,22 +5442,27 @@ core's times onto `std::chrono` and its integers to a fixed meaning `random` fills from a cryptographically secure source.** The bytes become secret keys and nonces. Source: `libraries/trystero/openspec/specs/trystero/spec.md` (proposals). -- **The core keeps its times as `std::chrono` and its integers at a fixed - meaning: a time of the backend's monotonic clock is a - `std::chrono::steady_clock::time_point` (`detail::time_point`) and a delay - a `std::chrono::milliseconds`; a Nostr event's `created_at` and a - subscription's `since` are `std::chrono::sys_seconds`; a Nostr kind and a - counter are `std::uint32_t`, an index or a count a `std::size_t`; and the +- **The core and the backend interface keep their times as `std::chrono` + and their integers at a fixed meaning: a time of the backend's monotonic + clock is a `std::chrono::steady_clock::time_point` (`detail::time_point`), + which `backend::factory::steady_now()` returns from an origin of the + backend's, and a delay a `std::chrono::milliseconds`; a Nostr event's + `created_at` and a subscription's `since` are `std::chrono::sys_seconds`, + which `backend::factory::unix_now()` returns; a Nostr kind and a counter + are `std::uint32_t`, an index or a count a `std::size_t`; and the backend's clocks reach the core only through `detail::steady_now` and - `detail::unix_now`.** Chapter 4's types of a fixed meaning. Every value is - Trystero's number, truncated where Trystero's is, so nothing a peer sees - changes. `double` stays where it is JavaScript's Number on Trystero's side, - which the oracle's fixtures pin: `str_to_num` and the sum of UTF-16 code - units it takes, the relay shuffle, and the action wire's float64 sizes and - offsets. The backend interface itself still gives its clocks as a `double` - of milliseconds (`now_ms`) and an `std::int64_t` of seconds - (`unix_seconds`), which those two functions convert (chapter 19). - Source: `include/webcpp/trystero/detail/clock.hpp` and + `detail::unix_now`, which return the seam's values unconverted.** Chapter + 4's types of a fixed meaning. Every value is Trystero's number, truncated + where Trystero's is, so nothing a peer sees changes. `double` stays where + it is JavaScript's Number on Trystero's side, which the oracle's fixtures + pin: `str_to_num` and the sum of UTF-16 code units it takes, the relay + shuffle, and the action wire's float64 sizes and offsets. The seam's two + methods lost the unit their names carried (`now_ms`, `unix_seconds`) when + their types took it, and the memory backend's virtual clock is a time + point from the steady clock's epoch, so that its tests compare durations + exactly. + Source: `include/webcpp/trystero/backend.hpp`, + `include/webcpp/trystero/detail/clock.hpp` and `include/webcpp/trystero/protocol/nostr.hpp` (libs/trystero). - **ICE servers are checked in the core: an unusable URL, or a TURN server without credentials, is dropped when the app is made and reported, and every @@ -5531,7 +5539,7 @@ core's times onto `std::chrono` and its integers to a fixed meaning - **Two parts are the target's own, chosen by `WEBCPP_TARGET_EMSCRIPTEN`: the sealer, natively OpenSSL's AES-256-GCM and in a page `crypto.subtle`, and the source of randomness, natively OpenSSL's `RAND_bytes` and in a page - `getentropy`; the WebRTC, the relays' session, the timer + `crypto.getRandomValues`; the WebRTC, the relays' session, the timer (`detail::timer`) and the clocks (`std::chrono::system_clock` and `std::chrono::steady_clock`) are one code on both.** Until webcpp::crypto is built (chapter 17), the platform's crypto is the target's own; @@ -5542,9 +5550,13 @@ core's times onto `std::chrono` and its integers to a fixed meaning Source: `doc/platform.adoc` and `doc/design.adoc` (libs/trystero). - **The platform's one source of randomness is checked wherever it is drawn: `random()` aborts the program without it, and a seal fails with - `error::backend_failure`.** Without secure randomness nothing is safe; the - browser backend ignored a failed `getentropy` before trystero's refactor, - as chapter 17 recalls, and that is not repeated. + `error::backend_failure`; in a page it is `crypto.getRandomValues`, called + from JavaScript that catches what it throws, so that a page whose function + is missing or throws has none.** Without secure randomness nothing is + safe: the browser backend ignored a failed `getentropy` before trystero's + refactor, as chapter 17 recalls, and that is not repeated; and Emscripten's + `getentropy` lets the page's exception into WebAssembly, which no call may + (below). Source: `include/webcpp/trystero/platform/entropy.hpp` and `include/webcpp/trystero/platform/backend.hpp` (libs/trystero). - **The window of `backend_config::max_peer_connections_per_minute` (256) @@ -5578,17 +5590,29 @@ core's times onto `std::chrono` and its integers to a fixed meaning `libraries/trystero/openspec/changes/archive/2026-10-09-genesis/reference/research/TRYSTERO_CPP_SPIKE/FINDINGS.md` (proposals). - **The relays' WebSocket is one session of webcpp::beast on both targets, - natively over Boost.Beast's own stream and in a page over webcpp::beast's - page `WebSocket`: Asio operations composed by callbacks (resolve, connect, - TLS, handshake, a read loop, one write at a time), each handler bound to - the room's allocator, and a connection that ends during a write clears its - queue while the write finishes on the text it moved out of it.** Beast + natively Boost.Beast's own WebSocket stream, over webcpp::beast's bounded + handshake layer, and in a page webcpp::beast's page `WebSocket`: Asio + operations composed by callbacks (resolve, connect, TLS, handshake, a read + loop, one write at a time), each handler bound to the room's allocator, + and a connection that ends during a write clears its queue while the write + finishes on the text it moved out of it.** Beast allows one write at a time, and the write's completion must never touch the cleared container; callbacks rather than coroutines, so that no coroutine frame, and no read buffer, is allocated outside the room's resource. The session names webcpp::asio and webcpp::beast only, and serves both targets. Source: `include/webcpp/trystero/platform/websocket.hpp` (libs/trystero). +- **The session's reads and writes complete into a handler of its own, which + carries the room's allocator and no executor, never into Asio's + `any_completion_handler`, and which calls the session's member through a + pointer.** An `any_completion_handler`'s executor is of another type than + the stream's, so Asio made an `any_completion_executor` with `new` for each + operation and wrapped each completion in a function object of its own + (measured natively: six `operator new` for a text sent and its echo + received, and none now, `platform_websocket_allocation`); and through the + pointer misc-no-recursion sees no cycle through Asio's post, on either + target. + Source: `include/webcpp/trystero/platform/websocket.hpp` (libs/trystero). - **A write that fails ends the connection at once, reporting one close, unless the session is already closing; and in a page `websocket_limits::max_queued_bytes` also bounds the page's @@ -5600,13 +5624,18 @@ core's times onto `std::chrono` and its integers to a fixed meaning that fail while the session closes are expected and change nothing, so a socket reports one close (`platform_page_websocket_late_events`). Source: `include/webcpp/trystero/platform/websocket.hpp` (libs/trystero). +- **A relay's binary message is dropped, on both targets.** NIP-01's + messages are texts, and the room would drop a text that is no Nostr + message. + Source: `include/webcpp/trystero/platform/websocket.hpp` (libs/trystero). - **A relay's URL is read with Boost.URL on both targets, by the same rules, as a page's `WebSocket` reads a `ws://` or `wss://` one: an IPv6 address in brackets reaches the resolver without them, the scheme in any case, a host name decoded and in lower case, the scheme's port by default; userinfo, a - fragment, a port beyond 65535, an IPvFuture host, and `http://` and - `https://`, which a page's `WebSocket` alone takes as `ws://` and `wss://`, - are refused, and report a close.** Boost before one's own (chapter 4), and + fragment, a port beyond 65535, an IPvFuture host, a host holding a byte + that a page's URL parser refuses in a host, and `http://` and `https://`, + which a page's `WebSocket` alone takes as `ws://` and `wss://`, are + refused, and report a close.** Boost before one's own (chapter 4), and one reading of a relay URL on both targets, which refuses none of Trystero's default relays, all `wss://`; the hand-written parser kept the brackets, so a relay at an IPv6 address was unreachable. @@ -5614,10 +5643,24 @@ core's times onto `std::chrono` and its integers to a fixed meaning - **A relay URL that a page's URL parser reads otherwise fails closed: an IPv4 address in another form than a dotted quad (`127.1`), and so any host whose last label is a number; an international name, which a page turns - into its A-label and Boost.URL does not; and a tab, a newline or a - backslash anywhere in it.** `ws://127.1/` reached 127.0.0.1 through the - system's resolver, and an international name went to it as raw UTF-8. + into its A-label and Boost.URL does not; a tab, a newline or a backslash + anywhere in it; and a character that RFC 3986 allows in no path, as a + space or `{`, which a page escapes and Boost.URL refuses.** `ws://127.1/` + reached 127.0.0.1 through the system's resolver, and an international name + went to it as raw UTF-8. Source: `doc/platform.adoc` (libs/trystero). +- **A relay over TLS is verified on both targets whatever the verify mode of + the context: the session sets `verify_peer` on its stream before the + handshake, and leaves the context as it is.** Asio's + `ssl::context(tls_client)` is `verify_none`, and `set_verify_callback` + does not change the mode, so natively a program's context made with + `load_verify_file` alone accepted any certificate for any name; and + webcpp::beast's page stream refuses a mode other than `verify_peer`, which + it reads from the stream before the context, so in a page such a context + failed every `wss://` relay, though the page's `WebSocket` always + verifies. + Source: `doc/platform.adoc` and + `include/webcpp/trystero/platform/websocket.hpp` (libs/trystero). - **No function of the platform backend throws, its constructors included: a TLS context OpenSSL cannot make, or a program's `result` that holds an error, is kept as that error, `tls_context()` returns it as a @@ -5700,10 +5743,14 @@ core's times onto `std::chrono` and its integers to a fixed meaning and `doc/platform.adoc` (libs/trystero). - **Text crosses into JavaScript through `platform::js_string`, straight from WebAssembly memory, and a relay's text back through webcpp::beast's page - stream, its UTF-8 length checked against `read_message_max` (1 MiB) before - any copy.** No `std::string` is made to carry it, and a string over its - bound is never copied into WebAssembly. - Source: `doc/platform.adoc` (libs/trystero). + stream, its UTF-8 length checked before any copy against + `read_message_max` (1 MiB), which the session sets before the + handshake.** No `std::string` is made to carry it, and a string over its + bound is never copied into WebAssembly; a page can deliver a relay's first + messages in the task of its open, before the handshake's completion runs, + so a bound set after it had those checked against the stream's 16 MiB. + Source: `doc/platform.adoc` and + `include/webcpp/trystero/platform/websocket.hpp` (libs/trystero). - **A page makes at most `runtime_options::max_peer_connections` (256 by default) peer connections across all its apps and rooms, the cap of the backend's webcpp::webrtc runtime over webcpp::webrtc's census of the page, @@ -5726,13 +5773,32 @@ core's times onto `std::chrono` and its integers to a fixed meaning - **In a page the sealer imports its key on its first operation and queues the operations that arrive while it imports.** (reason not recorded) Source: `libraries/trystero/openspec/specs/trystero/spec.md` (proposals). -- **A `page_call`'s handler lets no JavaScript error out: it checks the type - of the page's value before converting it.** A `BindingError` or a - `TypeError` out of a handler leaves `run` with it, and the program's run - never resumes (measured with Emscripten 6.0.11 under node, in either - suspension variant), as webcpp::asio's guide says; before `page_call`, - embind's typed functions refused a wrong type outside WebAssembly. +- **A page's sealer reads a Web Crypto settlement only when it is an + `ArrayBuffer`, and fails the seal or the open with + `error::backend_failure` otherwise.** Only a page whose `crypto.subtle` + was replaced settles with another value, whose reading as one could throw + (`new Uint8Array(-1)`) or read what it is not. + Source: `include/webcpp/trystero/platform/sealer.hpp` (libs/trystero). +- **In a page, under webcpp::beast's default policy, a TLS context that asks + for what a page cannot honour makes every `wss://` relay report a close: + authorities added, a client certificate or key, options, a method other + than `tls_client` or `sslv23_client`, or a verify callback other than + `host_name_verification` of the relay's host.** The browser makes the + handshake against its own authorities, and webcpp::beast's page stream + refuses what it cannot honour unless `webcpp-beast-unsupported=ignore` + leaves it to the browser (chapter 15, beast). Source: `doc/platform.adoc` (libs/trystero). +- **A `page_call`'s handler lets no JavaScript error out: it checks the type + of the page's value before converting it, and reads a number as a + `double`, checking its range before it becomes an integer.** A + `BindingError` or a `TypeError` out of a handler leaves `run` with it, and + the program's run never resumes (measured with Emscripten 6.0.11 under + node, in either suspension variant), as webcpp::asio's guide says; before + `page_call`, embind's typed functions refused a wrong type outside + WebAssembly; and in a build with assertions embind's `as()` + of a number beyond the type's range, as `1e10`, throws a `TypeError`. + Source: `doc/platform.adoc` and + `include/webcpp/trystero/platform/page.hpp` (libs/trystero). - **A `page_call`'s resource holds each call the page made until the `io_context` runs it or is destroyed, so it outlives the `io_context`; and the handler reads the page's value as it is when the handler runs.** A @@ -5751,6 +5817,17 @@ core's times onto `std::chrono` and its integers to a fixed meaning like everything else, and the native peer connections are the browser's in interface. Source: `doc/platform.adoc` and `doc/building.adoc` (libs/trystero). +- **Natively the relays' WebSocket runs over webcpp::beast's + `bounded_handshake_stream`, made with the room's allocator, with + `response_limits::body` 0: a relay that refuses the upgrade has its + response's header read, at most 8 KiB, and no byte of its body; in a page + the browser reads its own response.** Beast's WebSocket stream reads the + response with a parser of its own, whose limits none of its options + reaches, so a refusal's body was read up to 8 MiB outside the room's + resource (measured: a 4 MiB refusal had the room's thread allocate + 4,199,353 bytes, and 5,144 with the layer, `platform_websocket_allocation`). + Source: `doc/platform.adoc` and + `include/webcpp/trystero/platform/websocket.hpp` (libs/trystero). - **webcpp::webrtc posts every event of libdatachannel to the executor, through a weak reference; no handler runs on libdatachannel's threads.** Its callbacks run on its own threads, and an event that arrives after its object @@ -5784,13 +5861,6 @@ core's times onto `std::chrono` and its integers to a fixed meaning Natively only: a page cannot bind, and webcpp::webrtc refuses every connection a page asks it to bind. Source: `doc/platform.adoc` (libs/trystero). -- **Natively a relay over TLS is verified whatever the verify mode of the - context: the session sets `verify_peer` on its stream before the - handshake.** Asio's `ssl::context(tls_client)` is `verify_none`, and - `set_verify_callback` does not change the mode, so a program's context - made with `load_verify_file` alone accepted any certificate for any name; - a page's `WebSocket` always verifies. - Source: `doc/platform.adoc` (libs/trystero). - **Over TLS the connection names the host (SNI) through `webcpp::beast::set_server_name` only when it is a name once decoded, never an address, an escaped dotted quad among them, and checks the certificate @@ -5864,16 +5934,32 @@ core's times onto `std::chrono` and its integers to a fixed meaning - **`async_receive` refuses a view type at compile time.** A received view would outlive the message. Source: `libraries/trystero/openspec/specs/trystero/spec.md` (proposals). -- **The JSON payload is webcpp::document's: `webcpp::document::document`, the - user's choice of document's own allocation, and `pmr_document`, received - into a buffer of the room's resource; a C++ peer sends what - `JSON.stringify` writes of the document.** The owner's decision 5 of - trystero's refactor keeps no specialization for `boost::json::value`; the - pair mirrors `std::string` and `std::pmr::string`, and a sent document is - written into a string of the room's resource in pieces of 8 bytes, which - no standard library's string keeps outside its own object. - Source: `doc/usage.adoc` and `include/webcpp/trystero/protocol/json.hpp` - (libs/trystero). +- **The JSON payload is document's own pair, `webcpp::document::document`, + in the standard allocator, the user's choice, and + `webcpp::document::pmr::document`, received in the room's resource; a C++ + peer sends what `JSON.stringify` writes of the document, and a rejected + `async_receive` completes with document's `nothing()`, which allocates + nothing.** The owner's decision 5 of trystero's refactor keeps no + specialization for `boost::json::value`, and the owner's decision of + 2026-11-14 gave webcpp::document an allocator; the pair mirrors + `std::string` and `std::pmr::string`, with no alias of trystero's, and a + handle keeps document's rule: it refers to its document object, and moving + the document invalidates it. A sent document is written into a string of + the room's resource in pieces of 8 bytes, which no standard library's + string keeps outside its own object. + Source: `doc/usage.adoc`, `include/webcpp/trystero/room.hpp` and + `include/webcpp/trystero/protocol/json.hpp` (libs/trystero). +- **A received JSON payload's image grows to at most 96 times its length and + 64 KiB, which every valid payload fits, and to at most + `room_options::max_json_document_bytes`, webcpp::document's 64 MiB by + default.** Each value is a node of 192 bytes and takes at least two bytes + of text (measured on every shape, and pinned by the test `protocol`). A + ceiling tied tighter to the text, as a protocol text's is, refused arrays + of a few hundred numbers that Trystero JS delivers, so the program bounds + the memory instead; the bound is a difference, which `diff_json_refused` + shows. + Source: `doc/protocol.adoc`, `doc/differences.adoc` and + `include/webcpp/trystero/protocol/json.hpp` (libs/trystero). - **Actions of different types may share a name, which has one receiver slot.** One may receive as views while another sends by moving strings, as the chat example does. @@ -6170,9 +6256,30 @@ core's times onto `std::chrono` and its integers to a fixed meaning own; the digest is of the opened text, whose sealed encoding a resender can vary. Source: `libraries/trystero/openspec/specs/trystero/spec.md` (proposals). -- **A room holds at most 32 negotiations with peers it is not connected to: an - idle one gives its place to a new peer, and a refused peer is logged once.** - Anyone who knows the app and room ids can announce any number of peer ids. +- **A room holds at most 32 negotiations with peers it is not connected to: + an idle one, holding no connection and no offer of its peer being opened, + gives its place to a new peer, the one idle longest and, of those idle as + long, the one the room took first; a refused peer is logged once.** Anyone + who knows the app and room ids can announce any number of peer ids. + Opening an offer is the sealer's asynchronous step (Web Crypto in a page). + While it counted as idle, a tie in id order at one instant of a page's + coarse clock let new ids arriving meanwhile have honest offers dropped + unopened, their peers joining 2 s later, and let a flood of fresh ids have + every offer opened at once (measured: `room`'s + `an_offer_being_opened_keeps_its_place` and + `a_flood_of_offers_at_one_instant_is_bounded`); now the room opens offers + of at most 32 peers, one offer of each at a time. + Source: `doc/protocol.adoc` (libs/trystero). +- **A negotiation opens one offer of its peer at a time, as Trystero answers + one at a time: until it is opened, another offer in that name is ignored, + and the same offer through another relay has the answer sent there too.** + Each offer sent in a peer's name started an open of its own, holding its + copy, up to 64 KiB, in the room's resource, which only the relays' rate + bounded (measured: 42 offers in one name, 40 of them of 48 KiB, held 42 + opens and 1,976,152 bytes; `room`'s + `offers_in_one_name_are_opened_one_at_a_time`). As with Trystero, a forged + offer opened first has the peer's own wait until the peer sends it again, + 2 s later. Source: `doc/protocol.adoc` (libs/trystero). - **A room makes at most 64 connections in any 57,333 ms, counted from when they were made.** A place freed early by a connection that failed or closed @@ -6182,20 +6289,23 @@ core's times onto `std::chrono` and its integers to a fixed meaning relay, and once in 5.3 s, Trystero's announce interval, per relay.** A flood of low ids must not have the relays rate-limit the room. Source: `doc/protocol.adoc` (libs/trystero). -- **The strategy remembers the last 4096 event ids and drops a repeated one, - in a `boost::unordered_flat_set` hashed with SipHash under a key it draws - when it is made.** A signal reaches the room on several relays and must - reach the signaling once; an id is a relay's choice, and ids chosen to - share a bucket of the standard library's unseeded hash cost 26.7 us an - event against 0.12 us (measured). +- **The strategy remembers the ids of the newest 4096 events whose ids it + checked, and drops a repeated one, in a `boost::unordered_flat_set` hashed + with SipHash under a key it draws when it is made.** A signal reaches the + room on several relays and must reach the signaling once; an id is a + relay's choice, and ids chosen to share a bucket of the standard library's + unseeded hash cost 26.7 us an event against 0.12 us (measured). Source: `libraries/trystero/openspec/specs/trystero/spec.md` (proposals) and `include/webcpp/trystero/detail/nostr_strategy.hpp` (libs/trystero). -- **A Nostr event is acted on once only when its id is NIP-01's, 64 lowercase - hexadecimal digits, among the 4096 newest; any other id is acted on each - time and never stored.** Trystero remembers no id and acts on every event; - storing any id, a relay could fill the room's resource with ids of nearly - 1 MiB each. - Source: `include/webcpp/trystero/detail/nostr_strategy.hpp` (libs/trystero). +- **A Nostr event is dropped as a repeat only when its id is checked to be + its own, the SHA-256 of its NIP-01 serialization + (`protocol::nostr::has_own_id`); any other event is acted on each time + and its id never stored, as Trystero 0.26.0 acts on every event.** A relay + chooses the id it sends, so trusting it would let one relay hide a genuine + event behind a forged one sent first under its id; and a remembered id is + then 64 bytes, whatever a relay sends. + Source: `include/webcpp/trystero/detail/nostr_strategy.hpp` and + `include/webcpp/trystero/protocol/nostr.hpp` (libs/trystero). - **A lost relay is retried after a random share of a bound that starts at 3.3 s and doubles to 60 s, and comes back down only after a connection lasted 60 s.** A relay that closes the room at once after each open is then @@ -6283,15 +6393,16 @@ core's times onto `std::chrono` and its integers to a fixed meaning no allocator since C++17; the app moves `app_config::log` into its resource, which makes `app_config` move-only. Source: `doc/allocation.adoc` (libs/trystero). -- **Every JSON text a room reads is parsed by webcpp::document into a buffer - of the room's resource (of the app's for a remote candidate), an external - document that its owner, `protocol::json::document`, frees with the - buffer: twice the text and 4 KiB, made again twice as large when the parse - fills it, up to twice the caller's bound and 64 KiB.** document's external - storage allocates every value inside the buffer, so the values are in the - resource without a storage of the room's; and the image's bound refuses a - text of thousands of values once it has cost that bound. - Source: `doc/allocation.adoc` and +- **Every JSON text a room reads is parsed by `webcpp::document::parse` into + a `webcpp::document::pmr::document` of the room's resource, of the app's + for a remote candidate, which holds its image and the parse's working + state; a protocol text nests at most 16 deep, and its image grows in place + to at most twice the caller's bound and 64 KiB; trystero keeps no owner of + its own.** document's allocator holds every value and the working state, + so neither is outside the resource; Trystero's texts nest 4 deep at most, + and the image's bound refuses a text of thousands of values once it has + cost that bound. + Source: `doc/allocation.adoc`, `doc/protocol.adoc` and `include/webcpp/trystero/protocol/json.hpp` (libs/trystero). - **A post goes through the `io_context`'s own executor when the room's executor is one, and in a page the sealer awaits each Web Crypto promise @@ -6316,10 +6427,11 @@ core's times onto `std::chrono` and its integers to a fixed meaning - **`trystero::bytes` and `trystero::payload` keep `std::allocator`; every other container trystero declares is a `std::pmr` one or a Boost container over `std::pmr::polymorphic_allocator`.** Those two are the user's choice, - as `webcpp::document::document` is, whose image a received one takes from - the global `operator new`, as document's owned documents do; - `std::pmr::string`, `pmr_bytes` and `pmr_document` are the types that - receive in the room's resource. + as `webcpp::document::document` is, a received one holding its image and + its parse's working state in the standard allocator, as document's + `document` does; `std::pmr::string`, `pmr_bytes` and + `webcpp::document::pmr::document` are the types that receive in the + room's resource. Source: `doc/allocation.adoc` (libs/trystero). - **libsecp256k1 signs with a context preallocated in the room's resource, and verifies with its static context.** No allocation of a room escapes its @@ -6327,25 +6439,26 @@ core's times onto `std::chrono` and its integers to a fixed meaning Source: `doc/allocation.adoc` (libs/trystero). - **The allocations outside the resources are listed on the page, not claimed: libdatachannel's and OpenSSL's, with the copy libdatachannel's C API makes - of a message, `emscripten::val`'s, webcpp::document's working state while - it reads or writes a JSON text (its parser's stack, path and pending text, - its tree's record of each change, its writer's stack), each piece freed - before the call returns, Asio's once per context and its wrapper on an - executor that is not an `io_context`'s, a strand for one, which + of a message, `emscripten::val`'s, Asio's once per context and its wrapper + on an executor that is not an `io_context`'s, a strand for one, which webcpp::webrtc's completions get through `any_io_executor`; natively, for each relay connection, what Boost.Beast and Asio allocate of their own (the WebSocket's and the TCP stream's state, the WebSocket's write buffer, the TLS stream's two buffers, the resolver's state and results, the - handshake's request and response and, for a response that is not 101, its - body up to Beast's 8 MiB, which no option of its stream lowers, the verify - callback and its copy of the host, the waits of Beast's timers and each - keep-alive ping's frame), where in a page the stream's state is in the - room's resource; Emscripten's `select()`, Asyncify's unwind data when the - run suspends, and the storage of the map in which webcpp::asio's bridge - finds each pending Web Crypto promise.** They belong to a dependency or to - Asio, and webcpp::webrtc's posts from libdatachannel's threads may not - touch a resource used only on the executor; document's working state waits - for the owner's decision (chapter 19). + handshake's request and response, the response's header at most 8 KiB, + which webcpp::beast's bounded handshake layer reads, keeping a split + header line in the room's resource, and no byte of a refusal's body, the + verify callback and its copy of the host, the waits of Beast's timers and + each keep-alive ping's frame), where in a page the stream's state is in + the room's resource; in a page, for each relay connection, the results of + webcpp::asio's page resolver, and the strings embind makes of each event's + type, two for a message; Emscripten's `select()`, Asyncify's unwind data + when the run suspends, and the storage of the map in which webcpp::asio's + bridge finds each pending Web Crypto promise.** They belong to a + dependency or to Asio, and webcpp::webrtc's posts from libdatachannel's + threads may not touch a resource used only on the executor; and removing + a page relay's needs a change to webcpp::beast's page stream and to + webcpp::asio's page resolver (chapter 19). Source: `doc/allocation.adoc` (libs/trystero). - **No check catches a resource that ends too early: it is declared before the `io_context`, and its lifetime is the user's.** trystero holds a raw pointer @@ -6385,6 +6498,16 @@ core's times onto `std::chrono` and its integers to a fixed meaning a native program and a page's both name; a page's program links neither libdatachannel nor OpenSSL, as OpenSSL is optional for Asio. Source: `doc/design.adoc` and `build.jam` (libs/trystero). +- **Under Asyncify, `/webcpp/trystero//trystero` leaves Boost.JSON's + recursive descent, the `parse_*` functions of its `basic_parser`, out of + Asyncify's instrumentation (`-sASYNCIFY_REMOVE=@asyncify-remove.json`).** + None of them suspends. Instrumented, a level of a parse took some 6.5 KB of + node's stack in a debug build, so that a peer's first payload nested 256 + deep, document's default, overflowed node's 984 KB at about 150 levels; + uninstrumented it reaches 400, and in a release build more than 1,000 + (measured). A program whose own parse suspends from a selector's callback + cannot link this alias under Asyncify; under JSPI nothing is left out. + Source: `build.jam` and `doc/protocol.adoc` (libs/trystero). - **Only libsecp256k1 is externally provisioned, through command-line `SECP256K1_ROOT` / `SECP256K1_EMSCRIPTEN_ROOT`, then `.local/`, then native system paths outside Windows; the environment is never read.** Native @@ -6475,14 +6598,18 @@ core's times onto `std::chrono` and its integers to a fixed meaning container with no network but the loopback. Source: `doc/guarantees.adoc` (libs/trystero). - **The memory backend has a virtual clock, a deliver, drop or hold frame - filter, deferred opens, injection, failure and a buffering channel, and a - virtual run is bounded by 10^6 timers.** The sharing cases cannot be written - without them, timing cases on a scaled wall clock flake on loaded machines, - and a timer re-armed without delay fails a test by name instead of hanging - it. + filter, deferred opens, held sealer opens, injection, failure and a + buffering channel; the cases whose outcome depends on time run on the + virtual clock, which moves only from timer to timer, and a virtual run is + bounded by 10^6 timers.** The sharing cases cannot be written without + them; on a wall clock, scaled to run faster, a loaded or paused machine had + the rooms' timers fire while a case waited, which changed what it + compared, so those cases failed by chance; and a timer re-armed without + delay fails a test by name instead of hanging it. Source: `libraries/trystero/openspec/changes/archive/2026-11-14-shared-connection/reference/spec.md` - (proposals). + (proposals); `test/support/memory_backend.hpp` and `test/room_test.cpp` + (libs/trystero). - **The hooks' storage uses the default resource, and only when a test sets them.** The allocation test sets none, so its counts do not change. Source: @@ -6500,15 +6627,15 @@ core's times onto `std::chrono` and its integers to a fixed meaning `libraries/trystero/openspec/changes/archive/2026-11-14-shared-connection/reference/spec.md` (proposals). - **The allocation test tracks every global allocation until it is freed: - exchanging a `std::pmr::string` or a `pmr_bytes` sees none, a - `pmr_document` exactly what its write and read cost webcpp::document, - counted apart; each protocol text costs at most 8 allocations a value and - 16 more; nothing is left at a drain.** webcpp::document's working state - comes and goes inside each parse and write, so the test keeps each global - allocation by its address until it is freed. It replaces the global + exchanging a `std::pmr::string`, a `pmr_bytes` or a + `webcpp::document::pmr::document`, reading each protocol text, and both + long cases see none, natively and on emscripten; a planted allocation is + seen, so the zeros are not vacuous.** It replaces the global `operator new`, counts the C library's allocation functions where the - platform shows them, and makes Asio's once-per-context allocations before - it counts: without them, the 6 they make would still be out at the drain. + platform shows them (not MSVC's, nor any under AddressSanitizer), keeps + each global allocation by its address until it is freed, and makes Asio's + once-per-context allocations before it counts: without them, the 6 they + make would still be out at the drain. Source: `doc/allocation.adoc` and `test/allocation_test.cpp` (libs/trystero). - **On Emscripten the allocation test replaces `select()` with one that keeps @@ -6529,6 +6656,18 @@ core's times onto `std::chrono` and its integers to a fixed meaning `webcpp::test::exit_status`.** trystero links webcpp::asio's runtime, and under Asyncify a `main` that suspended loses what it returns. Source: `AGENTS.md` (libs/trystero). +- **Under Asyncify the room, `app_impl` and allocation tests run once more in + a `release` build, with webcpp::asio's 8,192 bytes of Asyncify stack, and a + test whose cases suspend runs each through `webcpp::test::run_case` + (`test/cases.hpp`), in a frame of its own that `main`'s frame never + holds.** b2's emscripten toolset links a `release` build without + optimization, so each suspension saves every local of every frame from + `main` down; at `-O3` a case that `main` alone calls is inlined into it, + and the room test's `main` saved 29,776 bytes at each suspension and + stopped at its first, where through `run_case` its deepest suspension + wrote 3,096 (measured on 2026-11-15 with Emscripten 6.0.11). + Source: `test/cases.hpp`, `test/Jamfile` and `doc/testing.adoc` + (libs/trystero). - **`platform_websocket`, the native interop peer and `shared_hardened` are built with the standard libraries' own checks (`_LIBCPP_HARDENING_MODE_EXTENSIVE`, `_GLIBCXX_ASSERTIONS`).** A completion @@ -6540,9 +6679,37 @@ core's times onto `std::chrono` and its integers to a fixed meaning build fails on a citation that names no anchor.** A comment sends its reader to the promise it relies on, and a stale citation fails the build. Source: `doc/guarantees.adoc` (libs/trystero). -- **The examples are linked and never run, and none has a twin in Trystero's - language; the interop lane compares trystero with Trystero instead.** Each - example needs the public relays or a browser. +- **The examples that join a room run over a relay of their own, and every + example that can have one has its twin on Trystero JS (the owner's + decision 8 of trystero's refactor).** The quick start and each program of + the appendix "Differences" that joins a room run natively in the own lane + `relayed`: `example/run_over_relay.mjs` starts + `test/oracle/interop/relay.mjs` on 127.0.0.1 and names it in + `TRYSTERO_RELAY_URL`, which the program reads; their twins in + `test/oracle/twins/` run in the `oracle` lane, the original as + `node --conditions=development`, through `test/oracle/run_twin.mjs` over a + relay of their own the same way. The public relays are a third party a + build must not depend on, and a relay of the build's own runs Trystero's + code unchanged. A twin's second peer is a second page, a worker thread + (`test/oracle/page.mjs`), since Trystero JS has one `selfId` per page; + Node's WebRTC is werift 0.24.4 as `rtcPolyfill`, which Trystero 0.26.0's + README names for Node. Of 14 programs, the twins agree with 1, the quick + start, and diverge from 11; the chat page and `diff_self_id_not_utf8` have + none, each with its reason in `test/oracle/twins/without-twin.txt`. + Source: `doc/testing.adoc` and `example/Jamfile` (libs/trystero). +- **One quick start, native and deterministic: two apps with self ids the + program fixes meet in `lobby`, exchange one message each way, print them, + leave and exit; without `TRYSTERO_RELAY_URL` they meet over Trystero's + public relays, as a user's program does; its twin agrees.** An example + whose output depends on who joins, and which runs until stopped, has + nothing to compare. The chat page shows the browser, linked and without a + twin: doc-check refuses an `.expected` beside a linked source, so one + source cannot be both (chapter 19). + Source: `example/quick_start.cpp` and `doc/testing.adoc` (libs/trystero); + `tools/doc/doc-check.py` (webcpp). +- **A difference no program can show is recorded with its reason on the + page.** Programs observe only through the public API, and through a + forwarding `backend::factory` where a room hands out nothing. Source: `doc/differences.adoc` (libs/trystero). ### asio (Boost.Asio on native, Emscripten and WASIp2/P3; implemented for 0.1.0 in preparation) @@ -7388,6 +7555,27 @@ facilities separately; a successful compile never proves runtime parity. a per-operation PMR resource may be destroyed inside that callback. Supplied HTTP reads respect the remaining DynamicBuffer maximum capacity and report `http::error::buffer_overflow` when an incomplete parser exhausts it. +- **A WebSocket client bounds the HTTP response its handshake reads with + `websocket::bounded_handshake_stream`, a next layer between the stream and + its transport: it parses the response's header with Beast's own parser + under `response_limits` (by default 8 KiB of header and 1 KiB after a + refusal's header), fails the handshake with `http::error::header_limit` or + `body_limit` after reading at most both bounds, and lets a 101 pass + through unchanged; the plain stream keeps upstream's limits.** The owner's + decision of 2026-11-14: upstream's handshake reads with Beast's default + parser limits, 8 KiB of header and 8 MiB of a refusal's body, outside the + caller's allocator, and natively that is Boost.Beast's own code and on + WASI the shipped copy, neither of which is corrected; a client that + connects to servers it does not trust selects the layer, as + webcpp::trystero's relays do. The layer starts its transport's operations + through a pointer, so that misc-no-recursion sees no cycle through it in a + consumer's lint, and the WASI facade passes an allocator-tagged + construction on to a next layer that uses an allocator + (`std::uses_allocator`), as Boost does natively. The browser's WebSocket + reads its own response; on Emscripten the layer serves only the guest + engine over a supplied channel. + Source: `include/webcpp/beast/websocket/bounded_handshake_stream.hpp` and + `doc/beast.adoc` (libs/beast). - The immutable upstream application corpus contains all 53 executable definitions at its pinned commit. Inventory checks validate original hashes, Jamfiles, CMake definitions and entry points. All adaptations are generated @@ -7409,7 +7597,7 @@ facilities separately; a successful compile never proves runtime parity. controls accompany TLS application evidence. Documentation follows Diataxis in AsciiDoc with MrDocs API reference and executable examples. -### webrtc (WebRTC data channels in Asio's model; own; implementing, increments 1 and 2 of 3) +### webrtc (WebRTC data channels in Asio's model; own; implementing, its three increments built) webcpp::webrtc is a header-only C++20 library of webcpp's own (`kind: own`, although it wraps libdatachannel natively) for peer connections and data @@ -7420,7 +7608,8 @@ where they differ, and `reference/plan.md` holds three increments: the interface, the runtime and the native implementation (built, in `libs/webrtc`, from one import commit of `reference/source/`), the browser implementation over webcpp::asio's bridge with its `browser` and `interop` lanes (built), and -trystero on it. +trystero on it (built, trystero's branch `webrtc-backend`, in its +`refactor`). - **A library of its own on webcpp::asio, not a part of webcpp::beast.** The owner's decision of 2026-11-14: beast is a source-compatible facade of @@ -7489,17 +7678,31 @@ trystero on it. - **In the browser it follows webcpp::beast's browser WebSocket as built: one intrusive registration of the bridge per object, arrivals staged and charged on arrival to the receive bound, one notification posted per batch, - JavaScript's exceptions caught in JavaScript and reported by DOMException - name, and the unsupported policy in an inline namespace with a propagated b2 - feature.** Those patterns are proved; where webrtc differs (a send refused - before the browser sees it leaves the channel open; several event kinds; - terminal cancellation only for the description operations, and in the - browser for adding a candidate, whose promise cannot be called back) the - design and the page say why. The page's census of `RTCPeerConnection`s, - kept in JavaScript until a `FinalizationRegistry` sees each collected, is - what `max_peer_connections` caps there. - Source: `libraries/webrtc/openspec/changes/genesis/design.md` D6, D8, D11, - D12 and D14 (proposals); `doc/browser.adoc` (libs/webrtc). + and JavaScript's exceptions caught in JavaScript and reported by + DOMException name.** Those patterns are proved; where webrtc differs (a + send refused before the browser sees it leaves the channel open; several + event kinds; terminal cancellation only for the description operations, + and in the browser for adding a candidate, whose promise cannot be called + back) the design and the page say why. The page's census of + `RTCPeerConnection`s, kept in JavaScript until a `FinalizationRegistry` + sees each collected, is what `max_peer_connections` caps there. + Source: `libraries/webrtc/openspec/changes/genesis/design.md` D6, D8, D11 + and D12 (proposals); `doc/browser.adoc` (libs/webrtc). +- **What a target cannot honour fails with `operation_not_supported` by + default, or is ignored under the propagated b2 feature + `webcpp-webrtc-unsupported=ignore` where the platform does something + equivalent of its own; on both targets the classes live in an inline + namespace named after the policy, so translation units that disagree fail + to link.** Natively the policy decides a data channel's + `max_packet_life_time` of 0, which libdatachannel's C API takes as 0 + retransmissions, so that a browser peer would read it as `maxRetransmits` + 0 (ruled on 2026-11-15); in the browser, `configuration::bind_address`. A + getter cannot fail: a native channel the peer announced with a lifetime of + 0 reads as `max_retransmits()` 0, whatever the policy. The design put the + native classes outside the namespace, as honouring every setting (chapter + 19). + Source: `libraries/webrtc/openspec/changes/genesis/design.md` D14 + (proposals); `doc/differences.adoc` and `doc/native.adoc` (libs/webrtc). - **The tests run on both targets: natively, on emscripten under Node with a fake connection where a real one is not needed, in headless Chrome with two peers in one page (the `browser` lane), and native against Chrome through a @@ -9100,8 +9303,9 @@ Open questions for the owner: ### trystero: bounded JSON parse (draft, superseded) -**Superseded** by trystero's JSON on webcpp::document (trystero `a0cfac5`; -chapter 15's trystero entry). document's objects are ordered indices, not +**Superseded** by trystero's JSON on webcpp::document (trystero `a0cfac5`, +then on its `webcpp::document::pmr::document`, `2af7906`; chapter 15's +trystero entry). document's objects are ordered indices, not hashed, so the quadratic parse this draft answers is gone, and with it the bound of 18 members, its `static_assert`, the colliding keys' generator (question 7) and `parse_payload`; the draft's byte bound for each caller is @@ -9110,10 +9314,10 @@ bound and 64 KiB. Of its questions, 1 is moot, since no numbered guarantee is added; 2 no longer matters, since no object's size is bounded; 3 is answered, the page's differences listing the bounds; 4 is answered, the platform backend reading a remote candidate, at most 16 KiB of it, on both -targets; 5 and 6 are moot, the allocation test measuring document's cost per -text. Its proposal is still marked `draft` (`.openspec.yaml`, proposals); -archiving it as withdrawn is the owner's (chapter 14). The draft's record -follows as it was. +targets; 5 and 6 are moot, the allocation test showing that no text a room +reads allocates outside its resource. Its proposal is still marked `draft` +(`.openspec.yaml`, proposals); archiving it as withdrawn is the owner's +(chapter 14). The draft's record follows as it was. A relay or a peer can stall a room with a text well under the 1 MiB bound: keys that collide in Boost.JSON's object hash, seeded with the object's @@ -9318,10 +9522,7 @@ it says. - **Fidelity and evidence (chapters 11 and 12).** Sixteen entries of xstate's appendix "Differences" have no `diff_` program (names, src, targets, undefined, system, time, deadlines, timers, tick, stop, gone, core-clock - among them); trystero has no `diff_` program, no twins and no - `without-twin.txt`, and its `test/oracle/Jamfile:16` runs the original - without `--conditions=development`; document has no twins, and its Node is - not pinned. + among them); document has no twins, and its Node is not pinned. ### The text of the rules @@ -9437,6 +9638,10 @@ says what the tree does. which `doc/roadmap.adoc` leaves out; `test/oracle/interop/js.html:149` still cites Trystero's source with a private shorthand, `C/`, where every other comment writes `dist/`. +- **webrtc.** The genesis `design.md` D14 puts the native classes outside the + unsupported policy's inline namespace, since they honoured every setting; + the tree puts them inside it, since natively the policy decides a data + channel's `max_packet_life_time` of 0 (webrtc `871a4ef`). - **asio.** The 2026-11-03 amendment reconciles default turn limit 100, supported targets, source-built TLS, private configuration/allocation fixes and guide order. Proposal source snapshots must name the final committed @@ -9456,10 +9661,11 @@ says what the tree does. ### trystero's refactor: open items -The first phase of trystero's refactor onto webcpp's libraries and Boost -(trystero's branch `refactor`, 2026-11-14), with its one platform backend, -the core's `std::chrono` and its JSON on webcpp::document since, leaves -these to their owners. +trystero's refactor onto webcpp's libraries and Boost (trystero's branch +`refactor`, at `459b08c` on 2026-11-15), with its one platform backend, its +`std::chrono` clocks, its examples' twins, its JSON on webcpp::document's +`pmr::document` and its relays' bounded handshake, leaves these to their +owners. - **asio.** `libs/asio/include/webcpp/asio/browser/src.hpp:189` cites a measurement made "in trystero's browser_event_loop_test.cpp", which the @@ -9468,54 +9674,43 @@ these to their owners. `/webcpp/trystero//native`, which is now `/webcpp/trystero//platform`, and says such a program selects exceptions for Trystero's worker-thread backend, which needs none since webcpp::webrtc's move. -- **Chapter 16.** Its "webcpp::webrtc and webcpp::crypto" still leaves the - relays' WebSockets to Beast, and its "Trystero on Asio and Beast" calls Asio - and Beast foundations for Trystero's later migration, which this phase made - for the relays (chapter 15's trystero entry). -- **trystero, its tests and examples.** `test/allocation_test.cpp` still - selects its target by the compiler's `__EMSCRIPTEN__`, where the library - uses config's `WEBCPP_TARGET_EMSCRIPTEN`, the condition chapter 8 asks a - program to share with its library; and the two quick starts, - `example/quick_start.cpp` and `example/native_quick_start.cpp`, are one - program over one backend now, which a later change may make one example on - both targets. +- **Chapter 16.** Its "webcpp::webrtc and webcpp::crypto" says webrtc's + increment 2 "brings" the browser implementation, built since, and still + leaves the relays' WebSockets to Beast; its "Trystero on Asio and Beast" + calls Asio and Beast foundations for Trystero's later migration, which the + refactor made (chapter 15's trystero entry). +- **trystero, its examples.** trystero's quick start is native alone, its + browser counterpart the chat page: a program with an `.expected` cannot + also be a `webcpp.link` page program, which doc-check refuses; a quick + start on both targets would need doc-check to accept a linked source whose + output another declaration compares. - **trystero, deferred.** Reaching a relay whose host is an international name, through webcpp::idna, or one written with a WHATWG IPv4 shorthand, - both failing closed today; natively, a deadline on the resolution of a + both failing closed today; and natively, a deadline on the resolution of a relay's name, which has none (the system's resolver on Asio's resolver - thread); and a bound on the body of a handshake response that is not 101, - which Boost.Beast reads up to 8 MiB outside the room's resource, and which - no option of its WebSocket stream lowers: it needs a change to Beast, or a - next layer that caps the bytes, which would change the native stream's - type. -- **trystero, the seam's clocks (in progress).** The backend interface still - gives its clocks as `now_ms()`, a `double`, and `unix_seconds()`, an - `std::int64_t`, which `detail/clock.hpp` converts, and making it return - `std::chrono::steady_clock::time_point` and `std::chrono::sys_seconds`, - with the memory backend's virtual clock, is under way in trystero's - refactor. -- **trystero, document's working state: an open decision of the owner.** - webcpp::document's parser and writer keep their working state (Boost.JSON's - parser stack, the path and the pending text, the tree's record of each - change, the writer's stack) in the standard allocator, about seven - allocations a value for each text a room reads, each freed before the call - returns. trystero's guarantee 5 and its allocation page - (`doc/guarantees.adoc`, `doc/allocation.adoc`) name it outside the - resources, and measure it; chapter 4 admits such storage only as an - approved exception, and none is approved. Whether the owner approves it, - or document takes a scratch resource for it, is open. -- **trystero, document's cost.** As WP7 measured it, natively at `-O2`, - document reads a relay's event in about 12 us, where Boost.JSON took - 1.6 us, and the chat's debug WebAssembly grew from 29.2 MB to 33.7 MB; the - release size is not measured. Neither figure is recorded in trystero's - tree. -- **The refactor's inventory understated document's working state.** Its - correction of the owner's decision 4 named, outside a document's buffer, - Boost.JSON's parser stack and `stringify`'s string alone; what document - allocates while it reads a text grows with its values, about seven - allocations a value, the tree recording each change. The inventory is the - integrator's working file, outside the tree; trystero's - `doc/allocation.adoc` has the measured list. + thread). +- **trystero, a page relay's allocations outside the room's resource.** In a + page webcpp::beast's stream reads, through embind, the type of each event + of the page's `WebSocket` into a `std::string` (`deliver`), and a + message's data type into another (`receive_message`), each a C library + allocation: two for each message a relay sends, one each for its open and + its close; and + webcpp::asio's page resolver makes its results with `new`, three for each + connection, five for a host longer than 10 bytes. trystero's + `doc/allocation.adoc` lists them, and `platform_page_relay_allocation` + counts exactly these; removing them needs a change to webcpp::beast's page + stream and to webcpp::asio's page resolver, which the owner has not + decided. +- **trystero, document's cost.** As WP7 measured it, natively at `-O2` and + before document took an allocator, document reads a relay's event in + about 12 us, where Boost.JSON took 1.6 us, and the chat's debug + WebAssembly grew from 29.2 MB to 33.7 MB; neither is measured since, nor + the release size, and neither figure is recorded in trystero's tree. +- **Emscripten's release link.** b2's emscripten toolset links a `release` + build without optimization, so that Asyncify's instrumentation is not + optimized and each suspension saves every frame from `main` down + (trystero's `doc/testing.adoc`), which a separate pull request against + `main` is fixing. ### webrtc: open questions From fc5a2646f7d056b82e49ad3179b86c7eb5edf67a Mon Sep 17 00:00:00 2001 From: R Date: Sun, 15 Nov 2026 03:36:55 -0300 Subject: [PATCH 43/61] trystero: the changelog's ten lines for the whole refactor --- libs/trystero | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/trystero b/libs/trystero index 459b08c8..203cff2f 160000 --- a/libs/trystero +++ b/libs/trystero @@ -1 +1 @@ -Subproject commit 459b08c812c17c90809b9a5c641f265a9cc43bde +Subproject commit 203cff2f5e03955d51991fd477ff7b67ecc66078 From 2d81593840f53dad603c1b9522fd0fd1ef3b7b4d Mon Sep 17 00:00:00 2001 From: R Date: Sun, 15 Nov 2026 03:37:17 -0300 Subject: [PATCH 44/61] guidelines: crypto's Emscripten entropy needs trystero's guard against a JavaScript exception --- CODING-GUIDELINES.md | 6 +++++- libs/trystero | 2 +- libs/webrtc | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index cea30b5d..e0f35fa9 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -8248,7 +8248,11 @@ are unchanged. No crypto implementation or new backend coverage is claimed. Emscripten), and `BCryptGenRandom` with `BCRYPT_USE_SYSTEM_PREFERRED_RNG` on Windows, with no cache, no generator in user space and no weaker fallback.** The owner's decision of 2026-10-11: entropy always takes the safest path, in - code simple enough to be read and checked by anyone. + code simple enough to be read and checked by anyone. Open: on Emscripten, + `getentropy` lets a JavaScript exception from a missing or throwing + `crypto.getRandomValues` into WebAssembly, which trystero measured and + avoided by calling it from a JavaScript block that catches (chapter 15, + trystero); crypto's Emscripten path needs the same guard. Source: `libraries/crypto/openspec/changes/genesis/design.md` D10 (proposals). - **The entropy function asks in pieces of at most 256 bytes, checks the diff --git a/libs/trystero b/libs/trystero index 203cff2f..6f35b389 160000 --- a/libs/trystero +++ b/libs/trystero @@ -1 +1 @@ -Subproject commit 203cff2f5e03955d51991fd477ff7b67ecc66078 +Subproject commit 6f35b38961cb95359fb35a689b3c5ca053334300 diff --git a/libs/webrtc b/libs/webrtc index 871a4efd..5fda378b 160000 --- a/libs/webrtc +++ b/libs/webrtc @@ -1 +1 @@ -Subproject commit 871a4efdc4feda2b79303eb58488ce13839a339d +Subproject commit 5fda378b7441a64f166b4f9e9585591a2fea7766 From dad88b88925b50bdd2c7c7d78c8d080027921a8e Mon Sep 17 00:00:00 2001 From: R Date: Sun, 15 Nov 2026 03:40:01 -0300 Subject: [PATCH 45/61] document: the allocator review's fixes --- libs/document | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/document b/libs/document index cc9c9173..e95b4096 160000 --- a/libs/document +++ b/libs/document @@ -1 +1 @@ -Subproject commit cc9c91739920b7b624888f31e2b6930678e2567c +Subproject commit e95b40966ee453913d458cbaf6656ab87ee2a1c7 From abc0d45d424e2b4287f334d0b8b2ffcc080d3f5e Mon Sep 17 00:00:00 2001 From: R Date: Sun, 15 Nov 2026 03:44:13 -0300 Subject: [PATCH 46/61] guidelines: document's allocators as built at e95b409 Chapter 15's document entry takes the allocator change and its review fixes, each bullet checked against document e95b409. Storage is basic_owned or basic_external of any allocator of std::byte, with the wd::pmr names; the allocator, rebound by construction, holds the owned image, in 16-byte blocks of which a misaligned one is given back as errc::capacity, and every operation's working state. An allocator's failure is errc::capacity with exceptions, through detail::unless_allocation_fails, the content as it was; anything else, and any failure without exceptions, ends the program. A document is allocator-aware as the standard containers are; most const reads ask the allocator for nothing, and the page names those that do; the image is the shareable type. A change its place cannot take is refused before its value is prepared, and an erasure cannot run out of room. A whole text never allocates Boost.JSON's stack, finish_with taking the last chunk; stringify keeps its stack in its string's allocator, and the writer its first 16 frames in room of its own. The allocator tests and their allocators are the evidence. Boost.Interprocess's exceptions.hpp joins the headers document includes. Chapter 19 no longer says document has no Allocator parameter, nor that its page leaves shareable types unsaid; the design discrepancies of the staging and of stringify_to go, the genesis's D5 on the process heap taking their place, and the examples are 22. --- CODING-GUIDELINES.md | 222 ++++++++++++++++++++++++++++++++----------- 1 file changed, 167 insertions(+), 55 deletions(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index e0f35fa9..2f122cba 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -4598,12 +4598,14 @@ proposals is given relative to `libraries/document/openspec/`. floating-point `std::from_chars`, and one code path serves every target. Source: `include/webcpp/document/traits.hpp` (libs/document). - **Of Boost.Interprocess only `offset_ptr.hpp`, - `mem_algo/rbtree_best_fit.hpp` and `sync/null_mutex.hpp` are included, with - a mutex family of document's own, `detail::no_mutexes`; never + `mem_algo/rbtree_best_fit.hpp`, `sync/null_mutex.hpp` and, for the + `bad_alloc` its allocators throw, `exceptions.hpp` are included, with a + mutex family of document's own, `detail::no_mutexes`; never `managed_external_buffer`, `segment_manager`, `allocators/allocator.hpp` or `sync/mutex_family.hpp`.** Those throw bare and do not compile without exceptions. - Source: `include/webcpp/document/detail/heap.hpp` (libs/document). + Source: `include/webcpp/document/detail/heap.hpp` and + `include/webcpp/document/detail/allocation.hpp` (libs/document). - **0.1.0 leaves out BigInt and fixed 256-bit integers.** `decimal128_t` holds 34-digit integers exactly, and Boost.Multiprecision's `int256_t` is 48 bytes, not trivially copyable, with bytes that differ between compilers and @@ -4651,8 +4653,9 @@ proposals is given relative to `libraries/document/openspec/`. `obj[3]` name nothing.** A handle names a member or an element, never both. Source: `doc/javascript.adoc` (libs/document). - **`pop`, `shift`, `splice`, `slice` and `concat` return what they remove or - copy in a new owned document, `result`, which holds `undefined` - for an empty array.** The elements then outlive the array; the cost, an + copy in a new owned document of the source's allocator, an external + source's included, as a `result`, which holds `undefined` for an empty + array.** The elements then outlive the array; the cost, an image allocated per `pop`, is measured and named as a place to tune. Source: `doc/arrays.adoc` (libs/document). - **Indices follow ECMA-262's relative index: a negative index counts from @@ -4813,11 +4816,12 @@ proposals is given relative to `libraries/document/openspec/`. **Errors and exceptions.** -- **The core never throws: every operation that can fail returns `result`, - and every writing function is `[[nodiscard]]` and completes or changes - nothing, a full heap included, in a build with exceptions and in one - without.** The parser's input is the network's, and a failure is a value - the program tests, not a crash. +- **The core never throws an error of its own: every operation that can fail + returns `result`, and every writing function is `[[nodiscard]]` and + completes or changes nothing, a full heap included, in a build with + exceptions and in one without; an allocator's failure is below.** The + parser's input is the network's, and a failure is a value the program + tests, not a crash. Source: `doc/introduction.adoc` (libs/document). - **`errc` names JavaScript's errors first, `syntax`, `type` and `range`, then `capacity`, `not_a_document`, `incompatible_document` and @@ -4845,14 +4849,25 @@ proposals is given relative to `libraries/document/openspec/`. generic program can ask with the concept whether the sugar is there, and the test `no_exceptions` holds the diagnostics. Source: `include/webcpp/document/config.hpp` (libs/document). -- **The process heap's `std::bad_alloc` is not an error value: the text - `stringify` returns, a missing member's key in a handle, the parser's frames - and pending text, and the staging of every tree change live there, mostly - inside `noexcept` functions, where it ends the program.** The image's heap - is never exhausted by surprise, since every operation finds its room - first; the process heap fails as it does for any C++ container, which the - library tolerates. - Source: `include/webcpp/document/detail/tree.hpp` (libs/document). +- **An allocator's failure is an error value: with exceptions, an operation + catches `std::bad_alloc`, a type derived from it, or Boost.Interprocess's + `bad_alloc` where it can still return (`detail::unless_allocation_fails`), + and returns `errc::capacity` with the document's content as it was, since a + change allocates all its working state before its first change; anything + else an allocator throws, and any allocator's failure without exceptions, + ends the program, as it does for a standard container.** A full resource is + then what a full image is, a value the program tests: only the bytes of + the heap's free space may differ, and a failed `parse_into` leaves its + buffer formatted, with the part of the document it built. + Boost.Interprocess's allocators throw a `bad_alloc` of their own, derived + from `std::exception` alone, and anything else leaves a `noexcept` + operation. `stringify`, whose result is its text, and the move assignment + between allocators that neither propagate nor are always equal, which has + no result, throw `std::bad_alloc`; the sugar throws `capacity_error`; and + the standard allocator's image, from the aligned `operator new` that + returns null, is `errc::capacity` in either build. + Source: `doc/allocation.adoc` and + `include/webcpp/document/detail/allocation.hpp` (libs/document). - **An allocation in the image that fails after its probe passed is reported through `boost::throw_exception(std::bad_alloc())`.** It is a bug of the library, never a run-time event, since every operation finds its room @@ -4920,27 +4935,89 @@ proposals is given relative to `libraries/document/openspec/`. **Memory and storage.** -- **Storage is the second template parameter: `owned`, the document's own - 16-aligned buffer, which starts at 4,096 bytes and grows to twice its size - or what an operation needs, up to `max_bytes` (1 GiB by default), or - `external`, a caller's `std::span` such as a browser's memory, - which never grows.** A document can live in memory it does not own, where a - full buffer is `errc::capacity` and changes nothing (the 1 GiB default and - the 4,096 start: reason not recorded). - Source: `doc/images.adoc` (libs/document). -- **An owned buffer comes from the global aligned `operator new` with - `std::nothrow`; document takes no `Allocator` parameter, and `external` - storage is how a program places an image.** (reason not recorded) - Source: `include/webcpp/document/detail/heap.hpp` (libs/document). +- **Storage is the second template parameter, `basic_owned`, the + document's own 16-aligned buffer, which starts at 4,096 bytes and grows to + twice its size or what an operation needs, up to `max_bytes` (1 GiB by + default), or `basic_external`, a caller's `std::span` + such as a browser's memory, which never grows, each of any allocator of + `std::byte`: `owned` and `external` are the standard allocator's, and + `wd::pmr` names a memory resource's (`pmr::owned`, `pmr::external`, + `pmr::document`, `pmr::basic_document`, `pmr::value`, `pmr::const_value`, + `pmr::parser`).** A document can live in memory it does not own, where a + full buffer is `errc::capacity` and changes nothing; and chapter 4 asks + for an allocator, which trystero needs to keep every allocation of a room + in the room's resource (the 1 GiB default and the 4,096 start: reason not + recorded). + Source: `doc/allocation.adoc`, `doc/images.adoc` and + `include/webcpp/document/storage.hpp` (libs/document). +- **The allocator, rebound by construction, holds the owned image and the + working state of every operation, owned or external: the records a change + stages, the stacks of a deep copy and a compaction, the parser's frames, + path, pending text and selectors, the writer's frames and held piece past + its own room, a missing member's key, the buffers a value is prepared in, + and the keys `Object.assign` takes.** A rebound allocator is constructed + from the document's, as the Allocator requirements ask, so one whose + rebinding constructor is explicit serves as well; for an external document + the working state is all the allocator holds. + Source: `doc/allocation.adoc` (libs/document). +- **An owned image is allocated in blocks of 16 bytes, so that a resource is + asked for an alignment of 16, and a buffer given misaligned is given back + at once and is `errc::capacity`; the region keeps the allocator's own + pointer to it, and every pointer inside the image is an `offset_ptr`.** The + image's heap needs 16-aligned addresses, which are over-aligned where + `std::max_align_t`'s alignment is 8, as on arm64 macOS and MSVC, so an + allocator that ignores the request is refused rather than trusted; an + allocator whose pointer carries a segment or a tag gets back what it + handed out; and the standard allocator's image keeps the global aligned + `operator new` that returns null. + Source: `doc/allocation.adoc` and `include/webcpp/document/detail/heap.hpp` + (libs/document). +- **A document is allocator-aware as the standard containers are: a move + takes the allocator; a move assignment between allocators that neither + propagate nor are always equal copies the owned image into the target's + and frees the source's, and is `noexcept` for allocators that propagate or + are always equal and for every external document; the copy constructor + asks `select_on_container_copy_construction`; `clone()` keeps the + document's allocator, and `clone(alloc)`, `create`, `parse`, `parse_into`, + `from_image`, `format`, `open` and `nothing` take one.** A program that + keeps a document in a resource of its own copies it there with `clone()`, + while the copy constructor gives what a standard container's copy gives, + the default resource for a polymorphic allocator; an external image, which + no allocator holds, is taken as it is. + Source: `doc/allocation.adoc` and `include/webcpp/document/document.hpp` + (libs/document). +- **Most `const` reads ask the allocator for nothing, `stringify` among them, + whose text and stack are in the standard allocator; `stringify_to` past + its own room (deeper than 16 containers, or a piece over 4096 bytes), + `operator[]` of a missing member whose key is longer than a short string + holds, and each copy of that handle, `clone`, `slice`, `concat` and + `compact_into` do, so that threads using those on one document at once + need a resource safe for several threads.** A standard container + allocates nothing in a `const` member, and several threads read it at + once whatever its resource; a document's reads keep that promise but for + those, which the page lists. + Source: `doc/allocation.adoc` (libs/document). +- **The image is the shareable type; a `basic_document`, its handles, its + parsers, its writers and the views of the pools hold the process's + addresses, the image's and the allocator's, and are not.** Each process + that maps an image opens it with a document of its own. + Source: `doc/allocation.adoc` (libs/document). - **Every change finds its room first: it lists its blocks (a node bounded by `node_probe_bytes`, `sizeof(node) + 128`, a string at its exact size), probes the heap with the non-throwing `allocate` and frees the probes, - grows an owned region or returns `errc::capacity`, then allocates for real - and rearranges by steps that cannot allocate.** A full heap is then an - error value and the document is unchanged; Boost.MultiIndex does not name - its node type, hence the bound, and the heap is deterministic, so the - probed blocks are found again. - Source: `changes/archive/2026-10-12-genesis/design.md` (proposals). + grows an owned region or returns `errc::capacity`, stages its working + state in the document's allocator, then allocates for real and rearranges + by steps that cannot allocate; a change that its place cannot take is + refused before its value is prepared, and an erasure lists the nodes it + erases through those nodes themselves, so it cannot run out of room, + though it still returns `errc::type` or `errc::range`.** A full heap is + then an error value and the document is unchanged; Boost.MultiIndex does + not name its node type, hence the bound, and the heap is deterministic, so + the probed blocks are found again. A refusal that allocates nothing keeps + the promise that a document holding nothing allocates nothing, and a + lookup by key and `==` allocate nothing either. + Source: `changes/archive/2026-10-12-genesis/design.md` (proposals); + `doc/allocation.adoc` (libs/document). - **A `modify` only swaps prepared values.** Boost.MultiIndex erases an element whose `modify` throws. Source: `AGENTS.md` (libs/document). @@ -4997,6 +5074,16 @@ proposals is given relative to `libraries/document/openspec/`. node by ids.** The document may grow and move between chunks, numbers stay exact, and any split gives the document a whole parse gives. Source: `changes/archive/2026-10-12-genesis/design.md` (proposals). +- **A text given whole, to `parse`, `parse_into` or the `finish_with(last)` + of a parser given no text before, never suspends Boost.JSON's parser; a + parse fed in chunks makes it allocate its suspension stack in the global + heap, once at the first suspension and again at each deeper one, the one + allocation of a parse outside the document's allocator; `finish()` keeps + its published signature.** Boost.JSON offers no way to place that stack; + and `finish_with` is a member of its own, since an overload of `finish` + would have `&basic_parser::finish` compile no more without a cast. + Source: `doc/allocation.adoc` and `include/webcpp/document/parser.hpp` + (libs/document). - **A parser that failed, by its text, a limit or a callback's failure or exception, stays failed, and a finished one takes no more text, until `reset()`.** (reason not recorded) @@ -5026,16 +5113,24 @@ proposals is given relative to `libraries/document/openspec/`. **Writing JSON.** - **`stringify` returns a `std::string` of `JSON.stringify(v, null, - indent)`'s bytes, the indent clamped to 10, and no text for `undefined`.** - `JSON.stringify` clamps its third argument to 10 and returns no text for - `undefined`. - Source: `include/webcpp/document/detail/writer.hpp` (libs/document). + indent)`'s bytes, the indent clamped to 10, and no text for `undefined`, + and keeps its stack in that string's allocator, asking the document's for + nothing.** `JSON.stringify` clamps its third argument to 10 and returns no + text for `undefined`; and a `const` read that asks a document's resource + for nothing can run on several threads at once. + Source: `include/webcpp/document/detail/writer.hpp` and + `include/webcpp/document/stringify.hpp` (libs/document). - **`stringify_to` writes the same bytes to a sink, a callable returning `void` or `result` used in place and never copied, in pieces of at - most `chunk` bytes (4096 by default), every piece but the last full.** A - sink's failure stops the writing and is returned unchanged (the 4096 - default is a ruling, reason not recorded). - Source: `include/webcpp/document/stringify.hpp` (libs/document). + most `chunk` bytes (4096 by default), every piece but the last full, and + allocates in the document's allocator only past its own room, for a value + nested deeper than 16 or a piece held back over 4096 bytes.** A sink's + failure stops the writing and is returned unchanged, as an allocator's is + as `errc::capacity`; a value nested 16 deep or less, in pieces of at most + 4096 bytes, allocates nothing, so a dozen small texts take nothing of a + small arena (the 4096 default is a ruling, reason not recorded). + Source: `include/webcpp/document/stringify.hpp` and `doc/stringify.adoc` + (libs/document). - **`quote` is `JSON.stringify` of a string alone: it appends the string as a JSON string literal, its quotes included, to any string the caller gives (`std::string`, `std::pmr::string`, or any type with @@ -5049,9 +5144,10 @@ proposals is given relative to `libraries/document/openspec/`. digits, as JavaScript does since ES2019. Source: `doc/stringify.adoc` (libs/document). - **The writer walks with a stack of its own that holds node ids, never - recursion and never nodes.** A document's depth is then bounded by memory, - not by the thread's stack, and nothing the walk holds is stale when the - image moves. + recursion and never nodes, its first 16 frames in room of its own.** A + document's depth is then bounded by memory, not by the thread's stack, + nothing the walk holds is stale when the image moves, and a shallow value + is written with no allocation. Source: `include/webcpp/document/detail/writer.hpp` (libs/document). **Streams of documents and Boost.Asio.** @@ -5255,6 +5351,21 @@ proposals is given relative to `libraries/document/openspec/`. none.** The replacements are the test program's instrument, the one place a mutable global is allowed. Source: `specs/document/spec.md` (proposals). +- **The `allocator*` tests run every operation in a counting resource over a + monotonic buffer whose upstream is the null resource: no global + `operator new` but exactly Boost.JSON's stack's in a chunked parse and + `stringify`'s own, every byte given back, and with exceptions each operation + failed at each of its allocations in turn, every failure `errc::capacity` + or a throwing place's `std::bad_alloc`, with the document's content as it + was and nothing it took kept; both traits and all three key orders; and + allocators of the tests' own: one that under-aligns, one whose pointer is + tagged, a resource that throws Boost.Interprocess's `bad_alloc`, one whose + rebinding constructor is explicit, one that propagates on a move + assignment, and one stateful but always equal.** Every allocation then has + a place the page names, a failure at any of them is shown to be a value, + and a leak on a path of failure fails. + Source: `doc/allocation.adoc`, `test/allocator_test.cpp` and + `test/counting.hpp` (libs/document). - **Each example's `.expected` is what Node prints for the same JavaScript, checked against Node before it is committed, and `document_image.expected` holds a digest of an image.** The page's output is then JavaScript's, and @@ -9489,10 +9600,9 @@ it says. test (`include/webcpp/xactor/scheduler.hpp`); xstate's machine has no `Allocator` parameter and holds `std::shared_ptr` and `std::function` (`machine.hpp:1322-1328`, `implementations.hpp:81-145`); wasi's response - holds its body as a `std::string`; these three are on the roadmap. document - has no `Allocator` parameter either, and is not on it. The pages of pratt, - idna and document do not say which of their types are shareable (each - library's `doc/allocation.adoc`). + holds its body as a `std::string`; these three are on the roadmap. The + pages of pratt and idna do not say which of their types are shareable + (each library's `doc/allocation.adoc`). - **Types of a fixed meaning (chapter 4).** Plain `int` or `unsigned` where no interface asks for it: pratt's binding powers and `max_depth` (`parser.hpp:54,175,199,309`, `calculator.hpp:988-1017`), wasi's @@ -9630,10 +9740,12 @@ says what the tree does. counts 22 functions where there are 21, names `uuid::rfc4122` where RFC 9562 replaced it, and leaves its O6 out of its reference. - **document.** The tree accepts `float`, which the specification refuses; - staging on the process heap inside a `noexcept` path contradicts the - genesis and `doc/errors.adoc`; `stringify_to` allocates, against - `doc/stringify.adoc`; the genesis keeps O5 open though it is resolved and - counts 20 examples where there are 21; `doc/testing.adoc` and + the genesis's D5 puts the text `stringify` returns, a missing member's key + and the parser's frames on the process heap, whose `std::bad_alloc` is + "the one failure that is not a value", where the tree keeps all but + `stringify`'s text in the document's allocator and, with exceptions, makes + a failure there `errc::capacity`; the genesis keeps O5 open though it is + resolved and counts 20 examples where there are 22; `doc/testing.adoc` and `doc/exceptions.adoc` are incomplete. - **trystero.** The genesis ties 0.1.0 to `160f431`, while 0.1.0 also holds the change `shared-connection` (trystero `e9326e9`). The specification gives From d8458ca1d092d170e19f9783cf4550669df3886f Mon Sep 17 00:00:00 2001 From: R Date: Sun, 15 Nov 2026 05:04:06 -0300 Subject: [PATCH 47/61] CODING-GUIDELINES: trystero's run_case under the release link at -O3 Chapter 15's trystero entry keeps run_case as the rule, which keeps a test's cases out of main's frame whatever the link, and gives the measurements under the link the Jamroot now gives a release program, -O3: the room, app_impl and allocation tests' deepest suspensions write 564, 440 and 408 bytes in release and 2,344, 2,068 and 2,020 in debug, now the deepest build, and a main with every case inlined fits at -O3. The release runs stay as trystero's only runs under Asyncify in the CI's emscripten lane. Chapter 19's "Emscripten's release link." is removed: the Jamroot's link options fixed it (#18). --- CODING-GUIDELINES.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index bf02c6fc..3dbf4dc1 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -6778,16 +6778,21 @@ makes a room read, through webcpp::beast's bounded handshake layer. `webcpp::test::exit_status`.** trystero links webcpp::asio's runtime, and under Asyncify a `main` that suspended loses what it returns. Source: `AGENTS.md` (libs/trystero). -- **Under Asyncify the room, `app_impl` and allocation tests run once more in - a `release` build, with webcpp::asio's 8,192 bytes of Asyncify stack, and a - test whose cases suspend runs each through `webcpp::test::run_case` - (`test/cases.hpp`), in a frame of its own that `main`'s frame never - holds.** b2's emscripten toolset links a `release` build without - optimization, so each suspension saves every local of every frame from - `main` down; at `-O3` a case that `main` alone calls is inlined into it, - and the room test's `main` saved 29,776 bytes at each suspension and - stopped at its first, where through `run_case` its deepest suspension - wrote 3,096 (measured on 2026-11-15 with Emscripten 6.0.11). +- **A test whose cases suspend runs each through `webcpp::test::run_case` + (`test/cases.hpp`), in a frame of its own that `main`'s frame never holds, + whatever the link; under Asyncify the room, `app_impl` and allocation tests + run once more in a `release` build, with webcpp::asio's 8,192 bytes of + Asyncify stack.** At `-O3` a case that `main` alone calls is inlined into + it, and a program linked without optimization, as b2 linked a `release` + build until the Jamroot gave the link its compile's level and as + `-O0` still links one, then saves every case's locals in + `main`'s frame at each suspension: the room test's `main` saved 29,776 + bytes so and the test stopped at its first suspension. Linked at `-O3`, + the three tests' deepest suspensions write 564, 440 and 408 bytes, and a + `main` with every case inlined fits too (616 for the room test); in + `debug`, now the deepest build, 2,344, 2,068 and 2,020 (measured on + 2026-11-15 with Emscripten 6.0.11). The `release` runs stay as trystero's + only runs under Asyncify in the CI's emscripten lane, which builds JSPI. Source: `test/cases.hpp`, `test/Jamfile` and `doc/testing.adoc` (libs/trystero). - **`platform_websocket`, the native interop peer and `shared_hardened` are @@ -9833,11 +9838,6 @@ owners. about 12 us, where Boost.JSON took 1.6 us, and the chat's debug WebAssembly grew from 29.2 MB to 33.7 MB; neither is measured since, nor the release size, and neither figure is recorded in trystero's tree. -- **Emscripten's release link.** b2's emscripten toolset links a `release` - build without optimization, so that Asyncify's instrumentation is not - optimized and each suspension saves every frame from `main` down - (trystero's `doc/testing.adoc`), which a separate pull request against - `main` is fixing. ### webrtc: open questions From 15c2b08e23a9a263c57e713534a9ffe732be5d0b Mon Sep 17 00:00:00 2001 From: R Date: Sun, 15 Nov 2026 05:04:39 -0300 Subject: [PATCH 48/61] trystero: the Asyncify measurements under the release link at -O3 --- libs/trystero | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/trystero b/libs/trystero index 6f35b389..370bbb2a 160000 --- a/libs/trystero +++ b/libs/trystero @@ -1 +1 @@ -Subproject commit 6f35b38961cb95359fb35a689b3c5ca053334300 +Subproject commit 370bbb2a380eb8800a01b2f21530e348c0434644 From b5a8922c82762f5bc43fbb50c3d4c1cdadc14e0f Mon Sep 17 00:00:00 2001 From: R Date: Sun, 15 Nov 2026 06:42:59 -0300 Subject: [PATCH 49/61] beast and trystero: the last lint findings and the Asyncify removelist warning --- libs/beast | 2 +- libs/trystero | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/beast b/libs/beast index 40e5f3d2..ae79a794 160000 --- a/libs/beast +++ b/libs/beast @@ -1 +1 @@ -Subproject commit 40e5f3d2e311dfbdd3fa710822e7a34a34208f01 +Subproject commit ae79a7944144010d59c66057bac2b5bd199c831f diff --git a/libs/trystero b/libs/trystero index 370bbb2a..b2cb9543 160000 --- a/libs/trystero +++ b/libs/trystero @@ -1 +1 @@ -Subproject commit 370bbb2a380eb8800a01b2f21530e348c0434644 +Subproject commit b2cb954387d6e0dcb86e856cbc78a84862b5af6f From 5550be42dd1a780fece318c741233170110a475f Mon Sep 17 00:00:00 2001 From: R Date: Sun, 15 Nov 2026 10:32:15 -0300 Subject: [PATCH 50/61] webrtc and trystero: their Asyncify programs in own lanes, so native builds without emscripten expand them The CI's native lanes failed at once with b2's unknown feature : webrtc's and trystero's targets naming asyncify were declared outside a lane, and asyncify composes a feature only the emscripten toolset defines. Both now form the own lane asyncify, as asio's and cobalt's do; AGENTS.md lists the lanes. --- AGENTS.md | 4 ++-- libs/trystero | 2 +- libs/webrtc | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index c9aefb53..ebfda519 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -84,8 +84,8 @@ for web developers and for AI developers (`CODING-GUIDELINES.md` chapter 16). | document | a JSON document that behaves as JavaScript does (key order, `JSON.stringify`'s bytes, the array methods), exact in decimal, in one relocatable image; webcpp's own; its parser is Boost.JSON's | native, wasip2, wasip3, emscripten; its oracle lane | a submodule at `libs/document`; its core never throws (`CODING-GUIDELINES.md` chapter 6) | | idna | internationalized domain names: Punycode, UTS 46's ToASCII and ToUnicode, conformant to IdnaTestV2, and IDNA2008's validity, over Unicode 17.0.0 tables generated into its headers; webcpp's own | native, wasip2, wasip3, emscripten; its own lane `tables` | a submodule at `libs/idna`; its errors are values, and its span forms allocate nothing | | lexical | the string formats JSON Schema names (date-time, email, hostname, ipv4/ipv6, uri, iri, uri-template, json-pointer, uuid, regex), each a validator that allocates nothing and a Boost.URL grammar rule; regex is an ECMA-262 syntax validator of its own, checked against V8; depends on idna and Boost.URL; webcpp's own | native, wasip2, wasip3, emscripten; its own lanes `generated` and `oracle` | a submodule at `libs/formats` | -| trystero | a port of Trystero 0.26.0, serverless WebRTC rooms; its one platform backend's WebRTC, on both targets, is webrtc's, and its Asio is named `webcpp::asio` | native, emscripten (both suspension variants); its own lanes `oracle`, `relayed` (its examples over a local relay, natively), `interop` and `provider-integration` | a submodule at `libs/trystero`; born with the allocation rule through `std::pmr`; works with exceptions on and off on both targets | -| webrtc | WebRTC peer connections and data channels with the W3C's names in Asio's model, natively over libdatachannel's C API and in the browser over the page's own objects, with exceptions on and off; webcpp's own | native, emscripten; its own lanes `browser` and `interop` | a submodule at `libs/webrtc`; increments 1 and 2 of 3 (`CODING-GUIDELINES.md` chapter 15) | +| trystero | a port of Trystero 0.26.0, serverless WebRTC rooms; its one platform backend's WebRTC, on both targets, is webrtc's, and its Asio is named `webcpp::asio` | native, emscripten (both suspension variants); its own lanes `oracle`, `relayed` (its examples over a local relay, natively), `interop`, `asyncify` and `provider-integration` | a submodule at `libs/trystero`; born with the allocation rule through `std::pmr`; works with exceptions on and off on both targets | +| webrtc | WebRTC peer connections and data channels with the W3C's names in Asio's model, natively over libdatachannel's C API and in the browser over the page's own objects, with exceptions on and off; webcpp's own | native, emscripten; its own lanes `browser`, `interop` and `asyncify` | a submodule at `libs/webrtc`; increments 1 and 2 of 3 (`CODING-GUIDELINES.md` chapter 15) | ### The layout diff --git a/libs/trystero b/libs/trystero index b2cb9543..781f7bab 160000 --- a/libs/trystero +++ b/libs/trystero @@ -1 +1 @@ -Subproject commit b2cb954387d6e0dcb86e856cbc78a84862b5af6f +Subproject commit 781f7baba26330d3dcc4eaf7ec5f5be677215b43 diff --git a/libs/webrtc b/libs/webrtc index 5fda378b..5ebc04e8 160000 --- a/libs/webrtc +++ b/libs/webrtc @@ -1 +1 @@ -Subproject commit 5fda378b7441a64f166b4f9e9585591a2fea7766 +Subproject commit 5ebc04e8fa710712f21e19b564adc70e3b453e2b From 51a753fcfe7f062f51c3c1456da2494087c16c04 Mon Sep 17 00:00:00 2001 From: R Date: Sun, 15 Nov 2026 10:58:42 -0300 Subject: [PATCH 51/61] document: a held callable's place declared with auto --- libs/document | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/document b/libs/document index e95b4096..b6f526c7 160000 --- a/libs/document +++ b/libs/document @@ -1 +1 @@ -Subproject commit e95b40966ee453913d458cbaf6656ab87ee2a1c7 +Subproject commit b6f526c7e218477a97b6e5660d04e06b0fa0d2f7 From 6dc2d7338fc703868ba2c7629d88ca6745014fcf Mon Sep 17 00:00:00 2001 From: R Date: Sun, 15 Nov 2026 12:35:01 -0300 Subject: [PATCH 52/61] webrtc: an operation takes its handler by rvalue reference --- libs/webrtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/webrtc b/libs/webrtc index 5ebc04e8..577e1906 160000 --- a/libs/webrtc +++ b/libs/webrtc @@ -1 +1 @@ -Subproject commit 5ebc04e8fa710712f21e19b564adc70e3b453e2b +Subproject commit 577e190643039f3ff5493e3db9c0ca009c312aeb From fdf0313f65b6cc1be75ad677c84bb705cb9ed8f3 Mon Sep 17 00:00:00 2001 From: R Date: Sun, 15 Nov 2026 12:37:23 -0300 Subject: [PATCH 53/61] beast: the handshake test allocates aligned memory as MSVC's C library does --- libs/beast | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/beast b/libs/beast index ae79a794..8763e1d9 160000 --- a/libs/beast +++ b/libs/beast @@ -1 +1 @@ -Subproject commit ae79a7944144010d59c66057bac2b5bd199c831f +Subproject commit 8763e1d93dca87994bb87c56eb18ca51accf00d3 From aab84a97b23b85af71cedaf876c441f0e427238e Mon Sep 17 00:00:00 2001 From: R Date: Sun, 15 Nov 2026 15:13:42 -0300 Subject: [PATCH 54/61] document: built clean by MSVC, its debug STL's container proxies counted apart --- libs/document | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/document b/libs/document index b6f526c7..b584b8f2 160000 --- a/libs/document +++ b/libs/document @@ -1 +1 @@ -Subproject commit b6f526c7e218477a97b6e5660d04e06b0fa0d2f7 +Subproject commit b584b8f2e7c0c7eefe6009e9c660a935734417a1 From 0f1a1ae48728f54723c58e340d2c7d15bf6790b6 Mon Sep 17 00:00:00 2001 From: R Date: Sun, 15 Nov 2026 17:16:43 -0300 Subject: [PATCH 55/61] webrtc: an operation's fallback by rvalue reference, read alike over libstdc++ --- libs/webrtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/webrtc b/libs/webrtc index 577e1906..ba3e533c 160000 --- a/libs/webrtc +++ b/libs/webrtc @@ -1 +1 @@ -Subproject commit 577e190643039f3ff5493e3db9c0ca009c312aeb +Subproject commit ba3e533c2723c4201c54381d0f7f122bf48f983e From 191fce4e2409c66e3c6e82b1931721faefe6b134 Mon Sep 17 00:00:00 2001 From: R Date: Sun, 15 Nov 2026 19:11:15 -0300 Subject: [PATCH 56/61] webrtc and trystero: read alike over libstdc++ by clang-tidy --- libs/trystero | 2 +- libs/webrtc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/trystero b/libs/trystero index 781f7bab..191cf99d 160000 --- a/libs/trystero +++ b/libs/trystero @@ -1 +1 @@ -Subproject commit 781f7baba26330d3dcc4eaf7ec5f5be677215b43 +Subproject commit 191cf99dbad0d1a46380c2dc132769830b800757 diff --git a/libs/webrtc b/libs/webrtc index ba3e533c..95b2d5dd 160000 --- a/libs/webrtc +++ b/libs/webrtc @@ -1 +1 @@ -Subproject commit ba3e533c2723c4201c54381d0f7f122bf48f983e +Subproject commit 95b2d5dd92a0704db7989d2e2154a8ac8985f733 From 94ee219b51e289e31e7390ace46cb5424bb7a90a Mon Sep 17 00:00:00 2001 From: R Date: Sun, 15 Nov 2026 19:33:58 -0300 Subject: [PATCH 57/61] trystero: a kept room frame advertises its room, as the peer's presence does Chrome can drop the presence a page sends as its answering channel opens, and Trystero JS sends it once per connection, so a room waiting for presence alone never bound the peer (the interop's two-rooms scenario, 3.3% on 2-CPU Linux). Chapter 15 now says a kept room frame is the peer's own advertisement. --- CODING-GUIDELINES.md | 7 +++++++ libs/trystero | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index 3dbf4dc1..cd6a932e 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -6211,6 +6211,13 @@ makes a room read, through webcpp::beast's bounded handshake layer. Source: `libraries/trystero/openspec/changes/archive/2026-11-14-shared-connection/specs/trystero/spec.md` (proposals). +- **A room frame of a room of the app that the connection keeps is the peer's + own advertisement of the room, as its presence is.** Trystero sends a + room's presence once per connection, and Chrome can drop what a page sends + on an answering channel as it opens, so a room waiting for that presence + alone would never bind a Trystero JS peer; only the peer writes its + connection's frames, so a forged announcement still binds nothing. + Source: `AGENTS.md` (libs/trystero). - **A bound room keeps its negotiation entry marked connected, and binds by signaling reuse only on its first meeting with that peer over that connection.** Otherwise a room bound by presence or reuse would offer to the diff --git a/libs/trystero b/libs/trystero index 191cf99d..3820d62c 160000 --- a/libs/trystero +++ b/libs/trystero @@ -1 +1 @@ -Subproject commit 191cf99dbad0d1a46380c2dc132769830b800757 +Subproject commit 3820d62c78b7668f4c504af50351c744c6ca8eb3 From c56254c48bd12ef0e42f2601c5370f2170e883ec Mon Sep 17 00:00:00 2001 From: R Date: Sun, 15 Nov 2026 22:42:40 -0300 Subject: [PATCH 58/61] tools/report: an action in a test's own directory is the test's MSVC's link writes the program and its .pdb in one action, which b2 records under the .pdb: a file no target the test needs, so a link-fail test's expected failure (webrtc's config_mismatch on msvc-14.3 and msvc-14.5) counted as a failure outside every test. A test's own directory, /.test//..., holds nothing of another test, so an action recorded under a file there belongs to the test. report_test moves native-failures' failing link to the program's .pdb: before, the test was 'not run' and the link outside every test; now it is the test's link failure. The CI's msvc-14.3 XML of #17 reads config_mismatch as a passing link-fail test. --- tools/report/lanes.py | 9 ++++++++- tools/report/report_test.py | 21 +++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/tools/report/lanes.py b/tools/report/lanes.py index 6c462691..9d09ce1d 100644 --- a/tools/report/lanes.py +++ b/tools/report/lanes.py @@ -340,6 +340,10 @@ def row(location: str, example: bool, row_name: str, row_type: str) -> tuple[Row # example, its .output, in //... toolsets: set[str] = set() owners: dict[str, list[Build]] = {} + # A test's own directory, /.test//..., holds nothing of another + # test: an action b2 records under a file there that no target needs is the test's, as MSVC's + # link, which writes the program and its .pdb at once and is recorded under the .pdb. + own_directories: dict[str, list[Build]] = {} for target, built_in in graph: location, _, file = target.partition('//') if target in tests: @@ -360,6 +364,8 @@ def row(location: str, example: bool, row_name: str, row_type: str) -> tuple[Row owner.builds.append(build) for owned in closure(graph, target, built_in): owners.setdefault(owned, []).append(build) + if target in tests: + own_directories.setdefault(built_in, []).append(build) # A lane that built nothing has no directory, only the toolset its command line names. from_directory = bool(toolsets) @@ -400,7 +406,8 @@ def row(location: str, example: bool, row_name: str, row_type: str) -> tuple[Row command = textwrap.dedent(text_of(element, 'command')).strip('\n') action = Action(text_of(element, 'name'), status, slashed(text_of(element, 'path')), command, text_of(element, 'output')) - builds = owners.get(action.path, []) + builds = (owners.get(action.path) + or own_directories.get(posixpath.dirname(action.path), [])) for build in builds: build.actions.append(action) if not builds and action.status != 0: diff --git a/tools/report/report_test.py b/tools/report/report_test.py index 7262a89f..0b0d3be8 100644 --- a/tools/report/report_test.py +++ b/tools/report/report_test.py @@ -696,6 +696,26 @@ def test_a_failure_outside_every_test_fails_the_lane(root: Path) -> None: check_pages(out) +def test_an_action_in_a_tests_own_directory_is_the_tests(root: Path) -> None: + # MSVC's link writes a program and its .pdb in one action, which b2 records under the .pdb: + # no target the test needs, but a file of the test's own directory, .test//..., + # which holds nothing of another test. Here fails_to_link's link is recorded so. + text = sample('native-failures').read_text(encoding='utf-8') + moved = text.replace('cxxstd-20-iso/fails_to_link]]>', 'cxxstd-20-iso/fails_to_link.pdb]]>') + assert moved.count('fails_to_link.pdb]]>') == 1, 'the link action, alone, moved' + (root / 'pdb.xml').write_text(moved, encoding='utf-8') + out = root / 'report' + result = report(out, ('native', root / 'pdb.xml')) + assert result.returncode == 1, outcome(result) + assert 'native: planted/fails_to_link: link' in result.stderr, outcome(result) + assert 'outside every test' not in result.stderr, outcome(result) + planted = matrix(out / 'planted.html') + assert planted.verdict('fails_to_link', 'native') == 'link' + output = linked(out / 'planted.html', planted.cells[('fails_to_link', 'native')].href) + assert 'missing()' in output.text, output.text + check_pages(out) + + def test_output_cdata_cannot_hold_is_shown(root: Path) -> None: # The test prints ]]>, which ends b2's CDATA early, markup, and a byte that is not UTF-8. data = sample('native-odd-output').read_bytes() @@ -907,6 +927,7 @@ def test_samples_read_as_b2_writes_them_today(root: Path) -> None: test_a_lane_is_what_its_name_says, test_an_own_lane_is_named_after_its_target_and_library, test_a_failure_outside_every_test_fails_the_lane, + test_an_action_in_a_tests_own_directory_is_the_tests, test_output_cdata_cannot_hold_is_shown, test_served_test_passes_and_fails_as_a_run, test_emscripten_lane_and_its_link_and_driven_tests, From 4ad731151564f0dfcfdf35cc5734a5efc2a81496 Mon Sep 17 00:00:00 2001 From: R Date: Sun, 15 Nov 2026 22:42:40 -0300 Subject: [PATCH 59/61] webrtc and trystero: MSVC's warnings, sections and debug-STL proxies, and the site's title --- libs/trystero | 2 +- libs/webrtc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/trystero b/libs/trystero index 3820d62c..0d21db65 160000 --- a/libs/trystero +++ b/libs/trystero @@ -1 +1 @@ -Subproject commit 3820d62c78b7668f4c504af50351c744c6ca8eb3 +Subproject commit 0d21db6540843fb887f2412b9d76986357bc80ef diff --git a/libs/webrtc b/libs/webrtc index 95b2d5dd..8f0f8831 160000 --- a/libs/webrtc +++ b/libs/webrtc @@ -1 +1 @@ -Subproject commit 95b2d5dd92a0704db7989d2e2154a8ac8985f733 +Subproject commit 8f0f8831488d793cdd3698ee0d3a18cb8a4b334d From 4c420895e21459b28d9c84e5f443438f1bdff8e7 Mon Sep 17 00:00:00 2001 From: R Date: Mon, 16 Nov 2026 11:24:22 -0300 Subject: [PATCH 60/61] webrtc and trystero: the nodiscard results rule webrtc asks for it as the libraries it builds on do (CODING-GUIDELINES' lint table names it); trystero's refactor marks its four new result functions. --- CODING-GUIDELINES.md | 2 +- libs/trystero | 2 +- libs/webrtc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index 026664ec..b1f64fd6 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -659,7 +659,7 @@ with `lint: failed: ` for each rule that failed. | bare throw | a `throw` expression in a library's public header (`libs/*/include/**`), outside comments and literals, at its line: inside `#ifndef WEBCPP__NO_EXCEPTIONS` too, in a template that nothing instantiates, which clang-tidy's analysis without exceptions does not see, and as a rethrow, `throw;`; `boost::throw_exception` is the one way to raise, `std::rethrow_exception` the one way to rethrow (above) | | changelog form | a library's changelog or a version's release notes out of `AGENTS.md` chapter 5's form: a section or a region missing or out of order, a line that starts with no verb of the list, a cross-reference, an inline anchor such as `[[nodiscard]]` outside a passthrough, more than ten lines for a library and a version, text outside a bullet | | canary pins | a `WEBCPP_CRYPTO__COMMIT` of crypto's `detail/canary.h` that is not the first seven digits of the commit the superproject records for its submodule (`ctaes`: `bitcoin`) | -| nodiscard results | a function of a library's `include/` that returns `boost::system::result` without `[[nodiscard]]`, at its line, when the library asks for the rule in its `meta/lint.json` (`"nodiscard-results"` and its reason; asio, beast, cobalt, crypto, hash and trystero do): `boost::system::result` carries no `[[nodiscard]]` of its own; and a malformed file or an unknown key | +| nodiscard results | a function of a library's `include/` that returns `boost::system::result` without `[[nodiscard]]`, at its line, when the library asks for the rule in its `meta/lint.json` (`"nodiscard-results"` and its reason; asio, beast, cobalt, crypto, hash, trystero and webrtc do): `boost::system::result` carries no `[[nodiscard]]` of its own; and a malformed file or an unknown key | A source b2 expects not to compile (`webcpp.compile-fail`), and one that must stop with the error it states (`webcpp.compile-diagnostic`), are left diff --git a/libs/trystero b/libs/trystero index c810bd61..3b06b735 160000 --- a/libs/trystero +++ b/libs/trystero @@ -1 +1 @@ -Subproject commit c810bd61a26ac7b4cc4b6e80756e490449e5a865 +Subproject commit 3b06b735357f5c42392e86089a1ef61c5f207002 diff --git a/libs/webrtc b/libs/webrtc index 8f0f8831..7c9f9b04 160000 --- a/libs/webrtc +++ b/libs/webrtc @@ -1 +1 @@ -Subproject commit 8f0f8831488d793cdd3698ee0d3a18cb8a4b334d +Subproject commit 7c9f9b0485f7a1b394aeef40b67f3975bb6d2a48 From 28100ac464ed88ccddc4e19f0b9994fcc1f29df0 Mon Sep 17 00:00:00 2001 From: R Date: Mon, 16 Nov 2026 12:11:26 -0300 Subject: [PATCH 61/61] trystero: its changelog's clocks line keeps its code spans whole --- libs/trystero | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/trystero b/libs/trystero index 3b06b735..2eb1c89f 160000 --- a/libs/trystero +++ b/libs/trystero @@ -1 +1 @@ -Subproject commit 3b06b735357f5c42392e86089a1ef61c5f207002 +Subproject commit 2eb1c89f35051a05de9470bc146d7bffbed1bc7a