Skip to main content

remem/user_context/recall/
types.rs

1use serde::Serialize;
2
3pub(super) const DEFAULT_LIMIT: usize = 12;
4pub(super) const MAX_LIMIT: usize = 50;
5pub(super) const DEFAULT_BUDGET_CHARS: usize = 4_000;
6pub(super) const MIN_BUDGET_CHARS: usize = 500;
7pub(super) const MAX_BUDGET_CHARS: usize = 12_000;
8pub(super) const MAX_CLAIM_SCAN: i64 = 200;
9pub(super) const MAX_MEMORY_SCAN: i64 = 1_000;
10pub(super) const MAX_SESSION_SCAN: i64 = 50;
11
12#[derive(Debug, Clone)]
13pub struct UserRecallRequest {
14    pub query: String,
15    pub project: String,
16    pub task_intent: Option<String>,
17    pub current_files: Vec<String>,
18    pub host: Option<String>,
19    pub owner_scope: Option<String>,
20    pub owner_key: Option<String>,
21    pub state_keys: Vec<String>,
22    pub include_sensitive: bool,
23    pub include_suppressed: bool,
24    pub limit: Option<i64>,
25    pub budget_chars: Option<usize>,
26}
27
28#[derive(Debug, Clone, Serialize)]
29pub struct UserRecallResult {
30    pub query: String,
31    pub project: String,
32    #[serde(skip_serializing_if = "Option::is_none")]
33    pub task_intent: Option<String>,
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub host: Option<String>,
36    pub empty: bool,
37    pub context: String,
38    pub usage_policy: Option<&'static str>,
39    pub included: Vec<UserRecallItem>,
40    pub dropped: Vec<UserRecallDroppedItem>,
41    pub diagnostics: UserRecallDiagnostics,
42}
43
44#[derive(Debug, Clone, Serialize)]
45pub struct UserRecallItem {
46    pub source_type: String,
47    #[serde(skip_serializing_if = "Option::is_none")]
48    pub source_id: Option<i64>,
49    #[serde(skip_serializing_if = "Option::is_none")]
50    pub title: Option<String>,
51    pub text: String,
52    pub reason_codes: Vec<String>,
53    #[serde(skip_serializing_if = "Option::is_none")]
54    pub source_refs: Option<serde_json::Value>,
55}
56
57#[derive(Debug, Clone, Serialize)]
58pub struct UserRecallDroppedItem {
59    pub source_type: String,
60    #[serde(skip_serializing_if = "Option::is_none")]
61    pub source_id: Option<i64>,
62    #[serde(skip_serializing_if = "Option::is_none")]
63    pub label: Option<String>,
64    pub reason_code: String,
65}
66
67#[derive(Debug, Clone, Serialize)]
68pub struct UserRecallDiagnostics {
69    pub requested_limit: usize,
70    pub budget_chars: usize,
71    pub used_chars: usize,
72    pub candidate_counts: UserRecallCandidateCounts,
73}
74
75#[derive(Debug, Clone, Default, Serialize)]
76pub struct UserRecallCandidateCounts {
77    pub summaries: usize,
78    pub claims: usize,
79    pub memories: usize,
80    pub current_state: usize,
81    pub workstreams: usize,
82    pub sessions: usize,
83    pub dropped: usize,
84}
85
86#[derive(Debug, Clone)]
87pub(super) struct NormalizedRequest {
88    pub(super) query: String,
89    pub(super) project: String,
90    pub(super) task_intent: Option<String>,
91    pub(super) host: Option<String>,
92    pub(super) owner_scope: String,
93    pub(super) owner_key: String,
94    pub(super) state_keys: Vec<String>,
95    pub(super) include_sensitive: bool,
96    pub(super) include_suppressed: bool,
97    pub(super) limit: usize,
98    pub(super) budget_chars: usize,
99    pub(super) terms: Vec<String>,
100}
101
102#[derive(Debug, Clone)]
103pub(super) struct RecallCandidate {
104    pub(super) source_type: String,
105    pub(super) source_id: Option<i64>,
106    pub(super) title: Option<String>,
107    pub(super) text: String,
108    pub(super) reason_codes: Vec<String>,
109    pub(super) source_refs: Option<serde_json::Value>,
110    pub(super) priority: i32,
111}
112
113#[derive(Debug, Clone)]
114pub(super) struct ClaimCandidate {
115    pub(super) id: i64,
116    pub(super) claim_type: String,
117    pub(super) claim_key: String,
118    pub(super) claim_text: String,
119    pub(super) owner_scope: String,
120    pub(super) owner_key: String,
121    pub(super) sensitivity: String,
122    pub(super) source_refs_json: String,
123    pub(super) status: String,
124    pub(super) valid_from_epoch: Option<i64>,
125    pub(super) valid_to_epoch: Option<i64>,
126}
127
128#[derive(Debug, Clone, Default)]
129pub(super) struct RecallState {
130    pub(super) candidates: Vec<RecallCandidate>,
131    pub(super) dropped: Vec<UserRecallDroppedItem>,
132    pub(super) counts: UserRecallCandidateCounts,
133}