Expand description
flow.ir Pure Rust schema + sync interpreter.
Node kinds (Step / Seq / Branch / Fanout / Loop / Try / Assign) + Expr ops
(canonical wire format — comparison / boolean / existence / arithmetic /
aggregate / call_extern) + sync eval + Dispatcher trait + Externs
registry + Path read/write.
mlua / futures / async 依存ゼロ。 async runtime + mlua binding は上流
mlua-flow-ir crate が担当する 4 層 stack の core 層。
§Quick start
use flow_ir_core::{eval, Dispatcher, EvalError, Expr, Node};
use serde_json::{json, Value};
let node: Node = serde_json::from_value(json!({
"kind": "step",
"ref": "uppercase",
"in": { "op": "path", "at": "$.input" },
"out": { "op": "path", "at": "$.output" },
})).unwrap();
struct Fixture;
impl Dispatcher for Fixture {
fn dispatch(&self, _r: &str, input: Value) -> Result<Value, EvalError> {
if let Value::String(s) = input {
Ok(Value::String(s.to_uppercase()))
} else {
Ok(input)
}
}
}
let out = eval(&node, json!({ "input": "hello" }), &Fixture).unwrap();
assert_eq!(out, json!({ "input": "hello", "output": "HELLO" }));Structs§
- Extern
Map HashMap-backedExternsimpl for host-side Rust closures.- Memory
Ctx - Default
CtxStorageimpl —Arc<Mutex<Value>>wrapper。 - NoExterns
- Empty registry — every
call_externraisesExternError(parity with canonical “requires opts.externs” error). Used by the externs-less compat wrappers (eval/eval_expr/eval_with_storage).
Enums§
- Eval
Error - Evaluation error.
- Expr
- flow.ir Expr op.
- Join
Mode - Fanout join semantics (Promise / futures combinators).
- Node
- flow.ir Node kind.
Traits§
- CtxStorage
- Ctx backend trait —
eval(_with_storage)系が ctx state を touch する 唯一の経路。&selfwrite (interior mutability) で 走行中の Flow と 外部 task が同じ ctx を共有 できる (= dispatch().await suspend 中に外部 task がctx.writeで State 注入 → resume 後 Step が read で観測、 という dynamic injection 経路を成立させる)。 - Dispatcher
- Dispatcher callback: resolves a
Step.refagainst the provided input, returns the step’s raw output value. - Externs
- Extern registry: resolves a
call_extern.refagainst evaluated args and returns the value. Mirror of canonicalopts.externs(flow-ir-luainterpreter.lua): each entry MUST be a pure function — no side effects, no flow control, value-shape manipulation only.
Functions§
- eval
- Legacy Value-passing sync evaluator — backward compat wrapper around
eval_with_storage+MemoryCtx.Valueを所有権で受け取り、 内部でMemoryCtx::new(ctx)を使って storage 版に委譲、 終了後の snapshot を返す。 - eval_
expr - Evaluate an
Expragainst a context value, returning the resolved JSON value. Externs-less compat wrapper —call_externraisesExternError. - eval_
expr_ with_ externs eval_expr+ externs registry forcall_externExpr resolution.- eval_
externs eval+ externs registry forcall_externExpr resolution.- eval_
with_ storage - Storage-backed sync evaluator —
CtxStorage経由で ctx を touch する正本。 - eval_
with_ storage_ externs eval_with_storage+ externs registry forcall_externExpr resolution.- is_
truthy - JSON value の truthy 判定 (= flow.ir Branch cond / Loop cond で使う)。 Bool は値そのまま、 null/false 以外は truthy (Lua / JS と整合)。
- read_
path - Read a path from a JSON value. Supports simple
$.a.b.cform. - write_
path - Write a value at the path location inside ctx, returning the updated ctx.
outmust be aPathExpr.