Address soundness hole in cycle prevention

This commit is contained in:
TechnoPorg committed 2026-01-29 06:56:17 +01:00
1 parent 4ad88bcd68
commit f82205baf4
80 files changed
+730 -717

No files matched your search

+21 -21
View File
@@ -27,7 +27,7 @@ async fn test_complex_type_safety() {
.unwrap();
// Correct type works
let custom = dag.get(&custom_task).unwrap();
let custom = dag.get(custom_task).unwrap();
assert_eq!(custom.value, 42);
// Type safety is enforced at compile time - we cannot get with wrong types
@@ -51,8 +51,8 @@ async fn test_generic_type_safety() {
.unwrap();
// Correct types work
assert_eq!(dag.get(&vec_i32).unwrap(), vec![1, 2, 3]);
assert!(dag.get(&vec_string).is_ok());
assert_eq!(dag.get(vec_i32).unwrap(), vec![1, 2, 3]);
assert!(dag.get(vec_string).is_ok());
}
#[tokio::test]
@@ -71,8 +71,8 @@ async fn test_option_result_type_safety() {
.unwrap();
// Correct wrapped types work
assert_eq!(dag.get(&opt_task).unwrap(), Some(42));
assert!(dag.get(&result_task).is_ok());
assert_eq!(dag.get(opt_task).unwrap(), Some(42));
assert!(dag.get(result_task).is_ok());
}
#[tokio::test]
@@ -94,7 +94,7 @@ async fn test_zero_sized_type_safety() {
.unwrap();
// Correct ZSTs work
assert!(dag.get(&zst1_task).is_ok());
assert!(dag.get(zst1_task).is_ok());
}
#[tokio::test]
@@ -115,13 +115,13 @@ async fn test_type_safety_with_many_types() {
.unwrap();
// Each type works correctly
assert_eq!(dag.get(&i32_task).unwrap(), 42i32);
assert_eq!(dag.get(&i64_task).unwrap(), 42i64);
assert_eq!(dag.get(&u32_task).unwrap(), 42u32);
assert_eq!(dag.get(&f32_task).unwrap(), 42.0f32);
assert_eq!(dag.get(&f64_task).unwrap(), 42.0f64);
assert_eq!(dag.get(&string_task).unwrap(), "42".to_string());
assert!(dag.get(&bool_task).unwrap());
assert_eq!(dag.get(i32_task).unwrap(), 42i32);
assert_eq!(dag.get(i64_task).unwrap(), 42i64);
assert_eq!(dag.get(u32_task).unwrap(), 42u32);
assert_eq!(dag.get(f32_task).unwrap(), 42.0f32);
assert_eq!(dag.get(f64_task).unwrap(), 42.0f64);
assert_eq!(dag.get(string_task).unwrap(), "42".to_string());
assert!(dag.get(bool_task).unwrap());
}
#[tokio::test]
@@ -134,7 +134,7 @@ async fn test_type_safety_single_dependency() {
// This compiles because types match (i32 -> i32)
let transform = dag
.add_task(task_fn(|x: i32| async move { x * 2 }))
.depends_on(&source);
.depends_on(source);
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap))
.await
@@ -156,7 +156,7 @@ async fn test_type_safety_tuple_dependencies() {
.add_task(task_fn(|(x, s, b): (i32, String, bool)| async move {
format!("{}: {} ({})", s, x, b)
}))
.depends_on((&a, &b, &c));
.depends_on((a, b, c));
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap))
.await
@@ -177,9 +177,9 @@ async fn test_type_safety_different_output_types() {
.await
.unwrap();
assert_eq!(dag.get(&int_source).unwrap(), 42);
assert_eq!(dag.get(&str_source).unwrap(), "test");
assert_eq!(dag.get(&vec_source).unwrap(), vec![1, 2, 3]);
assert_eq!(dag.get(int_source).unwrap(), 42);
assert_eq!(dag.get(str_source).unwrap(), "test");
assert_eq!(dag.get(vec_source).unwrap(), vec![1, 2, 3]);
}
#[tokio::test]
@@ -226,7 +226,7 @@ async fn test_type_safety_with_generics() {
.add_task(task_fn(
|opt: Option<i32>| async move { opt.map(|x| x * 2) },
))
.depends_on(&source);
.depends_on(source);
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap))
.await
@@ -240,7 +240,7 @@ async fn test_type_safety_with_generics() {
.add_task(task_fn(
|opt: Option<i32>| async move { opt.map(|x| x * 2) },
))
.depends_on(&source2);
.depends_on(source2);
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap))
.await
@@ -262,7 +262,7 @@ async fn test_large_tuple_input() {
.add_task(task_fn(
|(a, b, c, d, e): (i32, i32, i32, i32, i32)| async move { a + b + c + d + e },
))
.depends_on((&a, &b, &c, &d, &e));
.depends_on((a, b, c, d, e));
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap))
.await
+6 -6
View File
@@ -21,7 +21,7 @@ async fn test_get_with_wrong_type_returns_none() {
.unwrap();
// Verify correct type works
assert_eq!(dag.get(&int_task), Ok(42i32));
assert_eq!(dag.get(int_task), Ok(42i32));
// The type safety is enforced at compile time
// We cannot create fake handles with wrong types without accessing private fields
@@ -42,8 +42,8 @@ async fn test_handle_preserves_type() {
.unwrap();
// Get with correct types
assert_eq!(dag.get(&string_task).unwrap(), "hello".to_string());
assert_eq!(dag.get(&int_task).unwrap(), 42);
assert_eq!(dag.get(string_task).unwrap(), "hello".to_string());
assert_eq!(dag.get(int_task).unwrap(), 42);
// Type safety is enforced at compile time - we cannot create wrong-typed handles
}
@@ -53,15 +53,15 @@ async fn test_type_safety_handle_reuse() {
// Verify that handles maintain type safety across reuse
let dag = DagRunner::new();
let source = dag.add_task(task_fn(|_: ()| async { 100i32 }));
let source: TaskHandle<_> = dag.add_task(task_fn(|_: ()| async { 100i32 })).into();
// Use the same source handle multiple times
let double = dag
.add_task(task_fn(|x: i32| async move { x * 2 }))
.depends_on(&source);
.depends_on(source);
let triple = dag
.add_task(task_fn(|x: i32| async move { x * 3 }))
.depends_on(&source);
.depends_on(source);
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap))
.await