Skip to main content

Crate mlua_swarm_dsl

Crate mlua_swarm_dsl 

Source
Expand description

Lua internal DSL for Blueprint authoring (flow_dsl + bp_dsl).

Raw AST (JSON) authoring cost is high at real Blueprint scale (hundreds of lines and deep nesting for a multi-stage flow) — that cost motivated this module. flow_dsl.lua (flow.ir vocabulary) and bp_dsl.lua (Blueprint vocabulary, depends on flow_dsl) are baked into this binary via include_str! and preloaded into a fresh mlua::Lua VM so require("flow_dsl") / require("bp_dsl") resolve without touching the filesystem. The flow-ir / mlua-swarm-schema crates are not touched by this module — canonical JSON stays the wire format; the DSL is purely an authoring-time convenience that emits it.

§Crate positioning

This crate is the DSL frontend only (.bp.luaserde_json::Value). The compile pipeline (linker → shape lint → BPReady) lives in the sibling mlua-swarm-compile crate, which consumes the JSON this crate produces. mlua-swarm-schema (types) stays free of the mlua runtime dep so that consumers who only need type surfaces (e.g. the server’s wire codec) do not transitively pull the Lua interpreter.

Functions§

build_bp_from_script
Run a .bp.lua DSL script (source text, not a file path) in a fresh mlua::Lua VM and return its result as serde_json::Value.
build_bp_from_script_with_warnings
Like build_bp_from_script, but also drains the authoring-time warnings bp_dsl.lua accumulated during the run (currently the B.pipeline dead-halt lint: pipeline-level halt_on with zero gate-emitting stages). Best-effort: a script that never requires bp_dsl yields an empty list.
preload
Register flow_dsl and bp_dsl in lua’s package.preload table so require("flow_dsl") / require("bp_dsl") resolve to the baked-in Lua source. Idempotent to call more than once on the same Lua (each call simply re-sets the same two preload entries).