Skip to content

ci(test): the Worker's wasm32 unit tests and a new workers job (Test phase, stage 8, G-6) - #345

Merged
aRustyDev merged 12 commits into
mainfrom
ci/test-stage-workers
Nov 22, 2026
Merged

aRustyDev merged 12 commits into
mainfrom
ci/test-stage-workers

Conversation

@aRustyDev

@aRustyDev aRustyDev commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

Stage 8 of the Test phase (.agents/plans/ci-workflows/phases/0003-test.md, "Stage 8 in detail"): G-6, the Worker's wasm32 unit tests, and a new workers job in test.yml that runs them.

What it adds

  • 15 #[wasm_bindgen_test] tests in crates/worker/src/wasm_tests.rs, for the Worker's own glue that only a wasm32 build has: reading Env (the retention windows of feat(retention): run_retention, its windows and its admin routes #340 included), the composition root, the queue consumer, and the fetch entry point with its 8 MiB body ceiling. Inputs are generated where a domain can be (words over an alphabet for the six spellings of a flag and for the retention windows, decimal digits and bit boundaries for the number reader, every sign-in rate window to 200 s, every subset of the OIDC settings, bodies at the ceiling); the exceptions are named in the test and in status G-6.
  • The workers job (test.yml): nextest's new workers profile, one wasm-bindgen runner process per test, on Node. It is in the plan, the verdict and the gate from this PR on (ADR-0102 allows no advisory job in test.yml), and runs when thrust-worker is affected.
  • Harness: scripts/wasm-tests.sh (nextest and a count guard: every declared test must have run), scripts/wasm-test-runner.sh (cargo's runner for wasm32; refuses a wasm-bindgen-test-runner that is not the lock's wasm-bindgen exactly), scripts/lib/workerd-stubs.cjs (see below), [profile.wasm-test] (no debug info), .cargo/mutants-wasm.toml (cargo-mutants through the same runner, by hand).
  • Cargo.lock: +10 packages (all from wasm-bindgen-test, a wasm32-only dev-dependency of thrust-worker); the stage changes no existing package.
  • Unrelated, folded in at your word: url 2.5.8 → 2.5.9 and form_urlencoded 1.2.2 → 1.2.3. A new advisory, RUSTSEC-2026-0592 (a stack overflow in Url::origin() on nested blob: URLs), turned cargo deny red on main's own lock, so security / deny and gate went red for any PR that touches Cargo.lock. cargo update -p url --precise 2.5.9 (a plain cargo update -p url locks nothing); four lines each way in the lock. It is its own commit, so it can be lifted out.

