Module: Henitai::ConfigurationValidator::Rules

Defined in:
lib/henitai/configuration_validator/rules.rb,
sig/configuration_validator.rbs

Overview

Section-level validation rules.

Each validate_* method inspects one configuration section, warns about unknown keys via warn, and delegates leaf value checks to Scalars. Failures raise Henitai::ConfigurationError.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.configuration_error(message) ⇒ Object



156
157
158
# File 'lib/henitai/configuration_validator/rules.rb', line 156

def configuration_error(message)
  raise Henitai::ConfigurationError, message
end

.ensure_hash!(value, path) ⇒ Object



150
151
152
153
154
# File 'lib/henitai/configuration_validator/rules.rb', line 150

def ensure_hash!(value, path)
  return if value.is_a?(Hash)

  configuration_error("Invalid configuration value for #{path}: expected Hash, got #{value.class}")
end

.key_path(path, key) ⇒ Object



146
147
148
# File 'lib/henitai/configuration_validator/rules.rb', line 146

def key_path(path, key)
  path ? "#{path}.#{key}" : key.to_s
end

.validate_all_logs(raw) ⇒ Object



68
69
70
71
72
73
# File 'lib/henitai/configuration_validator/rules.rb', line 68

def validate_all_logs(raw)
  value = raw[:all_logs]
  return if value.nil?

  Scalars.validate_boolean(value, "all_logs")
end

.validate_coverage_criteria(raw) ⇒ Object



110
111
112
113
114
115
116
117
# File 'lib/henitai/configuration_validator/rules.rb', line 110

def validate_coverage_criteria(raw)
  value = raw[:coverage_criteria]
  return if value.nil?

  ensure_hash!(value, "coverage_criteria")
  warn_unknown_keys(value, VALID_COVERAGE_CRITERIA_KEYS, "coverage_criteria")
  value.each { |key, flag| Scalars.validate_boolean(flag, "coverage_criteria.#{key}") }
end

.validate_dashboard(raw) ⇒ Object



75
76
77
78
79
80
81
82
83
# File 'lib/henitai/configuration_validator/rules.rb', line 75

def validate_dashboard(raw)
  value = raw[:dashboard]
  return if value.nil?

  ensure_hash!(value, "dashboard")
  warn_unknown_keys(value, VALID_DASHBOARD_KEYS, "dashboard")
  Scalars.validate_optional_string(value[:project], "dashboard.project")
  Scalars.validate_optional_string(value[:base_url], "dashboard.base_url")
end

.validate_excludes(raw) ⇒ Object



33
34
35
# File 'lib/henitai/configuration_validator/rules.rb', line 33

def validate_excludes(raw)
  Scalars.validate_string_array(raw[:excludes], "excludes")
end

.validate_includes(raw) ⇒ Object



29
30
31
# File 'lib/henitai/configuration_validator/rules.rb', line 29

def validate_includes(raw)
  Scalars.validate_string_array(raw[:includes], "includes")
end

.validate_integration(raw) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/henitai/configuration_validator/rules.rb', line 19

def validate_integration(raw)
  value = raw[:integration]
  return if value.nil?
  return if value.is_a?(String)

  ensure_hash!(value, "integration")
  warn_unknown_keys(value, VALID_INTEGRATION_KEYS, "integration")
  Scalars.validate_optional_string(value[:name], "integration.name")
end

.validate_jobs(raw) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/henitai/configuration_validator/rules.rb', line 41

def validate_jobs(raw)
  value = raw[:jobs]
  return if value.nil?
  return if value.is_a?(Integer)

  configuration_error("Invalid configuration value for jobs: expected Integer, got #{value.class}")
end

.validate_mutation(raw) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
# File 'lib/henitai/configuration_validator/rules.rb', line 85

def validate_mutation(raw)
  value = raw[:mutation]
  return if value.nil?

  ensure_hash!(value, "mutation")
  warn_unknown_keys(value, VALID_MUTATION_KEYS, "mutation")
  Scalars.validate_operator(value[:operators])
  validate_mutation_limits(value)
  validate_mutation_filters(value)
  validate_sampling(value[:sampling])
end

.validate_mutation_filters(value) ⇒ Object



105
106
107
108
# File 'lib/henitai/configuration_validator/rules.rb', line 105

