1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
//! TigerStyle Constants
//!
//! All limits use big-endian naming: CATEGORY_SPECIFICS_UNIT_LIMIT
//! Example: CORE_MEMORY_SIZE_BYTES_MAX (not MAX_CORE_MEMORY_SIZE)
//!
//! Every constant includes units in the name:
//! - _BYTES_MAX/MIN for size limits
//! - _SECS_DEFAULT for time durations
//! - _COUNT_MAX for quantity limits
//! - _MS for milliseconds
// =============================================================================
// Core Memory Limits
// =============================================================================
/// Maximum size of core memory (always in LLM context)
pub const CORE_MEMORY_SIZE_BYTES_MAX: usize = 32 * 1024; // 32KB
/// Minimum size of core memory
pub const CORE_MEMORY_SIZE_BYTES_MIN: usize = 4 * 1024; // 4KB
/// Maximum size of a single memory block
pub const CORE_MEMORY_BLOCK_SIZE_BYTES_MAX: usize = 16 * 1024; // 16KB
/// Number of core memory block types
pub const CORE_MEMORY_BLOCK_TYPES_COUNT: usize = 6;
/// Maximum length of a block label
pub const CORE_MEMORY_BLOCK_LABEL_BYTES_MAX: usize = 64;
/// Maximum number of blocks in core memory
pub const CORE_MEMORY_BLOCKS_COUNT_MAX: usize = 32;
// =============================================================================
// Working Memory Limits
// =============================================================================
/// Maximum total size of working memory
pub const WORKING_MEMORY_SIZE_BYTES_MAX: usize = 1024 * 1024; // 1MB
/// Maximum size of a single working memory entry
pub const WORKING_MEMORY_ENTRY_SIZE_BYTES_MAX: usize = 64 * 1024; // 64KB
/// Default TTL for working memory entries
pub const WORKING_MEMORY_TTL_SECS_DEFAULT: u64 = 3600; // 1 hour
/// Maximum TTL for working memory entries
pub const WORKING_MEMORY_TTL_SECS_MAX: u64 = 86400 * 7; // 7 days
/// Maximum number of working memory entries
pub const WORKING_MEMORY_ENTRIES_COUNT_MAX: usize = 10_000;
// =============================================================================
// Entity Limits
// =============================================================================
/// Maximum size of entity content
pub const ENTITY_CONTENT_BYTES_MAX: usize = 1_000_000; // 1MB
/// Maximum length of entity name
pub const ENTITY_NAME_BYTES_MAX: usize = 256;
/// Maximum length of entity ID
pub const ENTITY_ID_BYTES_MAX: usize = 256;
/// Maximum number of tags per entity
pub const ENTITY_TAGS_COUNT_MAX: usize = 100;
/// Maximum length of a single tag
pub const ENTITY_TAG_BYTES_MAX: usize = 256;
// =============================================================================
// Evolution Limits (ADR-006, ADR-016)
// =============================================================================
/// Maximum length of evolution relation reason
pub const EVOLUTION_REASON_BYTES_MAX: usize = 1024;
/// Maximum number of evolution relations per entity
pub const EVOLUTION_RELATIONS_PER_ENTITY_COUNT_MAX: usize = 100;
/// Maximum existing entities to compare against in detection
pub const EVOLUTION_EXISTING_ENTITIES_COUNT_MAX: usize = 10;
/// Default confidence threshold for evolution detection
pub const EVOLUTION_CONFIDENCE_THRESHOLD_DEFAULT: f64 = 0.3;
/// Minimum confidence for evolution detection
pub const EVOLUTION_CONFIDENCE_MIN: f64 = 0.0;
/// Maximum confidence for evolution detection
pub const EVOLUTION_CONFIDENCE_MAX: f64 = 1.0;
// =============================================================================
// Search Limits
// =============================================================================
/// Maximum number of search results
pub const SEARCH_RESULTS_COUNT_MAX: usize = 100;
/// Default number of search results
pub const SEARCH_RESULTS_COUNT_DEFAULT: usize = 10;
/// Maximum length of search query
pub const SEARCH_QUERY_BYTES_MAX: usize = 10_000;
// =============================================================================
// Embedding Limits
// =============================================================================
/// Number of dimensions in embeddings
pub const EMBEDDING_DIMENSIONS_COUNT: usize = 1536;
/// Maximum batch size for embedding requests
pub const EMBEDDING_BATCH_SIZE_MAX: usize = 100;
// =============================================================================
// Storage Limits
// =============================================================================
/// Maximum number of retry attempts for storage operations
pub const STORAGE_RETRY_COUNT_MAX: u32 = 3;
/// Base delay between retries in milliseconds
pub const STORAGE_RETRY_DELAY_MS_BASE: u64 = 100;
/// Maximum delay between retries in milliseconds
pub const STORAGE_RETRY_DELAY_MS_MAX: u64 = 5000;
// =============================================================================
// DST (Deterministic Simulation Testing) Limits
// =============================================================================
/// Maximum number of simulation steps
pub const DST_SIMULATION_STEPS_MAX: u64 = 1_000_000;
/// Maximum probability for fault injection (1.0 = 100%)
pub const DST_FAULT_PROBABILITY_MAX: f64 = 1.0;
/// Maximum time advance per step in milliseconds
pub const DST_TIME_ADVANCE_MS_MAX: u64 = 86_400_000; // 24 hours
/// Maximum latency for simulated operations in milliseconds
pub const DST_LATENCY_MS_MAX: u64 = 10_000; // 10 seconds
// =============================================================================
// LLM Simulation Limits
// =============================================================================
/// Maximum size of LLM prompt
pub const LLM_PROMPT_BYTES_MAX: usize = 100_000; // 100KB
/// Maximum size of LLM response
pub const LLM_RESPONSE_BYTES_MAX: usize = 50_000; // 50KB
/// Minimum simulated latency for LLM calls
pub const LLM_LATENCY_MS_MIN: u64 = 50;
/// Maximum simulated latency for LLM calls
pub const LLM_LATENCY_MS_MAX: u64 = 2000;
/// Default simulated latency for LLM calls
pub const LLM_LATENCY_MS_DEFAULT: u64 = 100;
/// Maximum number of entities in extraction response
pub const LLM_ENTITIES_COUNT_MAX: usize = 50;
/// Maximum number of query rewrites
pub const LLM_QUERY_REWRITES_COUNT_MAX: usize = 5;
// =============================================================================
// Network Simulation Limits
// =============================================================================
/// Maximum network latency in milliseconds
pub const NETWORK_LATENCY_MS_MAX: u64 = 30_000; // 30 seconds
/// Default network base latency in milliseconds
pub const NETWORK_LATENCY_MS_DEFAULT: u64 = 1;
/// Default network latency jitter in milliseconds
pub const NETWORK_JITTER_MS_DEFAULT: u64 = 5;
/// Maximum pending messages per node
pub const NETWORK_PENDING_MESSAGES_COUNT_MAX: usize = 10_000;
// =============================================================================
// Entity Extraction Limits
// =============================================================================
/// Maximum size of text to extract from
pub const EXTRACTION_TEXT_BYTES_MAX: usize = 100_000; // 100KB
/// Maximum number of entities per extraction
pub const EXTRACTION_ENTITIES_COUNT_MAX: usize = 50;
/// Maximum number of relations per extraction
pub const EXTRACTION_RELATIONS_COUNT_MAX: usize = 100;
/// Minimum confidence for extracted entities/relations
pub const EXTRACTION_CONFIDENCE_MIN: f64 = 0.0;
/// Maximum confidence for extracted entities/relations
pub const EXTRACTION_CONFIDENCE_MAX: f64 = 1.0;
/// Default confidence when not specified
pub const EXTRACTION_CONFIDENCE_DEFAULT: f64 = 0.5;
/// Maximum length of entity name
pub const EXTRACTION_ENTITY_NAME_BYTES_MAX: usize = 256;
/// Maximum length of entity content
pub const EXTRACTION_ENTITY_CONTENT_BYTES_MAX: usize = 1000;
// =============================================================================
// Retrieval Limits (ADR-015)
// =============================================================================
/// Maximum number of search results
pub const RETRIEVAL_RESULTS_COUNT_MAX: usize = 100;
/// Default number of search results
pub const RETRIEVAL_RESULTS_COUNT_DEFAULT: usize = 10;
/// Maximum length of search query
pub const RETRIEVAL_QUERY_BYTES_MAX: usize = 10_000;
/// Maximum number of query rewrites from LLM
pub const RETRIEVAL_QUERY_REWRITE_COUNT_MAX: usize = 3;
/// RRF constant (standard value from literature)
pub const RETRIEVAL_RRF_K: usize = 60;
// =============================================================================
// Memory Class Limits (ADR-017)
// =============================================================================
/// Maximum text size for remember operations
pub const MEMORY_TEXT_BYTES_MAX: usize = 100_000;
/// Maximum results for recall operations
pub const MEMORY_RECALL_LIMIT_MAX: usize = 100;
/// Default results for recall operations
pub const MEMORY_RECALL_LIMIT_DEFAULT: usize = 10;
/// Default importance for entities
pub const MEMORY_IMPORTANCE_DEFAULT: f32 = 0.5;
/// Minimum importance value
pub const MEMORY_IMPORTANCE_MIN: f32 = 0.0;
/// Maximum importance value
pub const MEMORY_IMPORTANCE_MAX: f32 = 1.0;
// =============================================================================
// Time Constants
// =============================================================================
/// Milliseconds per second
pub const TIME_MS_PER_SEC: u64 = 1000;
/// Milliseconds per minute
pub const TIME_MS_PER_MIN: u64 = 60 * TIME_MS_PER_SEC;
/// Milliseconds per hour
pub const TIME_MS_PER_HOUR: u64 = 60 * TIME_MS_PER_MIN;
/// Milliseconds per day
pub const TIME_MS_PER_DAY: u64 = 24 * TIME_MS_PER_HOUR;