mnemo-grpc 0.5.21

gRPC API server for Mnemo
Documentation
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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
syntax = "proto3";

package mnemo.v1;

/// The core Mnemo gRPC service for memory operations.
service MnemoService {
  /// Store a new memory.
  rpc Remember(RememberRequest) returns (RememberResponse);

  /// Recall memories matching a query.
  rpc Recall(RecallRequest) returns (RecallResponse);

  /// Forget (delete/decay/archive) memories by ID.
  rpc Forget(ForgetRequest) returns (ForgetResponse);

  /// Health check.
  rpc Health(HealthRequest) returns (HealthResponse);

  /// Share a memory with another agent.
  rpc Share(ShareRequest) returns (ShareResponse);

  /// Create a checkpoint for the current state.
  rpc Checkpoint(CheckpointRequest) returns (CheckpointResponse);

  /// Consolidate related memories into one revisable topic document.
  rpc Consolidate(ConsolidateRequest) returns (ConsolidateResponse);

  /// Fork a new branch from an existing checkpoint.
  rpc Branch(BranchRequest) returns (BranchResponse);

  /// Merge a source branch into a target branch.
  rpc Merge(MergeRequest) returns (MergeResponse);

  /// Replay state from a checkpoint.
  rpc Replay(ReplayRequest) returns (ReplayResponse);

  /// Delegate permissions to another agent.
  rpc Delegate(DelegateRequest) returns (DelegateResponse);

  /// Verify hash chain integrity.
  rpc Verify(VerifyRequest) returns (VerifyResponse);

  /// GEM-aligned trajectory-correctness audit (arXiv:2605.26252).
  /// Complements Verify on the orthogonal trajectory axis.
  rpc TrajectoryAudit(TrajectoryAuditRequest) returns (TrajectoryAuditResponse);

  /// GDPR / DPDPA-aligned subject erasure by `subject:<id>` tag.
  rpc ForgetSubject(ForgetSubjectRequest) returns (ForgetSubjectResponse);
}

// ---------------------------------------------------------------------------
// Remember
// ---------------------------------------------------------------------------

message RememberRequest {
  string content = 1;
  optional string memory_type = 2;
  optional string scope = 3;
  optional float importance = 4;
  repeated string tags = 5;
  optional string metadata = 6;        // JSON-encoded string
  optional string thread_id = 7;
  optional uint64 ttl_seconds = 8;
  optional string agent_id = 9;
  optional string source_type = 10;
  optional string source_id = 11;
  optional string org_id = 12;
  optional float decay_rate = 13;
  optional string created_by = 14;
  repeated string related_to = 15;
}

message RememberResponse {
  string id = 1;
  string content_hash = 2;
}

// ---------------------------------------------------------------------------
// Recall
// ---------------------------------------------------------------------------

message RecallRequest {
  string query = 1;
  optional uint32 limit = 2;
  optional string strategy = 3;
  optional float min_importance = 4;
  repeated string tags = 5;
  optional string agent_id = 6;
  optional string memory_type = 7;
  optional string scope = 8;
  optional string org_id = 9;
  repeated float hybrid_weights = 10;
  optional float rrf_k = 11;
  optional string as_of = 12;
  /// When true, each ScoredMemory carries a score_breakdown.
  optional bool explain = 13;
  /// v0.4.8 — opt-in orientation cache. PEEK-anchored
  /// (arXiv:2605.19932). When set AND the server has an
  /// OrientationCacheStore attached, the recall maintains a
  /// per-namespace constant-token "context map" and returns a
  /// bounded rendering in `RecallResponse.orientation_cache`.
  optional OrientationCacheRequest orientation_cache = 14;
}

message OrientationCacheRequest {
  /// Operator-chosen namespace label. When omitted, derived from
  /// (org_id, agent_id).
  optional string namespace = 1;
  /// Maximum rendered tokens. Defaults to 512 when omitted.
  optional uint32 token_budget = 2;
  /// Include the rendered map in the response. Defaults to true.
  optional bool include_in_response = 3;
  /// Run the Distiller and update the in-process store. Defaults
  /// to true; set to false for read-only inspection.
  optional bool distill = 4;
}

