Skip to main content

leyline_engine/
manifest.rs

1//! The manifest: the mutable pointer that makes a set of segments *the*
2//! graph. Swapping it is the only mutation in the system (docs/SEGMENTS.md).
3
4use serde::{Deserialize, Serialize};
5
6pub const FORMAT_VERSION: u32 = 1;
7
8#[derive(Debug, Clone, Serialize, Deserialize)]
9#[serde(rename_all = "camelCase")]
10pub struct Manifest {
11    pub format_version: u32,
12    /// Monotonic; every committed flush or compaction bumps it. Surfaced by
13    /// the API as `manifestGeneration`.
14    pub generation: u64,
15    /// Append-only: a label's index is its identity in every segment ever
16    /// written. Compaction may not renumber.
17    pub labels: Vec<String>,
18    /// Id allocation resumes above everything ever committed.
19    pub next_node_id: u64,
20    pub node_count: u64,
21    pub edge_count: u64,
22    /// Oldest → newest.
23    pub segments: Vec<SegmentMeta>,
24}
25
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(rename_all = "camelCase")]
28pub struct SegmentMeta {
29    pub name: String,
30    pub level: u32,
31    pub edges: u64,
32    pub bytes: u64,
33}
34
35impl Manifest {
36    pub fn empty() -> Self {
37        Self {
38            format_version: FORMAT_VERSION,
39            generation: 0,
40            labels: Vec::new(),
41            next_node_id: 0,
42            node_count: 0,
43            edge_count: 0,
44            segments: Vec::new(),
45        }
46    }
47}