def validate_mutation_filters(value)
  Scalars.validate_string_array(value[:ignore_patterns], "mutation.ignore_patterns")
  Scalars.validate_ignore_patterns(value[:ignore_patterns])
end

.validate_mutation_limits(value) ⇒ Object



97
98
99
100
101
102
103
# File 'lib/henitai/configuration_validator/rules.rb', line 97

def validate_mutation_limits(value)
  Scalars.validate_timeout(value[:timeout])
  Scalars.validate_timeout_multiplier(value[:timeout_multiplier])
  Scalars.validate_max_flaky_retries(value[:max_flaky_retries])
  Scalars.validate_max_log_bytes(value[:max_log_bytes])
  Scalars.validate_max_timeout(value[:max_timeout])
end

.validate_reporters(raw) ⇒ Object



49
50
51
# File 'lib/henitai/configuration_validator/rules.rb', line 49

def validate_reporters(raw)
  Scalars.validate_string_array(raw[:reporters], "reporters")
end

.validate_reports(raw) ⇒ Object



57
58
59
60
61
62
63
64
65
66
# File 'lib/henitai/configuration_validator/rules.rb', line 57

def validate_reports(raw)
  value = raw[:reports]
  return if value.nil?

  ensure_hash!(value, "reports")
  warn_unknown_keys(value, VALID_REPORTS_KEYS, "reports")
  Scalars.validate_boolean(value[:checkpoint], "reports.checkpoint") unless value[:checkpoint].nil?
  Scalars.validate_checkpoint_every(value[:checkpoint_every])
  Scalars.validate_checkpoint_interval(value[:checkpoint_interval])
end

.validate_reports_dir(raw) ⇒ Object



53
54
55
# File 'lib/henitai/configuration_validator/rules.rb', line 53

def validate_reports_dir(raw)
  Scalars.validate_optional_string(raw[:reports_dir], "reports_dir")
end

.validate_sampling(value) ⇒ Object



128
129
130
131
132
133
134
135
136
# File 'lib/henitai/configuration_validator/rules.rb', line 128

def validate_sampling(value)
  return if value.nil?

  ensure_hash!(value, "mutation.sampling")
  warn_unknown_keys(value, VALID_SAMPLING_KEYS, "mutation.sampling")
  Scalars.validate_sampling_completeness(value)
  Scalars.validate_sampling_ratio(value[:ratio])
  Scalars.validate_sampling_strategy(value[:strategy])
end

.validate_test_excludes(raw) ⇒ Object



37
38
39
# File 'lib/henitai/configuration_validator/rules.rb', line 37

def validate_test_excludes(raw)
  Scalars.validate_string_array(raw[:test_excludes], "test_excludes")
end

.validate_thresholds(raw) ⇒ Object



119
120
121
122
123
124
125
126
# File 'lib/henitai/configuration_validator/rules.rb', line 119

def validate_thresholds(raw)
  value = raw[:thresholds]
  return if value.nil?

  ensure_hash!(value, "thresholds")
  warn_unknown_keys(value, VALID_THRESHOLDS_KEYS, "thresholds")
  value.each { |key, threshold| Scalars.validate_threshold(threshold, "thresholds.#{key}") }
end

.validate_top_level_keys(raw) ⇒ Object



15
16
17
# File 'lib/henitai/configuration_validator/rules.rb', line 15

def validate_top_level_keys(raw)
  warn_unknown_keys(raw, VALID_TOP_LEVEL_KEYS)
end

.warn_unknown_keys(raw, allowed_keys, path = nil) ⇒ Object



138
139
140
141
142
143
144
# File 'lib/henitai/configuration_validator/rules.rb', line 138

def warn_unknown_keys(raw, allowed_keys, path = nil)
  raw.each_key do |key|
    next if allowed_keys.include?(key)

    ConfigurationValidator.warn "Unknown configuration key: #{key_path(path, key)}"
  end
end

Instance Method Details

#self?.configuration_errorvoid

This method returns an undefined value.

Parameters:

  • (String)


35
# File 'sig/configuration_validator.rbs', line 35

def self?.configuration_error: (String) -> void

#self?.ensure_hash!void

This method returns an undefined value.

Parameters:

  • (Object)
  • (String)


34
# File 'sig/configuration_validator.rbs', line 34

def self?.ensure_hash!: (untyped, String) -> void

#self?.key_pathString

Parameters:

  • (String, nil)
  • (Symbol)

Returns:

  • (String)


