diff --git a/crates/aura-cli/tests/graph_construct.rs b/crates/aura-cli/tests/graph_construct.rs index 7f112ad..4a02c41 100644 --- a/crates/aura-cli/tests/graph_construct.rs +++ b/crates/aura-cli/tests/graph_construct.rs @@ -696,6 +696,38 @@ fn graph_params_accepts_an_op_script_matching_its_envelope() { assert_eq!(op_out, env_out, "op-script and envelope agree on the raw axis namespace"); } +/// Property (#226, the render positional closes the #202 on-ramp family): +/// `aura graph ` (the render positional) accepts an op-script +/// document (a JSON array) exactly as it accepts a #155 blueprint envelope (a +/// JSON object). Its two introspect siblings (`register`, `introspect --params`, +/// pinned above) already shape-discriminate via `composite_from_any`, but the +/// render positional still parses via the direct `blueprint_from_json` and so +/// rejects the op-script form — leaking the raw serde `invalid type: map, +/// expected u32` mislabeled as "blueprint document is not valid JSON". The +/// op-script and its own `graph build` envelope canonicalize to the same +/// Composite (the register content-id parity above proves the bytes match), so +/// both must render byte-identically at exit 0. +#[test] +fn graph_render_accepts_an_op_script_matching_its_envelope() { + let dir = temp_cwd("render-op-script"); + let op_script = dir.join("op-script.json"); + std::fs::write(&op_script, SIGNAL_DOC).expect("write op-script fixture"); + let (envelope_bytes, _e, built) = run(&["graph", "build"], SIGNAL_DOC); + assert!(built, "graph build produces the envelope"); + let envelope = dir.join("envelope.json"); + std::fs::write(&envelope, &envelope_bytes).expect("write envelope fixture"); + + let (env_out, env_err, env_code) = run_in(&dir, &["graph", envelope.to_str().unwrap()]); + assert_eq!(env_code, Some(0), "render envelope: {env_err}"); + let (op_out, op_err, op_code) = run_in(&dir, &["graph", op_script.to_str().unwrap()]); + assert_eq!(op_code, Some(0), "render op-script exits 0: {op_err}"); + assert!( + !op_err.contains("blueprint document is not valid JSON"), + "must not mislabel a valid op-script as invalid JSON: {op_err}" + ); + assert_eq!(op_out, env_out, "op-script and its built envelope render byte-identically"); +} + /// Property (#159): the shipped closed example (`examples/r_sma.json`) is /// genuinely closed, not merely byte-identical to the builder — `graph /// introspect --params` on it reports zero unbound params. The Cut-1