lmcode reference

Reference tables for the lmcode DSLB v6 specification, host CLI flags, lmcode_std_v3 standard interfaces, REST/CLI functions, and structured error codes.

Host SDK API surface

APIType / ReturnDescription
--versionCLI flagPrint the host tool name and semantic version on stdout and exit 0
--lmcode-schemaCLI flagPrint human-readable sorted context, function, and method summary lines and exit 0
--lmcode-schema --jsonCLI flagWrite the exact embedded dsl.schema: 2 JSON bytes to stdout and exit 0
--lmcode-signaturesCLI flagPrint one canonical signature per line in byte-sorted order and exit 0
--lmcode FILECLI flagLoad and verify FILE against the embedded schema, run body and rule entries, and emit the result frame
--first FILE / --last FILECLI builder flagsOrder multi-part builder slots while preserving registration-order result arrays
LMCODE_INVOCATION_FILEEnvironment variablePath to version-1 JSON invocation manifest specifying dry mode and exact file list
LMCODE_RETURN_BEGIN / ENDStdout frame markersDelimit the single-line compact UTF-8 JSON invocation envelope at process termination

Standard REST and CLI interfaces (lmcode_std_v3)

The default lmcode_std_v3 catalog provides 226 canonical signatures and 10 standard interfaces on RestExchange for HTTP/1.1 stdio endpoints and stateless CLI commands.

InterfaceCanonical declarationBehavior
RestGetinterface RestGet(exchange: RestExchange) -> voidHTTP GET endpoint bound by path annotation such as @"/users/:id"
RestPostinterface RestPost(exchange: RestExchange) -> voidHTTP POST endpoint bound by path annotation such as @"/users"
RestPutinterface RestPut(exchange: RestExchange) -> voidHTTP PUT endpoint bound by path annotation such as @"/users/:id"
RestDeleteinterface RestDelete(exchange: RestExchange) -> voidHTTP DELETE endpoint bound by path annotation such as @"/users/:id"
RestPatchinterface RestPatch(exchange: RestExchange) -> voidHTTP PATCH endpoint bound by path annotation such as @"/users/:id"
RestHeadinterface RestHead(exchange: RestExchange) -> voidHTTP HEAD endpoint bound by path annotation
RestOptionsinterface RestOptions(exchange: RestExchange) -> voidHTTP OPTIONS endpoint bound by path annotation
RestHandlerinterface RestHandler(exchange: RestExchange) -> voidMethod-prefixed (@"POST /users") or rest_route(method, path, annotation) handler
CliCommandinterface CliCommand(exchange: RestExchange) -> voidStateless CLI subcommand entry dispatched by rest_cli(args)
CliOptioninterface CliOption(exchange: RestExchange) -> voidStateless CLI flag or option entry dispatched before CliCommand by rest_cli(args)

Standard REST and CLI functions and methods

NameCanonical signatureDescription
rest_configfn rest_config(string, string) -> voidSet controller configuration keys such as prefix, max_body_bytes, or session before rest_serve()
rest_routefn rest_route(string, string, string) -> voidBind an HTTP method and path template (:param, :rest..., {param}, {rest...}) to a RestHandler annotation
rest_servefn rest_serve() -> voidValidate registered routes and request HTTP/1.1 stdio serving after the program body finishes
rest_stopfn rest_stop() -> voidStop stdio HTTP/1.1 serving after the active response finishes flushing
rest_clifn rest_cli(StrList) -> stringDispatch a single stateless CLI argv vector across CliOption, CliCommand, or REST routes and return the response body
RestExchange.methodmethod RestExchange.method() -> stringReturn the uppercase HTTP method verb for the active request
RestExchange.pathmethod RestExchange.path() -> stringReturn the percent-decoded request path without the query string
RestExchange.querymethod RestExchange.query(string) -> stringReturn the first value of a query key or empty string when absent
RestExchange.has_querymethod RestExchange.has_query(string) -> boolReturn true when the query key is present in the request target
RestExchange.parammethod RestExchange.param(string) -> stringReturn a matched path parameter from :param or :rest... (or {param} / {rest...})
RestExchange.headermethod RestExchange.header(string) -> stringReturn case-insensitive header value (repeated headers joined by comma-space)
RestExchange.has_headermethod RestExchange.has_header(string) -> boolReturn true when the header is present on the request
RestExchange.bodymethod RestExchange.body() -> stringReturn raw request body bytes
RestExchange.statusmethod RestExchange.status(int) -> voidSet HTTP response status code in range 200..599
RestExchange.set_headermethod RestExchange.set_header(string, string) -> voidSet or replace a response header outside managed framing headers
RestExchange.sendmethod RestExchange.send(string) -> voidReplace response body with raw bytes
RestExchange.jsonmethod RestExchange.json(string) -> voidReplace response body and set Content-Type to application/json
RestExchange.getmethod RestExchange.get(string) -> stringRead server-wide shared string state key or empty string when absent
RestExchange.setmethod RestExchange.set(string, string) -> voidWrite server-wide shared string state key
RestExchange.incrementmethod RestExchange.increment(string) -> intAtomically increment a named integer counter starting at 1

Structured error codes and exit statuses

Error codePhaseExit statusTrigger condition
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