Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
1462d22
asio: close task 9 review and preserve verified reference
Oct 14, 2026
74918f5
asio: record task 10 timer validation and reference
Oct 14, 2026
9c744d2
asio: record task 11 allocation validation and reference
Oct 14, 2026
d369018
asio: record local integration and the completed loader task
Oct 14, 2026
b810d52
asio: record task 13 browser validation
Oct 14, 2026
e55c7e5
asio: record task 14 guide and example validation
Oct 14, 2026
6b2edd9
asio: record optimized release measurements and validation
Oct 14, 2026
f6a9f18
asio: record the six-profile release size matrix
Oct 14, 2026
8353499
asio: record exception size and timing measurements
Oct 14, 2026
dd81555
asio: record Cobalt exception policy correction and runtime limits
Oct 14, 2026
66de70a
asio: record completed Cobalt source integration task
Oct 15, 2026
3dd5e86
asio: record completed bounded Cobalt entry point
Oct 15, 2026
b0a3485
asio: record configurable default turn limit
Oct 15, 2026
606723b
asio: record measured browser yield latency
Oct 15, 2026
5541a84
asio: record the documented default turn-limit rationale
Oct 15, 2026
814d6d1
asio: preserve yield benchmark figures and complete tables
Oct 15, 2026
e547e65
asio: record tasks 17 through 21 and reviewed local validation
Oct 15, 2026
48c7cf2
beast: specify WebAssembly portability for all upstream examples
Nov 3, 2026
52a67bd
beast: specify host HTTP and stream adaptations
Nov 3, 2026
853ce39
beast: record initial implementation and runtime validation [skip ci]
Nov 3, 2026
801de03
beast: record committed backends and application evidence
Nov 3, 2026
353b15d
beast: record completed native and WASIp3 application regressions
Nov 3, 2026
3c186b6
beast: record HTTP fixture correction and complete browser CI coverage
Nov 3, 2026
80afd85
beast: record verified client startup and protocol deadlines
Nov 3, 2026
457f8b9
docs: record reviewed Beast Windows integration fixes
Nov 3, 2026
3cbaf2b
proposals: integrate current main guidelines
Nov 3, 2026
1d486c0
beast: record exact final candidate CI
Nov 3, 2026
5a1fcb6
Record verified WASIp2 core and supplied WebSocket integration
Nov 3, 2026
85a0af2
Record final local cross-target verification
Nov 3, 2026
aeeb824
Record Asio capability completion and verified reference tree
Nov 3, 2026
303b4ce
asio and beast: refresh publication snapshots and capability limits
Nov 3, 2026
b344011
Record verified Asio publication candidate and browser startup coverage
Nov 3, 2026
aef8689
asio: Record CI fixture and native IOCP test corrections
Nov 3, 2026
aaa28fc
proposals: Record driven-test corrections and pending CI gates
Nov 3, 2026
67f6441
proposals: Record final CI findings and verified local corrections
Nov 4, 2026
3414dd6
proposals: Preserve accepted WASM work from main
Nov 4, 2026
1603df6
proposals: Record final integration candidate and local regressions
Nov 4, 2026
4c985f3
proposals: Record corrected CI candidate and Beast runtime harness
Nov 4, 2026
8731cdd
Record Asio and Beast integration and documentation follow-up
Nov 4, 2026
b80e85c
cobalt: propose independent Wasm integration and evidence matrix
Nov 4, 2026
ab55780
cobalt: record owner approval and start implementation
Nov 6, 2026
dcc9010
cobalt: record baseline and initial implementation evidence
Nov 6, 2026
fee0460
cobalt: record application and browser validation
Nov 6, 2026
1762f3f
network: record shipped-source contracts and local validation
Nov 7, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ libraries marked with it are published, in the superproject's `main`.
| organization | [agent-skills](organization/openspec/changes/archive/2026-10-13-agent-skills) | organization: agent skills in .agents/skills, in the proposals and the superproject | organization | implemented | 0.1.0 | 2026-10-13 | [code](https://github.com/webcpporg/webcpp/tree/5a441c1e90c5b242cf55c351edf6c79c37ef1f8d) |
| organization | [coding-guidelines](organization/openspec/changes/archive/2026-10-28-coding-guidelines) | organization: CODING-GUIDELINES.md, the single source of the rules and the design decisions | organization | implemented | 0.1.0 | 2026-10-26 | [code](https://github.com/webcpporg/webcpp/tree/a4c770e07becaa32b840554512b37d96b4440d18) |
| organization | [contributor-identity](organization/openspec/changes/archive/2026-10-13-contributor-identity) | organization: every contributor commits under their own git identity | organization | implemented | 0.1.0 | 2026-10-13 | [code](https://github.com/webcpporg/webcpp/tree/9a268b7efa8a9b7eab8810bc024486288c689fab) |
| asio | [genesis](libraries/asio/openspec/changes/genesis) | asio: Boost.Asio natively, the browser's event loop on Emscripten | wrapper | implementing | | 2026-10-11 | |
| beast | [genesis](libraries/beast/openspec/changes/genesis) | beast: Boost.Beast natively, the browser's WebSocket and fetch on Emscripten | wrapper | draft | | | |
| asio | [genesis](libraries/asio/openspec/changes/genesis) | asio: Boost.Asio across native, browsers and WASI | wrapper | implementing | | 2026-10-11 | [code](https://github.com/webcpporg/asio) |
| beast | [genesis](libraries/beast/openspec/changes/genesis) | beast: existing Boost.Beast applications on WASIp2, WASIp3 and Emscripten | wrapper | implementing | | 2026-11-06 | [code](https://github.com/webcpporg/beast) |
| cobalt | [genesis](libraries/cobalt/openspec/changes/genesis) | cobalt: existing Boost.Cobalt applications on native, browsers and WASIp2/P3 | wrapper | implementing | | 2026-11-06 | [code](https://github.com/webcpporg/cobalt) |
| config | [genesis](libraries/config/openspec/changes/archive/2026-10-09-genesis) | config: webcpp's configuration, the target, exceptions and version every library includes first | own | implemented | 0.1.0 | 2026-10-09 | [code](https://github.com/webcpporg/config/tree/2fad162) |
| crypto | [genesis](libraries/crypto/openspec/changes/genesis) | crypto: authenticated encryption, randomness and secp256k1 over C backends | wrapper | accepted | | 2026-10-11 | |
| document | [genesis](libraries/document/openspec/changes/archive/2026-10-12-genesis) | document: a JSON document for C++20 that behaves as JavaScript does, in one relocatable image | own | implemented | 0.1.0 | 2026-10-12 | [code](https://github.com/webcpporg/document/tree/ac29296) |
Expand Down
4 changes: 2 additions & 2 deletions libraries/asio/openspec/changes/genesis/.openspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ schema: spec-driven
created: 2026-10-10
webcpp:
library: asio
title: "asio: Boost.Asio natively, the browser's event loop on Emscripten"
title: "asio: Boost.Asio across native, browsers and WASI"
kind: wrapper
port_of: null
status: implementing
release: null
implementation: null
implementation: https://github.com/webcpporg/asio
decided: 2026-10-11
145 changes: 103 additions & 42 deletions libraries/asio/openspec/changes/genesis/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Constraints every decision below works within, from the superproject's rulebook
- header-only C++20, namespace `webcpp::asio`, headers under `<webcpp/asio/...>`, internals in
`detail`, macros `WEBCPP_ASIO_*`, include guards `WEBCPP_ASIO_<HEADER>_HPP`, the b2 target
`/webcpp/asio//asio`, the error category `webcpp.asio`;
- the library is built for native and Emscripten and has no WASI target; every test runs on each
- the library is built for native, Emscripten and WASIp2/P3; every test runs on each
target its Jamfile names, with exceptions on and off, in both suspension variants;
- errors as values (`boost::system::error_code`); an API that throws sits behind
`WEBCPP_ASIO_NO_EXCEPTIONS` and raises through `boost::throw_exception`;
Expand Down Expand Up @@ -45,27 +45,36 @@ Constraints every decision below works within, from the superproject's rulebook

**Non-Goals:**

- A WASI backend (`wasi:io/poll`, p3's async): a later increment with its own specification.
- WASIp2 multi-thread execution without an SDK/runtime profile; portable WASI host APIs remain separate.
- WebSocket and HTTP clients (webcpp::beast), WebRTC (webcpp::webrtc), relay transports and the b2
feature that enables one, trystero's migration, and offering the additions upstream to
Boost.Asio.
- Polling the page from C++, running the run family from a JavaScript event, or blocking the
page's thread without suspending.
- A thread pool: the page has no threads (`BOOST_ASIO_DISABLE_THREADS`).
- Implicit workers in a single-thread browser build. Explicit pthread builds retain their separate environment and affinity requirements.

## Decisions

### D1. A class derived from Boost's io_context, and every other name Boost's
### D1. Actual native Boost types and explicit Wasm source distribution

`webcpp::asio::io_context` derives from `boost::asio::io_context` on both targets, shares its
executor type and converts to `boost::asio::io_context&`; the timers are aliases of Boost's; a
program keeps naming `post`, `co_spawn`, `use_awaitable` and `bind_executor` from Boost.
The owner-approved 2026-11-06 migration supersedes the former derived native
context and include-overlay approach. Native equivalents are aliases of actual
Boost types. Wasm uses versioned implementation files under explicit WebCPP paths,
with one backend across Asio, Cobalt and Beast. Browser turn options are target
extensions, not extra native constructors. Applications migrate includes/namespaces
and use the selected backend's executors, traits and completion tokens consistently.

- **Why:** a program sets its options the same way everywhere, and code written against either
interoperates; Cobalt and Beast are templates over Boost's executor.
- **Alternatives:** a fork of Asio's scheduler (a maintenance burden and incompatible with
every library on Asio); a free function that runs a Boost context (nowhere to keep the
options).
`sources.json` identifies compiled support units and feeds the B2 source list.
Direct compiler and CMake consumers use an extracted archive with explicit SDK and
provider inputs, without Git, B2, patch programs or undeclared checkout paths.
Maintainer generators retain upstream hashes/licenses; consumers never execute them.
Known native Boost defects remain documented under the native identity contract.
Cobalt owns its core, runner and corrected SSL wrapper, including the separately
approved native SSL identity exception. Old Asio Cobalt names only forward.

The earlier decisions below record browser algorithm and integration history;
references to Boost's internals mean the selected Wasm backend, not permission to
restore native derived types, consumer overlays or Cobalt ownership inside Asio.

### D2. The run family is a composition of Boost's calls

Expand All @@ -79,18 +88,16 @@ in the reactor's `select`). Natively they are Boost's own through `using` declar
- **Consequence:** code that calls `run` through a `boost::asio::io_context&` gets Boost's run
without the limit (documented); Cobalt's `co_main` gets the limit by D11.

### D3. The yield is a MessageChannel macrotask, the limit 1000
### D3. A MessageChannel macrotask and a configurable default of 100

The yield is an `EM_ASYNC_JS` import whose promise a `MessageChannel` message resolves. The
default `max_handlers_per_turn` is 1000 (measured: the `setTimeout(0)` ran at iteration 1,000
under JSPI and 999 under Asyncify); 0 is taken as 1; a program changes it at construction or
later. A deadline is checked before each handler, so a passed deadline runs nothing and a
self-posting handler cannot outrun `run_for`.
The yield is an `EM_ASYNC_JS` import whose promise a `MessageChannel` message resolves.
The original default was 1000. After the 2026-10-15 yield-cost and responsiveness measurements,
the owner selected 100. `WEBCPP_ASIO_MAX_HANDLERS_PER_TURN` in config sets the compile-time
default; an application may define it before inclusion and override it per context. Zero
normalizes to one. A deadline is checked before each handler. No setting preempts a handler.

- **Why:** a macrotask lets the browser render, run timers and deliver events; `MessageChannel`
exists in node and in every browser. The default is to be measured again in the browser lane
against a frame's budget (the plan's stop rule: a 95th percentile above 8 ms stops the work
for the owner's decision).
The guide retains the benchmark methodology and observed costs. These observations justify
an adjustable compromise, not a portable time bound or an assurance of a fixed frame rate.

### D4. JSPI and Asyncify are build variants, a composite propagated feature

Expand Down Expand Up @@ -222,18 +229,39 @@ fails the same way, so only webcpp::beast's browser streams accept it and Beast'
code runs unchanged. A resolver that failed like the sockets was rejected: every Beast client
would change a line.

### D15. TLS names natively, a record on Emscripten, OpenSSL named by the program
### D15. Explicit source-built TLS on native and WASI

`<webcpp/asio/ssl.hpp>` is Boost's SSL interface on native and WASIp2/P3. The program explicitly
selects `/webcpp/asio//openssl` or `//tls`, backed by `/webcpp/third_party//openssl` and a
matching generated header/archive pair. The latter includes verified, replaceable embedded
CA data. Emscripten retains the browser TLS settings adapter and refuses guest OpenSSL.
Cobalt's optional `//cobalt_ssl` uses the same provider and checked SSL state/cancellation fixes.

This supersedes the original departure 4 (system shared OpenSSL). The source build and CA
package were approved in October and integrated locally on 2026-11-02; the owner ratified
reconciliation of this proposal with that implementation on 2026-11-03. OpenSSL's process-global
memory hooks are not an Asio per-operation allocator; the guide states that allocation boundary.

### D16. WASIp3 sockets, with explicit profile limitations

The original accepted browser scope excluded WASI because unmodified Boost 1.92 did not build
there. The owner approved the WASIp3 port on 2026-10-15, subsequently approved source-built TLS,
and approved applying these changes to this proposal on 2026-11-03. A checked private Boost
overlay now supplies timers, TCP/UDP and Cobalt integration on WASIp3. Native and browser
semantics remain distinct from host-controlled WASI network permissions.

`<webcpp/asio/ssl.hpp>` (not in the convenience header) is Boost's `ssl` natively, which needs
OpenSSL 3, and on Emscripten a record of the program's TLS settings that only webcpp::beast's
browser streams read. A program names `/webcpp/asio//openssl` for its native builds alone, by a
condition in its project; naming it for WebAssembly stops the compile with an instruction
(the owner rejected ignoring it there), and a machine that lacks OpenSSL stops the build.
WASIp3 single-thread builds support exceptions on/off. Cooperative threads require the SDK's
matching experimental sysroot; SDK 34 lacks its C++ exception runtime, so that profile refuses
exceptions on. The later owner-approved P2 extension below adds a single-thread reactor. Beast socket profiles follow
Asio's targets; Beast's portable messages, host HTTP and supplied streams do not require this
reactor and may support WASIp2 independently.

### D16. No WASI target
### D17. Coexistence with Trystero

Boost.Asio 1.92 does not compile for wasm32-wasip2 or wasm32-wasip3 with wasi-sdk 34. A library
on webcpp::asio declares native and Emscripten at most.
The owner clarified on 2026-11-03 that Asio and Beast are intended foundations for Trystero's
later migration. Combining the libraries MUST NOT be prohibited as a workaround for OpenSSL
provenance. A combined native program must use one OpenSSL provider, including libdatachannel's
transitive dependency. Migrating Trystero's application APIs remains a separate workstream.

## Risks / Trade-offs

Expand All @@ -251,23 +279,56 @@ on webcpp::asio declares native and Emscripten at most.

## Migration Plan

Nothing depends on asio yet. The library is developed in a superproject worktree at
`libs/asio`; once it is complete (task 23) the owner creates `webcpporg/asio` (gate G1), adds the
submodule (G2) and approves the pushes (G3). trystero's migration onto asio, webcpp::beast and
webcpp::webrtc are separate proposals.
The repository `webcpporg/asio` exists and the superproject integrated its submodule in
`2ba5116` on 2026-11-02. Tasks 22/23 now close the reconciled rulebook, complete-branch review
and both CI gates. `reference/STATUS.md` records exact tested commits and remaining work.
Beast already uses Asio; Trystero's migration onto Asio and Beast follows this foundation.

## Open Questions

- The default `max_handlers_per_turn` of 1000 is to be measured in headless Chrome (task 13);
the stop rule hands any value above an 8 ms 95th percentile to the owner.
- The b2 feature that enables a relay transport for a whole program (D13) is designed with the
first relay library.
- `asyncify-stack-size` should be measured again when b2's release link passes the optimization
level, and again when the Cobalt tests join the lane (task 16 step 5).
- The CI's levels (nightly, release) do not exist, so the Asyncify lanes run on every push
(departure 1) until they do.
- `/webcpp/asio//openssl` links the system's shared OpenSSL until webcpp::crypto builds
`/third_party//openssl` (departure 4).
- Native suites without exceptions run only on Emscripten for now (departure 5).
- The re-review of task 9's fix round was stopped by the owner's request to review every task one
by one (2026-10-11); it is open.
- The final review must cover the complete Asio branch and root integration, not only the
earlier task 9, tasks 17-21 or WASIp3/TLS review subsets.

### WASIp2 scope amendment approved on 2026-11-03

After the earlier P2 exclusion, Rodrigo explicitly approved both an Asio P2
pollable-based core and the four Beast supplied-stream WebSocket combinations.
This supersedes the no-P2-reactor restriction. Retain the Boost scheduler and
libc select/poll translation for timers, TCP and UDP. Forward asynchronous DNS
uses native address-stream pollables, with deferred initiation, cancellation and
associated executor/allocator semantics. The generic pollable descriptor bridge
is isolated and pinned to SDK 34.0's private libc ABI. P2 single-thread execution
supports both exception modes; the follow-up below adds verified guest TLS and
Cobalt. Multi-thread execution remains unavailable with the pinned SDK. Host HTTP and supplied streams remain separate
capabilities. This amendment does not declare every Beast P2 socket application
validated or restore the removed proposal tasks without their own evidence.


### Capability completion approved on 2026-11-03

The owner approved completing WebCPP-owned gaps and leaving SDK/host limits
explicitly documented and guarded. P2 receives the shared source-built OpenSSL,
CA and Cobalt/SSL targets in both exception modes. WASI UDP gains connected gather
send and scatter receive without weakening datagram boundaries. P3 asynchronous
forward DNS uses native subtasks/waitables in both thread profiles, with a checked
private libc descriptor bridge, deferred initiation and cancellation.

Explicit Emscripten pthread builds retain the selected JSPI/Asyncify mechanism.
Contexts run only on their creation thread; cross-thread posting and an explicit
main-runtime executor provide handoff without sharing JavaScript values across
threads. The main-thread poll adapter preserves ordinary application main/DOM
behavior rather than implicitly proxying main to a worker. Page isolation and
engine support remain external requirements.

`config.hpp` owns derived 0/1 capabilities. Optional provider selection is
separate, and explicit application requirements reject compiler-visible unsupported
combinations. Target-specific headers explain missing facilities. Runtime grants,
peer identities and host-blocking imports cannot be diagnosed by preprocessing.
No SDK upgrade, upstream Cobalt issue 287 repair or new Beast application-corpus
claim is implied by this amendment. Fresh publication gates remain necessary.
Loading