Evidence

  • 15 of 15 pass locally under nextest, on the tree merged with main (7.6 s wall, 6.6 s in nextest; 14 of 14 took 4.5 s before the merge: one process per test, all started at once, so the load of the machine moves it).
  • cargo-mutants on crates/worker/src/lib.rs through the same runner, on the merged tree: 52 mutants, 43 caught, 8 unviable, 1 missed, 0 timeouts. Before the fetch and queue tests: 33 caught, 11 missed. The one missed is scheduled → (): it hands the trigger's cron string to thrust_core::run_cron and logs the report, so over an empty memory store its only visible effect is a log line. What a trigger runs is tested natively (schedules.rs, outbox.rs) and by the contract suite's cron pass on the Worker, which since feat(jobs): schedule the daily hard delete on the Worker and the server #343 also covers the hard delete. feat(jobs): schedule the daily hard delete on the Worker and the server #343 changed that one function; cargo mutants --list on the merged tree gives the same 52, with only its line moved, and I did not run them again.
  • No defect was found in the Worker. Every red while building this was in a test or in the harness, so the mutant run, not the Worker, is the evidence these tests can fail.
  • The helper tests are extended, each with controls: test-wasm-tests.sh (66 checks, sh and dash), test_plan_ci.py (7,038), test_workflow_wiring.py (168), test-ci-scripts.sh (209 cases), mutate_gate.py (272 of 272 killed, none survived, on the merged tree).
  • On the merged tree, every deps guard but one, cargo deny (the ten new packages included), cargo fmt, the lint job's clippy runs, and the book build pass. check-openapi.sh was not run: Docker is not running on my machine, so its oasdiff step cannot start. This PR does not touch thrust-api-v1, where that document comes from, and CI's deps job runs it.
  • main moved while this was open (feat(retention): run_retention, its windows and its admin routes #340, retention): merged in, and the one source conflict handled: core_config now returns a Result, so the configuration test reads through a helper and a new test covers the two retention windows. feat(jobs): schedule the daily hard delete on the Worker and the server #343 touches test.yml, crates/worker/src/lib.rs, cicd.md and status.md too; whichever of us merges second merges main.

Things you should look at

  1. The host is Node, not workerd, which departs from ADR-0123. I found no public runner that hosts Rust unit tests inside workerd (vitest-pool-workers and Miniflare would only repeat the HTTP cells). What a test sees of Request, Response and streams is Node's. Recorded in status G-6, the defect matrix (X8) and real-backends.md.
  2. scripts/lib/workerd-stubs.cjs is hand-written custom code. The Worker's wasm imports four modules that exist only in workerd (cloudflare:workers|sockets|node|email), so plain Node fails to load it. The file answers them with Node's module.registerHooks (Node 22.15 or later; CI pins 22.22.0), and defines the one workerd global the entry points use (FixedLengthStream). tracing answers as workerd does outside an invocation. Each entry has a check and a control in test-wasm-tests.sh; the first run of the entry-point tests found two of them.
  3. One piece of custom code was replaced by a built-in. I first wrote an awk reader of Cargo.lock for the runner's version, without checking for one. cargo pkgid --locked wasm-bindgen does it (same answer, fails on none and on two versions), so the script is gone.
  4. A gap that nothing here closes: CI's lint does not read wasm_tests.rs. lint.yml's Worker clippy step has no --all-targets. I ran it by hand, found one type_complexity error and fixed it. A step in lint.yml would keep it clean, but that is the Lint phase's file, so I left it for you to decide (recommended for Phase 5).
  5. The job runs on Node 26.13.1, not the web jobs' 22.22.0. The first CI run failed all 15 tests on 22.22.0 with ERR_INTERNAL_ASSERTION ("a bug in Node.js"), though everything had passed locally on 26.9.0. Node's require(esm) path asserts that an import specifier's protocol is file:, node: or data: before any hook is asked, and the runner's CommonJS glue require()s the Worker's inline snippets, which import cloudflare:workers. I read lib/internal/modules/esm/loader.js of every release from 22.15 to 25.9: every 22 and 23 asserts, 24 before 24.12, 25 before 25.2; 26 has no such code. scripts/wasm-test-runner.sh now refuses an older Node in words, with a control for each boundary. 24.12 and later were read in source, not run.
  6. A hand-written table of 14 THRUST_V1_RATE_LIMIT spellings (Rule 9 (b)) and the queue consumer's few fixed batches are not generated; the second is a recorded Rule 9 gap.

Not covered

The edge Worker's runtime.rs (G-41) and the two preview Workers (your decision: thrust-worker only); a binding that is JavaScript null; a --no-default-features run (the tests need the memory feature, and the count guard says so).

CI evidence

  • Run 44822700250 (first): workers alone failed, all 15 tests, on Node 22.22.0 (above). Every other job was green and gate was red, as designed.
  • Run 44825424412 (on Node 26.13.1): green in every job, gate included. wasm32 tests: 15 of 15 declared, all passed. The workers job took 92 s, cold (No cache found: the cache is saved on main only): setup-rust 16 s, the runner install 2 s, the wasm-test build 35 s, nextest 19 s on 4 cores. It is on no critical path: the run took 8 m 41 s, set by the cells. ci-scripts ran test-wasm-tests.sh there too (66 of 66, none skipped), and deps ran check-openapi with Docker, which I could not run locally.
  • The warm number needs a run on main; it goes in the record of this stage after the merge.

🤖 Generated with Claude Code

aRustyDev and others added 6 commits November 20, 2026 16:21
…ge 8, G-6)

The Worker's configuration reading, composition root, queue consumer and fetch entry point exist only on wasm32, so nothing native reached them: only the worker-memory and worker-cf cells did, over HTTP.

