Class: OllamaAgent::Runtime::WAL
- Inherits:
-
Object
- Object
- OllamaAgent::Runtime::WAL
- Defined in:
- lib/ollama_agent/runtime/wal.rb
Overview
Mutation-focused view over EventStore (kind = mutation).
Constant Summary collapse
- MUTATION_KIND =
EventStore::MUTATION_KIND
- MUTATION_STEP_KIND =
"mutation_step"
Instance Method Summary collapse
-
#append_mutation(manifest_id:, logical_stamp:, payload:, intent_hash: nil, created_at: nil) ⇒ :inserted, :duplicate
See EventStore#append.
-
#append_mutation_step(manifest_id:, logical_stamp:, step:, data: {}) ⇒ Object
Fine-grained mutation progress (no
intent_hash; not deduped). -
#initialize(event_store) ⇒ WAL
constructor
A new instance of WAL.
-
#replay(manifest_id:) ⇒ Object
Yields mutation rows for
manifest_idin stableidorder.
Constructor Details
#initialize(event_store) ⇒ WAL
Returns a new instance of WAL.
15 16 17 |
# File 'lib/ollama_agent/runtime/wal.rb', line 15 def initialize(event_store) @event_store = event_store end |
Instance Method Details
#append_mutation(manifest_id:, logical_stamp:, payload:, intent_hash: nil, created_at: nil) ⇒ :inserted, :duplicate
Returns see EventStore#append.
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/ollama_agent/runtime/wal.rb', line 20 def append_mutation(manifest_id:, logical_stamp:, payload:, intent_hash: nil, created_at: nil) @event_store.append( manifest_id: manifest_id, logical_stamp: logical_stamp, kind: MUTATION_KIND, payload: payload, intent_hash: intent_hash, created_at: created_at ) end |
#append_mutation_step(manifest_id:, logical_stamp:, step:, data: {}) ⇒ Object
Fine-grained mutation progress (no intent_hash; not deduped).
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ollama_agent/runtime/wal.rb', line 32 def append_mutation_step(manifest_id:, logical_stamp:, step:, data: {}) blob = JSON.generate(data.merge("step" => step)) @event_store.append( manifest_id: manifest_id, logical_stamp: logical_stamp, kind: MUTATION_STEP_KIND, payload: blob, intent_hash: nil, created_at: nil ) end |
#replay(manifest_id:) ⇒ Object
Yields mutation rows for manifest_id in stable id order.
45 46 47 48 49 50 51 |
# File 'lib/ollama_agent/runtime/wal.rb', line 45 def replay(manifest_id:) return to_enum(:replay, manifest_id: manifest_id) unless block_given? @event_store.each_for(manifest_id: manifest_id) do |row| yield row if row["kind"] == MUTATION_KIND end end |