Skip to content

Commit 2dea285

Browse files
committed
feat: add threaded Wasmtime execution
1 parent cce9c5e commit 2dea285

161 files changed

Lines changed: 81317 additions & 2119 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci-nightly.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,51 @@ on:
66
- cron: "41 10 * * *"
77

88
jobs:
9+
xfstests:
10+
name: "xfstests (${{ matrix.wasm_backend }}, ${{ matrix.storage_backend }})"
11+
runs-on: [self-hosted, agentos-builder]
12+
timeout-minutes: 360
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
wasm_backend: [v8, wasmtime]
17+
storage_backend: [chunked_local, memory, chunked_s3]
18+
steps:
19+
- uses: actions/checkout@v4
20+
- uses: pnpm/action-setup@v4
21+
- uses: actions/setup-node@v4
22+
with:
23+
node-version: 22
24+
- uses: dtolnay/rust-toolchain@stable
25+
with:
26+
targets: wasm32-wasip1
27+
- run: pnpm install --frozen-lockfile
28+
- name: Run the pinned filesystem conformance corpus
29+
run: make -C tests/xfstests run
30+
env:
31+
XFSTESTS_WASM_BACKENDS: ${{ matrix.wasm_backend }}
32+
XFSTESTS_BACKENDS: ${{ matrix.storage_backend }}
33+
XFSTESTS_CONCURRENCY: '2'
34+
- name: Run the 1,000-file multi-process directory stress gate
35+
if: matrix.storage_backend == 'chunked_local'
36+
run: |
37+
cargo test --release -p agentos-native-sidecar \
38+
--test xfstests_correctness \
39+
xfstests_wasi_dirstress_process_matrix -- \
40+
--ignored --exact --nocapture --test-threads=1
41+
env:
42+
AGENTOS_TEST_WASM_BACKEND: ${{ matrix.wasm_backend }}
43+
XFSTESTS_ROOT: ${{ github.workspace }}/tests/xfstests/.work/xfstests
44+
AGENTOS_V8_BRIDGE_PREBUILT_DIR: ${{ github.workspace }}/tests/xfstests/.cache/v8-bridge
45+
CARGO_TARGET_DIR: ${{ github.workspace }}/tests/xfstests/.cache/cargo-target
46+
CARGO_BUILD_JOBS: '1'
47+
- uses: actions/upload-artifact@v4
48+
if: always()
49+
with:
50+
name: xfstests-${{ matrix.wasm_backend }}-${{ matrix.storage_backend }}
51+
path: tests/xfstests/report
52+
if-no-files-found: warn
53+
954
nightly:
1055
name: Nightly runtime validation
1156
runs-on: [self-hosted, agentos-builder]
@@ -43,6 +88,7 @@ jobs:
4388
- run: make -C toolchain commands
4489
- run: make -C toolchain cmd/duckdb
4590
- run: make -C toolchain codex
91+
- run: make -C toolchain/c pthread-conformance-wasm pthread-benchmark-wasm
4692
- run: node packages/runtime-core/scripts/copy-wasm-commands.mjs --require
4793
- name: Use stable Rust for repository validation
4894
run: echo "RUSTUP_TOOLCHAIN=stable" >> "$GITHUB_ENV"
@@ -83,6 +129,16 @@ jobs:
83129
- run: cargo build --release -p agentos-native-sidecar
84130
- run: cargo build --release -p agentos-native-baseline
85131
- run: cargo build --release --target wasm32-wasip1 -p agentos-native-baseline
132+
- name: Long mixed V8-JavaScript and Wasmtime leak/plateau gate
133+
run: pnpm --dir packages/runtime-benchmarks test:wasm-mixed-soak
134+
env:
135+
AGENTOS_SIDECAR_BIN: ${{ github.workspace }}/target/release/agentos-native-sidecar
136+
AGENTOS_WASMTIME_WORKER_PATH: ${{ github.workspace }}/target/release/agentos-native-sidecar
137+
- name: Wasmtime Threads startup, throughput, memory, concurrency, and termination
138+
run: pnpm --dir packages/runtime-benchmarks bench:wasm-threads
139+
env:
140+
AGENTOS_SIDECAR_BIN: ${{ github.workspace }}/target/release/agentos-native-sidecar
141+
AGENTOS_WASMTIME_WORKER_PATH: ${{ github.workspace }}/target/release/agentos-native-sidecar
86142
- run: pnpm --dir packages/runtime-benchmarks bench:matrix
87143
env:
88144
AGENTOS_SIDECAR_BIN: ${{ github.workspace }}/target/release/agentos-native-sidecar

.github/workflows/ci.yml

