{"record":{"id":"6ea4d8a460d6e282","repo":"bevyengine/bevy","slug":"dag-has-a-cross-dependency-between-nodes-0-and","errorCode":null,"errorMessage":"DAG has a cross-dependency between nodes {0:?} and {1:?}","messagePattern":"DAG has a cross-dependency between nodes (.+?) and (.+?)","errorType":"exception","errorClass":"DagCrossDependencyError","httpStatus":null,"severity":"error","filePath":"crates/bevy_ecs/src/schedule/graph/dag.rs","lineNumber":719,"sourceCode":"    fn default() -> Self {\n        Self(Default::default())\n    }\n}\n\nimpl<K: Debug, V: Debug, S> Debug for DagGroups<K, V, S> {\n    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n        f.debug_tuple(\"DagGroups\").field(&self.0).finish()\n    }\n}\n\n/// Error indicating that the graph has redundant edges.\n#[derive(Error, Debug)]\n#[error(\"DAG has redundant edges: {0:?}\")]\npub struct DagRedundancyError<N: GraphNodeId>(pub Vec<(N, N)>);\n\n/// Error indicating that two graphs both have a dependency between the same nodes.\n#[derive(Error, Debug)]\n#[error(\"DAG has a cross-dependency between nodes {0:?} and {1:?}\")]\npub struct DagCrossDependencyError<N>(pub N, pub N);\n\n/// Error indicating that the graph has overlapping groups between two keys.\n#[derive(Error, Debug)]\n#[error(\"DAG has overlapping groups between keys {0:?} and {1:?}\")]\npub struct DagOverlappingGroupError<K>(pub K, pub K);\n\n#[cfg(test)]\nmod tests {\n    use core::ops::DerefMut;\n\n    use crate::schedule::graph::{index, Dag, Direction, GraphNodeId, UnGraph};\n\n    #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]\n    struct TestNode(u32);\n\n    impl GraphNodeId for TestNode {\n        type Adjacent = (TestNode, Direction);","sourceCodeStart":701,"sourceCodeEnd":737,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_ecs/src/schedule/graph/dag.rs#L701-L737","documentation":"`DagCrossDependencyError` is the low-level graph error stating that nodes `{0}` and `{1}` carry dependencies in both directions between the hierarchy and dependency graphs — concretely, a `before`/`after` edge between a node and a set that contains it. Bevy wraps it into `ScheduleBuildError::CrossDependency` during schedule initialization; the two node ids identify the conflicting pair.","triggerScenarios":"The same condition as `CrossDependency`: a system or set ordered `.before`/`.after` a set it (transitively) belongs to. You encounter this raw type when matching on the inner error of `CrossDependency` or using the Dag API directly.","commonSituations":"Bracketing constraints ('run X after everything in set S' where X is in S); plugin A ordering against plugin B's set while contributing systems into it; transitive in_set chains making a local ordering global and self-referential.","solutions":["Repoint the ordering at a sibling system or set that does not contain the constrained node","Move the constrained node out of the set if it truly must bracket the set's execution","Trace which plugins contribute the `in_set` and `before` edges — the conflict is often between edges from two different sources"],"exampleFix":"// before\napp.add_systems(Update, x.in_set(S).before(S)); // DagCrossDependencyError(x, S)\n\n// after\napp.add_systems(Update, x.in_set(S));\napp.add_systems(Update, y.in_set(S).before(x)); // order inside the set instead","handlingStrategy":"try-catch","validationCode":"// Guard at config time: never emit ordering vs a containing set\nfn orderable(hierarchy: &SetHierarchy, node: SetId, target: SetId) -> bool {\n    !hierarchy.is_descendant_of(target, node)\n}","typeGuard":null,"tryCatchPattern":"match schedule.initialize(&mut world) {\n    Err(ScheduleBuildError::CrossDependency(err @ DagCrossDependencyError(_, _))) => {\n        // err.0/err.1 name the node/set pair; repoint the .before/.after edge at a sibling\n    }\n    other => other.map(|_| ()),\n}","preventionTips":["Order members against members, sets against sibling sets","When integrating plugins, review whether your ordering target transitively contains your systems","Keep the in_set lattice documented so 'ordering vs ancestor' mistakes are visible in review"],"tags":["bevy","ecs","schedule","dag","ordering"],"backgroundTag":"circular-ordering-constraint","analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}