Replace node definition string-based lookups with DefinitionIdentifier instances (#3451)

* create definition identifier and integrate it

* Bug fixes and code review

* formatting

* Fix migrations

* Fix remove handles migration

* formatting

* Fix test

* Fix tests 2

* fix deserialization

* Code review

* Small fixes

* Consolidate 'Morph' node migrations

* Add old SamplePointsNode name to migrations list

* Fix tests

* Unrelated small fix

* Fix migration crashes

* Fix tests

* Final code review

* fmt

* Add metadata

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Adam Gerhant
2026-01-12 23:09:43 -08:00
committed by GitHub
co-authored by Keavon Chambers
parent 4fea2b0fe7
commit a6052c5819
63 changed files with 843 additions and 802 deletions
+13 -13
View File
@@ -30,7 +30,7 @@ impl core::fmt::Display for ProtoNetwork {
return f.write_str("{{Unknown Node}}");
};
f.write_str("Node: ")?;
f.write_str(&node.identifier.name)?;
f.write_str(node.identifier.as_str())?;
f.write_str("\n")?;
f.write_str(&"\t".repeat(indent))?;
@@ -156,7 +156,7 @@ impl ProtoNode {
use std::hash::Hasher;
let mut hasher = rustc_hash::FxHasher::default();
self.identifier.name.hash(&mut hasher);
self.identifier.as_str().hash(&mut hasher);
self.construction_args.hash(&mut hasher);
if self.skip_deduplication {
self.original_location.path.hash(&mut hasher);
@@ -612,7 +612,7 @@ impl GraphError {
pub fn new(node: &ProtoNode, text: impl Into<GraphErrorType>) -> Self {
Self {
node_path: node.original_location.path.clone().unwrap_or_default(),
identifier: node.identifier.name.clone(),
identifier: Cow::Owned(node.identifier.as_str().to_string()),
error: text.into(),
}
}
@@ -916,7 +916,7 @@ mod test {
let ids: Vec<_> = construction_network.nodes.iter().map(|(id, _)| *id).collect();
println!("{ids:#?}");
println!("nodes: {:#?}", construction_network.nodes);
assert_eq!(construction_network.nodes[0].1.identifier.name.as_ref(), "value");
assert_eq!(construction_network.nodes[0].1.identifier.as_str(), "value");
assert_eq!(ids, vec![NodeId(0), NodeId(1), NodeId(2), NodeId(3)]);
}
@@ -929,7 +929,7 @@ mod test {
assert_eq!(sorted, vec![NodeId(0), NodeId(1), NodeId(2), NodeId(3)]);
let ids: Vec<_> = construction_network.nodes.iter().map(|(id, _)| *id).collect();
println!("{ids:#?}");
assert_eq!(construction_network.nodes[0].1.identifier.name.as_ref(), "value");
assert_eq!(construction_network.nodes[0].1.identifier.as_str(), "value");
assert_eq!(ids, vec![NodeId(0), NodeId(1), NodeId(2), NodeId(3)]);
}
@@ -940,7 +940,7 @@ mod test {
.insert_context_nullification_nodes()
.expect("Error when calling 'insert_context_nullification_nodes' on 'construction_network.");
construction_network.generate_stable_node_ids();
assert_eq!(construction_network.nodes[0].1.identifier.name.as_ref(), "value");
assert_eq!(construction_network.nodes[0].1.identifier.as_str(), "value");
let ids: Vec<_> = construction_network.nodes.iter().map(|(id, _)| *id).collect();
// If this assert fails: These NodeIds seem to be changing when you modify TaggedValue, just update them.
@@ -958,7 +958,7 @@ mod test {
(
NodeId(7),
ProtoNode {
identifier: "id".into(),
identifier: ProtoNodeIdentifier::new("id"),
call_argument: concrete!(()),
construction_args: ConstructionArgs::Nodes(vec![NodeId(11)]),
..Default::default()
@@ -967,7 +967,7 @@ mod test {
(
NodeId(1),
ProtoNode {
identifier: "id".into(),
identifier: ProtoNodeIdentifier::new("id"),
call_argument: concrete!(()),
construction_args: ConstructionArgs::Nodes(vec![NodeId(11)]),
..Default::default()
@@ -976,7 +976,7 @@ mod test {
(
NodeId(10),
ProtoNode {
identifier: "cons".into(),
identifier: ProtoNodeIdentifier::new("cons"),
call_argument: concrete!(u32),
construction_args: ConstructionArgs::Nodes(vec![NodeId(14)]),
..Default::default()
@@ -985,7 +985,7 @@ mod test {
(
NodeId(11),
ProtoNode {
identifier: "add".into(),
identifier: ProtoNodeIdentifier::new("add"),
call_argument: concrete!(()),
construction_args: ConstructionArgs::Nodes(vec![NodeId(10)]),
..Default::default()
@@ -994,7 +994,7 @@ mod test {
(
NodeId(14),
ProtoNode {
identifier: "value".into(),
identifier: ProtoNodeIdentifier::new("value"),
call_argument: concrete!(()),
construction_args: ConstructionArgs::Value(value::TaggedValue::U32(2).into()),
..Default::default()
@@ -1014,7 +1014,7 @@ mod test {
(
NodeId(1),
ProtoNode {
identifier: "id".into(),
identifier: ProtoNodeIdentifier::new("id"),
call_argument: concrete!(()),
construction_args: ConstructionArgs::Nodes(vec![NodeId(2)]),
..Default::default()
@@ -1023,7 +1023,7 @@ mod test {
(
NodeId(2),
ProtoNode {
identifier: "id".into(),
identifier: ProtoNodeIdentifier::new("id"),
call_argument: concrete!(()),
construction_args: ConstructionArgs::Nodes(vec![NodeId(1)]),
..Default::default()