MEP-54 research notes
These twelve notes are the deep research that fed MEP-54 (Mochi-to-Go transpiler). They are informative; the MEP body at /docs/mep/mep-0054 is normative. Each note is self-contained and can be read independently. Cross-references use [[note-slug]] markers.
Author: research pass for MEP-54 (Mochi-to-Go transpiler). Date: 2026-05-29 (GMT+7).
| # | Title | Topic |
|---|---|---|
| 01 | Language surface | Mochi features mapped onto Go 1.21+ lowering obligations |
| 02 | Design philosophy | Why Go, why the 1.21 floor, why native goroutines, why gotree not go/ast, why the runtime module is published |
| 03 | Prior-art transpilers | GopherJS, TinyGo, Joy, gccgo, gollvm, esc.go, JavaPoet analogues, the Kubernetes code generators, golang.org/x/tools/cmd/stringer, kube-openapi, sqlc, and the rejected idea of using go/ast |
| 04 | Runtime building blocks | The dev.mochilang/runtime/go module: agent, collections, datalog, llm, option, query, result, stream, stringz, timez. Why no third-party deps in the default build |
| 05 | Codegen design | aotir-to-Go lowering via the structural gotree AST, rendering through go/format, the closure-environment lifting pass, monomorphisation, stable item ordering |
| 06 | Type-system lowering | Mochi types onto int64 / float64 / string / []T / map[K]V / map[T]struct{} / struct / discriminated interface + variant structs / func(...) |
| 07 | Go target and portability | Go 1.21 / 1.26 matrix, the GOOS+GOARCH cross-compile story, the wasm/js vs wasip1 split, vendor-vs-proxy mode, why no TinyGo for the default path |
| 08 | Dataset pipeline | Query DSL lowering via straight-line for loops + slices stdlib helpers, hash/merge joins, group-by, top-K via container/heap, Datalog semi-naive evaluation at compile-time |
| 09 | Agents and streams | Mochi agents as a goroutine wrapping a chan Msg receive loop, streams as a struct of []chan T subscriber slots, async colouring as a typecheck pass with go statement boundaries |
| 10 | Build system | go build driver, the Driver.Build cache + sandbox, cross-compile invocation, deterministic flags (-trimpath, -buildvcs=false, -ldflags=-buildid=, SOURCE_DATE_EPOCH=0), pkg.go.dev publication |
| 11 | Testing gates | Per-phase Go test gates with vm3 oracle, byte-equal stdout diff, go vet secondary gate, reproducibility SHA-256 gate, publish dry-run via go mod tidy + go install |
| 12 | Risks and alternatives | Risk register (macOS LC_UUID, wasm-js no fetch glue, wasip1 no cgo, cassette drift, generic-method gap, hermetic-build gap, vet false positives) + rejected alternatives (go/ast, sync.Mutex channels, TinyGo default, inlined runtime, no published module, green-thread library, raw go/printer) |
Each note's filename uses the NN-slug.md convention; the leading NN- is stripped by Docusaurus for the URL path, so cross-links inside the notes use the unprefixed slug (e.g. [[language-surface]]).
The companion MEP body lives at /docs/mep/mep-0054. Implementation tracking lives at /docs/implementation/0054/.