Skip to main content

jellyflow_runtime/schema/registry/plans/
mod.rs

1mod canonicalize;
2mod migrate;
3mod writer;
4
5use jellyflow_core::core::Graph;
6
7use super::NodeRegistry;
8use crate::schema::migration::{CanonicalizeKindsPlan, MigrateNodesPlan};
9
10impl NodeRegistry {
11    /// Plans a transaction that rewrites aliased node kinds to their canonical kind.
12    pub fn plan_canonicalize_kinds(&self, graph: &Graph) -> CanonicalizeKindsPlan {
13        let mut planner = canonicalize::CanonicalizeKindsPlanner::new();
14
15        for (id, node) in &graph.nodes {
16            let canonical = self.resolve_kind(&node.kind);
17            planner.rewrite_node_kind(*id, node, canonical);
18        }
19
20        planner.finish()
21    }
22
23    /// Plans a transaction that upgrades node payloads to the latest registered kind version.
24    ///
25    /// This plan is intentionally best-effort:
26    /// - missing schema -> recorded as a report entry, no edits are produced
27    /// - missing migrator -> recorded as a report entry, no edits are produced
28    /// - migrator errors -> recorded as a report entry, no edits are produced for that node
29    ///
30    /// The returned transaction may also include `SetNodeKind` ops for aliased kinds.
31    pub fn plan_migrate_nodes(&self, graph: &Graph) -> MigrateNodesPlan {
32        migrate::MigrateNodesPlanner::new(self, graph).finish()
33    }
34}