Type System
LODE has scalar types (string, bool, int), collections (string[], list<T>, map<string,T>) and named types declared in the schema (record, variant, enum). There are no floats, no implicit coercion and no executable expressions: a LODE value is always plain, finite data.
The four v0.1 types (string, bool, string[], map<string,string>) keep their exact v0.1 meaning, wire encoding and fingerprint.
Type grammar
A field’s type is a type expression:
Type := "string" | "bool" | "int"
| "string[]" string set (order-insensitive)
| "list<" Type ">" ordered list (order is significant)
| "map<string," Type ">" string-keyed map (keys sorted)
| Name record, variant or enum from "types"
Name := [A-Z][A-Za-z0-9_]*Every type has exactly one spelling: no whitespace, map keys are always string. map<string,string> is the v0.1 map. Expressions nest freely: list<list<int>>, map<string,list<Rule>>.
Scalars
string
UTF-8 text. Must be well-formed Unicode (no lone surrogates).
Type tag: 0x01
{ "id": 1, "name": "title", "type": "string", "required": true }bool
A single byte: 0x01 for true, 0x00 for false.
Type tag: 0x02
int v0.2
A signed integer in the range ±(253 − 1). The range is the largest one that is exact in JSON numbers, JavaScript and 64-bit integers, so the same value reads back identically in every language. On the wire an int is 8 bytes, big-endian two’s complement.
An int field may set inclusive bounds:
{ "id": 2, "name": "weightBp", "type": "int", "min": 0, "max": 10000 }min and max are only allowed on int fields.
Type tag: 0x03
Why no floats? Two producers can print the same float differently (0.1 + 0.2), and fixed-point integers are exact everywhere. Store fractions as scaled integers: basis points (0.85 → 8500), milliseconds, micro-units.
Collections
string[] — string set
An array of strings whose order does not matter. The canonical form and the fingerprint sort it, so ["b","a"] and ["a","b"] are the same value. Duplicates are kept. Use it for keyword sets, tags and capability lists.
Type tag: 0x10
list<T> — ordered list v0.2
An array whose order is part of the value: ["b","a"] and ["a","b"] have different fingerprints. Use it for priority lists, rule tables, pipelines and anything evaluated in sequence. Items cannot be null.
{ "id": 3, "name": "fallbacks", "type": "list<string>" }Type tag: 0x11
map<string,T> v0.2 for T ≠ string
A string-keyed map. Keys are always sorted in the canonical form and on the wire, so key order never matters. Values cannot be null.
{ "id": 4, "name": "limits", "type": "map<string,int>" }Type tag: 0x20 for map<string,string>, 0x21 for every other value type.
Named types v0.2
Records, variants and enums are declared in the schema’s types section and referenced by name. See Named Types.
| Kind | JSON value | Type tag |
|---|---|---|
record | object with declared fields | 0x30 |
variant | object with exactly one declared field | 0x30 |
enum | one of the declared strings | 0x01 |
Type Tag Registry
| Type | Tag (hex) | Since |
|---|---|---|
string, enums | 0x01 | v0.1 |
bool | 0x02 | v0.1 |
int | 0x03 | v0.2 |
string[] | 0x10 | v0.1 |
list<T> | 0x11 | v0.2 |
map<string,string> | 0x20 | v0.1 |
map<string,T> | 0x21 | v0.2 |
| record, variant | 0x30 | v0.2 |
All other tags are reserved.
Type Coercion
LODE performs no implicit type coercion. "5" is not an int, 1 is not a bool. The type checker (check, lodec check) reports every mismatch with its path:
/stages/3/rules/0/emit/weightBp: expected int, got non-integer number 0.95For v0.1 schemas, compile keeps its v0.1 behaviour: map values are coerced with String().
Required vs Optional
Fields default to required: true if required is omitted. This applies to fields inside records too.
- Required fields must be present, or
check/compile/decodefail - Optional fields (
required: false) may be absent,undefinedornull; all three mean “absent” and produce the same canonical form, bytes and fingerprint - Records are closed: a key that is not declared in the type is an error (v0.2 checker)