-
-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathopenapi.yaml
More file actions
889 lines (843 loc) · 21.7 KB
/
openapi.yaml
File metadata and controls
889 lines (843 loc) · 21.7 KB
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
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
openapi: 3.0.3
info:
title: Shodh Memory API
description: |
Universal memory layer for AI agents with Hebbian learning.
## Key Features
- **Sub-millisecond latency**: No LLM calls in critical path
- **Hebbian learning**: Associations strengthen through use
- **Offline capable**: Local embeddings, no external API dependencies
- **Three retrieval modes**: semantic, associative, hybrid
## Authentication
All endpoints require `X-API-Key` header.
## Quick Start
1. Store a memory: `POST /api/remember`
2. Recall memories: `POST /api/recall`
3. Get context summary: `POST /api/context_summary`
version: 0.2.0
contact:
name: Shodh Memory
url: https://github.com/varun29ankuS/shodh-memory
license:
name: Apache-2.0
url: https://opensource.org/licenses/MIT
servers:
- url: http://localhost:3030
description: Local development server
- url: https://api.shodh-memory.com
description: Production server (if deployed)
security:
- ApiKeyAuth: []
components:
securitySchemes:
ApiKeyAuth:
type: apiKey
in: header
name: X-API-Key
description: API key for authentication
schemas:
# Core Memory Types
MemoryType:
type: string
enum:
- Observation
- Decision
- Learning
- Error
- Discovery
- Pattern
- Context
- Task
- Conversation
description: Type of memory being stored
RetrievalMode:
type: string
enum:
- semantic
- associative
- hybrid
default: hybrid
description: |
- semantic: Pure vector similarity search
- associative: Graph traversal with Hebbian-learned edges
- hybrid: Combined semantic + graph (recommended)
# Request/Response Schemas
RememberRequest:
type: object
required:
- user_id
- content
properties:
user_id:
type: string
description: Unique identifier for the user
example: "user-123"
content:
type: string
description: The memory content to store
example: "User prefers dark mode for all applications"
tags:
type: array
items:
type: string
description: Optional tags for categorization
example: ["preferences", "ui"]
memory_type:
$ref: '#/components/schemas/MemoryType'
external_id:
type: string
description: External system ID for linking (e.g., "linear:SHO-39")
example: "github:issue-123"
created_at:
type: string
format: date-time
description: Optional timestamp (ISO 8601). Defaults to current time.
example: "2025-12-15T06:30:00Z"
RememberResponse:
type: object
properties:
id:
type: string
description: Unique memory ID
example: "550e8400-e29b-41d4-a716-446655440000"
success:
type: boolean
example: true
RecallRequest:
type: object
required:
- user_id
- query
properties:
user_id:
type: string
description: User ID to search memories for
example: "user-123"
query:
type: string
description: Natural language search query
example: "What are the user's UI preferences?"
limit:
type: integer
default: 5
minimum: 1
maximum: 100
description: Maximum number of memories to return
mode:
$ref: '#/components/schemas/RetrievalMode'
RecallMemory:
type: object
properties:
id:
type: string
example: "550e8400-e29b-41d4-a716-446655440000"
experience:
type: object
properties:
content:
type: string
example: "User prefers dark mode for all applications"
memory_type:
type: string
example: "Decision"
tags:
type: array
items:
type: string
example: ["preferences", "ui"]
importance:
type: number
format: float
minimum: 0
maximum: 1
example: 0.75
created_at:
type: string
format: date-time
example: "2025-12-15T06:30:00Z"
score:
type: number
format: float
minimum: 0
maximum: 1
description: Relevance score for this query
example: 0.92
RecallResponse:
type: object
properties:
memories:
type: array
items:
$ref: '#/components/schemas/RecallMemory'
count:
type: integer
example: 3
retrieval_stats:
type: object
description: Optional retrieval statistics
properties:
semantic_candidates:
type: integer
graph_candidates:
type: integer
final_count:
type: integer
ContextSummaryRequest:
type: object
required:
- user_id
properties:
user_id:
type: string
example: "user-123"
include_decisions:
type: boolean
default: true
include_learnings:
type: boolean
default: true
include_context:
type: boolean
default: true
max_items:
type: integer
default: 5
minimum: 1
maximum: 50
SummaryItem:
type: object
properties:
id:
type: string
content:
type: string
importance:
type: number
format: float
created_at:
type: string
format: date-time
ContextSummaryResponse:
type: object
properties:
total_memories:
type: integer
example: 42
decisions:
type: array
items:
$ref: '#/components/schemas/SummaryItem'
learnings:
type: array
items:
$ref: '#/components/schemas/SummaryItem'
context:
type: array
items:
$ref: '#/components/schemas/SummaryItem'
patterns:
type: array
items:
$ref: '#/components/schemas/SummaryItem'
errors:
type: array
items:
$ref: '#/components/schemas/SummaryItem'
RelevanceConfig:
type: object
properties:
semantic_threshold:
type: number
format: float
default: 0.65
minimum: 0
maximum: 1
description: Minimum semantic similarity to surface
entity_threshold:
type: number
format: float
default: 0.4
minimum: 0
maximum: 1
max_results:
type: integer
default: 5
minimum: 1
maximum: 20
memory_types:
type: array
items:
type: string
description: Filter to specific memory types (empty = all)
ProactiveContextRequest:
type: object
required:
- user_id
- context
properties:
user_id:
type: string
example: "user-123"
context:
type: string
description: Current conversation context or user message
example: "I'm working on the authentication module"
entities:
type: array
items:
type: string
description: Pre-extracted entities (skips NER if provided)
config:
$ref: '#/components/schemas/RelevanceConfig'
SurfacedMemory:
type: object
properties:
id:
type: string
content:
type: string
memory_type:
type: string
importance:
type: number
format: float
relevance_score:
type: number
format: float
reason:
type: string
enum: [EntityMatch, SemanticSimilarity, Combined, RecentImportant]
matched_entities:
type: array
items:
type: string
created_at:
type: string
format: date-time
ProactiveContextResponse:
type: object
properties:
memories:
type: array
items:
$ref: '#/components/schemas/SurfacedMemory'
detected_entities:
type: array
items:
type: object
properties:
text:
type: string
entity_type:
type: string
salience:
type: number
format: float
latency_ms:
type: number
format: float
description: Processing time in milliseconds
example: 0.85
latency_target_met:
type: boolean
description: Whether <30ms target was met
example: true
BatchRememberRequest:
type: object
required:
- user_id
- memories
properties:
user_id:
type: string
memories:
type: array
items:
type: object
required:
- content
properties:
content:
type: string
tags:
type: array
items:
type: string
memory_type:
type: string
BatchRememberResponse:
type: object
properties:
ids:
type: array
items:
type: string
success_count:
type: integer
error_count:
type: integer
ForgetByTagsRequest:
type: object
required:
- user_id
- tags
properties:
user_id:
type: string
tags:
type: array
items:
type: string
description: Delete memories matching ANY of these tags
ForgetByDateRequest:
type: object
required:
- user_id
- start
- end
properties:
user_id:
type: string
start:
type: string
format: date-time
end:
type: string
format: date-time
RecallByTagsRequest:
type: object
required:
- user_id
- tags
properties:
user_id:
type: string
tags:
type: array
items:
type: string
limit:
type: integer
default: 20
RecallByDateRequest:
type: object
required:
- user_id
- start
- end
properties:
user_id:
type: string
start:
type: string
format: date-time
end:
type: string
format: date-time
limit:
type: integer
default: 20
MemoryStats:
type: object
properties:
total_memories:
type: integer
working_memory_count:
type: integer
session_memory_count:
type: integer
long_term_count:
type: integer
vector_index_count:
type: integer
graph_stats:
type: object
properties:
node_count:
type: integer
edge_count:
type: integer
avg_strength:
type: number
format: float
HealthResponse:
type: object
properties:
status:
type: string
enum: [healthy, degraded, unhealthy]
version:
type: string
uptime_seconds:
type: integer
Error:
type: object
properties:
error:
type: string
code:
type: string
details:
type: object
paths:
# Health & Status
/health:
get:
tags: [Health]
summary: Health check
security: []
responses:
'200':
description: Service is healthy
content:
application/json:
schema:
$ref: '#/components/schemas/HealthResponse'
# Core Memory Operations
/api/remember:
post:
tags: [Memory]
summary: Store a memory
description: |
Store a new memory with automatic embedding generation and indexing.
Memories are immediately available for recall.
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/RememberRequest'
responses:
'200':
description: Memory stored successfully
content:
application/json:
schema:
$ref: '#/components/schemas/RememberResponse'
'400':
description: Invalid request
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/api/recall:
post:
tags: [Memory]
summary: Recall memories
description: |
Search for relevant memories using natural language.
Supports three retrieval modes:
- **semantic**: Pure vector similarity
- **associative**: Graph traversal with Hebbian-learned edges
- **hybrid**: Combined approach (recommended)
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/RecallRequest'
responses:
'200':
description: Memories retrieved successfully
content:
application/json:
schema:
$ref: '#/components/schemas/RecallResponse'
/api/batch_remember:
post:
tags: [Memory]
summary: Store multiple memories at once
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/BatchRememberRequest'
responses:
'200':
description: Batch operation complete
content:
application/json:
schema:
$ref: '#/components/schemas/BatchRememberResponse'
/api/context_summary:
post:
tags: [Context]
summary: Get categorized context summary
description: |
Returns a summary of recent memories organized by type.
Useful for session bootstrap and context injection.
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ContextSummaryRequest'
responses:
'200':
description: Context summary
content:
application/json:
schema:
$ref: '#/components/schemas/ContextSummaryResponse'
/api/relevant:
post:
tags: [Context]
summary: Proactive memory surfacing
description: |
Surface relevant memories based on current context.
Uses entity matching + semantic similarity.
Target latency: <30ms (typically <1ms).
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ProactiveContextRequest'
responses:
'200':
description: Relevant memories surfaced
content:
application/json:
schema:
$ref: '#/components/schemas/ProactiveContextResponse'
# Recall Variants
/api/recall/tags:
post:
tags: [Recall]
summary: Recall memories by tags
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/RecallByTagsRequest'
responses:
'200':
description: Memories matching tags
content:
application/json:
schema:
$ref: '#/components/schemas/RecallResponse'
/api/recall/date:
post:
tags: [Recall]
summary: Recall memories by date range
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/RecallByDateRequest'
responses:
'200':
description: Memories in date range
content:
application/json:
schema:
$ref: '#/components/schemas/RecallResponse'
# Forget Operations
/api/forget/tags:
post:
tags: [Forget]
summary: Delete memories by tags
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ForgetByTagsRequest'
responses:
'200':
description: Memories deleted
content:
application/json:
schema:
type: object
properties:
deleted_count:
type: integer
/api/forget/date:
post:
tags: [Forget]
summary: Delete memories by date range
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ForgetByDateRequest'
responses:
'200':
description: Memories deleted
content:
application/json:
schema:
type: object
properties:
deleted_count:
type: integer
# Memory Management
/api/memory/{memory_id}:
get:
tags: [Memory]
summary: Get a specific memory
parameters:
- name: memory_id
in: path
required: true
schema:
type: string
- name: user_id
in: query
required: true
schema:
type: string
responses:
'200':
description: Memory details
content:
application/json:
schema:
$ref: '#/components/schemas/RecallMemory'
'404':
description: Memory not found
delete:
tags: [Memory]
summary: Delete a specific memory
parameters:
- name: memory_id
in: path
required: true
schema:
type: string
- name: user_id
in: query
required: true
schema:
type: string
responses:
'200':
description: Memory deleted
'404':
description: Memory not found
/api/list/{user_id}:
get:
tags: [Memory]
summary: List all memories for a user
parameters:
- name: user_id
in: path
required: true
schema:
type: string
- name: limit
in: query
schema:
type: integer
default: 20
responses:
'200':
description: List of memories
content:
application/json:
schema:
type: object
properties:
memories:
type: array
items:
$ref: '#/components/schemas/RecallMemory'
total:
type: integer
# Stats & Health
/api/users/{user_id}/stats:
get:
tags: [Stats]
summary: Get memory statistics for a user
parameters:
- name: user_id
in: path
required: true
schema:
type: string
responses:
'200':
description: Memory statistics
content:
application/json:
schema:
$ref: '#/components/schemas/MemoryStats'
/api/index/verify:
post:
tags: [Admin]
summary: Verify vector index integrity
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- user_id
properties:
user_id:
type: string
responses:
'200':
description: Index health status
content:
application/json:
schema:
type: object
properties:
healthy:
type: boolean
total_in_storage:
type: integer
indexed_count:
type: integer
orphaned_count:
type: integer
/api/index/repair:
post:
tags: [Admin]
summary: Repair vector index (re-index orphaned memories)
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- user_id
properties:
user_id:
type: string
responses:
'200':
description: Repair complete
content:
application/json:
schema:
type: object
properties:
repaired_count:
type: integer
failed_count:
type: integer
tags:
- name: Health
description: Service health and status
- name: Memory
description: Core memory operations (remember, recall)
- name: Context
description: Context management and proactive surfacing
- name: Recall
description: Specialized recall operations
- name: Forget
description: Memory deletion operations
- name: Stats
description: Statistics and metrics
- name: Admin
description: Administrative operations