lmcode-go skill

Use lmcode-go to embed the DSLB v6 virtual machine, 226-signature standard library, and REST/CLI controller into dependency-free Go 1.26+ executables.

Purpose

Compile static Go host binaries that expose typed Go structs and functions to lmcode bytecode, validate schemas, serve REST/CLI endpoints, and frame structured results.

When to use it

Use lmcode-go when building a Go command-line tool or service that executes compiled .dslb v6 programs without CGO or third-party Go modules.

Install

Import github.com/lmctl-ai/lmcode-go and github.com/lmctl-ai/lmcode-go/rest with Go 1.26 or newer and CGO_ENABLED=0.

Commands

CGO_ENABLED=0 go build ./...
CGO_ENABLED=0 go test ./...
go run ./cmd/conformance conformance/vectors
go run ./cmd/conformance -std conformance/stdlib-vectors
go run ./cmd/rest-serve app.dslb host.schema.json

Inputs and outputs

Safety rules

Worked examples

reg := lmcode.NewRegistry()
_ = reg.Function("add_tax", []string{"int"}, "int", func(a []lmcode.Value) (lmcode.Value, error) {
	return lmcode.Int(a[0].Int + 15), nil
})
prog, err := lmcode.Load(bytecodeBytes, schemaBytes, reg)
if err != nil {
	lmcode.ExitIfError("load", err)
}

Errors and exit codes

CodePhaseExitCondition
LOAD_BAD_BYTECODEload3Malformed DSLB v6 header, bad magic or version, truncated section, invalid opcode, or stack depth violation
LOAD_BAD_SCHEMAload3Host schema JSON fails dsl.schema 2 validation or declares an invalid result contract
LOAD_SCHEMA_MISMATCHload332-byte SHA-256 schema hash in DSLB v6 header does not match exact host schema bytes
LOAD_UNBOUNDload3Bytecode imports a context, function, or method signature not registered in the host Registry
RUN_ERRORrun3VM division or remainder by zero, or loop-free operand stack underflow
RUN_HOSTrun3Host callback failure, invalid encoding, expired collection handle, or REST route validation failure
APP_FAILapp4Post-run application domain validation failure or output stream write failure

How to verify

bash scripts/sync-std.sh --verify
bash scripts/sync-rest.sh --verify
CGO_ENABLED=0 go test ./...