lmcode-go-sample reference

Reference tables for the lmcode-go-sample (Go 1.26+ (CGO_ENABLED=0)) type conversions, 45 Shop/Ledger domain signatures, CLI protocol flags, and exit codes.

Host language type conversions

lmcode typeHost representationBoundary rule
intint64 (Value.Int)Use uint64 intermediates for explicit two's-complement wrapping
floatfloat64 (Value.Float)Binary64 with lmcode.FormatG15 trace output and math.Round ties-away currency rounding
boolbool (Value.Bool)Direct mapping to lmcode.Bool(v)
stringstring / []byte (Value.Str)Raw byte strings indexed by byte without UTF-8 rune decoding
Money / Items / Shop / Ledger*Money, *Items, *Shop, *LedgerTyped Go pointers retained in the Host arena
voidlmcode.None()Returned with nil error for void callbacks

Shop and Ledger host schema signatures

Canonical signatureKindDescription
context shop: ShopContext objectShop domain root owning three initial priced items (125, 250, 375 cents)
context ledger: LedgerContext objectLedger domain root recording Money entries and raw byte notes
enum CurrencyUSD | EURCurrency enumeration passed across the host boundary as member spelling strings
interface Adjuster(Money) -> voidSAM interfaceRule entry interface for in-place item adjustment (case 067)
interface Score(Money) -> intSAM interfaceRule entry interface for @item and @total host-dispatched scoring (cases 068-069)
fn fee(int) -> intHost functionPure host fee computation helper
fn money(int) -> MoneyHost function / conversionConstruct a Money handle in signed int64 cents (also declared int -> Money conversion)
fn money(float) -> MoneyHost function overloadConstruct a Money handle from finite currency units rounded half away from zero to cents
fn sample_tmp() -> stringHost functionReturn the isolated SAMPLE_TMP scratch directory path (opted into dry-mode preview)
method Money.amount() -> intHost methodReturn signed int64 cents stored in this Money handle
method Money.currency() -> CurrencyHost methodReturn the Currency enum member (such as USD) for this Money handle
method Money.set(int) -> MoneyHost method (returns: self)Update cents in place and return the same Money receiver handle
method Money.plus(Money) -> MoneyOperator +Allocate a Money handle with wrapped int64 sum of cents
method Money.minus(Money) -> MoneyOperator -Allocate a Money handle with wrapped int64 difference of cents
method Money.times(int) -> MoneyOperator *Allocate a Money handle with wrapped int64 product of cents
method Money.neg() -> MoneyUnary operator -Allocate a Money handle with wrapped int64 negated cents
method Shop.items() -> ItemsHost methodReturn the shop Items collection handle
method Shop.total() -> MoneyHost methodReturn a Money handle with the sum of all current shop items
method Items.len() -> intCollection protocolReturn item count to enable for (item in shop.items()) loops
method Items.at(int) -> MoneyCollection protocolReturn the existing Money handle at index preserving pointer/handle identity
method Ledger.record(Money) -> LedgerHost method (returns: self)Append a Money amount to the ledger and return the Ledger receiver
method Ledger.note(string) -> voidHost methodAppend a raw byte string note to the ledger
method Ledger.balance() -> MoneyHost methodReturn the current ledger balance as a Money handle
method Ledger.count() -> intHost methodReturn the number of recorded ledger entries

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 runtime error such as division or remainder by zero
RUN_HOSTrun3Host callback failure, invalid encoding, or expired collection handle
APP_FAILapp4Post-run application domain validation failure or output stream write failure