Class: Rubino::Memory::Backends::Default
- Inherits:
-
Rubino::Memory::Backend
- Object
- Rubino::Memory::Backend
- Rubino::Memory::Backends::Default
- Defined in:
- lib/rubino/memory/backends/default.rb
Overview
The default memory backend: a thin façade over the existing Store / Retriever / Extractor. Behavior is byte-identical to the pre-pluggable implementation — every call delegates to the same code paths (and therefore the same ThreatScanner + char-budget guards in Memory::Store) that the seams called directly before.
Named “default” because it is SQLite-table-backed today but is the baseline every install gets unless ‘memory.backend` is changed.
Class Method Summary collapse
Instance Method Summary collapse
- #count ⇒ Object
- #delete(id) ⇒ Object
- #extract(session_id) ⇒ Object
- #find(id) ⇒ Object
- #forget(kind:, old_text:) ⇒ Object
-
#initialize(config: nil, store: nil, retriever: nil) ⇒ Default
constructor
A new instance of Default.
-
#list(kind: nil, limit: 20, include_retired: false) ⇒ Object
The legacy store hard-deletes on replace — there are no retired rows, so ‘include_retired` is accepted for contract parity only.
- #project_context ⇒ Object
- #replace(kind:, old_text:, content:) ⇒ Object
-
#retrieve(session_id:, query: nil) ⇒ Object
‘query` is accepted for contract compatibility but ignored — the default backend returns “everything that fits”, exactly as today.
-
#store(kind:, content:, source_session_id: nil, confidence: 1.0, metadata: {}) ⇒ Object
– WRITE path –.
-
#user_profile ⇒ Object
– READ path –.
Methods inherited from Rubino::Memory::Backend
Constructor Details
#initialize(config: nil, store: nil, retriever: nil) ⇒ Default
Returns a new instance of Default.
19 20 21 22 23 |
# File 'lib/rubino/memory/backends/default.rb', line 19 def initialize(config: nil, store: nil, retriever: nil) super(config: config) @store = store || Store.new(config: @config) @retriever = retriever || Retriever.new(store: @store, config: @config) end |
Class Method Details
.backend_name ⇒ Object
15 16 17 |
# File 'lib/rubino/memory/backends/default.rb', line 15 def self.backend_name "default" end |
Instance Method Details
#count ⇒ Object
89 90 91 |
# File 'lib/rubino/memory/backends/default.rb', line 89 def count @store.count end |
#delete(id) ⇒ Object
85 86 87 |
# File 'lib/rubino/memory/backends/default.rb', line 85 def delete(id) @store.delete(id) end |
#extract(session_id) ⇒ Object
53 54 55 |
# File 'lib/rubino/memory/backends/default.rb', line 53 def extract(session_id) Extractor.new(store: @store).extract_from_session(session_id) end |
#find(id) ⇒ Object
81 82 83 |
# File 'lib/rubino/memory/backends/default.rb', line 81 def find(id) @store.find(id) end |
#forget(kind:, old_text:) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/rubino/memory/backends/default.rb', line 45 def forget(kind:, old_text:) target = find_by_substring(kind, old_text) return nil unless target @store.delete(target[:id]) target end |
#list(kind: nil, limit: 20, include_retired: false) ⇒ Object
The legacy store hard-deletes on replace — there are no retired rows, so ‘include_retired` is accepted for contract parity only.
77 78 79 |
# File 'lib/rubino/memory/backends/default.rb', line 77 def list(kind: nil, limit: 20, include_retired: false) @store.list(kind: kind, limit: limit) end |
#project_context ⇒ Object
63 64 65 |
# File 'lib/rubino/memory/backends/default.rb', line 63 def project_context @retriever.project_context end |
#replace(kind:, old_text:, content:) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/rubino/memory/backends/default.rb', line 37 def replace(kind:, old_text:, content:) target = find_by_substring(kind, old_text) return nil unless target @store.update(target[:id], content: content) target end |
#retrieve(session_id:, query: nil) ⇒ Object
‘query` is accepted for contract compatibility but ignored — the default backend returns “everything that fits”, exactly as today.
69 70 71 |
# File 'lib/rubino/memory/backends/default.rb', line 69 def retrieve(session_id:, query: nil) @retriever.relevant_for_session(session_id) end |
#store(kind:, content:, source_session_id: nil, confidence: 1.0, metadata: {}) ⇒ Object
– WRITE path –
27 28 29 30 31 32 33 34 35 |
# File 'lib/rubino/memory/backends/default.rb', line 27 def store(kind:, content:, source_session_id: nil, confidence: 1.0, metadata: {}) @store.create( kind: kind, content: content, source_session_id: source_session_id, confidence: confidence, metadata: ) end |
#user_profile ⇒ Object
– READ path –
59 60 61 |
# File 'lib/rubino/memory/backends/default.rb', line 59 def user_profile @retriever.user_profile end |