Module: RosettAi::Doctor

Defined in:
lib/rosett_ai/doctor.rb,
lib/rosett_ai/doctor/check.rb,
lib/rosett_ai/doctor/checks/cache_health_check.rb,
lib/rosett_ai/doctor/checks/ruby_version_check.rb,
lib/rosett_ai/doctor/checks/gem_dependency_check.rb,
lib/rosett_ai/doctor/checks/file_permission_check.rb,
lib/rosett_ai/doctor/checks/stale_home_nncc_check.rb,
lib/rosett_ai/doctor/checks/engine_detection_check.rb,
lib/rosett_ai/doctor/checks/dbus_availability_check.rb,
lib/rosett_ai/doctor/checks/stale_config_nncc_check.rb

Overview

Self-diagnostic runner for Rosett-AI runtime prerequisites.

Orchestrates registered checks and collects results. Each check implements the Check interface (#name, #run, #status,

message, #remediation).

See Also:

  • conf/design/doctorconf/design/doctor.yml

Author:

  • hugo

  • claude

Defined Under Namespace

Modules: Check, Checks

Constant Summary collapse

STATUSES =
['pass', 'warn', 'fail'].freeze

Class Method Summary collapse

Class Method Details

.check_namesArray<String>

Return the names of all registered checks.

Returns:

  • (Array<String>)


41
42
43
# File 'lib/rosett_ai/doctor.rb', line 41

def check_names
  checks.map(&:check_name)
end

.checksArray<Class>

Return all registered check classes.

Returns:

  • (Array<Class>)


34
35
36
# File 'lib/rosett_ai/doctor.rb', line 34

def checks
  @mutex.synchronize { @checks.dup }
end

.exit_code(results) ⇒ Integer

Determine the overall exit code from results.

Parameters:

  • results (Array<Hash>)

    check results

Returns:

  • (Integer)

    0=all pass, 1=any warn, 2=any fail



67
68
69
70
71
72
# File 'lib/rosett_ai/doctor.rb', line 67

def exit_code(results)
  return 2 if results.any? { |r| r[:status] == 'fail' }
  return 1 if results.any? { |r| r[:status] == 'warn' }

  0
end

.register(check_class)

This method returns an undefined value.

Register a check class.

Parameters:

  • check_class (Class)

    a class that includes Doctor::Check



27
28
29
# File 'lib/rosett_ai/doctor.rb', line 27

def register(check_class)
  @mutex.synchronize { @checks << check_class }
end

.reset!

This method returns an undefined value.

Reset registered checks. Intended for test isolation.



76
77
78
# File 'lib/rosett_ai/doctor.rb', line 76

def reset!
  @mutex.synchronize { @checks = [] }
end

.run_all(only: nil) ⇒ Array<Hash>

Run all registered checks (or a filtered subset).

Parameters:

  • only (String, nil) (defaults to: nil)

    run only the named check

Returns:

  • (Array<Hash>)

    results with :name, :status, :message, :remediation



49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/rosett_ai/doctor.rb', line 49

def run_all(only: nil)
  targets = only ? checks.select { |klass| klass.check_name == only } : checks
  targets.map do |check_class|
    instance = check_class.new
    instance.run
    {
      name: instance.name,
      status: instance.status.to_s,
      message: instance.message,
      remediation: instance.remediation
    }
  end
end