Class: RubynCode::Learning::Instinct

Inherits:
Data
  • Object
show all
Defined in:
lib/rubyn_code/learning/instinct.rb

Overview

Represents a learned pattern with confidence tracking and time-based decay.

Instincts are project-scoped patterns extracted from user sessions that can be injected into future system prompts to improve agent behavior.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, project_path:, pattern:, context_tags: [], confidence: 0.5, decay_rate: 0.05, times_applied: 0, times_helpful: 0, created_at: Time.now, updated_at: Time.now) ⇒ Instinct

Returns a new instance of Instinct.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/rubyn_code/learning/instinct.rb', line 23

def initialize(id:, project_path:, pattern:, context_tags: [], confidence: 0.5,
               decay_rate: 0.05, times_applied: 0, times_helpful: 0,
               created_at: Time.now, updated_at: Time.now)
  super(
    id: id,
    project_path: project_path,
    pattern: pattern,
    context_tags: Array(context_tags),
    confidence: confidence.to_f.clamp(0.0, 1.0),
    decay_rate: decay_rate.to_f,
    times_applied: times_applied.to_i,
    times_helpful: times_helpful.to_i,
    created_at: created_at,
    updated_at: updated_at
  )
end

Instance Attribute Details

#confidenceObject (readonly)

Returns the value of attribute confidence

Returns:

  • (Object)

    the current value of confidence



11
12
13
# File 'lib/rubyn_code/learning/instinct.rb', line 11

def confidence
  @confidence
end

#context_tagsObject (readonly)

Returns the value of attribute context_tags

Returns:

  • (Object)

    the current value of context_tags



11
12
13
# File 'lib/rubyn_code/learning/instinct.rb', line 11

def context_tags
  @context_tags
end

#created_atObject (readonly)

Returns the value of attribute created_at

Returns:

  • (Object)

    the current value of created_at



11
12
13
# File 'lib/rubyn_code/learning/instinct.rb', line 11

def created_at
  @created_at
end

#decay_rateObject (readonly)

Returns the value of attribute decay_rate

Returns:

  • (Object)

    the current value of decay_rate



11
12
13
# File 'lib/rubyn_code/learning/instinct.rb', line 11

def decay_rate
  @decay_rate
end

#idObject (readonly)

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



11
12
13
# File 'lib/rubyn_code/learning/instinct.rb', line 11

def id
  @id
end

#patternObject (readonly)

Returns the value of attribute pattern

Returns:

  • (Object)

    the current value of pattern



11
12
13
# File 'lib/rubyn_code/learning/instinct.rb', line 11

def pattern
  @pattern
end

#project_pathObject (readonly)

Returns the value of attribute project_path

Returns:

  • (Object)

    the current value of project_path



11
12
13
# File 'lib/rubyn_code/learning/instinct.rb', line 11

def project_path
  @project_path
end

#times_appliedObject (readonly)

Returns the value of attribute times_applied

Returns:

  • (Object)

    the current value of times_applied



11
12
13
# File 'lib/rubyn_code/learning/instinct.rb', line 11

def times_applied
  @times_applied
end

#times_helpfulObject (readonly)

Returns the value of attribute times_helpful

Returns:

  • (Object)

    the current value of times_helpful



11
12
13
# File 'lib/rubyn_code/learning/instinct.rb', line 11

def times_helpful
  @times_helpful
end

#updated_atObject (readonly)

Returns the value of attribute updated_at

Returns:

  • (Object)

    the current value of updated_at



11
12
13
# File 'lib/rubyn_code/learning/instinct.rb', line 11

def updated_at
  @updated_at
end