Class: Insika::Doctor

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

Overview

insika doctor (item 23 / §8.1 — OpenClaw's "strict config + doctor --fix", "the repo's best productization discipline"). A read-only diagnosis of a deployment's configuration that turns the scattered, silent boot warnings into ONE structured report — and, with --fix, applies the safe autofixes.

Every check is DATA (config over convention): an id, a title, and a lambda that inspects the injected collaborators and returns Findings. A Finding may carry a fix proc; fix! runs those and re-diagnoses. Collaborators are optional so the CLI can build them straight off the durable backend (no full app boot / no DEEPSEEK) and an env-only caller can skip the store checks entirely.

Defined Under Namespace

Classes: Finding, Report

Instance Method Summary collapse

Constructor Details

#initialize(env: ENV, settings_store: nil, llm_provider_store: nil, tool_store: nil, agent_file_store: nil, backend: nil, extra_env_specs: []) ⇒ Doctor

Returns a new instance of Doctor.



60
61
62
63
64
65
66
67
68
69
# File 'lib/insika/doctor.rb', line 60

def initialize(env: ENV, settings_store: nil, llm_provider_store: nil, tool_store: nil,
               agent_file_store: nil, backend: nil, extra_env_specs: [])
  @env = env
  @settings_store = settings_store
  @llm_provider_store = llm_provider_store
  @tool_store = tool_store
  @agent_file_store = agent_file_store
  @backend = backend
  @extra_env_specs = extra_env_specs
end

Instance Method Details

#fix!Object

Applies every fixable finding, then re-diagnoses. -> [Report before, Report after].



77
78
79
80
81
# File 'lib/insika/doctor.rb', line 77

def fix!
  before = run
  before.fixable.map(&:fix).each(&:call)
  [before, run]
end

#runObject

-> Report. Never raises (a broken check degrades to an :error Finding).



72
73
74
# File 'lib/insika/doctor.rb', line 72

def run
  Report.new(findings: checks.flat_map { |check| safe(check) }.freeze)
end