Skip to content
This repository was archived by the owner on Feb 6, 2026. It is now read-only.

Commit 07fb3a7

Browse files
zacharyhammstack72
authored andcommitted
fix(dal): make use edge kind method more succinct, ensure we include the edge info in the merkle tree hash calculation
1 parent 23c15ae commit 07fb3a7

17 files changed

Lines changed: 224 additions & 225 deletions

File tree

lib/dal/src/action/batch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ impl ActionBatch {
168168
workspace_snapshot
169169
.add_edge(
170170
category_id,
171-
EdgeWeight::new(change_set, EdgeWeightKind::use_not_as_default())?,
171+
EdgeWeight::new(change_set, EdgeWeightKind::new_use())?,
172172
id,
173173
)
174174
.await?;

lib/dal/src/action/prototype.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ impl ActionPrototype {
203203
workspace_snapshot
204204
.add_edge(
205205
id,
206-
EdgeWeight::new(change_set, EdgeWeightKind::use_not_as_default())?,
206+
EdgeWeight::new(change_set, EdgeWeightKind::new_use())?,
207207
func_id,
208208
)
209209
.await?;

lib/dal/src/action/runner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ impl ActionRunner {
247247
workspace_snapshot
248248
.add_edge(
249249
action_batch_id,
250-
EdgeWeight::new(change_set, EdgeWeightKind::use_not_as_default())?,
250+
EdgeWeight::new(change_set, EdgeWeightKind::new_use())?,
251251
id,
252252
)
253253
.await?;

lib/dal/src/attribute/prototype.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl AttributePrototype {
124124
workspace_snapshot
125125
.add_edge(
126126
id,
127-
EdgeWeight::new(change_set, EdgeWeightKind::use_not_as_default())?,
127+
EdgeWeight::new(change_set, EdgeWeightKind::new_use())?,
128128
func_id,
129129
)
130130
.await?;
@@ -230,7 +230,7 @@ impl AttributePrototype {
230230
.edges_directed(attribute_prototype_id, Direction::Outgoing)
231231
.await?
232232
.iter()
233-
.find(|(edge_weight, _, _)| edge_weight.kind() == &EdgeWeightKind::use_not_as_default())
233+
.find(|(edge_weight, _, _)| edge_weight.kind() == &EdgeWeightKind::new_use())
234234
.map(|(_, _, target_idx)| *target_idx)
235235
.ok_or(AttributePrototypeError::MissingFunction(
236236
attribute_prototype_id,
@@ -249,7 +249,7 @@ impl AttributePrototype {
249249
workspace_snapshot
250250
.add_edge(
251251
attribute_prototype_id,
252-
EdgeWeight::new(change_set, EdgeWeightKind::use_not_as_default())?,
252+
EdgeWeight::new(change_set, EdgeWeightKind::new_use())?,
253253
func_id,
254254
)
255255
.await?;

lib/dal/src/attribute/prototype/argument.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ impl AttributePrototypeArgument {
187187
workspace_snapshot
188188
.add_edge(
189189
id,
190-
EdgeWeight::new(change_set, EdgeWeightKind::use_not_as_default())?,
190+
EdgeWeight::new(change_set, EdgeWeightKind::new_use())?,
191191
arg_id,
192192
)
193193
.await?;
@@ -249,7 +249,7 @@ impl AttributePrototypeArgument {
249249
workspace_snapshot
250250
.add_edge(
251251
prototype_arg.id(),
252-
EdgeWeight::new(change_set, EdgeWeightKind::use_not_as_default())?,
252+
EdgeWeight::new(change_set, EdgeWeightKind::new_use())?,
253253
func_arg_id,
254254
)
255255
.await?;

lib/dal/src/component.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ impl Component {
292292
workspace_snapshot
293293
.add_edge(
294294
component_category_id,
295-
EdgeWeight::new(change_set, EdgeWeightKind::use_not_as_default())?,
295+
EdgeWeight::new(change_set, EdgeWeightKind::new_use())?,
296296
id,
297297
)
298298
.await?;
@@ -301,7 +301,7 @@ impl Component {
301301
workspace_snapshot
302302
.add_edge(
303303
id,
304-
EdgeWeight::new(change_set, EdgeWeightKind::use_not_as_default())?,
304+
EdgeWeight::new(change_set, EdgeWeightKind::new_use())?,
305305
schema_variant_id,
306306
)
307307
.await?;

lib/dal/src/func.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ impl Func {
196196
workspace_snapshot
197197
.add_edge(
198198
func_category_id,
199-
EdgeWeight::new(change_set, EdgeWeightKind::use_not_as_default())?,
199+
EdgeWeight::new(change_set, EdgeWeightKind::new_use())?,
200200
id,
201201
)
202202
.await?;
@@ -234,7 +234,7 @@ impl Func {
234234
let func_indices = workspace_snapshot
235235
.outgoing_targets_for_edge_weight_kind(
236236
func_category_id,
237-
EdgeWeightKind::use_not_as_default().into(),
237+
EdgeWeightKind::new_use().into(),
238238
)
239239
.await?;
240240
let name = name.as_ref();
@@ -384,7 +384,7 @@ impl Func {
384384
let arg_node_idx = workspace_snapshot.get_node_index_by_id(id).await?;
385385

386386
let users = workspace_snapshot
387-
.incoming_sources_for_edge_weight_kind(id, EdgeWeightKind::use_not_as_default().into())
387+
.incoming_sources_for_edge_weight_kind(id, EdgeWeightKind::new_use().into())
388388
.await?;
389389

390390
let change_set = ctx.change_set_pointer()?;
@@ -394,7 +394,7 @@ impl Func {
394394
change_set,
395395
user,
396396
arg_node_idx,
397-
EdgeWeightKind::use_not_as_default().into(),
397+
EdgeWeightKind::new_use().into(),
398398
)
399399
.await?;
400400
}

lib/dal/src/func/argument.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ impl FuncArgument {
193193
workspace_snapshot
194194
.add_edge(
195195
func_id,
196-
EdgeWeight::new(change_set, EdgeWeightKind::use_not_as_default())?,
196+
EdgeWeight::new(change_set, EdgeWeightKind::new_use())?,
197197
id,
198198
)
199199
.await?;

lib/dal/src/prop.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ impl Prop {
555555
.add_ordered_edge(
556556
change_set,
557557
ordered_prop_id,
558-
EdgeWeight::new(change_set, EdgeWeightKind::use_not_as_default())?,
558+
EdgeWeight::new(change_set, EdgeWeightKind::new_use())?,
559559
id,
560560
)
561561
.await?;
@@ -564,7 +564,7 @@ impl Prop {
564564
workspace_snapshot
565565
.add_edge(
566566
prop_id,
567-
EdgeWeight::new(change_set, EdgeWeightKind::use_not_as_default())?,
567+
EdgeWeight::new(change_set, EdgeWeightKind::new_use())?,
568568
id,
569569
)
570570
.await?;
@@ -573,7 +573,7 @@ impl Prop {
573573
workspace_snapshot
574574
.add_edge(
575575
schema_variant_id,
576-
EdgeWeight::new(change_set, EdgeWeightKind::use_not_as_default())?,
576+
EdgeWeight::new(change_set, EdgeWeightKind::new_use())?,
577577
id,
578578
)
579579
.await?;
@@ -610,10 +610,7 @@ impl Prop {
610610

611611
let workspace_snapshot = ctx.workspace_snapshot()?;
612612
for maybe_elem_node_idx in workspace_snapshot
613-
.outgoing_targets_for_edge_weight_kind(
614-
self.id,
615-
EdgeWeightKind::use_not_as_default().into(),
616-
)
613+
.outgoing_targets_for_edge_weight_kind(self.id, EdgeWeightKind::new_use().into())
617614
.await?
618615
{
619616
if let NodeWeight::Prop(prop_inner) = workspace_snapshot

lib/dal/src/schema.rs

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl Schema {
118118
workspace_snapshot
119119
.add_edge(
120120
schema_category_index_id,
121-
EdgeWeight::new(change_set, EdgeWeightKind::use_not_as_default())?,
121+
EdgeWeight::new(change_set, EdgeWeightKind::new_use())?,
122122
id,
123123
)
124124
.await?;
@@ -136,7 +136,7 @@ impl Schema {
136136
workspace_snapshot.edges_directed(self.id, Outgoing).await?;
137137

138138
for (edge_weight, _, target_index) in default_schema_variant_node_indicies {
139-
if *edge_weight.kind() == EdgeWeightKind::use_as_default() {
139+
if *edge_weight.kind() == EdgeWeightKind::new_use_default() {
140140
return Ok(Some(
141141
workspace_snapshot
142142
.get_node_weight(target_index)
@@ -164,19 +164,23 @@ impl Schema {
164164
);
165165

166166
// Our system will have edges as follows:
167-
// Schema -> Uses -> Schema Variant
168-
// In order to make a schema variant the default for a schema, we need to update the
169-
// correct edge from Use to Default:
170-
// Schema -> Default -> Schema Variant
171-
// Therefore, when we are setting a default schema variant we need to find any existing
172-
// Default edges and convert them back to uses AND we need to find the existing Use edge
173-
// between our nodes and change that to be a Default
174-
167+
//
168+
// Schema -> Use -> Schema Variant
169+
//
170+
// In order to make a schema variant the default for a schema, we need
171+
// to update the correct edge from Use to the default variant of Use,
172+
//
173+
// Schema -> Use {is_default = true} -> Schema Variant
174+
//
175+
// Therefore, when we are setting a default schema variant we need to
176+
// find any existing default Use edges and convert them back to uses AND we
177+
// need to find the existing Use edge between our nodes and change that
178+
// to be a default Use
175179
for (edge_weight, source_index, target_index) in workspace_snapshot
176180
.edges_directed_for_edge_weight_kind(
177181
self.id,
178182
Outgoing,
179-
EdgeWeightKind::use_as_default().into(),
183+
EdgeWeightKind::new_use_default().into(),
180184
)
181185
.await?
182186
{
@@ -194,10 +198,7 @@ impl Schema {
194198
workspace_snapshot
195199
.add_edge(
196200
self.id,
197-
EdgeWeight::new(
198-
ctx.change_set_pointer()?,
199-
EdgeWeightKind::use_not_as_default(),
200-
)?,
201+
EdgeWeight::new(ctx.change_set_pointer()?, EdgeWeightKind::new_use())?,
201202
schema_variant_id,
202203
)
203204
.await?;
@@ -207,7 +208,7 @@ impl Schema {
207208
.edges_directed_for_edge_weight_kind(
208209
self.id,
209210
Outgoing,
210-
EdgeWeightKind::use_not_as_default().into(),
211+
EdgeWeightKind::new_use().into(),
211212
)
212213
.await?
213214
{
@@ -225,7 +226,7 @@ impl Schema {
225226
workspace_snapshot
226227
.add_edge(
227228
self.id,
228-
EdgeWeight::new(ctx.change_set_pointer()?, EdgeWeightKind::use_as_default())?,
229+
EdgeWeight::new(ctx.change_set_pointer()?, EdgeWeightKind::new_use_default())?,
229230
schema_variant_id,
230231
)
231232
.await?;

0 commit comments

Comments
 (0)