From bbe2266b9e4032da1c83835e8b1d20a9670ab33f Mon Sep 17 00:00:00 2001 From: Brummel Date: Wed, 10 Jun 2026 11:10:23 +0200 Subject: [PATCH] plan: 0026 graph model serializer Iteration 1 of the graph render redesign: a read-only model_to_json(&Composite) in a new crates/aura-engine/src/graph_model.rs, hand-rolled deterministic JSON (RunReport::to_json house style, no serde). Six tasks: helpers, primitive record, scope (index keys + synthetic source nodes from bound roles), composite defs (@role/#N endpoints, distinct-once walk), top-level + byte golden + determinism, structural assertions + structural-miswire-differs + read-only. Decisions: home in aura-engine; node keys are indices (C23); input ports carry kind+firing, no name (per acceptance criterion 3); bound root source-roles minted as synthetic source nodes. --- docs/plans/0026-graph-model-serializer.md | 645 ++++++++++++++++++++++ 1 file changed, 645 insertions(+) create mode 100644 docs/plans/0026-graph-model-serializer.md diff --git a/docs/plans/0026-graph-model-serializer.md b/docs/plans/0026-graph-model-serializer.md new file mode 100644 index 0000000..d2556bb --- /dev/null +++ b/docs/plans/0026-graph-model-serializer.md @@ -0,0 +1,645 @@ +# Iteration 1 — graph model serializer — Implementation Plan + +> **Parent spec:** `docs/specs/0026-graph-render-redesign.md` +> +> **For agentic workers:** REQUIRED SUB-SKILL: use the `implement` skill to run this +> plan. Steps use `- [ ]` checkboxes for tracking. + +**Goal:** Add a read-only Rust serializer `model_to_json(&Composite) -> String` that +turns the harness root composite + every distinct composite type into the canonical, +deterministic JSON graph model the viewer (iteration 2) will consume. + +**Architecture:** A new `crates/aura-engine/src/graph_model.rs`, hand-rolled +deterministic JSON in the `RunReport::to_json` house style (no serde). It walks the +blueprint via the existing read-only accessors and emits a model with two top-level +keys: `root` (the harness scope) and `composites` (each distinct composite type once). +Read-only (C9): the function takes `&Composite`, returns `String`, and never calls +`eval`/`compile`/`bootstrap`. + +**Tech Stack:** aura-engine (`blueprint.rs` accessors, `harness::Edge`, +`report.rs` JSON idiom), aura-core (`NodeSchema`/`PortSpec`/`FieldSpec`/`ParamSpec`/ +`Firing`/`ScalarKind`). + +--- + +## Model shape (the contract this iteration produces) + +Resolved against the **types** (recon) and spec acceptance criterion 3, where the +spec's abridged example was prototype-flavoured: + +``` +{ + "root": , + "composites": { "": , ... } // first-seen order +} +``` + +- **scope** = `{ "nodes": { "": , ... }, "edges": [ , ... ] }` +- **composite-def** = `{ "inputs": [ , ... ], "outputs": [ [name,kind], ... ], + "nodes": {...}, "edges": [...] }` +- **node** (one of): + - primitive: `{ "prim": { "type":