Class: Phronomy::Memory::Storage::Base Abstract
- Inherits:
-
Object
- Object
- Phronomy::Memory::Storage::Base
- Defined in:
- lib/phronomy/memory/storage/base.rb
Overview
Subclass and implement all abstract methods.
Abstract base class for conversation storage backends.
Each backend manages two independent datasets per thread:
Raw messages — the original, unmodified conversation history. Every message is stored with a monotonically increasing seq number (0-based, scoped to thread_id). Raw messages are never modified or deleted; they are the authoritative record.
Compaction records — the output of LLM-based compaction (summarization). Each record covers a contiguous range [start_seq..end_seq] of raw messages and stores the summary text produced for that range. Multiple non-overlapping compaction records may exist per thread.
The conventional load/save/clear interface is kept for use by ConversationManager (compression path) and direct storage access.
Direct Known Subclasses
Instance Method Summary collapse
-
#append_raw(thread_id:, messages:, starting_seq:) ⇒ Object
Append new messages to the raw history for a thread.
-
#clear(thread_id:) ⇒ Object
Delete all messages for a thread.
-
#clear_compactions(thread_id:) ⇒ Object
Delete all compaction records for a thread.
-
#clear_raw(thread_id:) ⇒ Object
Delete raw messages for a thread (used in #clear).
-
#load(thread_id:) ⇒ Array
Load all messages for a thread in chronological order.
-
#load_compactions(thread_id:) ⇒ Array<Hash>
Return all compaction records for a thread in ascending start_seq order.
-
#load_raw(thread_id:) ⇒ Array<Hash>
Return all raw messages for a thread as an array of hashes.
-
#purge(thread_id:) ⇒ Object
Remove all stored data (raw messages, compaction records, legacy store) for a thread.
-
#purge_older_than(thread_id:, older_than:) ⇒ Object
Remove raw messages recorded before +older_than+ for a thread.
-
#save(thread_id:, messages:) ⇒ Object
Persist messages for a thread (replaces existing messages).
-
#save_compaction(thread_id:, start_seq:, end_seq:, summary_text:) ⇒ Object
Persist a compaction record for a thread.
Instance Method Details
#append_raw(thread_id:, messages:, starting_seq:) ⇒ Object
Append new messages to the raw history for a thread. Each message is stored together with its seq number.
62 63 64 |
# File 'lib/phronomy/memory/storage/base.rb', line 62 def append_raw(thread_id:, messages:, starting_seq:) raise NotImplementedError, "#{self.class}#append_raw is not implemented" end |
#clear(thread_id:) ⇒ Object
Delete all messages for a thread.
48 49 50 |
# File 'lib/phronomy/memory/storage/base.rb', line 48 def clear(thread_id:) raise NotImplementedError, "#{self.class}#clear is not implemented" end |
#clear_compactions(thread_id:) ⇒ Object
Delete all compaction records for a thread.
108 109 110 |
# File 'lib/phronomy/memory/storage/base.rb', line 108 def clear_compactions(thread_id:) raise NotImplementedError, "#{self.class}#clear_compactions is not implemented" end |
#clear_raw(thread_id:) ⇒ Object
Delete raw messages for a thread (used in #clear).
77 78 79 |
# File 'lib/phronomy/memory/storage/base.rb', line 77 def clear_raw(thread_id:) raise NotImplementedError, "#{self.class}#clear_raw is not implemented" end |
#load(thread_id:) ⇒ Array
Load all messages for a thread in chronological order.
33 34 35 |
# File 'lib/phronomy/memory/storage/base.rb', line 33 def load(thread_id:) raise NotImplementedError, "#{self.class}#load is not implemented" end |
#load_compactions(thread_id:) ⇒ Array<Hash>
Return all compaction records for a thread in ascending start_seq order.
101 102 103 |
# File 'lib/phronomy/memory/storage/base.rb', line 101 def load_compactions(thread_id:) raise NotImplementedError, "#{self.class}#load_compactions is not implemented" end |
#load_raw(thread_id:) ⇒ Array<Hash>
Return all raw messages for a thread as an array of hashes.
70 71 72 |
# File 'lib/phronomy/memory/storage/base.rb', line 70 def load_raw(thread_id:) raise NotImplementedError, "#{self.class}#load_raw is not implemented" end |
#purge(thread_id:) ⇒ Object
Remove all stored data (raw messages, compaction records, legacy store) for a thread. Equivalent to #clear, provided as a named alias to make the "right to erasure" intent explicit.
117 118 119 |
# File 'lib/phronomy/memory/storage/base.rb', line 117 def purge(thread_id:) clear(thread_id: thread_id) end |
#purge_older_than(thread_id:, older_than:) ⇒ Object
Remove raw messages recorded before +older_than+ for a thread. The default implementation is a no-op; backends that support timestamp-based deletion should override this method.
127 128 129 |
# File 'lib/phronomy/memory/storage/base.rb', line 127 def purge_older_than(thread_id:, older_than:) # no-op by default end |
#save(thread_id:, messages:) ⇒ Object
Persist messages for a thread (replaces existing messages).
41 42 43 |
# File 'lib/phronomy/memory/storage/base.rb', line 41 def save(thread_id:, messages:) raise NotImplementedError, "#{self.class}#save is not implemented" end |
#save_compaction(thread_id:, start_seq:, end_seq:, summary_text:) ⇒ Object
Persist a compaction record for a thread. A compaction record stores the LLM-generated summary that covers raw messages from start_seq to end_seq (inclusive).
93 94 95 |
# File 'lib/phronomy/memory/storage/base.rb', line 93 def save_compaction(thread_id:, start_seq:, end_seq:, summary_text:) raise NotImplementedError, "#{self.class}#save_compaction is not implemented" end |