Skip to main content

videre_api/
types.rs

1use serde::Serialize;
2
3/// Versioned model context attached to evidence captured by a Gallery action.
4#[derive(Debug, Clone, PartialEq, Eq)]
5pub struct TeachingContext {
6    pub embedding_model_id: String,
7    pub active_profile_id: Option<i64>,
8}
9
10/// Durable learning work committed with a visible people mutation.
11#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
12pub struct LearningAcknowledgement {
13    pub generation: u64,
14    pub event_ids: Vec<i64>,
15    pub message_key: String,
16}
17
18/// Learning status for the gallery background worker.
19#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
20pub struct FaceLearningStatus {
21    pub generation: u64,
22    pub trained_generation: u64,
23    pub status: String,
24    pub last_profile_id: Option<i64>,
25    /// What became of the last trained candidate: `promoted` or `rejected`,
26    /// or `None` before any candidate was stored. Lets a `current` status
27    /// say whether the last run changed the profile in use.
28    pub last_candidate: Option<String>,
29    pub last_error: Option<String>,
30    /// While `status` is `waiting`: the feedback training still needs, in
31    /// words the People page shows as is (`dissolve 2 more wrong clusters`).
32    pub feedback_needed: Option<String>,
33    pub pending_questions: usize,
34    /// The profile in use, if any: its id and stage (`suggestion` asks
35    /// questions, `grouping` may also shape clustering).
36    pub active_profile: Option<ActiveProfile>,
37    /// What learning contributes right now, in one sentence for the People
38    /// toolbar.
39    pub summary: String,
40}
41
42#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
43pub struct ActiveProfile {
44    pub profile_id: i64,
45    pub stage: String,
46}
47
48/// The stored outcome of one background training run.
49#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
50pub struct TrainedProfileSummary {
51    pub profile_id: i64,
52    pub model_kind: String,
53    pub promoted: bool,
54}
55
56/// Result of answering one identity question: the new delivery state and, for
57/// Yes and No, the durable learning work the answer committed.
58#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
59pub struct QuestionAnswerOutcome {
60    pub status: String,
61    pub acknowledgement: Option<LearningAcknowledgement>,
62}
63
64/// One labeled person: their confirmed faces plus a representative face id
65/// (the primary, or lowest id) used as the card thumbnail.
66#[derive(Serialize, Clone)]
67pub struct PersonData {
68    /// Identity: normalized, what URLs and actions use.
69    pub label: String,
70    /// What a reader sees. Falls back to `label` for a person whose row
71    /// predates the people table.
72    pub full_name: String,
73    pub face_ids: Vec<i64>,
74    pub representative_id: i64,
75    pub hashes: Vec<String>,
76}
77
78/// One unassigned cluster (green section in the labeling UI).
79#[derive(Serialize, Clone)]
80pub struct ClusterData {
81    pub cluster_id: i64,
82    pub face_ids: Vec<i64>,
83    pub hashes: Vec<String>,
84}
85
86/// One unclustered, unassigned face (orange section).
87#[derive(Serialize, Clone)]
88pub struct SingletonData {
89    pub face_id: i64,
90    pub hash: String,
91}
92
93/// Top-level payload for the labeling page.
94///
95/// `Default` is the "detection has never run" answer, which is a state rather
96/// than an error. See `faces_list`.
97#[derive(Serialize, Clone, Default)]
98pub struct FacesData {
99    pub people: Vec<PersonData>,
100    pub clusters: Vec<ClusterData>,
101    pub singletons: Vec<SingletonData>,
102}
103
104/// One face row on a cluster detail page.
105#[derive(Serialize, Clone)]
106pub struct ClusterFaceData {
107    pub face_id: i64,
108    pub hash: String,
109    pub path: String,
110}
111
112/// Cluster detail: every face in one unassigned cluster.
113#[derive(Serialize, Clone)]
114pub struct ClusterDetail {
115    pub cluster_id: i64,
116    pub faces: Vec<ClusterFaceData>,
117}
118
119/// One face row on a person detail page. `is_primary` marks the current
120/// default photo (the person's thumbnail on the labeling page).
121#[derive(Serialize, Clone)]
122pub struct PersonFaceData {
123    pub face_id: i64,
124    pub hash: String,
125    pub path: String,
126    pub is_primary: bool,
127}
128
129/// Person detail: every confirmed face for one person.
130#[derive(Serialize, Clone)]
131pub struct PersonDetail {
132    /// Identity: what the URL and every face row use.
133    pub label: String,
134    /// What a reader sees, and what the page lets them edit.
135    pub full_name: String,
136    pub faces: Vec<PersonFaceData>,
137}