agent-skill.md raw


name: moxie description: Use when writing, reviewing or debugging Moxie (.mx) code, or working on the Moxie compiler, runtime or stdlib. Moxie is a compiled systems language: a tree of domains (threads in one process), one arena stack per domain, no heap, no GC, no goroutines, no reflection and no empty interface, explicit-width integers, string=[]byte, | for text concatenation, channels and select for event dispatch.


Working in Moxie

The normative documents are in docs/. This sheet is the condensed form; decisions.md says which designs are real. When this sheet and the code disagree, the code is the record and this sheet is the bug.

What Moxie is not

Moxie is not Go. These are compile errors, not warnings:

writtenwhyinstead
int, uintundefined namesint32, int64, uint32, uint64
s + t on textno + on slicess \| t
appendremovedpush(s, v) - it grows
make(T, ...)removed[]T{:n}, []T{:n:c}, chan T{}, chan T{:N}, map[K]V{}
new(T)removed&T{}
any, interface{}removedan interface with at least one method
reflectremovednothing needs it: every builtin has String(), every boundary has a codec
recoverremovedpanic is death; deferred calls do not run
go f()no goroutinesspawn starts a domain thread
fallthroughremovedcase A, B: or a shared function
import "strings"removedbytes (string is []byte)
import "sync"removedone thread per domain
unnamed resultrejectedfunc f() (n int32)
value receiver on a structrejectedpointer receiver (a struct value is a copy)
var x = expr at package scoperejectedvar x T, assign in init()
int8(1000)constant overflowthe value must be representable

Types and values

the parent, and neither does a write through a subslice passed as an argument.

Memory, in one paragraph

No heap, no GC, no free. Every allocation goes to fnStack[fnTop]: a per-function arena released at return, a manual phase arena released at ManualArenaExit, a sovereign arena owned by a self-mutating receiver, or the root arena of the domain. Return values are encoded in the callee's frame, FnArenaPop releases it, and the caller decodes into its own arena. Parameters are owned by the caller; anything in the frame not attached to a named result is gone at return. push grows by itself - for one element, several, or a spread - so there is no capacity guard to write and no growth helper to call; a helper that returns a pointer-bearing slice is deep-copied by the return protocol and is quadratic when used in a loop.

Concurrency

loop. No scheduler, no preemption, no locks.

chan T{:N} is N outstanding messages; chan T{:N:bytes} declares the frame budget.

single result MUST be named closed and be of type chan struct{}.

never spawn on demand. Termination is cooperative - the breaker arm goes at every wait.

Style that is not mechanical

heavy scratch into a free helper.

wrong before the code is.

Before claiming something is done

Run it. A claim backed by recollection is not backed by anything; a claim backed by a build and a run is. Every compiler change lands in legacy/ first and _mxc_stage4/ second (wood law), unless it changes no emitted code - and say so explicitly when that is the reason.