Native Go WebAssembly Engine for GoRuntime Studio β high-fidelity simulation of Go runtime internals (GMP scheduler, channels, memory allocator, GC) compiled to WebAssembly and bridged to Svelte 5 via a zero-copy binary event protocol.
goruntime-kernel is the computational core of GoRuntime Studio. It replaces the legacy TypeScript-based simulation engine with a native Go runtime compiled to WebAssembly, delivering:
- 100% semantic fidelity β real Go code for
hchan,sudog, G/M/P scheduling, and memory management - 60 FPS performance β zero-allocation binary event streaming via
SharedArrayBufferRingBuffer - Deterministic time-travel debugging β memory snapshots for stepping forward and backward through execution
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β SVELTE 5 STUDIO UI β
β βββββββββββββββββββ βββββββββββββββββββββββββββ βββββββββββββββββ β
β β Header.svelte βββββΆβ timeline.store.svelte.tsβββββΆβCanvasView.slt β β
β β Controls & Step β β State, History & Issues β β 2D Graph Nodesβ β
β βββββββββββββββββββ βββββββββββββββββββββββββββ βββββββββββββββββ β
β β β² β² β
β β Dispatch Command β Update Reactive Nodes β β
β βΌ β β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β sync.bridge.ts β Binary Event Decoder & State Sync β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Invoke Exported Functions
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β GO WASM ENGINE SANDBOX β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Wasm Control API (cmd/wasm/main.go) β β
β β stepSend, stepReceive, spawnGoroutine, createSnapshot, restoreSnap β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β β β β
β βΌ 1. Trigger Execution βΌ 2. Save/Restore βΌ 3. Channel Opsβ
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β GO ENGINE CORE (pkg/) β β
β β βββββββββββββββ βββββββββββββββ βββββββββββββββ ββββββββββββββββ β β
β β β pkg/gmp β β pkg/memory β β pkg/channelsβ β pkg/snapshot β β β
β β β Scheduler β β Virtual Mem β β hchan/sudog β β Serializationβ β β
β β β G, M, P β β MHeap/MCacheβ β Wait Queues β β Time-Travel β β β
β β βββββββββββββββ βββββββββββββββ βββββββββββββββ ββββββββββββββββ β β
β β β β β β β
β β βΌ 3. Emit State Changes βΌ 4. Emit Events βΌ β β
β β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β β
β β β pkg/eventstream β 16-byte Binary Event Streamer β β β
β β β Fixed packets: G-M-P, Sudog, GC, Memory Alloc β β β
β β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β 4. Push Binary Events β
β βΌ β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β SharedArrayBuffer β Atomic RingBuffer Event Queue β β
β β Zero-copy, lock-free, 60 FPS β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
All communication between the Go Wasm kernel and the Svelte 5 UI occurs through a 16-byte fixed-size binary packet written into a SharedArrayBuffer RingBuffer.
| Offset | Size | Field | DataView Type | Description |
|---|---|---|---|---|
| 0β1 | 2 B | EventOp |
uint16 |
Operation code (spawn, park, chan send, mem alloc, etc.) |
| 2β5 | 4 B | EntityID |
uint32 |
Primary entity ID (Goroutine G, Channel hchan, etc.) |
| 6β9 | 4 B | TargetID |
uint32 |
Secondary / target ID (Processor P, sudog, address) |
| 10β13 | 4 B | ValueState |
uint32 |
Value, state, stack size, GC color, flags |
| 14β15 | 2 B | Sequence |
uint16 |
Monotonically increasing timeline step counter |
| Code | Name | Semantics |
|---|---|---|
0x0001 |
EV_G_SPAWN |
New goroutine G created (Gidle β Grunnable) |
0x0002 |
EV_G_SCHEDULE |
Goroutine assigned to Processor P (Grunnable β Grunning) |
0x0003 |
EV_G_PARK |
Goroutine parked / blocked (Grunning β Gwaiting) |
0x0004 |
EV_G_UNPARK |
Goroutine unblocked (Gwaiting β Grunnable) |
0x0005 |
EV_G_DIE |
Goroutine execution completed (Grunning β Gdead) |
0x0010 |
EV_CHAN_SEND |
Successful send into hchan |
0x0011 |
EV_CHAN_RECV |
Successful receive from hchan |
0x0012 |
EV_CHAN_BLOCK |
Blocking on channel, sudog enqueued |
0x0013 |
EV_CHAN_UNBLOCK |
sudog removed from wait queue, G unblocked |
0x0020 |
EV_MEM_ALLOC |
Heap allocation via MCache / MSpan |
0x0021 |
EV_STACK_GROW |
Stack expanded, copystack executed |
0x0022 |
EV_GC_MARK |
Object marked during tri-color GC phase |
| Offset | Size | Field | Description |
|---|---|---|---|
| 0β3 | 4 B | HeadIndex |
Next write position (updated by Go Wasm) |
| 4β7 | 4 B | TailIndex |
Last read position (updated by TypeScript) |
| 8β11 | 4 B | Capacity |
Max number of events in buffer (e.g. 4096) |
| 12β15 | 4 B | DroppedEvents |
Counter of lost events on overflow |
- Go 1.23+
- Node.js 20+ (for frontend bridge and tooling)
# Clone the repository
git clone https://github.com/DenysSkobalo/goruntime-kernel.git
cd goruntime-kernel
# Compile Go engine to WebAssembly
make build-wasm
# β dist/engine.wasm# Full pre-flight check (format, lint, test, build)
make check
# Individual targets
make test # Run Go unit tests
make bench # Run benchmarks
make lint # Run golangci-lint
make fmt # Format Go source files
make clean # Remove build artifactsCopy the generated artifact into the Studio frontend:
cp dist/engine.wasm ../goruntime-studio/public/The Svelte 5 bridge (sync.bridge.ts) will automatically load the Wasm module and begin polling the SharedArrayBuffer RingBuffer at 60 FPS via requestAnimationFrame.
engine/
βββ cmd/wasm/main.go # Wasm entrypoint, syscall/js bindings
βββ pkg/
β βββ eventstream/ # Binary Event Encoder & SharedArrayBuffer RingBuffer
β βββ gmp/ # Scheduler Engine (G, M, P queues, Work-Stealing)
β βββ channels/ # Channel Logic (hchan, sudog, WaitQ)
β βββ memory/ # Virtual Memory Layout (MHeap, MCache, copystack, GC)
β βββ snapshot/ # Memory Snapshot & Serialization Engine
βββ go.mod
βββ go.sum
βββ Makefile # Build, test, lint, format automation
βββ .golangci.yml # Linter configuration
βββ package.json # Node tooling (husky, commitlint, lint-staged)
βββ .github/workflows/ci.yml # GitHub Actions CI pipeline
| Document | Purpose |
|---|---|
| DEVELOPMENT.md | Deep-dive engineering spec: RingBuffer algorithms, GMP scheduler, channels, memory, snapshots |
| CONTRIBUTING.md | Contribution guidelines: branching model, GoDoc standards, Conventional Commits, PR checklist |
| SECURITY.md | Security policy and vulnerability disclosure |
| ADR-001 | Architectural Decision Record: migration from TS to Go Wasm |
| TES-001 | Technical Engine Specification: binary protocol, component APIs, migration plan |
We welcome contributions! Please read CONTRIBUTING.md for our branching model, code standards, and PR process.
All PRs must target the develop branch and pass make check.
MIT License Β© 2026 Denys Skobalo