Class: OllamaAgent::Runtime::WorkspaceWalReplay

Inherits:
Object
  • Object
show all
Defined in:
lib/ollama_agent/runtime/workspace_wal_replay.rb

Overview

Replays global mutation WAL (event_store.db) onto a workspace tree using blob content-addresses.

Instance Method Summary collapse

Constructor Details

#initialize(workspace_root:, event_store_db_path:, blob_store_kernel_dir:) ⇒ WorkspaceWalReplay

Returns a new instance of WorkspaceWalReplay.



15
16
17
18
19
# File 'lib/ollama_agent/runtime/workspace_wal_replay.rb', line 15

def initialize(workspace_root:, event_store_db_path:, blob_store_kernel_dir:)
  @root = File.expand_path(workspace_root.to_s)
  @event_store_db_path = event_store_db_path.to_s
  @blob_store = BlobStore.new(kernel_dir: blob_store_kernel_dir)
end

Instance Method Details

#replay!Object



21
22
23
24
25
26
27
28
29
# File 'lib/ollama_agent/runtime/workspace_wal_replay.rb', line 21

def replay!
  db = SQLite3::Database.new(@event_store_db_path, results_as_hash: true)
  store = EventStore.new(db)
  store.each_mutation_globally do |row|
    apply_mutation_payload(row["payload"])
  end
ensure
  db&.close
end