Class: Legion::Extensions::Agentic::Learning::Scaffolding::Helpers::Scaffold
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Learning::Scaffolding::Helpers::Scaffold
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/learning/scaffolding/helpers/scaffold.rb
Constant Summary
Constants included from Constants
Constants::COMPETENCE_CEILING, Constants::COMPETENCE_FLOOR, Constants::DECAY_RATE, Constants::DEFAULT_COMPETENCE, Constants::FADING_RATE, Constants::FAILURE_SETBACK, Constants::FRUSTRATION_THRESHOLD, Constants::LEARNING_GAIN, Constants::MASTERY_THRESHOLD, Constants::MAX_HISTORY, Constants::MAX_SCAFFOLDS, Constants::MAX_TASKS, Constants::SUPPORT_LEVELS, Constants::ZONE_LABELS, Constants::ZPD_LOWER, Constants::ZPD_UPPER
Instance Attribute Summary collapse
-
#competence ⇒ Object
readonly
Returns the value of attribute competence.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#last_practiced_at ⇒ Object
readonly
Returns the value of attribute last_practiced_at.
-
#practice_count ⇒ Object
readonly
Returns the value of attribute practice_count.
-
#skill_name ⇒ Object
readonly
Returns the value of attribute skill_name.
-
#support_level ⇒ Object
readonly
Returns the value of attribute support_level.
-
#task_history ⇒ Object
readonly
Returns the value of attribute task_history.
Instance Method Summary collapse
- #attempt_task(difficulty:, success:) ⇒ Object
- #current_zone ⇒ Object
- #fade_support! ⇒ Object
- #in_zpd? ⇒ Boolean
- #increase_support! ⇒ Object
-
#initialize(skill_name:, domain:, competence: DEFAULT_COMPETENCE) ⇒ Scaffold
constructor
A new instance of Scaffold.
- #mastered? ⇒ Boolean
- #recommended_difficulty ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(skill_name:, domain:, competence: DEFAULT_COMPETENCE) ⇒ Scaffold
Returns a new instance of Scaffold.
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/legion/extensions/agentic/learning/scaffolding/helpers/scaffold.rb', line 17 def initialize(skill_name:, domain:, competence: DEFAULT_COMPETENCE) @id = SecureRandom.uuid @skill_name = skill_name @domain = domain @competence = competence.to_f.clamp(COMPETENCE_FLOOR, COMPETENCE_CEILING) @support_level = initial_support_level @task_history = [] @practice_count = 0 @created_at = Time.now.utc @last_practiced_at = nil end |
Instance Attribute Details
#competence ⇒ Object (readonly)
Returns the value of attribute competence.
14 15 16 |
# File 'lib/legion/extensions/agentic/learning/scaffolding/helpers/scaffold.rb', line 14 def competence @competence end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
14 15 16 |
# File 'lib/legion/extensions/agentic/learning/scaffolding/helpers/scaffold.rb', line 14 def created_at @created_at end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
14 15 16 |
# File 'lib/legion/extensions/agentic/learning/scaffolding/helpers/scaffold.rb', line 14 def domain @domain end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
14 15 16 |
# File 'lib/legion/extensions/agentic/learning/scaffolding/helpers/scaffold.rb', line 14 def id @id end |
#last_practiced_at ⇒ Object (readonly)
Returns the value of attribute last_practiced_at.
14 15 16 |
# File 'lib/legion/extensions/agentic/learning/scaffolding/helpers/scaffold.rb', line 14 def last_practiced_at @last_practiced_at end |
#practice_count ⇒ Object (readonly)
Returns the value of attribute practice_count.
14 15 16 |
# File 'lib/legion/extensions/agentic/learning/scaffolding/helpers/scaffold.rb', line 14 def practice_count @practice_count end |
#skill_name ⇒ Object (readonly)
Returns the value of attribute skill_name.
14 15 16 |
# File 'lib/legion/extensions/agentic/learning/scaffolding/helpers/scaffold.rb', line 14 def skill_name @skill_name end |
#support_level ⇒ Object (readonly)
Returns the value of attribute support_level.
14 15 16 |
# File 'lib/legion/extensions/agentic/learning/scaffolding/helpers/scaffold.rb', line 14 def support_level @support_level end |
#task_history ⇒ Object (readonly)
Returns the value of attribute task_history.
14 15 16 |
# File 'lib/legion/extensions/agentic/learning/scaffolding/helpers/scaffold.rb', line 14 def task_history @task_history end |
Instance Method Details
#attempt_task(difficulty:, success:) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/legion/extensions/agentic/learning/scaffolding/helpers/scaffold.rb', line 29 def attempt_task(difficulty:, success:) diff = difficulty.to_f.clamp(COMPETENCE_FLOOR, COMPETENCE_CEILING) delta = compute_delta(difficulty: diff, success: success) @competence = (@competence + delta).clamp(COMPETENCE_FLOOR, COMPETENCE_CEILING) @practice_count += 1 @last_practiced_at = Time.now.utc record_task(difficulty: diff, success: success) adjust_support(success) @competence end |
#current_zone ⇒ Object
41 42 43 44 45 46 |
# File 'lib/legion/extensions/agentic/learning/scaffolding/helpers/scaffold.rb', line 41 def current_zone ZONE_LABELS.each do |range, label| return label if range.cover?(@competence) end :beyond_reach end |
#fade_support! ⇒ Object
52 53 54 55 56 57 |
# File 'lib/legion/extensions/agentic/learning/scaffolding/helpers/scaffold.rb', line 52 def fade_support! idx = SUPPORT_LEVELS.index(@support_level) || 0 return if idx >= SUPPORT_LEVELS.size - 1 @support_level = SUPPORT_LEVELS[idx + 1] end |
#in_zpd? ⇒ Boolean
70 71 72 |
# File 'lib/legion/extensions/agentic/learning/scaffolding/helpers/scaffold.rb', line 70 def in_zpd? @competence >= ZPD_LOWER && @competence < ZPD_UPPER end |
#increase_support! ⇒ Object
59 60 61 62 63 64 |
# File 'lib/legion/extensions/agentic/learning/scaffolding/helpers/scaffold.rb', line 59 def increase_support! idx = SUPPORT_LEVELS.index(@support_level) || (SUPPORT_LEVELS.size - 1) return if idx <= 0 @support_level = SUPPORT_LEVELS[idx - 1] end |
#mastered? ⇒ Boolean
66 67 68 |
# File 'lib/legion/extensions/agentic/learning/scaffolding/helpers/scaffold.rb', line 66 def mastered? @competence >= MASTERY_THRESHOLD end |
#recommended_difficulty ⇒ Object
48 49 50 |
# File 'lib/legion/extensions/agentic/learning/scaffolding/helpers/scaffold.rb', line 48 def recommended_difficulty (@competence + ((ZPD_UPPER - @competence) * 0.5)).clamp(COMPETENCE_FLOOR, COMPETENCE_CEILING) end |
#to_h ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/legion/extensions/agentic/learning/scaffolding/helpers/scaffold.rb', line 74 def to_h { id: @id, skill_name: @skill_name, domain: @domain, competence: @competence.round(4), support_level: @support_level, current_zone: current_zone, practice_count: @practice_count, mastered: mastered?, in_zpd: in_zpd?, created_at: @created_at, last_practiced_at: @last_practiced_at, task_history_size: @task_history.size } end |