Lines changed: 100 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,36 @@ jobs:
121121
workspaces: toolchain -> target
122122
key: wasm-commands-${{ hashFiles('toolchain/Cargo.lock') }}
123123
- run: pnpm install --frozen-lockfile --filter '@rivet-dev/agentos-runtime-core...'
124-
- run: make -C toolchain pr-commands
125-
- run: node packages/runtime-core/scripts/copy-wasm-commands.mjs --require-coreutils
124+
- run: make -C toolchain commands
125+
# DuckDB and Vim are intentionally outside the default command set because
126+
# they are heavy builds, but the runtime/parity suites require their real
127+
# command artifacts.
128+
- name: Build required heavy integration commands
129+
run: make -C toolchain cmd/duckdb cmd/vim
130+
- name: Build mandatory threaded-WASM conformance fixtures
131+
run: make -C toolchain/c pthread-conformance-wasm pthread-benchmark-wasm
132+
- name: Stage native/WASM C parity fixtures
133+
run: make -C toolchain/c conformance-artifacts
134+
- run: node packages/runtime-core/scripts/copy-wasm-commands.mjs --require
126135
- uses: actions/upload-artifact@v4
127136
with:
128137
name: wasm-commands
129138
path: packages/runtime-core/commands
130139
retention-days: 1
131140
if-no-files-found: error
141+
- uses: actions/upload-artifact@v4
142+
with:
143+
name: wasm-thread-fixtures
144+
path: |
145+
toolchain/c/build/pthread_conformance.wasm
146+
toolchain/c/build/pthread_benchmark.wasm
147+
toolchain/c/build/exec_variants
148+
if-no-files-found: error
149+
- uses: actions/upload-artifact@v4
150+
with:
151+
name: wasm-c-parity-fixtures
152+
path: toolchain/c/build/conformance
153+
if-no-files-found: error
132154

133155
rust:
134156
name: Rust
@@ -331,3 +353,79 @@ jobs:
331353
exit 1
332354
fi
333355
done
356+
357+
wasm-backend-matrix:
358+
name: "WASM backend (${{ matrix.backend }})"
359+
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'aggregate-ci')
360+
needs: [wasm-commands]
361+
runs-on: [self-hosted, agentos-builder]
362+
timeout-minutes: 180
363+
strategy:
364+
fail-fast: false
365+
matrix:
366+
backend: [v8, wasmtime]
367+
env:
368+
AGENTOS_TEST_WASM_BACKEND: ${{ matrix.backend }}
369+
AGENTOS_E2E_NETWORK: '1'
370+
AGENT_OS_CLIENT_ALLOW_E2E_SKIPS: '0'
371+
AGENTOS_SIDECAR_BIN: ${{ github.workspace }}/target/release/agentos-native-sidecar
372+
AGENTOS_WASMTIME_WORKER_PATH: ${{ github.workspace }}/target/release/agentos-native-sidecar
373+
AGENTOS_WASM_COMMANDS_DIR: ${{ github.workspace }}/packages/runtime-core/commands
374+
AGENTOS_C_WASM_COMMANDS_DIR: ${{ github.workspace }}/toolchain/c/build/conformance
375+
steps:
376+
- uses: actions/checkout@v4
377+
- uses: pnpm/action-setup@v4
378+
- uses: actions/setup-node@v4
379+
with:
380+
node-version: 22
381+
- uses: dtolnay/rust-toolchain@stable
382+
- uses: Swatinem/rust-cache@v2
383+
with:
384+
key: wasm-backend-${{ matrix.backend }}
385+
- run: pnpm install --frozen-lockfile
386+
- uses: actions/download-artifact@v4
387+
with:
388+
name: wasm-commands
389+
path: packages/runtime-core/commands
390+
- uses: actions/download-artifact@v4
391+
with:
392+
name: wasm-thread-fixtures
393+
path: toolchain/c/build
394+
- uses: actions/download-artifact@v4
395+
with:
396+
name: wasm-c-parity-fixtures
397+
path: toolchain/c/build/conformance
398+
- name: Restore and package the validated command corpus
399+
run: |
400+
mkdir -p toolchain/target/wasm32-wasip1/release/commands
401+
cp -a packages/runtime-core/commands/. toolchain/target/wasm32-wasip1/release/commands/
402+
node packages/runtime-core/scripts/copy-wasm-commands.mjs --require
403+
pnpm --filter @agentos-software/coreutils build:runtime
404+
pnpm --filter '@agentos-software/common...' build
405+
- name: Build the release sidecar and public test clients
406+
run: |
407+
cargo build --release -p agentos-native-sidecar
408+
pnpm --filter '@rivet-dev/agentos-runtime-core...' build
409+
pnpm --filter @rivet-dev/agentos-vm-test-harness build
410+
pnpm --filter @rivet-dev/agentos-core build
411+
pnpm --filter @rivet-dev/agentos build
412+
- name: Run all native sidecar tests through the selected VM backend
413+
run: cargo test --release -p agentos-native-sidecar --tests -- --test-threads=1
414+
- name: Run owned pthread libc conformance
415+
if: matrix.backend == 'wasmtime'
416+
run: cargo test --release -p agentos-native-sidecar --test wasmtime_safety owned_pthread_libc_mutex_cond_tls_join_detach_and_cancel_conform -- --ignored --exact --nocapture --test-threads=1
417+
- name: Run native-vs-WASM C conformance through the selected VM backend
418+
run: pnpm --dir packages/core exec vitest run --root ../.. toolchain/conformance/c-parity.test.ts --reporter=verbose --maxWorkers=1 --minWorkers=1
419+
- name: Run runtime-core WASM and cross-runtime integration serially
420+
run: pnpm --dir packages/runtime-core exec vitest run --reporter=verbose --maxWorkers=1 --minWorkers=1
421+
- name: Run the public TypeScript client suite serially
422+
run: pnpm --dir packages/core exec vitest run --reporter=verbose --maxWorkers=1 --minWorkers=1
423+
- name: Run the public Rust client without artifact skips
424+
run: cargo test -p agentos-client -- --test-threads=1
425+
- name: Run every registry software suite through the selected WASM backend
426+
run: pnpm exec turbo test --concurrency=1 --filter='@agentos-software/*'
427+
- name: Run deterministic actor, ACP, and agent-tool conformance
428+
run: pnpm --filter @rivet-dev/agentos test:e2e:run
429+
- name: Run mixed V8-JavaScript and Wasmtime resource-plateau smoke
430+
if: matrix.backend == 'wasmtime'
431+
run: pnpm --dir packages/runtime-benchmarks test:wasm-mixed-smoke