crates/worker/src/wasm_tests.rs holds 14 #[wasm_bindgen_test] functions, run by wasm-bindgen-test-runner on Node through nextest's new `workers` profile (scripts/wasm-tests.sh: one runner process per test, and a count guard that every declared test ran). cargo-mutants on crates/worker/src/lib.rs through the same runner, by hand (.cargo/mutants-wasm.toml): 52 mutants, 43 caught, 8 unviable, 1 missed (`scheduled`, whose only effect is a log line; the contract suite's cron pass covers it). Before the fetch and queue tests it was 33 caught and 11 missed.

scripts/wasm-test-runner.sh is cargo's runner for wasm32: it refuses a runner that is not the lock's wasm-bindgen exactly (asked of `cargo pkgid --locked`) and loads scripts/lib/workerd-stubs.cjs, which stands in for the workerd-only modules, and the FixedLengthStream global, that the Worker's wasm imports. [profile.wasm-test] drops debug info: 20 s a test with it, 1.85 s without.

The host is Node, not workerd as ADR-0123 names: no public runner hosts Rust unit tests inside workerd. Cargo.lock gains 10 packages, all from wasm-bindgen-test, a wasm32-only dev-dependency of thrust-worker.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
… and the gate (Test phase, stage 8)

A job in test.yml that runs scripts/wasm-tests.sh: Node from web/.node-version, the wasm32 target, and wasm-bindgen-test-runner installed at the version `cargo pkgid --locked wasm-bindgen` reads from Cargo.lock (taiki-e/install-action, checksummed). Cache key wasm-workers, saved on main only.

ADR-0102 allows no advisory job in a called workflow, so it is in the planner from the start (JOBS, WORKFLOWS, planned when thrust-worker is affected, and a rule for its scripts), in the verdict's needs and jobs, and in the dispatch default plan.

