Skip to main content

Crate graph_grammar

Crate graph_grammar 

Source
Expand description

graph-grammar ,a Rust crate + C-ABI cdylib exposing the graph-grammar rewrite engine to non-TypeScript callers. JSON in / JSON out, validated against the engine’s zod-derived schema, with behaviour (including the seeded RNG) reproduced bit-for-bit and verified by the conformance suite.

Module map: types ,serde data model (graph, rule, grammar) + ApiError rng ,Mulberry32 RNG, ported call-for-call from util.ts schema ,JSON-Schema validation at the boundary (the single contract) graph ,the mutable Host store (mirrors GraphIndex) matching ,VF2++ subgraph matcher (match.ts) rewrite ,single-rule application (rewrite.ts) engine ,the stateful step/run loop (engine.ts) api ,one-shot apply entry points (deterministic + seeded) ffi ,the gg_* C ABI

Structs§

ApiError
Error carried back across the FFI boundary as { "error": { code, detail } }.
Engine
Opaque stateful engine handle (exposed across the FFI as Engine*).

Functions§

apply_rule
Apply rule_json to graph_json once, deterministically (no RNG). Random PropExprs (randInt/randFloat) are rejected; use apply_rule_seeded.
apply_rule_seeded
Apply rule_json to graph_json once with a seeded RNG: stochastic match selection and random PropExprs are reproduced bit-for-bit against the TS engine’s findOneMatch(rng) + applyRule({ rng }) for the same seed.
run_grammar
Build an engine from a grammar, run it, and return (final_graph_json, applied). Convenience for tests / one-shot use; the FFI uses the stateful handle.