Class: RailsAiBridge::Config::Introspection
- Inherits:
-
Object
- Object
- RailsAiBridge::Config::Introspection
- Defined in:
- lib/rails_ai_bridge/config/introspection.rb
Overview
Holds introspector selection, exclusion rules, and caching settings.
Instance Attribute Summary collapse
-
#additional_introspectors ⇒ Hash{Symbol => Class}
Additional custom introspector classes.
-
#cache_ttl ⇒ Integer
TTL in seconds for cached introspection results.
-
#cache_warm_on_boot ⇒ Boolean
Whether to pre-populate the introspection cache on Rails boot.
-
#core_models ⇒ Array<String>
Model class names tagged as +core_entity+ in semantic classification (AI focus).
-
#disabled_introspection_categories ⇒ Array<Symbol>
Product-level category keys that subtract introspectors at runtime.
-
#excluded_models ⇒ Array<String>
Model class names excluded from introspection.
-
#excluded_paths ⇒ Array<String>
Directory names excluded from code search.
-
#excluded_tables ⇒ Array<String>
Table names/patterns excluded from schema introspection.
-
#expose_credentials_key_names ⇒ Boolean
Include credential key names in config introspection output.
-
#introspectors ⇒ Array<Symbol>
Active introspector keys.
-
#parallel_introspection ⇒ Boolean
Whether to run introspectors concurrently (requires concurrent-ruby).
-
#parallel_pool_size ⇒ Integer
Maximum number of threads in the parallel execution pool.
-
#parallel_timeout_seconds ⇒ Integer
Seconds to wait for each introspector future and for the thread pool to shut down cleanly.
-
#preset ⇒ Symbol?
Returns the active preset name, or +nil+ if introspectors were modified directly.
-
#search_code_allowed_file_types ⇒ Array<String>
Extra file extensions allowed for rails_search_code.
-
#search_code_pattern_max_bytes ⇒ Integer
Maximum +pattern+ size in bytes for Tools::SearchCode (ReDoS / abuse guard).
-
#search_code_timeout_seconds ⇒ Float
Seconds before Tools::SearchCode aborts (+0+ disables the timeout).
-
#snapshot_ttl ⇒ Integer
TTL in seconds for fingerprint snapshot caching (avoids redundant filesystem walks).
Instance Method Summary collapse
-
#effective_introspectors ⇒ Array<Symbol>
Introspectors after removing those disabled by #disabled_introspection_categories.
-
#excluded_table?(table_name) ⇒ Boolean
Whether a table name matches any #excluded_tables pattern (exact or glob).
-
#initialize ⇒ Introspection
constructor
Initializes Introspection configuration with sensible defaults.
Constructor Details
#initialize ⇒ Introspection
Initializes Introspection configuration with sensible defaults.
| Attribute | Default |
|---|---|
| +introspectors+ | +Configuration::PRESETS[:standard].dup+ |
| +preset+ | +:standard+ |
| +excluded_paths+ | +%w[node_modules tmp log vendor .git]+ |
| +excluded_models+ | common Rails/ActiveStorage/Action* class names |
| +core_models+ | +[]+ |
| +excluded_tables+ | +[]+ |
| +disabled_introspection_categories+ | +[]+ |
| +cache_ttl+ | +30+ (seconds) |
| +expose_credentials_key_names+ | +false+ |
| +additional_introspectors+ | +{}+ |
| +search_code_allowed_file_types+ | +[]+ |
| +search_code_pattern_max_bytes+ | +2048+ |
| +search_code_timeout_seconds+ | +5.0+ |
| +snapshot_ttl+ | +5+ (seconds) |
| +cache_warm_on_boot+ | +false+ |
| +parallel_introspection+ | +false+ |
| +parallel_pool_size+ | +4+ (threads) |
| +parallel_timeout_seconds+ | +10+ (seconds per-future and pool shutdown) |
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/rails_ai_bridge/config/introspection.rb', line 97 def initialize @introspectors = Configuration::PRESETS[:standard].dup @preset = :standard @excluded_paths = %w[node_modules tmp log vendor .git] @excluded_models = %w[ ApplicationRecord ActiveStorage::Blob ActiveStorage::Attachment ActiveStorage::VariantRecord ActionText::RichText ActionText::EncryptedRichText ActionMailbox::InboundEmail ActionMailbox::Record ] @core_models = [] @excluded_tables = [] @disabled_introspection_categories = [] @cache_ttl = 30 @expose_credentials_key_names = false @additional_introspectors = {} @search_code_allowed_file_types = [] @search_code_pattern_max_bytes = 2048 @search_code_timeout_seconds = 5.0 @snapshot_ttl = 5 @cache_warm_on_boot = false @parallel_introspection = false @parallel_pool_size = 4 @parallel_timeout_seconds = 10 end |
Instance Attribute Details
#additional_introspectors ⇒ Hash{Symbol => Class}
Returns additional custom introspector classes.
43 44 45 |
# File 'lib/rails_ai_bridge/config/introspection.rb', line 43 def additional_introspectors @additional_introspectors end |
#cache_ttl ⇒ Integer
Returns TTL in seconds for cached introspection results.
37 38 39 |
# File 'lib/rails_ai_bridge/config/introspection.rb', line 37 def cache_ttl @cache_ttl end |
#cache_warm_on_boot ⇒ Boolean
Returns whether to pre-populate the introspection cache on Rails boot.
58 59 60 |
# File 'lib/rails_ai_bridge/config/introspection.rb', line 58 def cache_warm_on_boot @cache_warm_on_boot end |
#core_models ⇒ Array<String>
Returns model class names tagged as +core_entity+ in semantic classification (AI focus).
28 29 30 |
# File 'lib/rails_ai_bridge/config/introspection.rb', line 28 def core_models @core_models end |
#disabled_introspection_categories ⇒ Array<Symbol>
Returns product-level category keys that subtract introspectors at runtime.
34 35 36 |
# File 'lib/rails_ai_bridge/config/introspection.rb', line 34 def disabled_introspection_categories @disabled_introspection_categories end |
#excluded_models ⇒ Array<String>
Returns model class names excluded from introspection.
25 26 27 |
# File 'lib/rails_ai_bridge/config/introspection.rb', line 25 def excluded_models @excluded_models end |
#excluded_paths ⇒ Array<String>
Returns directory names excluded from code search.
22 23 24 |
# File 'lib/rails_ai_bridge/config/introspection.rb', line 22 def excluded_paths @excluded_paths end |
#excluded_tables ⇒ Array<String>
Returns table names/patterns excluded from schema introspection.
31 32 33 |
# File 'lib/rails_ai_bridge/config/introspection.rb', line 31 def excluded_tables @excluded_tables end |
#expose_credentials_key_names ⇒ Boolean
Returns include credential key names in config introspection output.
40 41 42 |
# File 'lib/rails_ai_bridge/config/introspection.rb', line 40 def expose_credentials_key_names @expose_credentials_key_names end |
#introspectors ⇒ Array<Symbol>
Returns active introspector keys.
8 9 10 |
# File 'lib/rails_ai_bridge/config/introspection.rb', line 8 def introspectors @introspectors end |
#parallel_introspection ⇒ Boolean
Returns whether to run introspectors concurrently (requires concurrent-ruby).
61 62 63 |
# File 'lib/rails_ai_bridge/config/introspection.rb', line 61 def parallel_introspection @parallel_introspection end |
#parallel_pool_size ⇒ Integer
Returns maximum number of threads in the parallel execution pool. Capped at the number of introspectors so no idle threads are created. Default is +4+. Only relevant when #parallel_introspection is +true+.
66 67 68 |
# File 'lib/rails_ai_bridge/config/introspection.rb', line 66 def parallel_pool_size @parallel_pool_size end |
#parallel_timeout_seconds ⇒ Integer
Returns seconds to wait for each introspector future and for the thread pool to shut down cleanly. Introspectors that exceed this budget have their result replaced with +{ error: "timed out after Ns" }+. Default is +10+. Only relevant when #parallel_introspection is +true+.
72 73 74 |
# File 'lib/rails_ai_bridge/config/introspection.rb', line 72 def parallel_timeout_seconds @parallel_timeout_seconds end |
#preset ⇒ Symbol?
Returns the active preset name, or +nil+ if introspectors were modified directly.
138 139 140 |
# File 'lib/rails_ai_bridge/config/introspection.rb', line 138 def preset @preset end |
#search_code_allowed_file_types ⇒ Array<String>
Returns extra file extensions allowed for rails_search_code.
46 47 48 |
# File 'lib/rails_ai_bridge/config/introspection.rb', line 46 def search_code_allowed_file_types @search_code_allowed_file_types end |
#search_code_pattern_max_bytes ⇒ Integer
Returns maximum +pattern+ size in bytes for Tools::SearchCode (ReDoS / abuse guard).
49 50 51 |
# File 'lib/rails_ai_bridge/config/introspection.rb', line 49 def search_code_pattern_max_bytes @search_code_pattern_max_bytes end |
#search_code_timeout_seconds ⇒ Float
Returns seconds before Tools::SearchCode aborts (+0+ disables the timeout).
52 53 54 |
# File 'lib/rails_ai_bridge/config/introspection.rb', line 52 def search_code_timeout_seconds @search_code_timeout_seconds end |
#snapshot_ttl ⇒ Integer
Returns TTL in seconds for fingerprint snapshot caching (avoids redundant filesystem walks).
55 56 57 |
# File 'lib/rails_ai_bridge/config/introspection.rb', line 55 def snapshot_ttl @snapshot_ttl end |
Instance Method Details
#effective_introspectors ⇒ Array<Symbol>
Introspectors after removing those disabled by #disabled_introspection_categories.
143 144 145 146 147 148 |
# File 'lib/rails_ai_bridge/config/introspection.rb', line 143 def effective_introspectors disabled = @disabled_introspection_categories.flat_map do |c| Configuration::INTROSPECTION_CATEGORY_INTROSPECTORS[c.to_sym] || [] end.uniq @introspectors.reject { |i| disabled.include?(i) } end |
#excluded_table?(table_name) ⇒ Boolean
Whether a table name matches any #excluded_tables pattern (exact or glob).
154 155 156 157 158 |
# File 'lib/rails_ai_bridge/config/introspection.rb', line 154 def excluded_table?(table_name) return false if table_name.nil? || table_name.to_s.empty? @excluded_tables.any? { |pat| ExclusionHelper.table_pattern_match?(pat.to_s, table_name.to_s) } end |