From 01663208af61119f81fd4287eacbb04e0966f3e0 Mon Sep 17 00:00:00 2001 From: R Date: Mon, 26 Oct 2026 11:42:23 -0400 Subject: [PATCH 1/5] CODING-GUIDELINES.md: the rules and every design decision, in one place The organization's proposal coding-guidelines, accepted on 2026-10-26. CODING-GUIDELINES.md holds every rule on how code is written and every decision of webcpp's design, each with its reason, in nineteen chapters. Chapters 1 to 13 are AGENTS.md's rules moved word for word, each citation rewritten to the chapter's new home. Chapters 14 and 15 gather the organization's and each library's design decisions; 16 to 19 hold the roadmap, the proposals not built and the conflicts still open. AGENTS.md keeps how to work in the tree, in six chapters. --- AGENTS.md | 1282 +----- CODING-GUIDELINES.md | 8894 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 9086 insertions(+), 1090 deletions(-) create mode 100644 CODING-GUIDELINES.md diff --git a/AGENTS.md b/AGENTS.md index 1739d325..bbc59a68 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,38 +1,39 @@ # Working on webcpp -This is webcpp's rulebook. It is written for coding agents and human -contributors alike, and it holds every rule needed to port a library to -webcpp or to change one: an agent with no other context ports a library by -following it. Each library's own `AGENTS.md` (`libs//AGENTS.md`) holds -only what is specific to that library: the original and its version, how its -oracle drives the original, its particular cautions. Read this file first, -then the library's. - -Agent skills, short playbooks that point into this file for recurring +This file is how to work in webcpp's tree, for coding agents and human +contributors alike: what webcpp is and where everything is, the +prerequisites and the commands, the API reference and the pages, the tests, +the lanes, the report, the site and the CI, the changelogs and the +releases, and the facts of b2. The rules every change keeps, how code is +written and every decision of webcpp's design with its reason, are in +[CODING-GUIDELINES.md](CODING-GUIDELINES.md), the single source of them. +Read it first, then this file, then the library's own `AGENTS.md` +(`libs//AGENTS.md`), which holds only what is specific to that +library: the original and its version, how its oracle drives the original, +its particular cautions. With the two files, an agent with no other context +ports a library or changes one. + +Agent skills, short playbooks that point into the two files for recurring tasks, are in `.agents/skills//SKILL.md`: the library's conventions, a port, the build and its lanes, the documentation and the site, and text and -commits. They never replace a rule here; where one disagrees, this file wins. +commits. They never replace a rule; where one disagrees, the file it points +to wins. -This file describes the tree as it is. What is still to come is listed in -the roadmap (chapter 13), to which every other mention of it refers. Every -command below runs from the superproject's root, in a shell where `CPATH`, -`CPLUS_INCLUDE_PATH` and `C_INCLUDE_PATH` are unset (chapter 12). +This file describes the tree as it is. What is still to come is in the +roadmap, `CODING-GUIDELINES.md` chapter 16, to which every other mention of +it refers. Every command below runs from the superproject's root, in a +shell where `CPATH`, `CPLUS_INCLUDE_PATH` and `C_INCLUDE_PATH` are unset +(chapter 6). A chapter of this file is cited as "chapter N", one of the +guidelines as "`CODING-GUIDELINES.md` chapter N". ## Contents 1. What webcpp is -2. Choosing and registering a port -3. Names -4. Fidelity -5. Evidence: oracle and twins -6. C++ rules -7. Doc Comments and the API reference -8. Documentation -9. Tests, lanes, the report, the site and CI -10. Process -11. Commits and text -12. b2 facts -13. Roadmap +2. The API reference +3. Documentation +4. Tests, lanes, the report, the site and CI +5. Changelogs and releases +6. b2 facts ## 1. What webcpp is @@ -66,7 +67,7 @@ Each target has its purpose: | native | a program that wants close integration with its operating system | The documentation is written for C++ developers, and will also be written -for web developers and for AI developers (chapter 13). +for web developers and for AI developers (`CODING-GUIDELINES.md` chapter 16). ### The libraries @@ -74,10 +75,10 @@ for web developers and for AI developers (chapter 13). | --- | --- | --- | --- | | config | webcpp's configuration, which every library includes first: the target, exceptions and webcpp's version, as Boost.Config is Boost's; webcpp's own | native, wasip2, wasip3, emscripten | a submodule at `libs/config` | | xactor | a deterministic actor system, webcpp's own | native, wasip2, wasip3 (`xactor_asio` native only) | a submodule at `libs/xactor`; the model for every port | -| xstate | a port of XState 5.33.2's state machines and actors; depends on xactor and Boost.JSON | native, wasip2, wasip3; its oracle lane | a submodule at `libs/xstate`; the first user of the shared oracle (chapter 5) | -| pratt | a Pratt parser engine, generic through concepts, with a calculator built on it, webcpp's own | native, emscripten, wasip2, wasip3 | a submodule at `libs/pratt`; born with the allocation rule (chapter 6) | -| wasi | header-only helpers for C++ built as WebAssembly components: the HTTP handler a component exports, webcpp's own | wasip2, wasip3 (`response.hpp` also natively); its own lanes `http`, the components wasmtime serves | a submodule at `libs/wasi`; the first library built as components (chapter 9) | -| 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 (chapter 6) | +| xstate | a port of XState 5.33.2's state machines and actors; depends on xactor and Boost.JSON | native, wasip2, wasip3; its oracle lane | a submodule at `libs/xstate`; the first user of the shared oracle (`CODING-GUIDELINES.md` chapter 12) | +| pratt | a Pratt parser engine, generic through concepts, with a calculator built on it, webcpp's own | native, emscripten, wasip2, wasip3 | a submodule at `libs/pratt`; born with the allocation rule (`CODING-GUIDELINES.md` chapter 4) | +| wasi | header-only helpers for C++ built as WebAssembly components: the HTTP handler a component exports, webcpp's own | wasip2, wasip3 (`response.hpp` also natively); its own lanes `http`, the components wasmtime serves | a submodule at `libs/wasi`; the first library built as components (chapter 4) | +| 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` | @@ -88,7 +89,10 @@ for web developers and for AI developers (chapter 13). webcpp/ Jamroot the single build configuration: finds Boost, checks its version, sets what every library shares, registers each library - AGENTS.md this rulebook + AGENTS.md how to work in the tree: the tools, the commands, the + lanes, the CI and the releases + CODING-GUIDELINES.md the rules on how code is written and every design + decision, with its reason: the single source of them README.md what webcpp is, the prerequisites, getting started LICENSE_1_0.txt .clang-format clang-format's style, every repository's, which a library's own may @@ -100,24 +104,26 @@ webcpp/ 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 - /webcpp/third_party// (chapter 2) + /webcpp/third_party// (guidelines chapter 10) doc/ the index page (index.adoc, Jamfile) releases/ each version's release notes, which the index page shows site/ the site, a repository of its own, webcpporg/webcpporg.github.io, a - submodule here: its pages, components, tools and tests (chapter 9) + submodule here: its pages, components, tools and tests (chapter 4) tools/ - webcpp.jam the Jamfile API (chapter 9): webcpp.targets, webcpp.run, ... + webcpp.jam the Jamfile API (chapter 4): webcpp.targets, webcpp.run, ... target.jam the targets, and the target a toolset builds for, which webcpp.jam and component.jam both read throw_exception.cpp what Boost calls in place of a throw, in a user's build without exceptions - boost_json.cpp Boost.JSON's definitions, built as /webcpp//boost_json (chapter 2) - boost_test_runner.cpp Boost.Test's header-only framework, for webcpp.boost-test (chapter 9) + boost_json.cpp Boost.JSON's definitions, built as /webcpp//boost_json + (guidelines chapter 10) + boost_test_runner.cpp Boost.Test's header-only framework, for webcpp.boost-test + (guidelines chapter 8) boost/ Jamfile: the compiled Boost libraries built from Boost's sources (/webcpp//boost_url, boost_charconv, boost_locale and boost_cobalt) - oracle/ the shared oracle (chapter 5): oracle.jam, twins.py, compare.py and their - tests + oracle/ the shared oracle (guidelines chapter 12): oracle.jam, + twins.py, compare.py and their tests lint/ lint.sh, rules.py, compile_commands.py and their test doc/ the documentation toolchain: doc.jam, reference.py, doc_comments.py, doc-check.py, libraries.py, counts.py, the Asciidoctor.js extensions, the @@ -129,7 +135,7 @@ webcpp/ drive/ drive.jam, the rule of a driven test (webcpp.drive), which a script of the original's language runs over a linked program, drive.py, which runs it bounded, and its test - generated/ generated.jam, the rule of a library's generated files (chapter 9), + generated/ generated.jam, the rule of a library's generated files (chapter 4), generated.py, which runs a generator and checks or writes what it writes, and its test node/ install.py, which installs the Node packages of the documentation, an @@ -146,13 +152,13 @@ webcpp/ toolsets), container/Dockerfile (the image of the container lanes), and actions/{boost,wasi-sdk,wasmtime,wit-bindgen,wasi-wit,emsdk, secp256k1,libdatachannel,openssl,chrome,container,mrdocs,node}/ - (chapter 9) + (chapter 4) site/ site.jam, the rules of b2 site and b2 site-serve, catalogue.py (the site's libraries.json), redirect.py (the old address's two pages) and - their tests (chapter 9) + their tests (chapter 4) release/ changelog.py, the form of a changelog, which the lint checks; release.py, the release tooling; template.adoc; scratch.py and their tests - .github/ workflows/library.yml, workflows/ci.yml, actionlint.yaml (chapter 9) + .github/ workflows/library.yml, workflows/ci.yml, actionlint.yaml (chapter 4) .local/ machine-local, git-ignored (below) bin/ b2's build directory, git-ignored ``` @@ -163,21 +169,24 @@ A library's layout: libs// build.jam project /webcpp/: its headers and dependencies include/webcpp/.hpp the convenience header, which includes every public header but - one that brings an optional heavy dependency (chapter 3) + one that brings an optional heavy dependency + (guidelines chapter 3) include/webcpp//... one header per responsibility wit/ the worlds of a library that builds WebAssembly components, whose bindings its build.jam declares (wasi's http-p2.wit and http-p3.wit) test/ Jamfile, the tests, and .clang-tidy when the tests need one - test/oracle/ a port's oracle (chapter 5): its Jamfile, the pinned original, - the scripts that drive it, and the twins + test/oracle/ a port's oracle (guidelines chapter 12): its Jamfile, + the pinned original, the scripts that drive it, and the + twins example/ Jamfile, the programs and their .expected outputs, and a served - program's .requests (chapter 9) + program's .requests (chapter 4) doc/ Jamfile, the page (.adoc and its sections), mrdocs.yml, - and counts.py when the page counts what only it holds (chapter 8) + and counts.py when the page counts what only it holds (chapter 3) doc/changelog.adoc its changelog, the page's last appendix meta/libraries.json Boost's fields, plus "port-of" meta/include-boundaries.json - the include boundaries the lint checks, when it has any (chapter 6) + the include boundaries the lint checks, when it has any + (guidelines chapter 9) README.md AGENTS.md only what is specific to this library LICENSE_1_0.txt @@ -188,7 +197,7 @@ libs// (InheritParentConfig) and adds only what its code needs, with the reason in a comment, as wasi's names the macros its main is written between (MacroBlockBegin, MacroBlockEnd) - .github/workflows/ci.yml calls the superproject's library.yml (chapter 9) + .github/workflows/ci.yml calls the superproject's library.yml (chapter 4) ``` A library has no Jamroot. It is developed inside a checkout of the @@ -213,7 +222,7 @@ Jamroot is its build configuration, and `libs/` is its repository. and the WIT for a reference that parses a component's bindings (wasi's), and emsdk, whose `em++` and `clang++` read a reference for Emscripten's target, that of a library with a header that builds only on emscripten - (`-sWEBCPP_EMSDK=`, else `.local/emsdk`, chapter 7); + (`-sWEBCPP_EMSDK=`, else `.local/emsdk`, chapter 2); - for a library's oracle lane: Node and npm, with Boost and a C++ toolset; - for the lint: wasi-sdk 34's clang-format, clang-tidy and clang++, Node, the wasip2 and wasip3 toolsets, the emscripten toolset when a library @@ -221,29 +230,29 @@ Jamroot is its build configuration, and `libs/` is its repository. toolsets compile; - for emscripten: Emscripten 6.0.11, from emsdk, and Node, which runs its programs; the tests of the build need it too; -- for trystero, until webcpp builds them from `third_party/` (chapter 13): - libsecp256k1 0.8.0, static, with its `schnorrsig` and `extrakeys` modules, - natively and, for emscripten, built with Emscripten; and, for its native - backend, libdatachannel 0.24.6, built with the compiler and the standard - library that build the programs, and OpenSSL 3. Each is found in the - directory of its `include/` and `lib/` that `-sSECP256K1_ROOT=`, - `-sSECP256K1_EMSCRIPTEN_ROOT=`, `-sLIBDATACHANNEL_ROOT=` and - `-sOPENSSL_ROOT=` on b2's command line name, never the environment, - else in `.local/secp256k1-native`, `.local/secp256k1-emscripten`, - `.local/libdatachannel` and `.local/openssl` when it holds the library's - header (below), else, natively outside Windows, in `/usr/include` or - `/usr/local/include`, where a system install is legitimate; a relative - `-s` is read from b2's working directory. When none holds a library's - header, trystero is left out, its programs skipped, with one line that - names the library and every place it looked, so that `b2 test` builds - every other library, and the index names trystero without a link to its - page; with `webcpp-require-external=on` on b2's command line, as the CI +- for trystero, until webcpp builds them from `third_party/` + (`CODING-GUIDELINES.md` chapter 16): libsecp256k1 0.8.0, static, with its + `schnorrsig` and `extrakeys` modules, natively and, for emscripten, built + with Emscripten; and, for its native backend, libdatachannel 0.24.6, built + with the compiler and the standard library that build the programs, and + OpenSSL 3. Each is found in the directory of its `include/` and `lib/` that + `-sSECP256K1_ROOT=`, `-sSECP256K1_EMSCRIPTEN_ROOT=`, + `-sLIBDATACHANNEL_ROOT=` and `-sOPENSSL_ROOT=` on b2's command + line name, never the environment, else in `.local/secp256k1-native`, + `.local/secp256k1-emscripten`, `.local/libdatachannel` and `.local/openssl` + when it holds the library's header (below), else, natively outside Windows, + in `/usr/include` or `/usr/local/include`, where a system install is + legitimate; a relative `-s` is read from b2's working directory. When none + holds a library's header, trystero is left out, its programs skipped, with + one line that names the library and every place it looked, so that `b2 test` + builds every other library, and the index names trystero without a link to + its page; with `webcpp-require-external=on` on b2's command line, as the CI and the lint build, the build stops instead, naming both libraries - (`webcpp.external` and its kin, chapter 9). trystero's page says how each is built. The CI's actions build - them so (chapter 9). + (`webcpp.external` and its kin, chapter 4). trystero's page says how each is + built. The CI's actions build them so (chapter 4). -Each toolchain is installed by hand and configured in `user-config.jam`, -until webcpp bundles the toolchains (chapter 13). b2 reads +Each toolchain is installed by hand and configured in `user-config.jam`, until +webcpp bundles the toolchains (`CODING-GUIDELINES.md` chapter 16). b2 reads `~/user-config.jam`, or the file `--user-config=` names: ``` @@ -304,7 +313,7 @@ and `/webcpp//boost_cobalt` (`tools/boost/Jamfile`). An installed Boost has none reads them from `-sBOOST_SOURCE=` on b2's command line (or `-s BOOST_SOURCE=`), which wins, else `BOOST_SOURCE` as a user-config.jam's `modules.poke : BOOST_SOURCE : ;` or the environment gives it, which b2 -cannot tell apart (chapter 12), else `.local/boost-source`: a tree with +cannot tell apart (chapter 6), else `.local/boost-source`: a tree with Boost's `boost/version.hpp` and the `libs//src` of each library, which `bash tools/ci/actions/boost/install.sh source .local/boost-source` fills from the archive the CI uses, checked against its SHA-256. It writes @@ -327,7 +336,7 @@ install of emsdk, or a link to one) with Emscripten's cache in `.local/secp256k1-native`, `.local/secp256k1-emscripten`, `.local/libdatachannel` and `.local/openssl` (`include/openssl` and the two libraries of the system's OpenSSL 3, linked, as the CI's `openssl` action -lays them out), where the CI's actions install them too (chapter 9). The +lays them out), where the CI's actions install them too (chapter 4). The build finds each of them there with no `-s`: `b2 -a doc`, whose reference parses trystero's native backend, runs as it is. Another directory is named with `-sSECP256K1_ROOT=` and its kin on b2's command line, never with @@ -339,7 +348,7 @@ where the `using clang` lines of `user-config.jam` name it, and, for a script's component, `-sWASI_SDK` (above). The emsdk is where the `using emscripten` line of `user-config.jam` names its `em++`, for the emscripten toolset, and, for a reference read for Emscripten's target, -`-sWEBCPP_EMSDK=` on b2's command line, else `.local/emsdk` (chapter 7): +`-sWEBCPP_EMSDK=` on b2's command line, else `.local/emsdk` (chapter 2): not a `modules.poke` of `user-config.jam`, nor the environment's `EMSDK`. `tools/lint/compile_commands.py` runs b2 with `.local/user-config.jam`, else with the file `$WEBCPP_USER_CONFIG` names, else with b2's own search. The @@ -376,661 +385,35 @@ told: `b2 --user-config=.local/user-config.jam ...`. | `b2 test` | every library's tests, natively | | `b2 example` | every library's examples: each is built, run with its `.input` as its standard input when it has one, and its output compared with its `.expected` | | `b2 doc` | the index page, `doc/html/index.html`, and every library's page, `libs//doc/html/index.html` | -| `b2 doc -sWEBCPP_INDEX=site` | the same, with the index linking each page where the site serves it, `libs//` (chapter 8) | +| `b2 doc -sWEBCPP_INDEX=site` | the same, with the index linking each page where the site serves it, `libs//` (chapter 3) | | `b2 libs//test` | one library's tests; `libs//example` and `libs//doc` likewise | | `b2 libs//test//` | one test, while working on it (`scheduler`) | | `b2 libs//doc//reference` | one library's API reference alone, MrDocs strict | | `b2 toolset=clang-wasip2 testing.launcher=wasmtime libs//test libs//example` | the same for wasm32-wasip2; `clang-wasip3` for wasm32-wasip3; one toolset per command | -| `b2 toolset=emscripten libs//test libs//example` | the same for emscripten, whose programs b2's toolset runs with node itself: never with a `testing.launcher` (chapter 9) | +| `b2 toolset=emscripten libs//test libs//example` | the same for emscripten, whose programs b2's toolset runs with node itself: never with a `testing.launcher` (chapter 4) | | `b2 install --prefix=` | copies every library's headers to `/include/webcpp/`, and its licence files, `LICENSE_1_0.txt` and a port's `LICENSE-.txt`, beside them in `/include/webcpp//` | | `b2 declared-targets -d0` | prints each ` ` pair the libraries declare: the CI's lanes | -| `b2 declared-lanes -d0` | prints each ` ` line of a library's own lanes, such as its oracle's, and ` ` once per target for a lane that names the targets it runs on; the kind is `original` for a lane that runs the original's language, else `programs` (chapters 5 and 9) | -| `b2 toolset=clang-wasip2 testing.launcher=wasmtime libs//test//` | an own lane on wasip2, such as wasi's served tests, `libs/wasi/test//http` and `libs/wasi/example//http` (chapter 9) | +| `b2 declared-lanes -d0` | prints each ` ` line of a library's own lanes, such as its oracle's, and ` ` once per target for a lane that names the targets it runs on; the kind is `original` for a lane that runs the original's language, else `programs` (`CODING-GUIDELINES.md` chapter 12 and chapter 4) | +| `b2 toolset=clang-wasip2 testing.launcher=wasmtime libs//test//` | an own lane on wasip2, such as wasi's served tests, `libs/wasi/test//http` and `libs/wasi/example//http` (chapter 4) | | `b2 -sWIT_BINDGEN= -sWASI_WIT_P2= -sWASI_WIT_P3= -sWASMTIME= ...` | any of these with the tools of a component where the defaults do not find them (above) | -| `b2 libs//test/oracle//oracle` | a port's oracle lane: the original runs the cases and the twins, and the results are compared (chapter 5) | -| `b2 libs//test/oracle//update-expected` | writes the original's results again, the only writer of an expected result (chapter 5) | -| `b2 libs//test//generated-` | a library's generated files checked against their generator: written into the build directory and compared, byte for byte (chapter 9) | -| `b2 libs//test//update-generated` | writes every generated file of that Jamfile again, the only writer of a generated file (chapter 9) | +| `b2 libs//test/oracle//oracle` | a port's oracle lane: the original runs the cases and the twins, and the results are compared (`CODING-GUIDELINES.md` chapter 12) | +| `b2 libs//test/oracle//update-expected` | writes the original's results again, the only writer of an expected result (`CODING-GUIDELINES.md` chapter 12) | +| `b2 libs//test//generated-` | a library's generated files checked against their generator: written into the build directory and compared, byte for byte (chapter 4) | +| `b2 libs//test//update-generated` | writes every generated file of that Jamfile again, the only writer of a generated file (chapter 4) | | `b2 -a ...` | any of these from scratch; the only build that counts as evidence | -| `tools/lint/lint.sh --clang-format /bin/clang-format --clang-tidy /bin/clang-tidy` | the lint, of the superproject and every library (chapter 6) | -| `python3 tools//_test.py` | a test of the build or of a tool (chapter 10) | -| `python3 tools/ci/matrix.py plan`, `own-lanes`, `lane`, `own-lane`, `register`, `report` | the CI's lanes and own lanes, run the way the CI runs them (chapter 9) | -| `b2 site`, `b2 site-serve` | the whole site, the site's pages with every library's page and the report, into `bin/site/`, every link checked (`tools/site/site.jam`, `tools/ci/assemble.py`); `site-serve` then serves it on http://127.0.0.1:8765/; `-sWEBCPP_SITE=release -sWEBCPP_SITE_VERSION=` builds the release channel (chapter 9) | -| `b2 check-release` | what a tag needs: every library's change has a line, the release notes are complete, and the version agrees everywhere (chapter 11) | -| `b2 whats-new` | writes the skeleton of a version's "What's new", from its release notes (chapter 11) | -| `b2 dist` | writes the version's reproducible archive and its checksum (chapter 11) | - -## 2. Choosing and registering a port - -### Choosing - -- **What.** A library widely used for the web in another language, ported at - an exact version of the original: a tag or a published release, recorded in - `meta/libraries.json` and in the library's `AGENTS.md`. A port follows that - version; moving to another one is a change of its own, with its evidence. -- **The licence.** An original under a licence compatible with BSL-1.0 can be - ported: MIT, BSD and Apache-2.0. GPL cannot. MPL is decided case by case, - by the owner. A port that derives from the original's code keeps the - original's notice, unchanged, in `LICENSE-.txt` (`LICENSE-XSTATE.txt`, - `LICENSE-TRYSTERO.txt`), and its README names the parts that derive from - it. That adds no licence to webcpp's code: every file of webcpp is BSL-1.0 - only, and no repository has a `LICENSE-MIT.txt`. A library of webcpp's own, - like xactor and pratt, has no `LICENSE-.txt`. -- **The name.** `[a-z][a-z0-9_]*`, the name of the original where it has one - (xstate, trystero). `index` is reserved, in any case: the index page is the - doc build's page `index`, and the report refuses a library of that name, - nor `target`, `has`, `no`, `lib` or `version`, which config's macros take - (`WEBCPP_TARGET_*`, `WEBCPP_HAS_EXCEPTIONS`, ...), nor `test`, which the - test-only macros take (`WEBCPP_TEST_*`): the index refuses each. - -### The checklist of a new library - -Each item is done before the port's first green CI; the first two are the -owner's: - -1. **The repository** `webcpporg/`, public from its first commit, made - by the owner. An agent never creates a remote repository, never pushes, - and never changes a GitHub setting. Until the repository exists, the - library is a local repository at `libs/` (`git init`), which the - lint and the build already treat as a library. -2. **The submodule**, added by the owner once the repository exists, with a - URL relative to the superproject's, as Boost's `.gitmodules` writes its - libraries' (`libs/xactor` is `../xactor.git`), so that a clone fetches - the libraries over the same protocol as the superproject: - - ``` - git submodule add ../.git libs/ - ``` - - Never `git add -A` or `git add libs` in the superproject: a library is a - repository of its own, and the superproject records only its commit. -3. **`meta/libraries.json`**, Boost's file, with webcpp's `"port-of"`: - - ```json - { - "key": "xstate", - "name": "xstate", - "authors": ["R"], - "description": "One sentence that says what the library is.", - "category": ["State"], - "maintainers": ["R "], - "cxxstd": "20", - "port-of": { - "name": "XState", - "language": "TypeScript", - "version": "5.33.2", - "url": "https://github.com/statelyai/xstate", - "licence": "MIT" - } - } - ``` - - `"port-of"` is `null` for a library of webcpp's own (xactor's is). `name`, - `description` and `port-of` are required, and every field of `port-of`, - whose `url` is an `https` URL; `tools/doc/libraries.py` fails the doc build, - naming the file and the field, otherwise. -4. **`build.jam`**, which the Jamroot finds by its glob `libs/*/build.jam` and - registers as `/webcpp/`. It declares one target, named after the - library, that adds its headers and its dependencies: - - ``` - # Copyright (c) 2026 WebCpp.org - # ... the licence notice (chapter 11) - - project /webcpp/ ; - - alias : : : : include /boost//headers /webcpp/config//config ; - ``` - - Every library adds config's target, `/webcpp/config//config`, - since its `config.hpp` includes `` (chapter 3). A - dependency on another library is written as its target, - `/webcpp/xactor//xactor`. A compiled Boost library is built by - webcpp from Boost's sources (chapter 1): a library that needs Boost.URL - adds `/webcpp//boost_url` to its target's usage requirements, - static, built once per variant with Boost.URL's own macros; never - `/boost//url`, which would link the system's, nor - `/webcpp/boost-libraries//boost_url`, which the Jamroot's alias checks - the sources' version for. Boost.Charconv and Boost.Locale likewise, - `/webcpp//boost_charconv` and `/webcpp//boost_locale`: - Boost.Locale without ICU, with what it gives on each target in this - table: - - | Target | `/webcpp//boost_locale` | `/webcpp//boost_charconv` | - | --- | --- | --- | - | native Linux (gcc, clang, glibc) | backends posix and std; iconv from glibc; no ICU (measured) | yes (measured) | - | native macOS (Apple clang, gcc) | backends posix and std; iconv from the system's libiconv, `-liconv` given by the target; no ICU (measured) | yes (measured) | - | native Windows (MSVC) | backends winapi and std, no iconv, no ICU: Boost's own configuration on Windows. Not measured here: no Windows machine; the first CI run that builds it is its measurement, and a failure is reported to the owner, never hidden | yes; not measured here | - | wasip2, wasip3 | backends posix and std; iconv from wasi-libc; number, currency and date formatting in the C locale's form (no locale data, no ICU); a catalog is read from a directory the test gives (`webcpp.data`) (measured) | yes (measured) | - | emscripten | backends posix and std; iconv from Emscripten's libc; a catalog is read from the host's files, as natively; single-threaded: Boost.Locale's sources alone are compiled with `BOOST_HAS_PTHREADS`, so that Boost.Thread's mutex, which three of them include, builds against Emscripten's pthread functions, which do nothing there; no program gets it, nor `-pthread`, and no public header of Boost.Locale depends on it, which `tools/test/boost_libraries_test.py` checks by preprocessing every one with it and without (measured) | yes (measured) | - | any target, `exception-handling=off` | refused by name: Boost.Locale throws and catches unguarded (61 `throw`, 14 `try` in its sources, 8 `throw` in its headers) | yes (measured natively and on wasip2) | - - Since Boost.Locale needs exceptions, a program that names - `/webcpp//boost_locale`, directly or through a library, declares - `on` in its own requirements, which keeps it with - exceptions in a build without them, the lint's twins included (chapter 6): - b2 ignores it as a usage requirement, and the refusal stops the whole - build, naming that fix but not the program, which b2 does not give it. - - A library that needs Boost.JSON adds `/webcpp//boost_json` to its - target's usage requirements, as xstate's `build.jam` does: the Jamroot's - `boost_json`, `tools/boost_json.cpp`, compiles Boost.JSON's definitions - (``, as Boost.JSON documents for a header-only build) - into a static library, once per variant, so a user's build without - exceptions gets them built without exceptions too. A library that builds - WebAssembly components declares the C bindings of its worlds there too, - with `webcpp.wit-bindings` (chapter 9), as wasi's `build.jam` does for the - world of each WASI version under its `wit/`. Nothing else registers a - library: the test, example and doc directories join the aggregates `test`, - `example` and `doc` by themselves, and `include/webcpp/**` joins - `install`. -5. **`test/Jamfile`, `example/Jamfile` and `doc/Jamfile`**, with the rules of - chapter 9 and chapter 8. -6. **The files of the repository:** `LICENSE_1_0.txt`, `README.md` (what the - library is, how to build and test it inside the superproject, where its - page is published, its licence), `AGENTS.md` (only what is specific to it, - with a link to this file as `../../AGENTS.md`), `doc/changelog.adoc` (its - changelog, the page's last appendix, chapter 11), `.gitattributes`, and a - `.gitignore` that holds at least `doc/html/`, and for a library with an - oracle `node_modules`, the link to the installed packages, which a pattern - with a slash would miss, and `.node-modules/`, where `tools/node/install.py` - installs them: the superproject's own `.gitignore` names only its top-level - `doc/html/`. -7. **CI.** `.github/workflows/ci.yml`, which calls the superproject's - reusable workflow (chapter 9), as `libs/xactor/.github/workflows/ci.yml` - does: - - ```yaml - jobs: - ci: - uses: webcpporg/webcpp/.github/workflows/library.yml@main - with: - library: - ``` - -8. **The index page.** It lists every library of `libs/` from its - `meta/libraries.json`, so the entry exists once the file does, and `b2 doc` - shows it in `doc/html/index.html`, linked to the library's page, and its - line under New Libraries in the release notes of the version in - preparation. A library without a page fails the index. -9. **`LICENSE-.txt`**, where the port derives from the original's - code (above). - -### Third-party code - -What a library or its tests use and webcpp does not own is never copied into -a library: it is a submodule under `third_party/libs/`, pinned at a -commit, with the URL of its own repository, and `third_party/Jamfile` -declares it as `/webcpp/third_party//`, whose usage requirements -give a program what it needs. It keeps its own licence and notices, and the -lint never reads it (chapter 6). Adding one is the owner's decision; moving -its pin is a change of its own, with its evidence. A target whose submodule -is not checked out stops the build that needs it, naming `git submodule -update --init third_party/libs/`; a build that needs none never looks. - -| Target | What it is | Licence | -| --- | --- | --- | -| `json-schema-test-suite` | the JSON Schema Test Suite at `5b0ee16` (2026-09-21), test data: a test that names it reads the suite at run time from the directory its define `WEBCPP_TEST_JSON_SCHEMA_TEST_SUITE` gives, on every target (wasmtime is given it, `webcpp.data`), and runs again when a file of the suite changes | MIT | -| `nativejson-benchmark` | Milo Yip's nativejson-benchmark at `478d572` (2022-10-28), test data: document's benchmarks (`libs/document/bench`) read its `data/canada.json`, `data/citm_catalog.json` and `data/twitter.json` at run time under the directory its define `WEBCPP_TEST_NATIVEJSON_BENCHMARK` gives, on every target (wasmtime is given it, `webcpp.data`), and run again when one of them changes; its own submodules are never checked out | MIT | - -## 3. Names - -| What | Rule | xactor's | -| --- | --- | --- | -| namespace | `webcpp::` | `webcpp::xactor` | -| what is not public | a namespace `detail`, at any depth | `webcpp::xactor::detail` | -| convenience header | `.hpp>`, which includes every public header, but may leave out one that brings an optional heavy dependency (below) | `` | -| headers | `/...>`, one per responsibility, `snake_case` | `` | -| macros | `WEBCPP__*` | `WEBCPP_XACTOR_*` | -| configuration | `/config.hpp>`, which every public header includes first, which includes `` first, with `WEBCPP__NO_EXCEPTIONS` (chapter 6) | `` | -| test-only macros | `WEBCPP_TEST_*` | | -| include guards | `WEBCPP__
_HPP` | `WEBCPP_XACTOR_ACTOR_LOGIC_HPP` | -| b2 target | `/webcpp///` | `/webcpp/xactor//xactor` | -| error category | `webcpp.` | `webcpp.xactor` | -| identifiers | `snake_case`, Boost's convention; `.clang-tidy` enforces it | | - -config is the one exception: it holds the collection's macros, `WEBCPP_*`, as -Boost.Config holds `BOOST_*`, in `` and -``, whose include guards are `WEBCPP_CONFIG_HPP` and -`WEBCPP_VERSION_HPP`, and declares no namespace. - -A convenience header may leave out a public header that brings an optional -heavy dependency, which a user of the rest should not pay for, and names in -its comment the header it leaves out and the dependency: -`` includes pratt's engine, and leaves out -``, which brings Boost.Decimal. - -A test's helpers that are shared between tests go in `webcpp::test` -(`libs/xactor/test/require.hpp`). Example programs alias the namespace -(`namespace xactor = webcpp::xactor;`), as Boost's do. - -## 4. Fidelity - -- A port behaves as the original, at the version it ports: the same results, - the same order of events, the same errors, for the same inputs. -- Every difference is a decision, recorded in the page's appendix - "Differences": what the original does, what the port does, and why. A - difference forced by C++ (no garbage collector, value types where the - original shares objects) is still recorded. -- Each difference has an example `example/diff_.cpp`, with its - `.expected`, and its twin in the original's language (chapter 5), which - shows the original's behaviour; the page shows both outputs side by side. - xstate is the model, with its `diff_spawn_id`: XState keys a child spawned - without an id as `"undefined"`, the port as an empty string, and the page - shows the two outputs, each printed by its program. -- No divergence goes unrecorded. A difference found later, in a test, a - review or a user's report, is either fixed or recorded in the same change - that finds it. - -## 5. Evidence: oracle and twins - -A port's evidence is the original itself. The port's tests do not state by -hand what the original does: the pinned original runs the same cases and the -twins of the examples, and the port must produce what it produced. The -oracle that does it is shared by every port, in `tools/oracle/`; xstate is -its first user, and the model: - -| Shared, in `tools/oracle/` | Per library, in `libs//test/oracle/` | -| --- | --- | -| the twin runner, `twins.py`, with its agreeing, divergent and without-twin bookkeeping | the pinned original (`package.json` and `package-lock.json`, for JavaScript) | -| output and tree comparison, `twins.py` and `compare.py` | the oracle scripts that drive the original over the cases (xstate's `oracle.mjs` and `actors.mjs`) | -| `update-expected`, with its refusals | the cases, and their C++ runner, under the library's `test/` | -| the `.jam` module of rules, `oracle.jam`, that the library's `test/oracle/Jamfile` calls | the twins, `twins/`, with `without-twin.txt` | -| the CI action that installs the language's runtime, `tools/ci/actions/node` | | - -- **Cases.** The original's tests are ported as data-driven cases, which the - C++ runner runs against the port. -- **Expected results.** The oracle runs the pinned original over the same - cases and writes the expected results. The port must produce them. -- **Twins.** Every documented example has a twin in the original's language, - `.mjs` beside the C++ program in the library's twin directory, which - the page includes through `{twins}`. A twin either agrees (prints exactly - what the C++ example prints), or diverges, with the original's output - recorded as its own `.expected` and the difference in the appendix - (chapter 4), or is listed as without a twin, with the reason, as a line - `: ` of the twin directory's `without-twin.txt`. -- **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 - file: only `update-generated` writes it (chapter 9). -- **How the original runs.** Each library declares it: for JavaScript and - TypeScript, `node --conditions=development`. - -### The rules (`tools/oracle/oracle.jam`) - -A library's `test/oracle/Jamfile` declares its oracle with four rules of -`tools/webcpp.jam`. xstate's, whole after its licence notice and its first -comment: - -``` -import webcpp ; - -webcpp.original node --conditions=development ; -webcpp.twins ../../example : twins : .mjs - : --test-reporter=spec --test-reporter-destination=stderr ; -webcpp.cases machines : oracle.mjs : ../fixtures/cases : ../fixtures/expected ; -webcpp.cases actors : actors.mjs : ../fixtures/actors/cases : ../fixtures/actors/expected ; -webcpp.lane oracle : twins cases-machines cases-actors ; -``` +| `tools/lint/lint.sh --clang-format /bin/clang-format --clang-tidy /bin/clang-tidy` | the lint, of the superproject and every library (`CODING-GUIDELINES.md` chapter 9) | +| `python3 tools//_test.py` | a test of the build or of a tool (`CODING-GUIDELINES.md` chapter 1) | +| `python3 tools/ci/matrix.py plan`, `own-lanes`, `lane`, `own-lane`, `register`, `report` | the CI's lanes and own lanes, run the way the CI runs them (chapter 4) | +| `b2 site`, `b2 site-serve` | the whole site, the site's pages with every library's page and the report, into `bin/site/`, every link checked (`tools/site/site.jam`, `tools/ci/assemble.py`); `site-serve` then serves it on http://127.0.0.1:8765/; `-sWEBCPP_SITE=release -sWEBCPP_SITE_VERSION=` builds the release channel (chapter 4) | +| `b2 check-release` | what a tag needs: every library's change has a line, the release notes are complete, and the version agrees everywhere (chapter 5) | +| `b2 whats-new` | writes the skeleton of a version's "What's new", from its release notes (chapter 5) | +| `b2 dist` | writes the version's reproducible archive and its checksum (chapter 5) | -| Rule | What it declares | -| --- | --- | -| `webcpp.original + [ : ] ;` | how a program of the original's language runs, once and first; and the target `node-modules`, which installs what `package-lock.json` beside the Jamfile, or in the `` given (relative to the Jamfile: document's `test/js` runs the tests of `js/`, whose package pins Playwright and TypeScript), pins with `npm ci`, through `tools/node/install.py`: once per lockfile under `.node-modules/`, linked at `node_modules`, so that runs at once never install over each other | -| `webcpp.twins : : : * ;` | the target `twins`: `twins.py` runs the twin `/` of every program `/.cpp`, at any depth, with the original's words and the extra words, and compares what it prints with the program's `.expected`, or with the twin's own `.expected` for a difference, which must then differ from the program's. Declared once per library: the page shows and counts its twins (chapter 8) | -| `webcpp.cases :