Class: Insika::ConfigStore

Inherits:
Object
  • Object
show all
Defined in:
lib/insika/config_store.rb

Overview

CONFIGURATION DOMAIN store. Unlike the EXECUTION stores (session/task/checkpoint/pending/memory), this holds the configuration the Studio authors at runtime: agents (profiles), general settings, LLM providers and MCP instances. Scoped KV over any Insika::Store — durable when the backend is SQLite (survives a restart, like everything else).

logical scope -> physical namespace "config:". Values are JSON-serializable Hashes (symbol becomes string on the round-trip, per the Store contract; the domain re-symbolizes at the edge — see StoredProfileSource).

Defined Under Namespace

Classes: UnknownScope

Constant Summary collapse

SCOPE_PREFIX =
"config"
SCOPES =

agent_files/skills: the CONTENT of per-agent prompts and shared skills lives in the Store (single source of truth, a SQLite backup), not on disk — disk becomes only seed/import. goldens: authored eval cases — config, like the prompts and skills: the corpus on disk is seed and export, the store is what a deployment runs and what the Studio edits. baselines: the ACCEPTED state of each agent's golden set. Config for the same reason: it is a curated decision ("this is the bar"), the file is its export, and the refinement gate reads it from inside a deployment that has no checkout. agent_skills: the per-agent SPECIALIZATIONS of a shared skill (and agent-private skills). A second scope rather than a composite key in skills, so the shared records are untouched by the agent dimension arriving — no migration, and a live deployment keeps serving exactly what it served.

%w[agents settings llm_providers mcp agent_files skills agent_skills
system_files tools goldens baselines].freeze

Instance Method Summary collapse

Constructor Details

#initialize(store:) ⇒ ConfigStore

Returns a new instance of ConfigStore.



37
38
39
# File 'lib/insika/config_store.rb', line 37

def initialize(store:)
  @store = store
end

Instance Method Details

#all(scope) ⇒ Object

-> [Hash] all records of the scope (lexicographic key order)



63
64
65
66
# File 'lib/insika/config_store.rb', line 63

def all(scope)
  s = ns(scope)
  @store.list(s).filter_map { |k| @store.get(s, k) }
end

#delete(scope, key) ⇒ Object

-> bool (did it exist?)



53
54
55
# File 'lib/insika/config_store.rb', line 53

def delete(scope, key)
  @store.delete(ns(scope), key.to_s)
end

#get(scope, key) ⇒ Object

-> Hash | nil



48
49
50
# File 'lib/insika/config_store.rb', line 48

def get(scope, key)
  @store.get(ns(scope), key.to_s)
end

#keys(scope) ⇒ Object

-> [String] keys of the scope, sorted lexicographically



58
59
60
# File 'lib/insika/config_store.rb', line 58

def keys(scope)
  @store.list(ns(scope))
end

#put(scope, key, value) ⇒ Object

Upsert (last-write-wins). -> value (the same Hash that was passed)



42
43
44
45
# File 'lib/insika/config_store.rb', line 42

def put(scope, key, value)
  @store.set(ns(scope), key.to_s, stringify(value))
  value
end