Repository navigation
Description
Scope
Build on #34 to implement synchronous, owned wasi::thread-spawn(i32) -> i32 for the exact Rust 1.95 wasm32-wasip1-threads guest. Under a short controller lock, reserve a valid nonzero TID; reject configured cap or closing state with a deterministic negative result and facade semantic diagnostic. Drop the lock before native spawn, Store/Instance construction, Wasm execution, and joining.
Each accepted guest spawn creates one native std::thread with a fresh Store, a fresh Instance from the one shared InstancePre, and calls the exported wasi_thread_start(tid, start_arg). start_arg is opaque. All instances share compiled code, the one engine-owned SharedMemory/heap, capability/resource registry, and the one caller-provided RuntimeHandle identity; Store, Instance, Wasm stack, TLS, and execution state are distinct.
Update the source-only real guest to prove ordinary std::thread, Arc, atomics, Mutex, channel, and deterministic concurrent-map behavior. It writes a bounded atomic result record in shared linear memory. The host proves root plus two guest children observe the same allocation and expected synchronization result.
RED → GREEN
- RED: feat(wasm): add private threaded root execution substrate #34 root execution has a deterministic thread-spawn rejection and no child bootstrap.
- GREEN: direct real artifact test proves root plus two native child threads; one module/engine/prelink/shared-memory/runtime identity; distinct Store/Instance/TLS identities; expected Arc/atomic/mutex/channel/map result record; and a bounded host read using atomics.
- Max-thread rejection returns the documented negative value, leaks no slot/handle, and leaves the registry unchanged.
- Cooperative normal completion joins root and child workers, reports each typed outcome, and leaves zero live registrations/JoinHandles.
- Characterize nonzero proc_exit and child trap outcomes as typed semantic results. Do not call kernal-api-run twice when root start already reaches guest main.
Platform and safety
Support Linux/macOS/Windows on x86-64 and ARM64 through Wasmtime 45 Cranelift. Native threads own their Stores; no Store/Instance is shared. The host never holds the registry lock during Wasm execution. Shared-memory observation uses only atomic accesses.
Non-goals
No async guest resources/streams/blobs, filesystem/network/process/random authority, broad WASI, public backend types, pool allocator, Tauri, timeout/fuel/epoch policy, cancellation, hostile blocked-atomic teardown, or forced thread termination. Cooperative normal completion only; containment belongs to #27/#28.
Dependencies and related work
- Parent: feat(wasm): bootstrap real threaded guest instances over shared memory #32; depends on feat(wasm): add private threaded root execution substrate #34; parent chain feat(wasm): add threaded Rust guest and owned thread bootstrap #26/feat(wasm): establish threaded sketch build, import validation, and lifecycle substrate #15; contributes to feat(wasm): prove a streamed kernal-api Rust sketch runtime with zccache and extension2 cores #13/feat(wasm): drive a Tauri screenshot task through the async kernal API #14.
- The source-only artifact builder is blocked by soldr#2919; do not bypass Soldr or commit a Wasm output as a workaround.
Activity
zackees commentedon Aug 27, 2026
Lifecycle correction: command root is not Wasm instantiation
The prior instantiate-only wording is temporary #34 substrate behavior and is superseded for the real Rust command profile.
Definitive v1 lifecycle
Never call
_start,__main_void, orkernal-api-runin a child. Never manually invoke the Wasm start section.The distinction is material: Wasmtime v45 says instantiation automatically executes the Wasm start function, explicitly not exported
_start; its publicInstancePre::instantiateuses that path. Wasmtime v45 instance source. Rust 1.95’swasm32-wasip1-threadstarget enables imported/exported shared memory and passes--import-memory --export-memory --shared-memory --max-memory=1073741824. Exact target definition. Its bundled LLVM linker emits a synthetic shared-memory start (__wasm_init_memory/__wasm_start) for once-only passive-data initialization; it is not root business entry. Exact Rust 1.95 bundled LLVM source, tool-conventions rationale.The command CRT exports
_start, which calls constructors and__main_void; that is the root-only user-code path. wasi-libc command CRT. The child entry is insteadwasi_thread_start(i32, i32) -> (), which installs per-instance stack/TLS before invoking guest thread work. wasi-libc thread trampoline. Wasmtime’s v45 reference implementation uses fresh Store + instantiate + typedwasi_thread_startfor children. Reference implementation.Verifier correction/evidence. The direct real-command artifact’s current characterization is
instantiate => Startedwithout a guest thread spawn; commitb508732corrected the earlier expectedTrappedassertion accordingly. That is the essential diagnostic: instantiate has not reached Rust main. The checked-in temporary root fixture reports one preparation and two supplied-runtime/kernel-yield observations over two explicit synthetic-root executions; it is not evidence for a real command artifact. No Wasm binary/hash is checked in, so no artifact digest is a stable acceptance value. The directsoldr rustcartifact remains diagnostic-only; soldr#2919 still blocks the Cargo-built acceptance path.#35 GREEN must prove: real Rust 1.95 command artifact,
instantiate + _startonce, root then twostd::threadchildren; each childinstantiate + wasi_thread_startonce; no duplicate root main; shared-memory atomic result/TLS proof; no second compilation/prelink/memory/runtime identity. Reactor/library output stays deferred: it does not supply command main and Rust’s current reactor-thread initialization remains an upstream problem (rust-lang/rust#146843).zackees commentedon Aug 27, 2026
Merged threaded bootstrap in #40. Validation covered the Windows Soldr gates, managed Bosn 0.1.3 fmt/lint/test, and the direct Rust 1.95 validation artifact (SHA-256 BA33416332CCCF7F4DA879C6BC04D7BF6A3DDBBBF8D068546ACC3EFC7F157A21). #35 remains open because normal Cargo guest-artifact materialization is still blocked by soldr#2919.