message OrientationCacheResponse {
  string namespace = 1;
  repeated OrientationEntry entities = 2;
  repeated OrientationEntry constants = 3;
  repeated OrientationEntry schemas = 4;
  uint32 token_estimate = 5;
  uint32 budget = 6;
  uint64 hit_count = 7;
}

message OrientationEntry {
  string key = 1;
  string value = 2;
  uint32 freq = 3;
  uint32 token_estimate = 4;
}

message ScoreBreakdown {
  float vector = 1;
  float bm25 = 2;
  float graph = 3;
  float recency = 4;
  uint32 rrf_rank = 5;
}

message RecallResponse {
  repeated ScoredMemory memories = 1;
  uint32 total = 2;
  optional OrientationCacheResponse orientation_cache = 3;
  // v0.5.1 — active-reconstruction belief-state node (MRAgent
  // arXiv:2606.06036), present when strategy = "reconstruct".
  optional Reconstruction reconstruction = 4;
}

message Reconstruction {
  string cue = 1;
  string summary = 2;
  repeated string source_ids = 3;
  repeated string linked_context_ids = 4;
  float confidence = 5;
}

message ScoredMemory {
  string id = 1;
  string content = 2;
  string memory_type = 3;
  float importance = 4;
  float score = 5;
  string created_at = 6;
  string agent_id = 7;
  string scope = 8;
  repeated string tags = 9;
  string metadata = 10;                 // JSON-encoded string
  uint64 access_count = 11;
  string updated_at = 12;
  optional ScoreBreakdown score_breakdown = 13;
}

// ---------------------------------------------------------------------------
// Forget
// ---------------------------------------------------------------------------

message ForgetRequest {
  repeated string memory_ids = 1;
  optional string strategy = 2;
  optional string agent_id = 3;
}

message ForgetResponse {
  repeated string forgotten = 1;
  repeated ForgetError errors = 2;
}

message ForgetError {
  string id = 1;
  string error = 2;
}

// ---------------------------------------------------------------------------
// Health
// ---------------------------------------------------------------------------

message HealthRequest {}

message HealthResponse {
  string status = 1;
  string version = 2;
}

// ---------------------------------------------------------------------------
// Share
// ---------------------------------------------------------------------------

message ShareRequest {
  string memory_id = 1;
  string target_agent_id = 2;
  repeated string target_agent_ids = 3;
  optional string permission = 4;
  optional double expires_in_hours = 5;
  optional string agent_id = 6;
  repeated string memory_ids = 7;
}

message ShareResponse {
  string acl_id = 1;
  repeated string acl_ids = 2;
  string memory_id = 3;
  string shared_with = 4;
  repeated string shared_with_all = 5;
  string permission = 6;
}

// ---------------------------------------------------------------------------
// Checkpoint
// ---------------------------------------------------------------------------

message CheckpointRequest {
  string thread_id = 1;
  optional string agent_id = 2;
  optional string branch_name = 3;
  string state_snapshot = 4;
  optional string label = 5;
  optional string metadata = 6;
}

message CheckpointResponse {
  string checkpoint_id = 1;
  optional string parent_id = 2;
  string branch_name = 3;
}

// ---------------------------------------------------------------------------
// Consolidate (topic-document consolidation, Infini-Memory arXiv:2606.10677)
// ---------------------------------------------------------------------------

message ConsolidateRequest {
  repeated string memory_ids = 1;
  string topic_name = 2;
  optional string agent_id = 3;
  optional string summary = 4;
  optional string supersede = 5;
  optional string thread_id = 6;
  optional string metadata = 7;
}

message ConsolidateResponse {
  string topic_document_id = 1;
  string topic_name = 2;
  uint64 source_count = 3;
  uint32 version = 4;
  optional string superseded_id = 5;
  repeated string member_ids = 6;
  string content_hash = 7;
  string consolidation_event_id = 8;
  optional string revision_event_id = 9;
}

// ---------------------------------------------------------------------------
// Branch
// ---------------------------------------------------------------------------

message BranchRequest {
  string thread_id = 1;
  optional string agent_id = 2;
  string new_branch_name = 3;
  optional string source_checkpoint_id = 4;
  optional string source_branch = 5;
}

message BranchResponse {
  string checkpoint_id = 1;
  string branch_name = 2;
  string source_checkpoint_id = 3;
}

