Module: Engram::Ports::MemoryStore
- Included in:
- Adapters::InMemoryStore, Adapters::PgvectorStore
- Defined in:
- lib/engram/ports/memory_store.rb
Overview
Contract for a place memories are persisted and searched. Implementations: Adapters::InMemoryStore, Adapters::PgvectorStore.
Instance Method Summary collapse
-
#add(record) ⇒ Object
Persist a Record.
-
#all(scope:) ⇒ Object
All Records for a scope (mostly for inspection/tests).
-
#delete(id:) ⇒ Object
Remove a memory by id.
-
#search(embedding:, scope:, limit:) ⇒ Object
Return up to ‘limit` Records in `scope` nearest to `embedding`, ordered most-relevant first.
-
#touch(id:, at: Time.now) ⇒ Object
Update the last-accessed timestamp of a memory.
-
#update(id:, record:) ⇒ Object
Replace the content/embedding of an existing memory.
Instance Method Details
#add(record) ⇒ Object
Persist a Record. Returns the stored Record.
9 10 11 |
# File 'lib/engram/ports/memory_store.rb', line 9 def add(record) raise NotImplementedError, "#{self.class} must implement #add" end |
#all(scope:) ⇒ Object
All Records for a scope (mostly for inspection/tests).
20 21 22 |
# File 'lib/engram/ports/memory_store.rb', line 20 def all(scope:) raise NotImplementedError, "#{self.class} must implement #all" end |
#delete(id:) ⇒ Object
Remove a memory by id. Used by consolidation (FORGET).
31 32 33 |
# File 'lib/engram/ports/memory_store.rb', line 31 def delete(id:) raise NotImplementedError, "#{self.class} must implement #delete" end |
#search(embedding:, scope:, limit:) ⇒ Object
Return up to ‘limit` Records in `scope` nearest to `embedding`, ordered most-relevant first.
15 16 17 |
# File 'lib/engram/ports/memory_store.rb', line 15 def search(embedding:, scope:, limit:) raise NotImplementedError, "#{self.class} must implement #search" end |
#touch(id:, at: Time.now) ⇒ Object
Update the last-accessed timestamp of a memory. Used by recency-aware recall.
36 37 38 |
# File 'lib/engram/ports/memory_store.rb', line 36 def touch(id:, at: Time.now) raise NotImplementedError, "#{self.class} must implement #touch" end |
#update(id:, record:) ⇒ Object
Replace the content/embedding of an existing memory. Used by consolidation (UPDATE). Returns the updated Record.
26 27 28 |
# File 'lib/engram/ports/memory_store.rb', line 26 def update(id:, record:) raise NotImplementedError, "#{self.class} must implement #update" end |