.github/workflows/publish.yaml

Lines changed: 70 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,25 @@ jobs:
7373
key: wasm-commands-${{ hashFiles('toolchain/Cargo.lock') }}
7474
- run: pnpm install --frozen-lockfile --filter '@rivet-dev/agentos-runtime-core...'
7575
- run: make -C toolchain commands
76+
# These real upstream commands are intentionally outside the fast default
77+
# toolchain target, but are part of the published and parity-tested corpus.
78+
- name: Build required heavy release commands
79+
run: make -C toolchain cmd/duckdb cmd/vim
80+
- run: make -C toolchain/c pthread-conformance-wasm
81+
- run: make -C toolchain/c build/exec_variants
7682
- run: node packages/runtime-core/scripts/copy-wasm-commands.mjs --require
7783
- uses: actions/upload-artifact@v4
7884
with:
7985
name: wasm-commands
8086
path: packages/runtime-core/commands
8187
if-no-files-found: error
88+
- uses: actions/upload-artifact@v4
89+
with:
90+
name: wasm-thread-fixtures
91+
path: |
92+
toolchain/c/build/pthread_conformance.wasm
93+
toolchain/c/build/exec_variants
94+
if-no-files-found: error
8295

8396
codex-wasm:
8497
name: Codex WASI
@@ -272,10 +285,63 @@ jobs:
272285
path: target/sidecar-artifacts/${{ matrix.platform }}
273286
if-no-files-found: error
274287