Tests, each with controls: test-wasm-tests.sh (46 checks, in the ci-scripts list; sh and dash), test_plan_ci.py, test_workflow_wiring.py, test-ci-scripts.sh (workers among test.yml's jobs: 209 cases) and mutate_gate.py (270 of 270 mutants killed, none survived).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
running.md (the workers profile, the script, the job and a runbook for a red one), cicd.md (the job, how it is planned, and the examples table run again through the planner, which showed two rows already out of date), status.md G-6 (what is built, the cargo-mutants result with its one survivor, what is still open, and the departure from ADR-0123), the defect matrix X8, real-backends.md, AGENTS.md's Commands table and the workflows README.

The phase document gets its stage 8 section: the survey, the custom code with its probes, the measurements and the pass log. The plan's status lines said no stage of the phase had started; they now say where it stands.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Two things came with it:

- docs/src/architecture/cicd.md: both sides edited the test.yml row (mine: the workers job and 47 commands; main's: 65 mutant rows). Kept mine, with 65.
- crates/worker/src/wasm_tests.rs: #340 made `core_config` return a Result (a retention window that is not a number of days stops the Worker from building its app), so the configuration test now reads through `configured`, and a new test covers the two windows: each into its own field, every word over an alphabet and the u32 boundaries against the test's own decimal reference, a bad window named and the good one beside it not, and the composition root refusing one. 15 tests now.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ion windows)

15 tests and not 14: the new one covers the two retention windows #340 added to the Worker's configuration. Run again on the merged tree: 15 of 15 pass, and cargo-mutants on crates/worker/src/lib.rs has the same result (52 mutants, 43 caught, 8 unviable, 1 missed, `scheduled`, now at line 428). The times are recorded as measured, both runs: the same script took 4.5 s on 14 tests and 7.6 s on 15, and the same 52 mutants 6 m 25 s and 11 m 32 s, and the phase document says that it is not known whether that is load or the merged code.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@aRustyDev
aRustyDev temporarily deployed to preview-control-plane November 20, 2026 21:42 — with GitHub Actions Inactive
@socket-security

socket-security Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedcargo/​wasm-bindgen-test@​0.3.8010010093100100
Addedcargo/​form_urlencoded@​1.2.310010093100100

View full report

… cloudflare: imports

The first CI run of the job failed all 15 tests on Node 22.22.0, the web jobs' pin (web/.node-version), with ERR_INTERNAL_ASSERTION ("a bug in Node.js") at ModuleLoader.getModuleJobForRequire. Everything had passed locally, on Node 26.9.0.

The runner's glue is CommonJS and require()s the Worker's inline JavaScript snippets, which are ES modules that import `cloudflare:workers` and its like. Node's require(esm) path asserts that an import specifier's protocol is file:, node: or data:, before any resolve hook is asked, so scripts/lib/workerd-stubs.cjs cannot help. Reading lib/internal/modules/esm/loader.js of every release from 22.15 to 25.9: every 22 and 23 asserts (22.23.5 is the last 22), 24 asserts before 24.12.0, 25 before 25.2.0, and 26 has no such code.

The job pins Node 26.13.1. scripts/wasm-test-runner.sh refuses an older Node in words, so that nobody reads "a bug in Node.js"; test-wasm-tests.sh holds each boundary with stand-in nodes and a broken copy of the wrapper for each (66 checks), test_workflow_wiring.py holds the pin to 26 or later, and mutate_gate.py changes it three ways (272 of 272 mutants killed). The runbook, the status row and the phase document say what happened.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@aRustyDev
aRustyDev temporarily deployed to preview-control-plane November 20, 2026 22:01 — with GitHub Actions Inactive
Run 44825424412, green in every job, gate included: the workers job took 92 s with a cold cache (the cache is saved on main only), 35 s of it the wasm build and 19 s the 15 tests on the runner's 4 cores; it is on no critical path (the run took 8 m 41 s, set by the cells). The first run, 44822700250, failed workers alone on Node 22.22.0; that is in the phase document already. Passes 2 and 5 of the stage are updated: 2 holds, 5 has its cold number and waits for a run on main for the warm one. The helper counts are the ones after the Node guard (66 checks, 168 wiring checks, 272 mutants).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@aRustyDev
aRustyDev temporarily deployed to preview-control-plane November 20, 2026 22:12 — with GitHub Actions Inactive
aRustyDev and others added 2 commits November 22, 2026 18:03
… stage 8)

#343 made the Worker's cron handler hand the trigger's own cron string to thrust_core::run_cron, so the sentence that said its only effect is a log line over the sweeper was no longer exactly right. What a trigger runs is tested natively (crates/core/usecases/tests/schedules.rs and outbox.rs) and by the contract suite's cron pass on the Worker, which now also has worker_cron_scheduled_handler_runs_the_hard_delete. `cargo mutants --list` on the merged tree gives the same 52 mutants as before, with only scheduled's line moved (428 to 432); they were not run again, and the documents say so.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@aRustyDev
aRustyDev temporarily deployed to preview-control-plane November 22, 2026 23:06 — with GitHub Actions Inactive
aRustyDev and others added 2 commits November 22, 2026 18:18
url 2.5.8 and earlier overflow the stack in `Url::origin()` on a nested `blob:` URL, which aborts the process and which catch_unwind does not catch. The advisory appeared after the last green run, so `cargo deny` fails on main's own Cargo.lock too: security / deny, and so gate, is red for any change that touches Cargo.lock or a manifest.

`cargo update -p url --precise 2.5.9`: a plain `cargo update -p url` locks nothing, and the precise form moves url and its one dependency form_urlencoded (1.2.2 to 1.2.3), four lines each way in the lock and no other package. url is reached through ammonia, bollard, lettre and oauth2. It is unrelated to the stage-8 work of this pull request and was folded in at the owner's word, as its own commit.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…nged no package (stage 8)

The phase document's Cargo.lock row said no existing package changed. The stage still changed none; the url and form_urlencoded bump for RUSTSEC-2026-0592 is in the same pull request, as its own commit, and the row says so and says why.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@aRustyDev
aRustyDev temporarily deployed to preview-control-plane November 22, 2026 23:18 — with GitHub Actions Inactive
@aRustyDev
aRustyDev merged commit a5f1197 into main Nov 22, 2026
49 checks passed
@aRustyDev
aRustyDev deleted the ci/test-stage-workers branch November 22, 2026 23:31

This branch was previously deployed

1 inactive deployment
preview-control-plane — 9432a4f9 Deployed Nov 22, 2026 by aRustyDev via reconcile #612
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant