lmcode skill
Use the lmcode specification to author schema-bound _lmcode_ blocks, validate DSLB v6 bytecode, and verify cross-runtime conformance.
Purpose
Define the exact language syntax, dsl.schema: 2 contract, DSLB v6 binary layout, lmcode_std_v3 226-signature catalog, REST/CLI stdio protocol, and conformance vectors shared by all lmcode runtimes.
When to use it
Use lmcode when designing a new host schema, writing _lmcode_ programs with rule entries or REST/CLI endpoints, implementing a new language runtime SDK, or auditing cross-runtime conformance.
Install
Clone lmctl-ai/lmcode and install @lmctl-ai/lmctl (0.2.444 or newer; CI pins a newer compiler in scripts/ci/compiler-version) with Node.js and Python 3 to run the grammar and conformance checks. Released hosts may still ship the 206-signature catalog without the REST/CLI interfaces.
Commands
git clone https://github.com/lmctl-ai/lmcode.git
cd lmcode
python3 tests/grammar/tree_sitter_differential.py --json /tmp/tree-sitter-diff.json
Inputs and outputs
- Input: dsl.schema: 2 JSON files, _lmcode_ source blocks, and compiled .dslb v6 bytecode files.
- Output: canonical signature lists, verified DSLB v6 chunks, HTTP/1.1 responses over stdio, and LMCODE_RETURN JSON envelopes.
- Locks: std/rest/lmcode-rest.schema.json (the 20 REST/CLI signatures + 10 standard interfaces of the 226-signature catalog) and tests/rest-suite (shared HTTP/1.1 and CLI scenarios).
Safety rules
- Never execute unverified bytecode or bypass the 32-byte SHA-256 schema hash check in the DSLB v6 header.
- Keep stdout reserved for protocol frames during rest_serve() or LMCODE_RETURN framing; send diagnostics to stderr.
- Treat VM strings as raw byte sequences that may contain interior NUL bytes or non-UTF-8 bytes.
Worked examples
# Check both Tree-sitter grammars against the pinned compiler
python3 tests/grammar/tree_sitter_differential.py --json /tmp/tree-sitter-diff.json
# List the REST/CLI fragment declarations (20 signatures + 10 interfaces)
python3 -m json.tool std/rest/lmcode-rest.schema.json
Errors and exit codes
| Code | Phase | Exit | Condition |
|---|---|---|---|
| LOAD_BAD_BYTECODE | load | 3 | Malformed DSLB v6 header, bad magic or version, truncated section, invalid opcode, or stack depth violation |
| LOAD_BAD_SCHEMA | load | 3 | Host schema JSON fails dsl.schema 2 validation or declares an invalid result contract |
| LOAD_SCHEMA_MISMATCH | load | 3 | 32-byte SHA-256 schema hash in DSLB v6 header does not match exact host schema bytes |
| LOAD_UNBOUND | load | 3 | Bytecode imports a context, function, or method signature not registered in the host Registry |
| RUN_ERROR | run | 3 | VM division or remainder by zero, or loop-free operand stack underflow |
| RUN_HOST | run | 3 | Host callback failure, invalid encoding, expired collection handle, or REST route validation failure |
| APP_FAIL | app | 4 | Post-run application domain validation failure or output stream write failure |
How to verify
python3 tests/grammar/tree_sitter_differential.py --json /tmp/tree-sitter-diff.json