Class: Ace::Review::Molecules::Strategies::FullStrategy
- Inherits:
-
Object
- Object
- Ace::Review::Molecules::Strategies::FullStrategy
- Defined in:
- lib/ace/review/molecules/strategies/full_strategy.rb
Overview
Full strategy - passes subject through without splitting
The simplest strategy that sends the entire subject as a single review unit. Suitable when the subject fits within the model’s context window (with safety margin for prompts and output).
Constant Summary collapse
- DEFAULT_CONTEXT_MARGIN =
Default safety margin - reserve this percentage of context for prompts and output Subject should fit within (1 - margin) of the model’s limit Can be overridden via config
0.15
Instance Method Summary collapse
-
#can_handle?(subject, model_context_limit) ⇒ Boolean
Check if this strategy can handle the given subject.
-
#initialize(config = {}) ⇒ FullStrategy
constructor
A new instance of FullStrategy.
-
#prepare(subject, context = {}) ⇒ Array<Hash>
Prepare the subject for review.
-
#strategy_name ⇒ Symbol
Strategy name for logging and debugging.
Constructor Details
#initialize(config = {}) ⇒ FullStrategy
Returns a new instance of FullStrategy.
29 30 31 32 33 |
# File 'lib/ace/review/molecules/strategies/full_strategy.rb', line 29 def initialize(config = {}) # Normalize keys to symbols for consistent access (supports YAML string keys) @config = normalize_config_keys(config) @context_margin = @config[:headroom] || DEFAULT_CONTEXT_MARGIN end |
Instance Method Details
#can_handle?(subject, model_context_limit) ⇒ Boolean
Check if this strategy can handle the given subject
Returns true if the estimated token count of the subject fits within the model’s context limit (with safety margin).
60 61 62 63 64 65 66 67 |
# File 'lib/ace/review/molecules/strategies/full_strategy.rb', line 60 def can_handle?(subject, model_context_limit) return false if subject.nil? || subject.empty? return false if model_context_limit.nil? || model_context_limit <= 0 estimated_tokens = Ace::Review::Atoms::TokenEstimator.estimate(subject) safe_limit = (model_context_limit * (1 - @context_margin)).to_i estimated_tokens < safe_limit end |
#prepare(subject, context = {}) ⇒ Array<Hash>
Prepare the subject for review
For the full strategy, this simply wraps the entire subject in a single review unit with appropriate metadata.
93 94 95 96 97 98 99 100 101 102 |
# File 'lib/ace/review/molecules/strategies/full_strategy.rb', line 93 def prepare(subject, context = {}) [{ content: subject, metadata: { strategy: :full, chunk_index: 0, total_chunks: 1 } }] end |
#strategy_name ⇒ Symbol
Strategy name for logging and debugging
107 108 109 |
# File 'lib/ace/review/molecules/strategies/full_strategy.rb', line 107 def strategy_name :full end |