Skip to main content

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).

#TitleTopic
01Language surfaceMochi features mapped onto Go 1.21+ lowering obligations
02Design philosophyWhy Go, why the 1.21 floor, why native goroutines, why gotree not go/ast, why the runtime module is published
03Prior-art transpilersGopherJS, 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
04Runtime building blocksThe dev.mochilang/runtime/go module: agent, collections, datalog, llm, option, query, result, stream, stringz, timez. Why no third-party deps in the default build
05Codegen designaotir-to-Go lowering via the structural gotree AST, rendering through go/format, the closure-environment lifting pass, monomorphisation, stable item ordering
06Type-system loweringMochi types onto int64 / float64 / string / []T / map[K]V / map[T]struct{} / struct / discriminated interface + variant structs / func(...)
07Go target and portabilityGo 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
08Dataset pipelineQuery 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
09Agents and streamsMochi 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
10Build systemgo 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
11Testing gatesPer-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
12Risks and alternativesRisk 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/.