288+
smoke-sidecar-artifacts:
289+
needs: [wasm-commands, build-sidecar, build-sidecar-darwin]
290+
name: "Packaged WASM backends (${{ matrix.platform }})"
291+
strategy:
292+
fail-fast: false
293+
matrix:
294+
include:
295+
- platform: linux-x64-gnu
296+
runner: [self-hosted, agentos-builder]
297+
- platform: linux-arm64-gnu
298+
runner: [self-hosted, agentos-builder-arm64]
299+
- platform: darwin-x64
300+
runner: macos-15-intel
301+
- platform: darwin-arm64
302+
runner: macos-15
303+
runs-on: ${{ matrix.runner }}
304+
steps:
305+
- uses: actions/checkout@v4
306+
- uses: pnpm/action-setup@v4
307+
- uses: actions/setup-node@v4
308+
with:
309+
node-version: 22
310+
cache: pnpm
311+
cache-dependency-path: pnpm-lock.yaml
312+
- uses: dtolnay/rust-toolchain@master
313+
with:
314+
toolchain: ${{ env.RUST_TOOLCHAIN }}
315+
- run: pnpm install --frozen-lockfile --filter '@rivet-dev/agentos-runtime-core...'
316+
- uses: actions/download-artifact@v4
317+
with:
318+
name: wasm-commands
319+
path: packages/runtime-core/commands
320+
- uses: actions/download-artifact@v4
321+
with:
322+
name: wasm-thread-fixtures
323+
path: target/wasm-thread-fixtures
324+
- uses: actions/download-artifact@v4
325+
with:
326+
name: sidecar-${{ matrix.platform }}
327+
path: target/smoke-sidecar
328+
- name: Stage the actual release binary in its npm platform package
329+
run: |
330+
set -euo pipefail
331+
package_dir="packages/runtime-sidecar/npm/${{ matrix.platform }}"
332+
cp target/smoke-sidecar/agentos-native-sidecar "$package_dir/agentos-native-sidecar"
333+
chmod +x "$package_dir/agentos-native-sidecar"
334+
- run: pnpm --filter @rivet-dev/agentos-runtime-core build
335+
- name: Install tarballs and exercise every shipped WASM selector
336+
run: |
337+
node scripts/ci/smoke-packed-wasm-backends.mjs \
338+
--platform-package "packages/runtime-sidecar/npm/${{ matrix.platform }}" \
339+
--thread-fixture target/wasm-thread-fixtures/pthread_conformance.wasm
340+
275341
publish-npm:
276-
needs: [context, wasm-commands, codex-wasm, wasmtime-darwin-smoke, build-sidecar, build-sidecar-darwin]
342+
needs: [context, wasm-commands, codex-wasm, wasmtime-darwin-smoke, build-sidecar, build-sidecar-darwin, smoke-sidecar-artifacts]
277343
name: Publish npm
278-
if: ${{ !cancelled() && needs.wasm-commands.result == 'success' && needs.codex-wasm.result == 'success' && needs.wasmtime-darwin-smoke.result == 'success' && needs.build-sidecar.result == 'success' && needs.build-sidecar-darwin.result == 'success' }}
344+
if: ${{ !cancelled() && needs.wasm-commands.result == 'success' && needs.codex-wasm.result == 'success' && needs.wasmtime-darwin-smoke.result == 'success' && needs.build-sidecar.result == 'success' && needs.build-sidecar-darwin.result == 'success' && needs.smoke-sidecar-artifacts.result == 'success' }}
279345
runs-on: ubuntu-latest
280346
steps:
281347
- uses: actions/checkout@v4
@@ -357,9 +423,9 @@ jobs:
357423
${{ needs.context.outputs.trigger == 'release' && '--release-mode' || '' }}
358424
359425
release-assets:
360-
needs: [context, wasmtime-darwin-smoke, build-sidecar, build-sidecar-darwin]
426+
needs: [context, wasmtime-darwin-smoke, build-sidecar, build-sidecar-darwin, smoke-sidecar-artifacts]
361427
name: Release assets
362-
if: ${{ !cancelled() && needs.wasmtime-darwin-smoke.result == 'success' && needs.build-sidecar.result == 'success' && needs.build-sidecar-darwin.result == 'success' }}
428+
if: ${{ !cancelled() && needs.wasmtime-darwin-smoke.result == 'success' && needs.build-sidecar.result == 'success' && needs.build-sidecar-darwin.result == 'success' && needs.smoke-sidecar-artifacts.result == 'success' }}
363429
runs-on: ubuntu-latest
364430
permissions:
365431
contents: write

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,14 @@ secrets/**/*
4343
# Generated WASM toolchain and software artifacts. These are rebuilt for tests
4444
# and releases and must never be committed.
4545
packages/runtime-core/commands/
46+
packages/runtime-sidecar/npm/*/agentos-native-sidecar
47+
packages/sidecar-binary/npm/*/agentos-sidecar
4648
toolchain/vendor/
4749
toolchain/c/build/
4850
toolchain/c/vendor/
4951
toolchain/c/libs/
5052
toolchain/c/sysroot/
53+
toolchain/c/sysroot-threads/
5154
toolchain/c/.cache/
5255
toolchain/std-patches/wasi-libc-overrides/*.o
5356
software/*/bin/
@@ -86,6 +89,7 @@ scripts/ralph/.codex-last-msg-*
8689

8790
# Local caches and stray outputs
8891
.agentos/
92+
.cache/
8993
crates/execution/assets/v8-bridge.js
9094
crates/execution/assets/v8-bridge-zlib.js
9195
crates/execution/.agentos-pyodide-cache/

Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,10 @@ vbare-compiler = { package = "rivet-vbare-compiler", version = "0.0.5" }
8686
wasmtime = { version = "=46.0.0", default-features = false, features = [
8787
"async",
8888
"cranelift",
89+
"gc",
90+
"gc-drc",
8991
"runtime",
9092
"std",
93+
"threads",
9194
] }
9295
wasmparser = "=0.251.0"

0 commit comments

Comments
 (0)