Repository navigation
arisrvx: clients' WebAssembly guests, (room-run module ...), run as their client's program (G4) - #1283
Merged
Conversation
…heir client's program (G4)
A client can send arisrvx a WebAssembly module to run as its own
(ARIADNE_SCRIPTING_HOSTS.md §6.3 and §8.6, G4's first part). The server
document opts in with server: client_guests:, on or {steps, time,
memory_mb}, the same caps as client_programs:.
- The call. (room-run module arg ...) takes the module's bytes in place of
the source, and calls its export run, or the one (room-run-opts (dict
"export" E) ...) names, with the list of the arguments. The request
carries "guest" and "export" on room-call's path.
- As its client's program. ServerDocument::run_client_guest starts S3's
client process (now start_client): the participant's chroot, the
default-deny environment with the five gated writers, the caps and one
at a time. The guest is that program's one call: ScriptEngine's new
client_activation makes it, and run_as_program_work (factored out of
export_activation) runs it as the program's sliced work. So its call,
state imports and data reads reach only that environment. data.write is
refused, and memory_mb caps its linear memory (16 MiB by default).
- Its calls in a narrowed environment. A sliced call's call() ran through
a closure that used apply from the process's environment, which a
client's program doesn't hold. The closure now has apply in a scope of
its own, so a call still reaches only what the process holds.
- In the wasm engine. The module compiles on the app's pool, off the
relay's loop. The relay holds the guest until then (the new
ScriptActivation::ready), so the wait costs none of its caps, for at
most 10 s. The last 16 modules stay compiled. A start function is
refused (has_start: it would run unsliced as the instance is made).
_initialize and ari_alloc get 1M gas each, charged to the program. Each
run has its own instance.
- Hosts. arisrvx links the engine where wasmtime is found
(ARISRV_WITH_WASM makes it required). Stock arisrv refuses a document
with client_guests:, and arisrvx refuses one under --bind-writes off.
Tests:
- ServerBlockTest.ClientGuestsTakeOnOffOrCaps.
- Four ServerDocumentTest cases with a fake engine: the run, what its
calls reach, the refusals and caps, and the hold until it is ready.
- Three WasmClientGuestTest cases on wasmtime: the run, what a guest may
not do, the engine's refusals.
- RoomCallsTest.ParseCall: the guest field.
- arisrvx_room_call_guest: arisrvx and ari over gRPC, with
client_guest.wat as bytes.
- arisrv_doc_client_guests_need_arisrvx.
Docs: ARIADNE.md §9.7.2, and the roadmap's status, §6.3, §8.6 and the S3
and G4 rows.
transfix
enabled auto-merge (squash)
November 16, 2026 00:26
This was referenced Nov 16, 2026
Merged
transfix
added a commit
that referenced
this pull request
Nov 16, 2026
- script_engine.cpp: #1283 factors the sliced form's process lookup into calling_process, which run_as_program_work (a client's WebAssembly guest, run as its client's program) shares. The lookup keeps this branch's group: the calling process is on the group whose pump runs the call (an isolated document's), else on group 0. - STATE_EXEC_THREADED.md: notes that run_as_program_work shares the lookup.
transfix
added a commit
that referenced
this pull request
Nov 18, 2026
…, with hooks, leases and a gas ledger (#1290) A plan, nothing built: docs/roadmap/ARIADNE_RESIDENT_GUESTS.md, from the owner's ask after G4's first part (#1283). - RG1: a client starts a resident guest that the relay keeps, one instance across firings, with hooks (on_tick, watch, msg, timer, owner, close). It writes its own conf.rooms.<room>.guests.<gid> under the participant rule and reads what its owner is sent. - RG2: a gas ledger per principal, kept by salted hash: a grant at first sight, refill as a token bucket, a fee per firing, reserve then settle, starving at zero, a journal store behind an interface. - RG3: leases past the connection (linger with a reset on reconnect, forever, ttl), reattaching by principal, closing reasons, and an admin role. - RG4-RG7: DSL residents, hibernation, guests on clients (a Promise compile and the gas pass in the page), and the Worker backstop. Twelve decisions (D1-D12) are open, each with a recommendation. ARIADNE_SCRIPTING_HOSTS.md §8.7 points to it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
G4, first part of the scripting-hosts roadmap (§6.3 and §8.6): a client can send arisrvx a WebAssembly module to run there as the client's own. It runs as that client's S3 program does, so it has the same chroot, environment, write gate and caps, and nothing more.
The call
room-runtakes the module's bytes in place of the DSL source: ab"\0asm..."literal, or bytes the client read.room-run-asyncandroom-run-optswork the same way, androom-run-opts'"export"names the function to call (runby default).room-call's path the request carries"guest"(bytes) and"export"in place of"fn"or"program". The value comes back as typed CBOR.How the relay runs it
ServerDocument::run_client_gueststarts S3's client process (factored out asstart_client). That gives it:conf.rooms.<room>.participants.<pid>;room_write_gate::may_write;client_guests:, which only lowerariadne.limits.action_max_*;ScriptEngine::client_activationis new. It is an engine's way to run a client's code, and is null by default.run_as_program_work, factored out ofexport_activation's sliced path, runs it as the program's own sliced work.call, state imports and data reads reach only that environment.stepscaps it. It can't call the two natives that run it.call()ran through a small DSL closure that tookapplyfrom the process's environment. A client's narrowed environment doesn't holdapply, so every such call was aNameError. The closure now hasapplyin a scope of its own (SlicedCall). What the activation calls is still only what the process holds.ClientGuest):submitPooled), off the relay's loop.ScriptActivation::ready, new), and starts its program at the next step after that. So the wait costs none of its caps.resource_exhausted.has_start, new inwasm_binary), because a start would run to its end on 100M gas as the instance is made._initializeand eachari_allocget 1M gas, a thousand steps, charged to the program.memory_mb(16 MiB by default), and never aboveariadne.limits.wasm_max_memory.data.writeis refused (a client's program makes no host object). It gets WASI's stubs alone, noari_initand no hooks.-DARISRV_WITH_WASM=ONmakes a missing wasmtime a configure error.client_guests:.--bind-writes off.invalid: not a module, over 1 MiB, a start function, or no export named.failed: it doesn't compile, doesn't export the function, traps,fail()s, or raisesPermissionErrororMemoryError.unavailable: noclient_guests:, a relay without WebAssembly, or the document not loaded.rate_limitedandresource_exhausted, as for programs.Not in it (later parts of G4)
Tests
ServerBlockTest.ClientGuestsTakeOnOffOrCaps.ServerDocumentTestcases with a fake engine, so they run without wasmtime:spawn, not the running natives, not the relay's keys, nothing outside its participant;WasmClientGuestTestcases on wasmtime:pose,spawn,volume_new, memory past the cap, the step cap;RoomCallsTest.ParseCallgains the guest field.arisrvx_room_call_guestruns arisrvx with a--docand anari testclient over gRPC, in seven cases. The guest issrc/arisrv/tests/client_guest.wat, carried as bytes in the client.arisrv_doc_client_guests_need_arisrvxchecks stock arisrv's refusal.ServerDocumentTest,ServerBlockTest,RoomCallsTest,WasmClientGuestTest, the two new ctests, and S3'sarisrv_room_call_programandarisrv_room_call_unavailable);arisrv*test, the script lane and engine, and everyWasm*test;^Ariadnesuite passes, 825 of 825 (5 skipped as on master).-fsyntax-only -Wall -Wextrafinds nothing new in the five changed sources or the three changed tests (it caught a duplicate helper name, fixed). clang-format 18.1.8 is clean on the changed lines.