Class: Ace::Review::Molecules::Strategies::FullStrategy

Inherits:
Object
  • Object
show all
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).

Examples:

Basic usage

strategy = FullStrategy.new
if strategy.can_handle?(subject, 128_000)
  units = strategy.prepare(subject, context)
  # units = [{ content: subject, metadata: { strategy: :full, ... } }]
end

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

Constructor Details

#initialize(config = {}) ⇒ FullStrategy

Returns a new instance of FullStrategy.

Parameters:

  • config (Hash) (defaults to: {})

    Strategy configuration

Options Hash (config):

  • :headroom (Float)

    Override the default context margin (0.0-1.0)



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).

Examples:

strategy.can_handle?("small code", 128_000)  #=> true
strategy.can_handle?(huge_codebase, 8_000)   #=> false

Parameters:

  • subject (String)

    The review subject text

  • model_context_limit (Integer)

    Model’s token limit

Returns:

  • (Boolean)

    true if subject fits within safe context window



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.

Examples:

Return format

[{
  content: "full subject...",
  metadata: {
    strategy: :full,
    chunk_index: 0,
    total_chunks: 1
  }
}]

Parameters:

  • subject (String)

    The review subject text

  • context (Hash) (defaults to: {})

    Review context (see below)

Options Hash (context):

  • :system_prompt (String)

    Base system prompt for the reviewer

  • :user_prompt (String)

    User instructions or focus areas

  • :model (String)

    Model identifier

  • :model_context_limit (Integer)

    Token limit for the model

  • :preset (Hash)

    Full preset configuration

  • :file_list (Array<String>)

    List of files being reviewed

Returns:

  • (Array<Hash>)

    Array with single review unit



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_nameSymbol

Strategy name for logging and debugging

Returns:

  • (Symbol)

    :full



107
108
109
# File 'lib/ace/review/molecules/strategies/full_strategy.rb', line 107

def strategy_name
  :full
end