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_jsontograph_jsononce, deterministically (no RNG). Random PropExprs (randInt/randFloat) are rejected; useapply_rule_seeded. - apply_
rule_ seeded - Apply
rule_jsontograph_jsononce with a seeded RNG: stochastic match selection and random PropExprs are reproduced bit-for-bit against the TS engine’sfindOneMatch(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.