relay_knowledge/storage/contracts/
canvas.rs1use std::collections::BTreeMap;
2
3use crate::domain::GraphVersion;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7pub enum GraphCanvasSelection {
8 Knowledge,
9 Code,
10 Mixed,
11}
12
13impl GraphCanvasSelection {
14 pub const fn includes_knowledge(self) -> bool {
15 matches!(self, Self::Knowledge | Self::Mixed)
16 }
17
18 pub const fn includes_code(self) -> bool {
19 matches!(self, Self::Code | Self::Mixed)
20 }
21}
22
23#[derive(Debug, Clone, PartialEq, Eq)]
25pub struct GraphCanvasStorageRequest {
26 pub selection: GraphCanvasSelection,
27 pub source_scope: Option<String>,
28 pub query: Option<String>,
29 pub graph_version: GraphVersion,
30 pub limit: usize,
31}
32
33#[derive(Debug, Clone, PartialEq, Eq)]
35pub struct GraphCanvasStorageNode {
36 pub id: String,
37 pub kind: String,
38 pub label: String,
39 pub subtitle: Option<String>,
40 pub source_scope: Option<String>,
41 pub graph_version: GraphVersion,
42 pub weight: u32,
43 pub status: Option<String>,
44 pub details: BTreeMap<String, String>,
45}
46
47#[derive(Debug, Clone, PartialEq, Eq)]
49pub struct GraphCanvasStorageEdge {
50 pub id: String,
51 pub kind: String,
52 pub source: String,
53 pub target: String,
54 pub label: String,
55 pub graph_version: GraphVersion,
56 pub confidence_basis_points: Option<u16>,
57 pub evidence_count: Option<usize>,
58 pub details: BTreeMap<String, String>,
59}
60
61#[derive(Debug, Clone, PartialEq, Eq)]
63pub struct GraphCanvasStorageSnapshot {
64 pub nodes: Vec<GraphCanvasStorageNode>,
65 pub edges: Vec<GraphCanvasStorageEdge>,
66 pub available_kinds: Vec<String>,
67 pub truncated: bool,
68}
69
70#[cfg(test)]
71#[path = "canvas_tests.rs"]
72mod tests;