Skip to content

Commit e078ce9

Browse files
committed
docs(runtime): clarify semantics of internal NodeId and PatchTrace fields
1 parent 91ec1de commit e078ce9

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/runtime/src/diff.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,14 @@ pub fn diff(source: &LinkMLValue, target: &LinkMLValue, treat_missing_as_null: b
237237

238238
#[derive(Debug, Clone, Default)]
239239
pub struct PatchTrace {
240+
/// Node IDs of subtrees that were newly created by the patch.
241+
///
242+
/// See [`crate::NodeId`] for semantics: these are internal, ephemeral IDs
243+
/// that are useful for tooling and provenance, not object identifiers.
240244
pub added: Vec<NodeId>,
245+
/// Node IDs of subtrees that were removed by the patch.
241246
pub deleted: Vec<NodeId>,
247+
/// Node IDs of nodes that were directly updated (e.g., parent containers, scalars).
242248
pub updated: Vec<NodeId>,
243249
}
244250

src/runtime/src/lib.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,18 @@ pub enum LinkMLValue {
9191
},
9292
}
9393

94-
// Stable node identifiers assigned to every LinkMLValue node
94+
/// Internal node identifier used for provenance and update tracking.
95+
///
96+
/// Node IDs are assigned to every `LinkMLValue` node when values are constructed or
97+
/// transformed. They exist solely as technical identifiers to help with patching and
98+
/// provenance (for example, `PatchTrace.added`/`deleted` collect `NodeId`s of affected
99+
/// subtrees). They are not intended to identify domain objects — for that, use LinkML
100+
/// identifier or key slots as defined in the schema.
101+
///
102+
/// Important properties:
103+
/// - Local and ephemeral: loading the same data twice will yield different `NodeId`s.
104+
/// - Non-persistent: never serialize or expose as a model identifier.
105+
/// - Useful for tracking modifications within a single in-memory value.
95106
pub type NodeId = u64;
96107

97108
static NEXT_NODE_ID: AtomicU64 = AtomicU64::new(1);
@@ -101,6 +112,10 @@ fn new_node_id() -> NodeId {
101112
}
102113

103114
impl LinkMLValue {
115+
/// Returns the internal [`NodeId`] of this node.
116+
///
117+
/// This ID is only for internal provenance/update tracking and is not a
118+
/// semantic identifier of the represented object.
104119
pub fn node_id(&self) -> NodeId {
105120
match self {
106121
LinkMLValue::Scalar { node_id, .. }

0 commit comments

Comments
 (0)