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