Class: OllamaAgent::Runtime::DatabaseRegistry

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

Overview

Opens kernel SQLite databases under root_dir/.ollama_agent/kernel/ and applies idempotent migrations.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root_dir:) ⇒ DatabaseRegistry

Returns a new instance of DatabaseRegistry.

Parameters:

  • root_dir (String)

    workspace root



13
14
15
16
17
18
19
20
# File 'lib/ollama_agent/runtime/database_registry.rb', line 13

def initialize(root_dir:)
  @root_dir = root_dir
  @kernel_dir = File.join(root_dir, ".ollama_agent", "kernel")
  @open_mutex = Mutex.new
  @event_store = nil
  @runtime = nil
  @migrations_ran = false
end

Instance Attribute Details

#kernel_dirObject (readonly)

Returns the value of attribute kernel_dir.



32
33
34
# File 'lib/ollama_agent/runtime/database_registry.rb', line 32

def kernel_dir
  @kernel_dir
end

Instance Method Details

#event_storeSQLite3::Database

Returns event store connection (WAL, synchronous FULL).

Returns:

  • (SQLite3::Database)

    event store connection (WAL, synchronous FULL)



23
24
25
# File 'lib/ollama_agent/runtime/database_registry.rb', line 23

def event_store
  open_mutex_sync { @event_store ||= connect_event_store }
end

#runtimeSQLite3::Database

Returns runtime connection (WAL, synchronous NORMAL).

Returns:

  • (SQLite3::Database)

    runtime connection (WAL, synchronous NORMAL)



28
29
30
# File 'lib/ollama_agent/runtime/database_registry.rb', line 28

def runtime
  open_mutex_sync { @runtime ||= connect_runtime }
end