behavior-contracts 0.2.3

Language-neutral IR runtime core (expression evaluation, template rendering, execution plan, canonical serialization) shared across DSL implementations. Passes the dsl-contracts conformance vectors byte-for-byte.
Documentation

behavior-contracts (Rust)

Language-neutral IR runtime COMMON core for the dsl-contracts spec, ported to Rust. This is one of several byte-parity implementations (TypeScript, Python, Rust, Go) that all consume the same conformance vectors.

It contains only the thin DSL-agnostic primitives judged COMMON by runtime-boundary.md — no backend execution, key resolution, retry tuning, or any DSL/graphddb-specific concepts.

Public primitives

Function Purpose
evaluate_expression(node, scope) Evaluate an expression-ir.md IR tree
render_template(template, params) Strict {param} rendering
run_plan(plan, ops, exec) Execution-plan skeleton (stage / Skip propagation / Policy Kind)
canonical_value / canonical_json Canonical serialization (key identity / fingerprint)
py_float_repr(f) CPython repr(float) byte-identical decimal
validate_envelope(env, supported, …) spec-version fail-closed check
assert_portable(value) Portability Guard
decode_value / deep_equals / encode_value Conformance adapter COMMON part

Value model

int = checked i64, float = f64 (NaN/±Inf are Failures at the boundary), plus string / bool / null / arr / obj. The int/float distinction is normative: int 1 != float 1.0.

Conformance

cargo run --bin conformance     # runs all 147 vectors from ../conformance/vectors
cargo test                      # unit tests + conformance runner

The runner performs a pre-flight spec-version sweep and fail-closes (exit 2) on any version mismatch before executing a single vector.

License

MIT OR Apache-2.0