Expand description
§josie-core
Core runtime and execution planner for JOSIE (JSON Omni Safe Interactive Expressions).
§Module Roles
| Module | Responsibility | Public Entry Points |
|---|---|---|
runtime | Tree evaluator + operator registry | evaluate, Operators, State |
program | Program envelope validation, compile planning, pipeline execution | parse_program, compile_program, execute_program* |
compiler | serde_json::Value expression -> typed IR | Expr and compile_expr |
vm | Fast typed IR evaluator | eval_expr, IterLocals |
jval | Internal value representation for VM execution | JVal |
§Execution Contract
- Parse/validate once.
- Compile once into best available strategy.
- Execute many times.
Optimization tiers in program:
- Specialized internal fast plans.
- Specialized typed host-call fast plans.
- Compiled pipeline IR path.
- Generic tree/pipeline fallback.
Rule: all optimized paths must preserve the same observable semantics as the generic evaluator.
§Hello World (Simple API)
use josie_core::eval;
use serde_json::json;
let out = eval(&json!(["util.concat", "Hello", ", ", "World"])).expect("eval");
assert_eq!(out, json!("Hello, World"));§Inject Custom x.* Operator
use josie_core::{Context, EvalResult, Operator, Operators, State, evaluate};
use serde_json::{json, Value};
fn op_x_echo(args: &[Value], _ctx: &mut Context) -> EvalResult {
Ok(args.first().cloned().unwrap_or(Value::Null))
}
let mut operators = Operators::new();
operators.register("x.echo", op_x_echo as Operator);
let mut state = State::new();
let expr = json!(["x.echo", {"ok": true}]);
let mut ctx = Context { state: &mut state, operators: &operators, event: None };
let out = evaluate(&expr, &mut ctx).expect("x.echo");
assert_eq!(out, json!({"ok": true}));Re-exports§
pub use compiler::Expr;pub use engine::Engine;pub use jval::JVal;pub use reader::ReaderError;pub use reader::read;pub use reader::read_program;pub use runtime::Context;pub use runtime::EvalError;pub use runtime::EvalResult;pub use runtime::EventContext;pub use runtime::FunctionDef;pub use runtime::JsonNode;pub use runtime::Operator;pub use runtime::Operators;pub use runtime::State;pub use runtime::evaluate;pub use runtime::get_path;pub use runtime::set_path;pub use vm::IterLocals;pub use vm::eval_expr;
Modules§
- compiler
- Expression compiler from JSON tree nodes to typed
ExprIR. - engine
- jval
- Internal value model used by compiled execution paths.
- program
- Program-level contract and optimized execution strategies.
- reader
- runtime
- Runtime evaluator and operator registry for JOSIE tree expressions.
- vm
- Typed VM evaluator for compiled
Expr.
Functions§
- eval
- Evaluate an expression with default runtime components:
- eval_
with_ operators - Evaluate an expression with caller-provided operators and empty state.
- eval_
with_ state - Evaluate an expression with caller-provided state and default operators.