Declarations & Metadata
In declaration mode, a .lex file evaluates to one deterministic canonical value without performing I/O, touching the network, or running effects.
Declaration primitives
| Primitive | Meaning |
|---|---|
lexicon { ... } | Tagged lexicon record holding metadata, source, inputs, outputs, and optional development. |
plan { ... } | Tagged system or session plan record. |
described(value, meta) | Attaches metadata to value transparently without changing recipe or tree hashes. |
module(blake3:...) | Typed content-addressed module object reference (Module_Ref). |
here() | Typed Tree_Ref of the source tree that holds the current declaration file. |
import("path.lex") | Evaluates a relative .lex file inside the same tree; refuses .., leading /, and non-.lex paths. |
declaration(blake3:...) | Lazy reference to the lexicon of a content-addressed tree; its value is its outputs. |
recipe(builder, args) | Lazy build specification identified by its domain-separated BLAKE3 recipe_hash. |
store(name, rights) | Store access grant using a flag set such as .Read | .Write. |
github(...), git(...), archive(...), github_release(...) | Typed input source records resolved through pins.lex; never touch the network during evaluation. |
Attaching metadata with described
described(value, description) is transparent to every consumer of value: field access, calls, and recipe inputs see the inner value directly. Canonical recipe hashing strips descriptions so fixing a sentence triggers zero rebuilds.
let
item = described({ value = described(40, { about = "Base value." }) }, { about = "Container." }),
add = described((x) => x + 2, { about = "Adds two." })
in
add(item.value)
42- Replacement: nesting
described(described(v, a), b)replaces the whole description withbwithout merging fields. - Cleared on mutation:
described(r, d) with { x = 1 }drops the description because the value changed.
Lexicon metadata and SPDX validation
The freestanding lex:metadata package validates lexicon and output metadata against strict offline rules:
about: one sentence ending in a full stop, no line breaks, no second sentence, at most 160 bytes.license: recursive-descent SPDX license expression validated against the pinned SPDX License List and Exceptions insrc/metadata/spdx_list.odin. SupportsAND,OR,WITH, parentheses, andLicenseRef-<name>; refusesNOASSERTIONandNONE.subjects: closed flag set overSubject(Graphics,Text,Network,Storage,Security,Processes,Memory,Time,Sound,Input,Faults,Kernel).keywords: lowercase ASCII letters, digits, and underscores; refuses duplicates and words already inSubject.provenance: closedSource_Provenance(.Source,.Native_Code,.Firmware,.Bytecode); required onarchiveandgithub_release.vulnerabilities: OSV identifiers (CVE-...,GHSA-...) paired with.Affected,.Not_Affected(requires anote), or.Fixed.
Canonical pins (pins.lex)
pins.lex lives beside lexicon.lex and records every pinned input in one canonical form: inputs sorted by UTF-8 byte order, one field per line in byte order. lex:pins reads only canonical evaluator output, never raw text.
{
gt = {
address = "https://github.com/sachahjkl/gui_toolkit",
commit = "a2fced8cfaca4c44b980fabed8702575b2a9558e",
tree = blake3:1111111111111111111111111111111111111111111111111111111111111111,
},
}
{ gt = { address = "https://github.com/sachahjkl/gui_toolkit", commit = "a2fced8cfaca4c44b980fabed8702575b2a9558e", tree = blake3:1111111111111111111111111111111111111111111111111111111111111111 } }A lexicon with no external inputs keeps an empty pin record {} so readers know nothing was omitted. Required pin fields are address, commit, and tree; optional fields are branch, version, signature, nix_archive_hash, and nested inputs.