Module: RaceGuard::IndexIntegrity::Runner

Defined in:
lib/race_guard/index_integrity/runner.rb

Overview

Orchestrates model scan, schema indexes, and comparison (Epic 5.4 core).

Class Method Summary collapse

Class Method Details

.exit_code_for(root, stdout: $stdout, stderr: $stderr) ⇒ Integer

Returns 0 if no violations, 1 otherwise.

Returns:

  • (Integer)

    0 if no violations, 1 otherwise



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/race_guard/index_integrity/runner.rb', line 15

def exit_code_for(root, stdout: $stdout, stderr: $stderr)
  root = Pathname.new(root)
  validations = scan_models(root)
  indexes = load_indexes(root, stderr: stderr)
  return 1 if indexes.nil?

  violations = ComparisonEngine.missing_indexes(validations: validations, indexes: indexes)
  if violations.empty?
    stdout.puts 'Index integrity: OK (no missing unique indexes for validations).'
    0
  else
    violations.each { |v| stdout.puts(v.message) }
    1
  end
end