Class: RosettAi::Project::DriftDetector
- Inherits:
-
Object
- Object
- RosettAi::Project::DriftDetector
- Defined in:
- lib/rosett_ai/project/drift_detector.rb
Overview
Detects configuration drift in rosett-ai-managed projects.
Supports two drift types:
- Forward drift: source YAML differs from compiled native config
- Template drift: project config differs from template baseline
Constant Summary collapse
- DRIFT_TYPES =
['forward', 'template'].freeze
Instance Method Summary collapse
-
#detect(type: nil) ⇒ Hash
Detects drift of the specified type.
-
#drifted?(type: nil) ⇒ Boolean
True if any drift detected.
-
#initialize(project_root:) ⇒ DriftDetector
constructor
A new instance of DriftDetector.
Constructor Details
#initialize(project_root:) ⇒ DriftDetector
Returns a new instance of DriftDetector.
23 24 25 26 |
# File 'lib/rosett_ai/project/drift_detector.rb', line 23 def initialize(project_root:) @project_root = project_root @project_dir = project_root.join('.rosett-ai') end |
Instance Method Details
#detect(type: nil) ⇒ Hash
Detects drift of the specified type.
32 33 34 35 36 37 38 39 40 |
# File 'lib/rosett_ai/project/drift_detector.rb', line 32 def detect(type: nil) results = {} results[:forward] = detect_forward_drift if type.nil? || type == 'forward' results[:template] = detect_template_drift if type.nil? || type == 'template' results end |
#drifted?(type: nil) ⇒ Boolean
Returns true if any drift detected.
43 44 45 46 |
# File 'lib/rosett_ai/project/drift_detector.rb', line 43 def drifted?(type: nil) results = detect(type: type) results.values.any?(&:any?) end |