33
# File 'sig/configuration_validator.rbs', line 33

def self?.key_path: (String?, Symbol) -> String

#self?.validate_all_logsvoid

This method returns an undefined value.

Parameters:

  • (Hash[Symbol, untyped])


24
# File 'sig/configuration_validator.rbs', line 24

def self?.validate_all_logs: (Hash[Symbol, untyped]) -> void

#self?.validate_coverage_criteriavoid

This method returns an undefined value.

Parameters:

  • (Hash[Symbol, untyped])


29
# File 'sig/configuration_validator.rbs', line 29

def self?.validate_coverage_criteria: (Hash[Symbol, untyped]) -> void

#self?.validate_dashboardvoid

This method returns an undefined value.

Parameters:

  • (Hash[Symbol, untyped])


25
# File 'sig/configuration_validator.rbs', line 25

def self?.validate_dashboard: (Hash[Symbol, untyped]) -> void

#self?.validate_excludesvoid

This method returns an undefined value.

Parameters:

  • (Hash[Symbol, untyped])


20
# File 'sig/configuration_validator.rbs', line 20

def self?.validate_excludes: (Hash[Symbol, untyped]) -> void

#self?.validate_includesvoid

This method returns an undefined value.

Parameters:

  • (Hash[Symbol, untyped])


19
# File 'sig/configuration_validator.rbs', line 19

def self?.validate_includes: (Hash[Symbol, untyped]) -> void

#self?.validate_integrationvoid

This method returns an undefined value.

Parameters:

  • (Hash[Symbol, untyped])


18
# File 'sig/configuration_validator.rbs', line 18

def self?.validate_integration: (Hash[Symbol, untyped]) -> void

#self?.validate_jobsvoid

This method returns an undefined value.

Parameters:

  • (Hash[Symbol, untyped])


21
# File 'sig/configuration_validator.rbs', line 21

def self?.validate_jobs: (Hash[Symbol, untyped]) -> void

#self?.validate_mutationvoid

This method returns an undefined value.

Parameters:

  • (Hash[Symbol, untyped])


26
# File 'sig/configuration_validator.rbs', line 26

def self?.validate_mutation: (Hash[Symbol, untyped]) -> void

#self?.validate_mutation_filtersvoid

This method returns an undefined value.

Parameters:

  • (Hash[Symbol, untyped])


28
# File 'sig/configuration_validator.rbs', line 28

def self?.validate_mutation_filters: (Hash[Symbol, untyped]) -> void

#self?.validate_mutation_limitsvoid

This method returns an undefined value.

Parameters:

  • (Hash[Symbol, untyped])


27
# File 'sig/configuration_validator.rbs', line 27

def self?.validate_mutation_limits: (Hash[Symbol, untyped]) -> void

#self?.validate_reportersvoid

This method returns an undefined value.

Parameters:

  • (Hash[Symbol, untyped])


22
# File 'sig/configuration_validator.rbs', line 22

def self?.validate_reporters: (Hash[Symbol, untyped]) -> void

#self?.validate_reports_dirvoid

This method returns an undefined value.

Parameters:

  • (Hash[Symbol, untyped])


23
# File 'sig/configuration_validator.rbs', line 23

def self?.validate_reports_dir: (Hash[Symbol, untyped]) -> void

#self?.validate_samplingvoid

This method returns an undefined value.

Parameters:

  • (Object)


31
# File 'sig/configuration_validator.rbs', line 31

def self?.validate_sampling: (untyped) -> void

#self?.validate_thresholdsvoid

This method returns an undefined value.

Parameters:

  • (Hash[Symbol, untyped])


30
# File 'sig/configuration_validator.rbs', line 30

def self?.validate_thresholds: (Hash[Symbol, untyped]) -> void

#self?.validate_top_level_keysvoid

This method returns an undefined value.

Parameters:

  • (Hash[Symbol, untyped])


17
# File 'sig/configuration_validator.rbs', line 17

def self?.validate_top_level_keys: (Hash[Symbol, untyped]) -> void

#self?.warn_unknown_keysvoid

This method returns an undefined value.

Parameters:

  • (Hash[Symbol, untyped])
  • (Array[Symbol])
  • (String, nil)


32
# File 'sig/configuration_validator.rbs', line 32

def self?.warn_unknown_keys: (Hash[Symbol, untyped], Array[Symbol], ?String?) -> void