Core swactor now compiles for wasm32-unknown-unknown: - Added `wasm` feature flag (bundles no_random + web-time) - Platform-aware Instant: web_time::Instant on wasm, std::time on native - cfg-gated Runtime::run() and RuntimeHandle (thread::spawn unavailable on wasm32 — browser crate provides Web Worker-based alternative) - Validated: crossbeam-queue, atomics, Mutex, RwLock, thread parking all work on wasm32 with atomics target feature - Updated crates/wasm/ to use new `wasm` feature Authored by Claude, lovingly guided by Zachery Aaron Shores-Chmielewski
2.4 KiB
2.4 KiB
Current Task
Stage 1 — Platform Abstraction Layer Step: Complete Attempt: 1 of 3
Key Files (read these first on resume)
big-feature-phase/TASK.md— workflow rulesbig-feature-phase/notes/constraints.md— guardrailsbig-feature-phase/notes/feature-stages/02-single-worker-browser.md— Stage 2 specCargo.toml—wasmfeature flag,web-timedep (lines 23, 30)src/lib.rs— platform-awareInstantre-export (lines 20-24)src/runtime.rs— cfg-gatedrun()(line 340) andRuntimeHandle(line 73)crates/wasm/Cargo.toml— now usesfeatures = ["wasm"]docs/development_history/in-browser/PLATFORM_ABSTRACTION.md— what was done
Last Action & Result
Completed Stage 1 (Platform Abstraction Layer):
- Added
web-timedep +wasmfeature (no_random+web-time) - Replaced
std::time::Instant→crate::Instantin runtime.rs, worker.rs - cfg-gated
Runtime::run()andRuntimeHandlefornot(target_arch = "wasm32") - Removed unused
Muteximport from worker.rs - Updated
crates/wasm/to usewasmfeature - Key finding: most std::sync/thread primitives work on wasm32 with atomics; only
thread::spawnneeded gating - All native tests pass, wasm32 compilation succeeds
Next Action
Begin Stage 2 (Single-Worker Browser Runtime) — notes/feature-stages/02-single-worker-browser.md:
- Create
crates/wasm-browser/crate structure - Implement
BrowserRuntimewasm-bindgen API (spawn, send, tick, try_recv, stats) - Actor registration macro/pattern for JS-accessible spawning
- Auto-scheduling via setTimeout(0) loop
- Message serialization across JS↔Wasm boundary
- Tests (wasm-pack test or Node.js)
Completed This Session
- Cycle 0 research artifacts (constraints.md, research_synthesis.md, 6 stage docs)
- Stage 1:
web-timedep +wasmfeature flag in Cargo.toml - Stage 1: Platform-aware
Instantre-export in src/lib.rs - Stage 1: cfg-gated
Runtime::run()andRuntimeHandlein src/runtime.rs - Stage 1: Updated crates/wasm/ to use
wasmfeature - Stage 1: Validated wasm32 compilation and native tests
- Stage 1: Development history doc
Open Questions / Blockers
- Stage 2: Need to decide on message serialization (serde-wasm-bindgen vs raw bytes)
- Stage 2: Actor registration pattern — macro vs manual factory map
- Stage 3: Web Worker thread state initialization needs investigation (does std:🧵:current() work in a Web Worker context?)