// ---------------------------------------------------------------------------
// Merge
// ---------------------------------------------------------------------------

message MergeRequest {
  string thread_id = 1;
  optional string agent_id = 2;
  string source_branch = 3;
  optional string target_branch = 4;
  optional string strategy = 5;
  repeated string cherry_pick_ids = 6;
}

message MergeResponse {
  string checkpoint_id = 1;
  string target_branch = 2;
  uint32 merged_memory_count = 3;
}

// ---------------------------------------------------------------------------
// Replay
// ---------------------------------------------------------------------------

message ReplayRequest {
  string thread_id = 1;
  optional string agent_id = 2;
  optional string checkpoint_id = 3;
  optional string branch_name = 4;
  /// RFC3339 timestamp. When set, synthesizes a virtual checkpoint from memory
  /// and event state at that instant (overrides `checkpoint_id`).
  optional string as_of = 5;
}

message ReplayResponse {
  string checkpoint_json = 1;
  repeated ReplayMemory memories = 2;
  uint32 event_count = 3;
  optional bool chain_valid = 4;
  optional uint32 chain_total = 5;
  optional uint32 chain_verified = 6;
}

message ReplayMemory {
  string id = 1;
  string content = 2;
  string memory_type = 3;
  string created_at = 4;
}

// ---------------------------------------------------------------------------
// Delegate
// ---------------------------------------------------------------------------

message DelegateRequest {
  string delegator_id = 1;
  string delegate_id = 2;
  string permission = 3;
  repeated string memory_ids = 4;
  repeated string tags = 5;
  optional uint32 max_depth = 6;
  optional double expires_in_hours = 7;
}

message DelegateResponse {
  string delegation_id = 1;
}

// ---------------------------------------------------------------------------
// Verify
// ---------------------------------------------------------------------------

message VerifyRequest {
  optional string agent_id = 1;
  optional string thread_id = 2;
}

message VerifyResponse {
  bool valid = 1;
  uint32 total_records = 2;
  uint32 verified_records = 3;
  optional string first_broken_at = 4;
  optional string error_message = 5;
}

// ---------------------------------------------------------------------------
// ForgetSubject
// ---------------------------------------------------------------------------

message ForgetSubjectRequest {
  string subject_id = 1;
  optional string strategy = 2;    // "redact" (default), "hard_delete", "soft_delete"
  optional string agent_id = 3;
}

message ForgetSubjectResponse {
  string subject_id = 1;
  string strategy = 2;
  uint32 matched = 3;
  repeated string forgotten = 4;
  uint32 cascaded_events = 5;
  repeated ForgetError errors = 6;
}

// ---------------------------------------------------------------------------
// TrajectoryAudit (v0.4.x — GEM arXiv:2605.26252)
// ---------------------------------------------------------------------------

message TrajectoryAuditRequest {
  optional string agent_id = 1;
  optional string thread_id = 2;
  optional uint64 active_bank_ceiling = 3;
  optional string fact_key = 4;
  /// Strategies considered policy-driven by signal (c). Defaults to
  /// the five canonical strategies when empty.
  repeated string named_forget_strategies = 5;
}

message TrajectoryAuditResponse {
  string scope_label = 1;
  uint32 event_count = 2;
  bool all_ok = 3;
  TrajectoryFinding unregulated_growth = 4;
  TrajectoryFinding missing_semantic_revision = 5;
  TrajectoryFinding capacity_driven_forgetting = 6;
  TrajectoryFinding read_only_retrieval = 7;
  /// JSON-encoded full TrajectoryAuditReport (including timelines,
  /// per-fact stale lists, etc.) so language clients can deserialise
  /// the rich shape without re-mapping every nested field through
  /// protobuf. The summary fields above are sufficient for a CI gate.
  string report_json = 8;
}

message TrajectoryFinding {
  /// "ok" / "warn" / "fail"
  string severity = 1;
  /// Best-effort scalar count attached to the finding (breach_count
  /// for (a), stale_facts.len() for (b), unlabelled count for (c),
  /// read_only_scopes.len() for (d)). The full structured data lives
  /// in `TrajectoryAuditResponse.report_json`.
  uint32 count = 2;
}