Skip to main content

jellyflow_runtime/runtime/
commit.rs

1//! Canonical runtime commit payloads.
2//!
3//! Store commits are represented as reversible graph transactions. Adapter-specific projections,
4//! such as XyFlow-style node/edge changes, are derived outside this module.
5
6use serde::{Deserialize, Serialize};
7
8use jellyflow_core::ops::{GraphOp, GraphTransaction};
9
10/// Full-fidelity committed graph patch.
11///
12/// This is the primary commit payload for controlled integrations. It preserves every
13/// `GraphOp`, including ports, groups, sticky notes, imports, symbols, and other resources.
14#[derive(Debug, Clone, Default, Serialize, Deserialize)]
15pub struct NodeGraphPatch {
16    /// Reversible transaction committed by the store.
17    pub transaction: GraphTransaction,
18}
19
20impl NodeGraphPatch {
21    pub fn new(transaction: GraphTransaction) -> Self {
22        Self { transaction }
23    }
24
25    pub fn transaction(&self) -> &GraphTransaction {
26        &self.transaction
27    }
28
29    pub fn into_transaction(self) -> GraphTransaction {
30        self.transaction
31    }
32
33    pub fn ops(&self) -> &[GraphOp] {
34        self.transaction.ops()
35    }
36
37    pub fn is_empty(&self) -> bool {
38        self.transaction.is_empty()
39    }
40}
41
42impl From<GraphTransaction> for NodeGraphPatch {
43    fn from(transaction: GraphTransaction) -> Self {
44        Self::new(transaction)
45    }
46}