Class: Aidp::Harness::FilterDefinition
- Inherits:
-
Object
- Object
- Aidp::Harness::FilterDefinition
- Defined in:
- lib/aidp/harness/filter_definition.rb
Overview
Value object representing a generated filter definition Created by AI during configuration, applied deterministically at runtime
Instance Attribute Summary collapse
-
#context_lines ⇒ Object
readonly
Returns the value of attribute context_lines.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#error_patterns ⇒ Object
readonly
Returns the value of attribute error_patterns.
-
#error_section_end ⇒ Object
readonly
Returns the value of attribute error_section_end.
-
#error_section_start ⇒ Object
readonly
Returns the value of attribute error_section_start.
-
#failure_section_end ⇒ Object
readonly
Returns the value of attribute failure_section_end.
-
#failure_section_start ⇒ Object
readonly
Returns the value of attribute failure_section_start.
-
#important_patterns ⇒ Object
readonly
Returns the value of attribute important_patterns.
-
#location_patterns ⇒ Object
readonly
Returns the value of attribute location_patterns.
-
#noise_patterns ⇒ Object
readonly
Returns the value of attribute noise_patterns.
-
#summary_patterns ⇒ Object
readonly
Returns the value of attribute summary_patterns.
-
#tool_command ⇒ Object
readonly
Returns the value of attribute tool_command.
-
#tool_name ⇒ Object
readonly
Returns the value of attribute tool_name.
Class Method Summary collapse
-
.from_hash(hash) ⇒ FilterDefinition
Create from a hash (e.g., loaded from YAML config).
Instance Method Summary collapse
-
#==(other) ⇒ Object
(also: #eql?)
Equality based on all attributes.
-
#error_line?(line) ⇒ Boolean
Check if a line matches any error pattern.
-
#extract_locations(line) ⇒ Array<String>
Extract file locations from a line.
-
#has_error_section? ⇒ Boolean
Check if this definition has error section markers.
-
#has_failure_section? ⇒ Boolean
Check if this definition has failure section markers.
- #hash ⇒ Object
-
#important_line?(line) ⇒ Boolean
Check if a line should always be kept.
-
#initialize(tool_name:, tool_command: nil, summary_patterns: [], failure_section_start: nil, failure_section_end: nil, error_section_start: nil, error_section_end: nil, error_patterns: [], location_patterns: [], noise_patterns: [], important_patterns: [], context_lines: 3, created_at: nil) ⇒ FilterDefinition
constructor
Initialize a filter definition.
-
#noise_line?(line) ⇒ Boolean
Check if a line should be filtered as noise.
-
#summary_line?(line) ⇒ Boolean
Check if a line matches any summary pattern.
-
#to_h ⇒ Hash
Convert to hash for serialization (e.g., saving to YAML).
Constructor Details
#initialize(tool_name:, tool_command: nil, summary_patterns: [], failure_section_start: nil, failure_section_end: nil, error_section_start: nil, error_section_end: nil, error_patterns: [], location_patterns: [], noise_patterns: [], important_patterns: [], context_lines: 3, created_at: nil) ⇒ FilterDefinition
Initialize a filter definition
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/aidp/harness/filter_definition.rb', line 42 def initialize( tool_name:, tool_command: nil, summary_patterns: [], failure_section_start: nil, failure_section_end: nil, error_section_start: nil, error_section_end: nil, error_patterns: [], location_patterns: [], noise_patterns: [], important_patterns: [], context_lines: 3, created_at: nil ) @tool_name = tool_name @tool_command = tool_command @summary_patterns = compile_patterns(summary_patterns) @failure_section_start = compile_pattern(failure_section_start) @failure_section_end = compile_pattern(failure_section_end) @error_section_start = compile_pattern(error_section_start) @error_section_end = compile_pattern(error_section_end) @error_patterns = compile_patterns(error_patterns) @location_patterns = compile_patterns(location_patterns) @noise_patterns = compile_patterns(noise_patterns) @important_patterns = compile_patterns(important_patterns) @context_lines = context_lines @created_at = created_at || Time.now freeze end |
Instance Attribute Details
#context_lines ⇒ Object (readonly)
Returns the value of attribute context_lines.
22 23 24 |
# File 'lib/aidp/harness/filter_definition.rb', line 22 def context_lines @context_lines end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
22 23 24 |
# File 'lib/aidp/harness/filter_definition.rb', line 22 def created_at @created_at end |
#error_patterns ⇒ Object (readonly)
Returns the value of attribute error_patterns.
22 23 24 |
# File 'lib/aidp/harness/filter_definition.rb', line 22 def error_patterns @error_patterns end |
#error_section_end ⇒ Object (readonly)
Returns the value of attribute error_section_end.
22 23 24 |
# File 'lib/aidp/harness/filter_definition.rb', line 22 def error_section_end @error_section_end end |
#error_section_start ⇒ Object (readonly)
Returns the value of attribute error_section_start.
22 23 24 |
# File 'lib/aidp/harness/filter_definition.rb', line 22 def error_section_start @error_section_start end |
#failure_section_end ⇒ Object (readonly)
Returns the value of attribute failure_section_end.
22 23 24 |
# File 'lib/aidp/harness/filter_definition.rb', line 22 def failure_section_end @failure_section_end end |
#failure_section_start ⇒ Object (readonly)
Returns the value of attribute failure_section_start.
22 23 24 |
# File 'lib/aidp/harness/filter_definition.rb', line 22 def failure_section_start @failure_section_start end |
#important_patterns ⇒ Object (readonly)
Returns the value of attribute important_patterns.
22 23 24 |
# File 'lib/aidp/harness/filter_definition.rb', line 22 def important_patterns @important_patterns end |
#location_patterns ⇒ Object (readonly)
Returns the value of attribute location_patterns.
22 23 24 |
# File 'lib/aidp/harness/filter_definition.rb', line 22 def location_patterns @location_patterns end |
#noise_patterns ⇒ Object (readonly)
Returns the value of attribute noise_patterns.
22 23 24 |
# File 'lib/aidp/harness/filter_definition.rb', line 22 def noise_patterns @noise_patterns end |
#summary_patterns ⇒ Object (readonly)
Returns the value of attribute summary_patterns.
22 23 24 |
# File 'lib/aidp/harness/filter_definition.rb', line 22 def summary_patterns @summary_patterns end |
#tool_command ⇒ Object (readonly)
Returns the value of attribute tool_command.
22 23 24 |
# File 'lib/aidp/harness/filter_definition.rb', line 22 def tool_command @tool_command end |
#tool_name ⇒ Object (readonly)
Returns the value of attribute tool_name.
22 23 24 |
# File 'lib/aidp/harness/filter_definition.rb', line 22 def tool_name @tool_name end |
Class Method Details
.from_hash(hash) ⇒ FilterDefinition
Create from a hash (e.g., loaded from YAML config)
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/aidp/harness/filter_definition.rb', line 78 def self.from_hash(hash) hash = hash.transform_keys(&:to_sym) new( tool_name: hash[:tool_name] || "unknown", tool_command: hash[:tool_command], summary_patterns: Array(hash[:summary_patterns]), failure_section_start: hash[:failure_section_start], failure_section_end: hash[:failure_section_end], error_section_start: hash[:error_section_start], error_section_end: hash[:error_section_end], error_patterns: Array(hash[:error_patterns]), location_patterns: Array(hash[:location_patterns]), noise_patterns: Array(hash[:noise_patterns]), important_patterns: Array(hash[:important_patterns]), context_lines: hash[:context_lines] || 3, created_at: hash[:created_at] ? Time.parse(hash[:created_at].to_s) : nil ) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
Equality based on all attributes
176 177 178 179 180 |
# File 'lib/aidp/harness/filter_definition.rb', line 176 def ==(other) return false unless other.is_a?(FilterDefinition) to_h == other.to_h end |
#error_line?(line) ⇒ Boolean
Check if a line matches any error pattern
145 146 147 |
# File 'lib/aidp/harness/filter_definition.rb', line 145 def error_line?(line) @error_patterns.any? { |pattern| line.match?(pattern) } end |
#extract_locations(line) ⇒ Array<String>
Extract file locations from a line
169 170 171 172 173 |
# File 'lib/aidp/harness/filter_definition.rb', line 169 def extract_locations(line) @location_patterns.flat_map do |pattern| line.scan(pattern).flatten end.compact.uniq end |
#has_error_section? ⇒ Boolean
Check if this definition has error section markers
129 130 131 |
# File 'lib/aidp/harness/filter_definition.rb', line 129 def has_error_section? !@error_section_start.nil? end |
#has_failure_section? ⇒ Boolean
Check if this definition has failure section markers
122 123 124 |
# File 'lib/aidp/harness/filter_definition.rb', line 122 def has_failure_section? !@failure_section_start.nil? end |
#hash ⇒ Object
184 185 186 |
# File 'lib/aidp/harness/filter_definition.rb', line 184 def hash to_h.hash end |
#important_line?(line) ⇒ Boolean
Check if a line should always be kept
161 162 163 |
# File 'lib/aidp/harness/filter_definition.rb', line 161 def important_line?(line) @important_patterns.any? { |pattern| line.match?(pattern) } end |
#noise_line?(line) ⇒ Boolean
Check if a line should be filtered as noise
153 154 155 |
# File 'lib/aidp/harness/filter_definition.rb', line 153 def noise_line?(line) @noise_patterns.any? { |pattern| line.match?(pattern) } end |
#summary_line?(line) ⇒ Boolean
Check if a line matches any summary pattern
137 138 139 |
# File 'lib/aidp/harness/filter_definition.rb', line 137 def summary_line?(line) @summary_patterns.any? { |pattern| line.match?(pattern) } end |
#to_h ⇒ Hash
Convert to hash for serialization (e.g., saving to YAML)
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/aidp/harness/filter_definition.rb', line 101 def to_h { tool_name: @tool_name, tool_command: @tool_command, summary_patterns: patterns_to_strings(@summary_patterns), failure_section_start: pattern_to_string(@failure_section_start), failure_section_end: pattern_to_string(@failure_section_end), error_section_start: pattern_to_string(@error_section_start), error_section_end: pattern_to_string(@error_section_end), error_patterns: patterns_to_strings(@error_patterns), location_patterns: patterns_to_strings(@location_patterns), noise_patterns: patterns_to_strings(@noise_patterns), important_patterns: patterns_to_strings(@important_patterns), context_lines: @context_lines, created_at: @created_at&.iso8601 }.compact end |