Add a typed-handle GraphBuilder for name-based blueprint wiring #64
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Blueprint topology is wired today purely by raw positional indices. An edge is
four bare
usizefields —Edge { from, to, slot, from_field }(
crates/aura-engine/src/harness.rs:30) — wherefrom/toare positions in theComposite'snodesVec,slotindexes the consumer'sNodeSchema.inputs, andfrom_fieldindexes the producer's output record. The authored form is dense andbrittle:
Inserting a node renumbers every edge that referenced a later position; the
integers carry no meaning at the call site, so hand-comments (
// fast -> Sub.lhs)stand in for what the code cannot say.
By contrast, params are already addressed by name
(
bp.with("sma_cross.fast.length", 2),crates/aura-engine/src/blueprint.rs:259),and the graph-model viewer already renders endpoints with name-ish handles
(
@price,#0,crates/aura-engine/src/graph_model.rs:140). Only topologyauthoring is still bare indices.
Proposed shape
A fluent, additive
GraphBuilder(new module) where node references are typedvalues, not strings:
add()returns aNodeHandlecarrying the assignednodes-Vec index — acompiler-checked value, impossible to mistype. Only port names are strings.
PortSpec.name/FieldSpec.name(
crates/aura-core/src/node.rs:39,50, shipped by specdocs/specs/0027-name-input-ports.md).build()emits the existingComposite(
crates/aura-engine/src/blueprint.rs:139) unchanged; everything downstream(
compile_with_params,inline_composite,FlatGraph) is untouched. Namesresolve at the authoring boundary and never reach the compilat — the same
posture param-name resolution already has
(
crates/aura-engine/src/blueprint.rs:413), so the index-wired-compilatinvariant (C23) holds by construction.
This is the endorsed fluent-Rust-builder shape (C10), not a stringly-typed
mini-language: endpoints are typed values, the only strings are port names looked
up against real declared schema data.
Acceptance
GraphBuilderproduces aCompositebyte-identical (sameFlatGraphedges/sources) to the hand-wired index form — pinned by a parity test on the
shared sma_cross harness fixtures (
crates/aura-engine/src/test_fixtures.rs).surface (unknown node / unknown port / ambiguous port) mirroring
PrimitiveBuilder::bind's collect-then-reject(
crates/aura-core/src/node.rs:170).Compositeisadded into the parent and addressed by its derived role/output names).Composite::newstays public and unchanged; existing callsites keep compiling. The two authoring forms coexist.
Verified prerequisites and limits
impl From<Composite> for BlueprintNodetoday — onlyFrom<PrimitiveBuilder>(crates/aura-engine/src/blueprint.rs:44); nestedcomposites are wrapped by hand as
BlueprintNode::Composite(...)(e.g.crates/aura-engine/src/test_fixtures.rs:64). Theaddpath for a nestedcomposite needs this
Fromimpl (or an explicit lift method) added.Every shipped node satisfies this today, but spec 0027 deliberately left
PortSpec.namenon-load-bearing and unguarded — so this becomes a softexpectation for builder-wired nodes (a within-node uniqueness guard is the
natural enforcement point).
#21, closed)legible — a named slot replaces the bare index — but not structurally
impossible: correct port names with transposed sources still resolve. The
structural fix (promoting
PortSpec.name/FieldSpec.nameto load-bearingaddressing keys plus an all-required-ports-connected check) is a distinct,
ledger-level follow-up that spec 0027 already deferred ("its own cycle, now
better-equipped because the names exist to validate against"); tracked
separately.