Class: OllamaAgent::Runtime::WAL

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(event_store) ⇒ WAL

Returns a new instance of WAL.

Parameters:



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.

Returns:



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