Problem
Workers can only share raw SharedArrayBuffer bytes; every object crossing a thread is copied. The engine is Bun's prebuilt WebKit, which has no SharedStruct, and the optional zig-js engine lives outside this repo. There is also no way to load Home modules from JS. "Threads with shared objects" needs an engine-level answer. (New direction.)
Evidence (origin/main @ d4b219507)
Scope
- Evaluate: (a) generate JS accessor classes from Home struct layouts, backed by a SAB and using Home's locks/atomics; (b) implement the TC39 shared-structs proposal (shared structs, shared arrays,
Atomics.Mutex/Condition) in zig-js or a JSC fork; (c) Home modules loadable from JS withSynctypes exposed as shared objects. - Define the memory model (JS SAB model vs. Home orderings) and the GC interaction for shared objects.
Acceptance criteria
- RFC merged in
docs/docs/DECISIONS.md. - Prototype: two JS workers and one Home-native thread mutate one struct under a mutex with no lost updates.
Links
Depends on: #802, #807, #810 Related: #806, #786 Part of #814.