Class: Phronomy::Agent::JournalProjection
- Inherits:
-
Object
- Object
- Phronomy::Agent::JournalProjection
- Defined in:
- lib/phronomy/agent/journal_projection.rb
Constant Summary collapse
- MESSAGE_KINDS =
%i[ external_message assistant_message tool_message ].freeze
- KNOWLEDGE_RESET_KINDS =
%i[knowledge_cleared context_reset].freeze
Instance Method Summary collapse
-
#context_records ⇒ Object
Returns all persistent records eligible for Context selection.
-
#initialize(persistence:, agent_root:) ⇒ JournalProjection
constructor
A new instance of JournalProjection.
- #llm_call_records ⇒ Object
- #records ⇒ Object
- #transcript_records ⇒ Object
Constructor Details
#initialize(persistence:, agent_root:) ⇒ JournalProjection
Returns a new instance of JournalProjection.
13 14 15 16 |
# File 'lib/phronomy/agent/journal_projection.rb', line 13 def initialize(persistence:, agent_root:) @persistence = persistence @agent_root = agent_root end |
Instance Method Details
#context_records ⇒ Object
Returns all persistent records eligible for Context selection. Knowledge has an independent logical lifetime from the transcript: clear_transcript! does not remove Knowledge, while knowledge_cleared and context_reset invalidate earlier Knowledge records by Journal position.
31 32 33 34 35 |
# File 'lib/phronomy/agent/journal_projection.rb', line 31 def context_records (transcript_records + active_knowledge_records) .sort_by { |record| [record.sequence || 0, record.record_id] } .freeze end |
#llm_call_records ⇒ Object
37 38 39 |
# File 'lib/phronomy/agent/journal_projection.rb', line 37 def llm_call_records records.select { |record| record.kind == :llm_call_recorded } end |
#records ⇒ Object
41 42 43 |
# File 'lib/phronomy/agent/journal_projection.rb', line 41 def records @records ||= @persistence.journals.read(@agent_root.agent_id) end |
#transcript_records ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/phronomy/agent/journal_projection.rb', line 18 def transcript_records generation = @agent_root.transcript_generation records.select do |record| record.context_candidate && record.context_generation == generation && MESSAGE_KINDS.include?(record.kind) end end |