@@ -39,9 +39,11 @@ impl CogneeMemory {
3939
4040#[ async_trait]
4141impl Memory for CogneeMemory {
42+ /// Returns the Cognee driver identifier.
4243 fn name ( & self ) -> & str {
4344 self . inner . name ( )
4445 }
46+ /// Stores an internally sourced record through the shared contract.
4547 async fn store (
4648 & self ,
4749 n : & str ,
@@ -52,6 +54,7 @@ impl Memory for CogneeMemory {
5254 ) -> anyhow:: Result < ( ) > {
5355 self . inner . store ( n, k, c, cat, s) . await
5456 }
57+ /// Stores a record while preserving its provenance taint.
5558 async fn store_with_taint (
5659 & self ,
5760 n : & str ,
@@ -63,6 +66,7 @@ impl Memory for CogneeMemory {
6366 ) -> anyhow:: Result < ( ) > {
6467 self . inner . store_with_taint ( n, k, c, cat, s, t) . await
6568 }
69+ /// Runs native Cognee recall and applies TinyMemory filters.
6670 async fn recall (
6771 & self ,
6872 q : & str ,
@@ -71,13 +75,15 @@ impl Memory for CogneeMemory {
7175 ) -> anyhow:: Result < Vec < tinymemory_api:: types:: MemoryEntry > > {
7276 self . inner . recall ( q, l, o) . await
7377 }
78+ /// Fetches one exact namespace/key record.
7479 async fn get (
7580 & self ,
7681 n : & str ,
7782 k : & str ,
7883 ) -> anyhow:: Result < Option < tinymemory_api:: types:: MemoryEntry > > {
7984 self . inner . get ( n, k) . await
8085 }
86+ /// Lists records matching the supplied TinyMemory filters.
8187 async fn list (
8288 & self ,
8389 n : Option < & str > ,
@@ -86,41 +92,50 @@ impl Memory for CogneeMemory {
8692 ) -> anyhow:: Result < Vec < tinymemory_api:: types:: MemoryEntry > > {
8793 self . inner . list ( n, c, s) . await
8894 }
95+ /// Deletes one exact namespace/key record.
8996 async fn forget ( & self , n : & str , k : & str ) -> anyhow:: Result < bool > {
9097 self . inner . forget ( n, k) . await
9198 }
99+ /// Summarizes every namespace visible through this adapter.
92100 async fn namespace_summaries (
93101 & self ,
94102 ) -> anyhow:: Result < Vec < tinymemory_api:: types:: NamespaceSummary > > {
95103 self . inner . namespace_summaries ( ) . await
96104 }
105+ /// Counts every record visible through this adapter.
97106 async fn count ( & self ) -> anyhow:: Result < usize > {
98107 self . inner . count ( ) . await
99108 }
109+ /// Checks whether the configured Cognee service is reachable.
100110 async fn health_check ( & self ) -> bool {
101111 self . inner . health_check ( ) . await
102112 }
103113}
104114
105115#[ derive( Debug ) ]
116+ /// Cognee-specific REST operations and wire-format conversion.
106117struct CogneeDialect {
107118 client : HttpClient ,
108119}
109120
110121#[ derive( Debug , Clone ) ]
122+ /// Identity of a Cognee dataset used for one TinyMemory namespace.
111123struct Dataset {
112124 id : String ,
113125 name : String ,
114126}
115127
116128impl CogneeDialect {
129+ /// Encodes a TinyMemory namespace as a collision-free Cognee dataset name.
117130 fn dataset_name ( namespace : & str ) -> String {
118131 format ! ( "tinymemory__{}" , encode( namespace) )
119132 }
133+ /// Encodes a TinyMemory key as the uploaded envelope's filename.
120134 fn filename ( key : & str ) -> String {
121135 format ! ( "{}.tinymemory.json" , encode( key) )
122136 }
123137
138+ /// Discovers only datasets owned by the TinyMemory adapter.
124139 async fn datasets ( & self ) -> anyhow:: Result < Vec < Dataset > > {
125140 let response: Value = self
126141 . client
@@ -140,6 +155,7 @@ impl CogneeDialect {
140155 . collect ( ) )
141156 }
142157
158+ /// Downloads and decodes every TinyMemory envelope in one dataset.
143159 async fn dataset_entries ( & self , dataset : & Dataset ) -> anyhow:: Result < Vec < StoredEntry > > {
144160 let response: Value = self
145161 . client
@@ -187,6 +203,7 @@ impl CogneeDialect {
187203 Ok ( entries)
188204 }
189205
206+ /// Resolves the dataset assigned to a namespace.
190207 async fn find_dataset ( & self , namespace : & str ) -> anyhow:: Result < Option < Dataset > > {
191208 let name = Self :: dataset_name ( namespace) ;
192209 Ok ( self
@@ -196,6 +213,7 @@ impl CogneeDialect {
196213 . find ( |dataset| dataset. name == name) )
197214 }
198215
216+ /// Deletes a stored envelope using its composite remote identifier.
199217 async fn delete_entry ( & self , entry : & StoredEntry ) -> anyhow:: Result < ( ) > {
200218 let ( dataset_id, data_id) = entry
201219 . remote_id
@@ -214,10 +232,12 @@ impl CogneeDialect {
214232
215233#[ async_trait]
216234impl Dialect for CogneeDialect {
235+ /// Returns the stable Cognee driver identifier.
217236 fn name ( & self ) -> & ' static str {
218237 COGNEE_DRIVER_ID
219238 }
220239
240+ /// Replaces an existing envelope and uploads the new exact record.
221241 async fn upsert ( & self , entry : StoredEntry ) -> anyhow:: Result < ( ) > {
222242 if let Some ( existing) = self
223243 . entries ( )
@@ -252,6 +272,7 @@ impl Dialect for CogneeDialect {
252272 Ok ( ( ) )
253273 }
254274
275+ /// Enumerates records across all TinyMemory-owned Cognee datasets.
255276 async fn entries ( & self ) -> anyhow:: Result < Vec < StoredEntry > > {
256277 let mut entries = Vec :: new ( ) ;
257278 for dataset in self . datasets ( ) . await ? {
@@ -260,6 +281,7 @@ impl Dialect for CogneeDialect {
260281 Ok ( entries)
261282 }
262283
284+ /// Executes Cognee's native chunk recall and decodes returned envelopes.
263285 async fn search (
264286 & self ,
265287 query : & str ,
@@ -309,6 +331,7 @@ impl Dialect for CogneeDialect {
309331 Ok ( entries)
310332 }
311333
334+ /// Finds and deletes an exact TinyMemory logical record.
312335 async fn delete ( & self , namespace : & str , key : & str ) -> anyhow:: Result < bool > {
313336 let Some ( dataset) = self . find_dataset ( namespace) . await ? else {
314337 return Ok ( false ) ;
@@ -325,6 +348,7 @@ impl Dialect for CogneeDialect {
325348 Ok ( true )
326349 }
327350
351+ /// Checks Cognee's aggregate health endpoint.
328352 async fn health ( & self ) -> bool {
329353 self . client . healthy ( "health" ) . await
330354 }
0 commit comments