core_api/history.rs
1use core_storage::Value;
2
3/// A single change event in a node's history, paired with the WAL commit that produced it.
4///
5/// ## Horizon
6///
7/// History reaches back only to the last WAL-truncating snapshot, exactly like `open_at`.
8/// Snapshots written with `keep_wal: true` preserve deeper history. This is the honest,
9/// zero-cost contract; a durable history log is out of scope.
10///
11/// ## Derived edges
12///
13/// Rule-created (derived) edges are **not** in the WAL and therefore do not appear in
14/// history. Only edges written directly by the application are recorded.
15#[derive(Debug, PartialEq)]
16pub struct HistoryEntry {
17 /// 0-based WAL frame index of the commit that produced this change.
18 pub commit: u64,
19 pub change: HistoryChange,
20}
21
22#[derive(Debug, PartialEq)]
23pub enum HistoryChange {
24 NodeInserted {
25 label: String,
26 },
27 PropSet {
28 field: String,
29 value: Value,
30 },
31 PropRemoved {
32 field: String,
33 },
34 /// An edge involving this node was added.
35 ///
36 /// `outgoing` is `true` if this node is the source, `false` if it is the destination.
37 ///
38 /// Self-edges (src == dst == this node) produce a single entry with `outgoing: true`.
39 EdgeAdded {
40 edge_type: String,
41 other: String,
42 outgoing: bool,
43 },
44 /// An edge involving this node was removed.
45 ///
46 /// `outgoing` is `true` if this node is the source, `false` if it is the destination.
47 ///
48 /// Self-edges (src == dst == this node) produce a single entry with `outgoing: true`.
49 EdgeRemoved {
50 edge_type: String,
51 other: String,
52 outgoing: bool,
53 },
54 NodeDeleted,
55}