1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
use serde::{Deserialize, Serialize};
/// Complete store-wide state carried by [`super::MutationOp::SetEdgeEmbeddingStore`].
///
/// **Variant order is on-disk format.** Append only.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum EdgeEmbeddingStoreState {
Absent,
Present {
dimension: usize,
metric: Option<String>,
model_id: Option<String>,
},
}
/// Complete vector and source-text provenance for one relationship.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct EdgeVectorWalState {
pub vector: Vec<f32>,
/// `None` explicitly clears generated-text provenance for this member.
pub text_hash: Option<u64>,
}
/// One complete store column over a parallel group's final ordered members.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct EdgeGroupStoreWalState {
/// Source text column, not the derived `_emb` store spelling.
pub text_column: String,
/// Exactly one cell per final group member.
pub members: Vec<Option<EdgeVectorWalState>>,
}
pub type EdgeEmbeddingGroupDigest = [u8; 32];
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum EdgeVectorCellPatchWal {
Keep,
Replace(EdgeVectorWalState),
Clear,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum EdgeGroupMemberPatchWal {
Prior {
prior_ordinal: u32,
cells: Vec<EdgeVectorCellPatchWal>,
},
New {
cells: Vec<Option<EdgeVectorWalState>>,
},
}
/// Relative vector state paired with the immediately preceding topology event.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct EdgeGroupEmbeddingPatchWal {
pub base_digest: EdgeEmbeddingGroupDigest,
pub result_digest: EdgeEmbeddingGroupDigest,
/// Sorted store set the writer's `base_digest` was taken over — the set as
/// of *before* this commit, so a store created by this commit is in
/// [`Self::stores`] but not here.
///
/// Carried so a base disagreement decodes as a named error naming both
/// sets. Without it the only symptom is `base digest mismatch`, a hash
/// comparison that says nothing about *what* disagreed, and the reopen
/// fails permanently with no way to tell a genuinely corrupt log from a
/// writer and reader that scoped the base differently.
pub base_stores: Vec<String>,
/// Complete, sorted source-column order for every member's `cells`.
pub stores: Vec<String>,
/// Final member order; omitted prior ordinals are deletions.
pub members: Vec<EdgeGroupMemberPatchWal>,
}