lex-agentic-executive 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +12 -0
- data/Gemfile +5 -0
- data/LICENSE +21 -0
- data/README.md +13 -0
- data/lex-agentic-executive.gemspec +30 -0
- data/lib/legion/extensions/agentic/executive/autopilot/client.rb +19 -0
- data/lib/legion/extensions/agentic/executive/autopilot/helpers/autopilot_engine.rb +161 -0
- data/lib/legion/extensions/agentic/executive/autopilot/helpers/constants.rb +62 -0
- data/lib/legion/extensions/agentic/executive/autopilot/helpers/mode_event.rb +51 -0
- data/lib/legion/extensions/agentic/executive/autopilot/helpers/routine.rb +91 -0
- data/lib/legion/extensions/agentic/executive/autopilot/runners/cognitive_autopilot.rb +93 -0
- data/lib/legion/extensions/agentic/executive/autopilot/version.rb +13 -0
- data/lib/legion/extensions/agentic/executive/autopilot.rb +20 -0
- data/lib/legion/extensions/agentic/executive/chunking/client.rb +21 -0
- data/lib/legion/extensions/agentic/executive/chunking/helpers/chunk.rb +92 -0
- data/lib/legion/extensions/agentic/executive/chunking/helpers/chunking_engine.rb +147 -0
- data/lib/legion/extensions/agentic/executive/chunking/helpers/constants.rb +56 -0
- data/lib/legion/extensions/agentic/executive/chunking/helpers/information_item.rb +51 -0
- data/lib/legion/extensions/agentic/executive/chunking/runners/cognitive_chunking.rb +111 -0
- data/lib/legion/extensions/agentic/executive/chunking/version.rb +13 -0
- data/lib/legion/extensions/agentic/executive/chunking.rb +21 -0
- data/lib/legion/extensions/agentic/executive/cognitive_debt/client.rb +28 -0
- data/lib/legion/extensions/agentic/executive/cognitive_debt/helpers/constants.rb +36 -0
- data/lib/legion/extensions/agentic/executive/cognitive_debt/helpers/debt_engine.rb +118 -0
- data/lib/legion/extensions/agentic/executive/cognitive_debt/helpers/debt_item.rb +83 -0
- data/lib/legion/extensions/agentic/executive/cognitive_debt/runners/cognitive_debt.rb +84 -0
- data/lib/legion/extensions/agentic/executive/cognitive_debt/version.rb +13 -0
- data/lib/legion/extensions/agentic/executive/cognitive_debt.rb +19 -0
- data/lib/legion/extensions/agentic/executive/compass/client.rb +15 -0
- data/lib/legion/extensions/agentic/executive/compass/helpers/bearing.rb +79 -0
- data/lib/legion/extensions/agentic/executive/compass/helpers/compass_engine.rb +108 -0
- data/lib/legion/extensions/agentic/executive/compass/helpers/constants.rb +65 -0
- data/lib/legion/extensions/agentic/executive/compass/helpers/magnetic_bias.rb +81 -0
- data/lib/legion/extensions/agentic/executive/compass/runners/cognitive_compass.rb +76 -0
- data/lib/legion/extensions/agentic/executive/compass/version.rb +13 -0
- data/lib/legion/extensions/agentic/executive/compass.rb +22 -0
- data/lib/legion/extensions/agentic/executive/control/client.rb +19 -0
- data/lib/legion/extensions/agentic/executive/control/helpers/constants.rb +45 -0
- data/lib/legion/extensions/agentic/executive/control/helpers/control_signal.rb +79 -0
- data/lib/legion/extensions/agentic/executive/control/helpers/controller.rb +140 -0
- data/lib/legion/extensions/agentic/executive/control/helpers/goal.rb +72 -0
- data/lib/legion/extensions/agentic/executive/control/runners/cognitive_control.rb +74 -0
- data/lib/legion/extensions/agentic/executive/control/version.rb +13 -0
- data/lib/legion/extensions/agentic/executive/control.rb +21 -0
- data/lib/legion/extensions/agentic/executive/decision_fatigue/client.rb +28 -0
- data/lib/legion/extensions/agentic/executive/decision_fatigue/helpers/constants.rb +51 -0
- data/lib/legion/extensions/agentic/executive/decision_fatigue/helpers/decision_record.rb +50 -0
- data/lib/legion/extensions/agentic/executive/decision_fatigue/helpers/fatigue_engine.rb +114 -0
- data/lib/legion/extensions/agentic/executive/decision_fatigue/runners/decision_fatigue.rb +94 -0
- data/lib/legion/extensions/agentic/executive/decision_fatigue/version.rb +13 -0
- data/lib/legion/extensions/agentic/executive/decision_fatigue.rb +19 -0
- data/lib/legion/extensions/agentic/executive/disengagement/client.rb +24 -0
- data/lib/legion/extensions/agentic/executive/disengagement/helpers/constants.rb +48 -0
- data/lib/legion/extensions/agentic/executive/disengagement/helpers/disengagement_engine.rb +101 -0
- data/lib/legion/extensions/agentic/executive/disengagement/helpers/goal.rb +105 -0
- data/lib/legion/extensions/agentic/executive/disengagement/runners/cognitive_disengagement.rb +90 -0
- data/lib/legion/extensions/agentic/executive/disengagement/version.rb +13 -0
- data/lib/legion/extensions/agentic/executive/disengagement.rb +19 -0
- data/lib/legion/extensions/agentic/executive/dissonance_resolution/client.rb +19 -0
- data/lib/legion/extensions/agentic/executive/dissonance_resolution/helpers/constants.rb +38 -0
- data/lib/legion/extensions/agentic/executive/dissonance_resolution/helpers/dissonance_conflict.rb +90 -0
- data/lib/legion/extensions/agentic/executive/dissonance_resolution/helpers/resolution_engine.rb +155 -0
- data/lib/legion/extensions/agentic/executive/dissonance_resolution/runners/cognitive_dissonance_resolution.rb +74 -0
- data/lib/legion/extensions/agentic/executive/dissonance_resolution/version.rb +13 -0
- data/lib/legion/extensions/agentic/executive/dissonance_resolution.rb +19 -0
- data/lib/legion/extensions/agentic/executive/dual_process/client.rb +25 -0
- data/lib/legion/extensions/agentic/executive/dual_process/helpers/constants.rb +44 -0
- data/lib/legion/extensions/agentic/executive/dual_process/helpers/decision.rb +50 -0
- data/lib/legion/extensions/agentic/executive/dual_process/helpers/dual_process_engine.rb +200 -0
- data/lib/legion/extensions/agentic/executive/dual_process/helpers/heuristic.rb +67 -0
- data/lib/legion/extensions/agentic/executive/dual_process/runners/dual_process.rb +87 -0
- data/lib/legion/extensions/agentic/executive/dual_process/version.rb +13 -0
- data/lib/legion/extensions/agentic/executive/dual_process.rb +20 -0
- data/lib/legion/extensions/agentic/executive/dwell/client.rb +19 -0
- data/lib/legion/extensions/agentic/executive/dwell/helpers/constants.rb +65 -0
- data/lib/legion/extensions/agentic/executive/dwell/helpers/dwell_engine.rb +126 -0
- data/lib/legion/extensions/agentic/executive/dwell/helpers/dwell_topic.rb +119 -0
- data/lib/legion/extensions/agentic/executive/dwell/runners/cognitive_dwell.rb +87 -0
- data/lib/legion/extensions/agentic/executive/dwell/version.rb +13 -0
- data/lib/legion/extensions/agentic/executive/dwell.rb +19 -0
- data/lib/legion/extensions/agentic/executive/executive_function/actors/recovery.rb +45 -0
- data/lib/legion/extensions/agentic/executive/executive_function/client.rb +27 -0
- data/lib/legion/extensions/agentic/executive/executive_function/helpers/ef_component.rb +58 -0
- data/lib/legion/extensions/agentic/executive/executive_function/helpers/executive_controller.rb +129 -0
- data/lib/legion/extensions/agentic/executive/executive_function/runners/executive_function.rb +104 -0
- data/lib/legion/extensions/agentic/executive/executive_function/version.rb +13 -0
- data/lib/legion/extensions/agentic/executive/executive_function.rb +18 -0
- data/lib/legion/extensions/agentic/executive/flexibility/actors/tick.rb +31 -0
- data/lib/legion/extensions/agentic/executive/flexibility/client.rb +28 -0
- data/lib/legion/extensions/agentic/executive/flexibility/helpers/constants.rb +39 -0
- data/lib/legion/extensions/agentic/executive/flexibility/helpers/flexibility_engine.rb +109 -0
- data/lib/legion/extensions/agentic/executive/flexibility/helpers/task_set.rb +69 -0
- data/lib/legion/extensions/agentic/executive/flexibility/runners/cognitive_flexibility.rb +77 -0
- data/lib/legion/extensions/agentic/executive/flexibility/version.rb +13 -0
- data/lib/legion/extensions/agentic/executive/flexibility.rb +19 -0
- data/lib/legion/extensions/agentic/executive/flexibility_training/client.rb +29 -0
- data/lib/legion/extensions/agentic/executive/flexibility_training/helpers/constants.rb +57 -0
- data/lib/legion/extensions/agentic/executive/flexibility_training/helpers/flexibility_engine.rb +178 -0
- data/lib/legion/extensions/agentic/executive/flexibility_training/helpers/switch_trial.rb +54 -0
- data/lib/legion/extensions/agentic/executive/flexibility_training/helpers/training_task.rb +54 -0
- data/lib/legion/extensions/agentic/executive/flexibility_training/runners/cognitive_flexibility_training.rb +134 -0
- data/lib/legion/extensions/agentic/executive/flexibility_training/version.rb +13 -0
- data/lib/legion/extensions/agentic/executive/flexibility_training.rb +20 -0
- data/lib/legion/extensions/agentic/executive/goal_management/client.rb +28 -0
- data/lib/legion/extensions/agentic/executive/goal_management/helpers/constants.rb +49 -0
- data/lib/legion/extensions/agentic/executive/goal_management/helpers/goal.rb +153 -0
- data/lib/legion/extensions/agentic/executive/goal_management/helpers/goal_engine.rb +265 -0
- data/lib/legion/extensions/agentic/executive/goal_management/runners/goal_management.rb +169 -0
- data/lib/legion/extensions/agentic/executive/goal_management/version.rb +13 -0
- data/lib/legion/extensions/agentic/executive/goal_management.rb +19 -0
- data/lib/legion/extensions/agentic/executive/inertia/client.rb +15 -0
- data/lib/legion/extensions/agentic/executive/inertia/helpers/belief.rb +99 -0
- data/lib/legion/extensions/agentic/executive/inertia/helpers/constants.rb +45 -0
- data/lib/legion/extensions/agentic/executive/inertia/helpers/inertia_engine.rb +111 -0
- data/lib/legion/extensions/agentic/executive/inertia/runners/cognitive_inertia.rb +74 -0
- data/lib/legion/extensions/agentic/executive/inertia/version.rb +13 -0
- data/lib/legion/extensions/agentic/executive/inertia.rb +19 -0
- data/lib/legion/extensions/agentic/executive/inhibition/client.rb +27 -0
- data/lib/legion/extensions/agentic/executive/inhibition/helpers/constants.rb +36 -0
- data/lib/legion/extensions/agentic/executive/inhibition/helpers/impulse.rb +37 -0
- data/lib/legion/extensions/agentic/executive/inhibition/helpers/inhibition_model.rb +122 -0
- data/lib/legion/extensions/agentic/executive/inhibition/helpers/inhibition_store.rb +72 -0
- data/lib/legion/extensions/agentic/executive/inhibition/runners/inhibition.rb +155 -0
- data/lib/legion/extensions/agentic/executive/inhibition/version.rb +13 -0
- data/lib/legion/extensions/agentic/executive/inhibition.rb +20 -0
- data/lib/legion/extensions/agentic/executive/load/client.rb +25 -0
- data/lib/legion/extensions/agentic/executive/load/helpers/constants.rb +36 -0
- data/lib/legion/extensions/agentic/executive/load/helpers/load_model.rb +146 -0
- data/lib/legion/extensions/agentic/executive/load/runners/cognitive_load.rb +120 -0
- data/lib/legion/extensions/agentic/executive/load/version.rb +13 -0
- data/lib/legion/extensions/agentic/executive/load.rb +18 -0
- data/lib/legion/extensions/agentic/executive/load_balancing/client.rb +19 -0
- data/lib/legion/extensions/agentic/executive/load_balancing/helpers/constants.rb +44 -0
- data/lib/legion/extensions/agentic/executive/load_balancing/helpers/load_balancer.rb +137 -0
- data/lib/legion/extensions/agentic/executive/load_balancing/helpers/subsystem.rb +101 -0
- data/lib/legion/extensions/agentic/executive/load_balancing/runners/cognitive_load_balancing.rb +69 -0
- data/lib/legion/extensions/agentic/executive/load_balancing/version.rb +13 -0
- data/lib/legion/extensions/agentic/executive/load_balancing.rb +19 -0
- data/lib/legion/extensions/agentic/executive/planning/client.rb +27 -0
- data/lib/legion/extensions/agentic/executive/planning/helpers/constants.rb +26 -0
- data/lib/legion/extensions/agentic/executive/planning/helpers/plan.rb +110 -0
- data/lib/legion/extensions/agentic/executive/planning/helpers/plan_step.rb +82 -0
- data/lib/legion/extensions/agentic/executive/planning/helpers/plan_store.rb +161 -0
- data/lib/legion/extensions/agentic/executive/planning/runners/planning.rb +123 -0
- data/lib/legion/extensions/agentic/executive/planning/version.rb +13 -0
- data/lib/legion/extensions/agentic/executive/planning.rb +20 -0
- data/lib/legion/extensions/agentic/executive/prospective_memory/client.rb +28 -0
- data/lib/legion/extensions/agentic/executive/prospective_memory/helpers/constants.rb +32 -0
- data/lib/legion/extensions/agentic/executive/prospective_memory/helpers/intention.rb +94 -0
- data/lib/legion/extensions/agentic/executive/prospective_memory/helpers/prospective_engine.rb +157 -0
- data/lib/legion/extensions/agentic/executive/prospective_memory/runners/prospective_memory.rb +146 -0
- data/lib/legion/extensions/agentic/executive/prospective_memory/version.rb +13 -0
- data/lib/legion/extensions/agentic/executive/prospective_memory.rb +19 -0
- data/lib/legion/extensions/agentic/executive/triage/client.rb +19 -0
- data/lib/legion/extensions/agentic/executive/triage/helpers/constants.rb +70 -0
- data/lib/legion/extensions/agentic/executive/triage/helpers/demand.rb +101 -0
- data/lib/legion/extensions/agentic/executive/triage/helpers/triage_engine.rb +150 -0
- data/lib/legion/extensions/agentic/executive/triage/runners/cognitive_triage.rb +110 -0
- data/lib/legion/extensions/agentic/executive/triage/version.rb +13 -0
- data/lib/legion/extensions/agentic/executive/triage.rb +19 -0
- data/lib/legion/extensions/agentic/executive/version.rb +11 -0
- data/lib/legion/extensions/agentic/executive/volition/client.rb +27 -0
- data/lib/legion/extensions/agentic/executive/volition/helpers/constants.rb +51 -0
- data/lib/legion/extensions/agentic/executive/volition/helpers/drive_synthesizer.rb +158 -0
- data/lib/legion/extensions/agentic/executive/volition/helpers/intention.rb +56 -0
- data/lib/legion/extensions/agentic/executive/volition/helpers/intention_stack.rb +140 -0
- data/lib/legion/extensions/agentic/executive/volition/runners/volition.rb +129 -0
- data/lib/legion/extensions/agentic/executive/volition/version.rb +13 -0
- data/lib/legion/extensions/agentic/executive/volition.rb +20 -0
- data/lib/legion/extensions/agentic/executive/working_memory/client.rb +21 -0
- data/lib/legion/extensions/agentic/executive/working_memory/helpers/buffer.rb +124 -0
- data/lib/legion/extensions/agentic/executive/working_memory/helpers/buffer_item.rb +72 -0
- data/lib/legion/extensions/agentic/executive/working_memory/helpers/constants.rb +47 -0
- data/lib/legion/extensions/agentic/executive/working_memory/runners/working_memory.rb +102 -0
- data/lib/legion/extensions/agentic/executive/working_memory/version.rb +13 -0
- data/lib/legion/extensions/agentic/executive/working_memory.rb +19 -0
- data/lib/legion/extensions/agentic/executive.rb +40 -0
- data/spec/legion/extensions/agentic/executive/autopilot/client_spec.rb +21 -0
- data/spec/legion/extensions/agentic/executive/autopilot/cognitive_autopilot_spec.rb +7 -0
- data/spec/legion/extensions/agentic/executive/autopilot/helpers/autopilot_engine_spec.rb +166 -0
- data/spec/legion/extensions/agentic/executive/autopilot/helpers/constants_spec.rb +37 -0
- data/spec/legion/extensions/agentic/executive/autopilot/helpers/mode_event_spec.rb +30 -0
- data/spec/legion/extensions/agentic/executive/autopilot/helpers/routine_spec.rb +133 -0
- data/spec/legion/extensions/agentic/executive/autopilot/runners_spec.rb +108 -0
- data/spec/legion/extensions/agentic/executive/chunking/client_spec.rb +67 -0
- data/spec/legion/extensions/agentic/executive/chunking/helpers/chunk_spec.rb +187 -0
- data/spec/legion/extensions/agentic/executive/chunking/helpers/chunking_engine_spec.rb +290 -0
- data/spec/legion/extensions/agentic/executive/chunking/helpers/constants_spec.rb +116 -0
- data/spec/legion/extensions/agentic/executive/chunking/helpers/information_item_spec.rb +75 -0
- data/spec/legion/extensions/agentic/executive/chunking/runners/cognitive_chunking_spec.rb +169 -0
- data/spec/legion/extensions/agentic/executive/cognitive_debt/client_spec.rb +73 -0
- data/spec/legion/extensions/agentic/executive/cognitive_debt/cognitive_debt_spec.rb +15 -0
- data/spec/legion/extensions/agentic/executive/cognitive_debt/helpers/constants_spec.rb +78 -0
- data/spec/legion/extensions/agentic/executive/cognitive_debt/helpers/debt_engine_spec.rb +297 -0
- data/spec/legion/extensions/agentic/executive/cognitive_debt/helpers/debt_item_spec.rb +233 -0
- data/spec/legion/extensions/agentic/executive/cognitive_debt/runners/cognitive_debt_spec.rb +196 -0
- data/spec/legion/extensions/agentic/executive/compass/client_spec.rb +16 -0
- data/spec/legion/extensions/agentic/executive/compass/helpers/bearing_spec.rb +93 -0
- data/spec/legion/extensions/agentic/executive/compass/helpers/compass_engine_spec.rb +113 -0
- data/spec/legion/extensions/agentic/executive/compass/helpers/constants_spec.rb +45 -0
- data/spec/legion/extensions/agentic/executive/compass/helpers/magnetic_bias_spec.rb +103 -0
- data/spec/legion/extensions/agentic/executive/compass/runners/cognitive_compass_spec.rb +80 -0
- data/spec/legion/extensions/agentic/executive/control/client_spec.rb +23 -0
- data/spec/legion/extensions/agentic/executive/control/helpers/control_signal_spec.rb +118 -0
- data/spec/legion/extensions/agentic/executive/control/helpers/controller_spec.rb +167 -0
- data/spec/legion/extensions/agentic/executive/control/helpers/goal_spec.rb +99 -0
- data/spec/legion/extensions/agentic/executive/control/runners/cognitive_control_spec.rb +107 -0
- data/spec/legion/extensions/agentic/executive/decision_fatigue/client_spec.rb +24 -0
- data/spec/legion/extensions/agentic/executive/decision_fatigue/helpers/constants_spec.rb +93 -0
- data/spec/legion/extensions/agentic/executive/decision_fatigue/helpers/decision_record_spec.rb +89 -0
- data/spec/legion/extensions/agentic/executive/decision_fatigue/helpers/fatigue_engine_spec.rb +216 -0
- data/spec/legion/extensions/agentic/executive/decision_fatigue/runners/decision_fatigue_spec.rb +180 -0
- data/spec/legion/extensions/agentic/executive/disengagement/helpers/constants_spec.rb +81 -0
- data/spec/legion/extensions/agentic/executive/disengagement/helpers/disengagement_engine_spec.rb +213 -0
- data/spec/legion/extensions/agentic/executive/disengagement/helpers/goal_spec.rb +289 -0
- data/spec/legion/extensions/agentic/executive/disengagement/runners/cognitive_disengagement_spec.rb +215 -0
- data/spec/legion/extensions/agentic/executive/dissonance_resolution/client_spec.rb +20 -0
- data/spec/legion/extensions/agentic/executive/dissonance_resolution/helpers/dissonance_conflict_spec.rb +107 -0
- data/spec/legion/extensions/agentic/executive/dissonance_resolution/helpers/resolution_engine_spec.rb +122 -0
- data/spec/legion/extensions/agentic/executive/dissonance_resolution/runners/cognitive_dissonance_resolution_spec.rb +49 -0
- data/spec/legion/extensions/agentic/executive/dual_process/client_spec.rb +74 -0
- data/spec/legion/extensions/agentic/executive/dual_process/helpers/constants_spec.rb +55 -0
- data/spec/legion/extensions/agentic/executive/dual_process/helpers/decision_spec.rb +76 -0
- data/spec/legion/extensions/agentic/executive/dual_process/helpers/dual_process_engine_spec.rb +274 -0
- data/spec/legion/extensions/agentic/executive/dual_process/helpers/heuristic_spec.rb +144 -0
- data/spec/legion/extensions/agentic/executive/dual_process/runners/dual_process_spec.rb +188 -0
- data/spec/legion/extensions/agentic/executive/dwell/cognitive_dwell_spec.rb +7 -0
- data/spec/legion/extensions/agentic/executive/dwell/helpers/dwell_engine_spec.rb +136 -0
- data/spec/legion/extensions/agentic/executive/dwell/helpers/dwell_topic_spec.rb +152 -0
- data/spec/legion/extensions/agentic/executive/executive_function/client_spec.rb +40 -0
- data/spec/legion/extensions/agentic/executive/executive_function/helpers/ef_component_spec.rb +108 -0
- data/spec/legion/extensions/agentic/executive/executive_function/helpers/executive_controller_spec.rb +136 -0
- data/spec/legion/extensions/agentic/executive/executive_function/runners/executive_function_spec.rb +191 -0
- data/spec/legion/extensions/agentic/executive/flexibility/client_spec.rb +20 -0
- data/spec/legion/extensions/agentic/executive/flexibility/helpers/flexibility_engine_spec.rb +119 -0
- data/spec/legion/extensions/agentic/executive/flexibility/helpers/task_set_spec.rb +87 -0
- data/spec/legion/extensions/agentic/executive/flexibility/runners/cognitive_flexibility_spec.rb +69 -0
- data/spec/legion/extensions/agentic/executive/flexibility_training/client_spec.rb +39 -0
- data/spec/legion/extensions/agentic/executive/flexibility_training/helpers/constants_spec.rb +67 -0
- data/spec/legion/extensions/agentic/executive/flexibility_training/helpers/flexibility_engine_spec.rb +209 -0
- data/spec/legion/extensions/agentic/executive/flexibility_training/helpers/switch_trial_spec.rb +77 -0
- data/spec/legion/extensions/agentic/executive/flexibility_training/helpers/training_task_spec.rb +97 -0
- data/spec/legion/extensions/agentic/executive/flexibility_training/runners/cognitive_flexibility_training_spec.rb +171 -0
- data/spec/legion/extensions/agentic/executive/goal_management/client_spec.rb +34 -0
- data/spec/legion/extensions/agentic/executive/goal_management/goal_management_spec.rb +11 -0
- data/spec/legion/extensions/agentic/executive/goal_management/helpers/constants_spec.rb +94 -0
- data/spec/legion/extensions/agentic/executive/goal_management/helpers/goal_engine_spec.rb +358 -0
- data/spec/legion/extensions/agentic/executive/goal_management/helpers/goal_spec.rb +283 -0
- data/spec/legion/extensions/agentic/executive/goal_management/runners/goal_management_spec.rb +244 -0
- data/spec/legion/extensions/agentic/executive/inertia/helpers/belief_spec.rb +128 -0
- data/spec/legion/extensions/agentic/executive/inertia/helpers/inertia_engine_spec.rb +104 -0
- data/spec/legion/extensions/agentic/executive/inertia/runners/cognitive_inertia_spec.rb +59 -0
- data/spec/legion/extensions/agentic/executive/inhibition/client_spec.rb +43 -0
- data/spec/legion/extensions/agentic/executive/inhibition/helpers/constants_spec.rb +108 -0
- data/spec/legion/extensions/agentic/executive/inhibition/helpers/impulse_spec.rb +101 -0
- data/spec/legion/extensions/agentic/executive/inhibition/helpers/inhibition_model_spec.rb +245 -0
- data/spec/legion/extensions/agentic/executive/inhibition/helpers/inhibition_store_spec.rb +126 -0
- data/spec/legion/extensions/agentic/executive/inhibition/runners/inhibition_spec.rb +242 -0
- data/spec/legion/extensions/agentic/executive/load/client_spec.rb +94 -0
- data/spec/legion/extensions/agentic/executive/load/helpers/constants_spec.rb +62 -0
- data/spec/legion/extensions/agentic/executive/load/helpers/load_model_spec.rb +314 -0
- data/spec/legion/extensions/agentic/executive/load/runners/cognitive_load_spec.rb +231 -0
- data/spec/legion/extensions/agentic/executive/load_balancing/client_spec.rb +20 -0
- data/spec/legion/extensions/agentic/executive/load_balancing/helpers/load_balancer_spec.rb +106 -0
- data/spec/legion/extensions/agentic/executive/load_balancing/helpers/subsystem_spec.rb +106 -0
- data/spec/legion/extensions/agentic/executive/load_balancing/runners/cognitive_load_balancing_spec.rb +52 -0
- data/spec/legion/extensions/agentic/executive/planning/client_spec.rb +91 -0
- data/spec/legion/extensions/agentic/executive/planning/helpers/constants_spec.rb +91 -0
- data/spec/legion/extensions/agentic/executive/planning/helpers/plan_spec.rb +230 -0
- data/spec/legion/extensions/agentic/executive/planning/helpers/plan_step_spec.rb +159 -0
- data/spec/legion/extensions/agentic/executive/planning/helpers/plan_store_spec.rb +317 -0
- data/spec/legion/extensions/agentic/executive/planning/runners/planning_spec.rb +217 -0
- data/spec/legion/extensions/agentic/executive/prospective_memory/client_spec.rb +24 -0
- data/spec/legion/extensions/agentic/executive/prospective_memory/helpers/constants_spec.rb +84 -0
- data/spec/legion/extensions/agentic/executive/prospective_memory/helpers/intention_spec.rb +194 -0
- data/spec/legion/extensions/agentic/executive/prospective_memory/helpers/prospective_engine_spec.rb +255 -0
- data/spec/legion/extensions/agentic/executive/prospective_memory/runners/prospective_memory_spec.rb +220 -0
- data/spec/legion/extensions/agentic/executive/triage/client_spec.rb +28 -0
- data/spec/legion/extensions/agentic/executive/triage/cognitive_triage_spec.rb +7 -0
- data/spec/legion/extensions/agentic/executive/triage/helpers/constants_spec.rb +41 -0
- data/spec/legion/extensions/agentic/executive/triage/helpers/demand_spec.rb +139 -0
- data/spec/legion/extensions/agentic/executive/triage/helpers/triage_engine_spec.rb +183 -0
- data/spec/legion/extensions/agentic/executive/triage/runners_spec.rb +127 -0
- data/spec/legion/extensions/agentic/executive/volition/client_spec.rb +25 -0
- data/spec/legion/extensions/agentic/executive/volition/helpers/drive_synthesizer_spec.rb +99 -0
- data/spec/legion/extensions/agentic/executive/volition/helpers/intention_spec.rb +93 -0
- data/spec/legion/extensions/agentic/executive/volition/helpers/intention_stack_spec.rb +129 -0
- data/spec/legion/extensions/agentic/executive/volition/runners/volition_spec.rb +135 -0
- data/spec/legion/extensions/agentic/executive/working_memory/client_spec.rb +93 -0
- data/spec/legion/extensions/agentic/executive/working_memory/helpers/buffer_item_spec.rb +185 -0
- data/spec/legion/extensions/agentic/executive/working_memory/helpers/buffer_spec.rb +232 -0
- data/spec/legion/extensions/agentic/executive/working_memory/helpers/constants_spec.rb +99 -0
- data/spec/legion/extensions/agentic/executive/working_memory/runners/working_memory_spec.rb +191 -0
- data/spec/spec_helper.rb +46 -0
- metadata +380 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Executive
|
|
7
|
+
module Chunking
|
|
8
|
+
module Helpers
|
|
9
|
+
class Chunk
|
|
10
|
+
include Constants
|
|
11
|
+
|
|
12
|
+
attr_reader :id, :label, :item_ids, :sub_chunk_ids, :coherence, :recall_strength,
|
|
13
|
+
:access_count, :created_at
|
|
14
|
+
|
|
15
|
+
def initialize(label:, item_ids: [])
|
|
16
|
+
@id = ::SecureRandom.uuid
|
|
17
|
+
@label = label
|
|
18
|
+
@item_ids = item_ids.dup
|
|
19
|
+
@sub_chunk_ids = []
|
|
20
|
+
@coherence = DEFAULT_COHERENCE
|
|
21
|
+
@recall_strength = 0.8
|
|
22
|
+
@access_count = 0
|
|
23
|
+
@created_at = Time.now.utc
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def add_item!(item_id:)
|
|
27
|
+
@item_ids << item_id unless @item_ids.include?(item_id)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def remove_item!(item_id:)
|
|
31
|
+
@item_ids.delete(item_id)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def add_sub_chunk!(chunk_id:)
|
|
35
|
+
@sub_chunk_ids << chunk_id unless @sub_chunk_ids.include?(chunk_id)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def reinforce!
|
|
39
|
+
@access_count += 1
|
|
40
|
+
@coherence = [(@coherence + COHERENCE_BOOST).round(10), 1.0].min
|
|
41
|
+
@recall_strength = [(@recall_strength + RECALL_BOOST).round(10), 1.0].min
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def decay!
|
|
45
|
+
@recall_strength = [(@recall_strength - RECALL_DECAY).round(10), 0.0].max
|
|
46
|
+
@coherence = [(@coherence - COHERENCE_DECAY).round(10), 0.0].max
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def size
|
|
50
|
+
@item_ids.size
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def hierarchical?
|
|
54
|
+
!@sub_chunk_ids.empty?
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def coherence_label
|
|
58
|
+
COHERENCE_LABELS.find { |range, _| range.cover?(@coherence) }&.last || :unchunked
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def recall_label
|
|
62
|
+
RECALL_LABELS.find { |range, _| range.cover?(@recall_strength) }&.last || :forgotten
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def size_label
|
|
66
|
+
CHUNK_SIZE_LABELS.find { |range, _| range.cover?(size) }&.last || :micro
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def to_h
|
|
70
|
+
{
|
|
71
|
+
id: @id,
|
|
72
|
+
label: @label,
|
|
73
|
+
item_ids: @item_ids.dup,
|
|
74
|
+
sub_chunk_ids: @sub_chunk_ids.dup,
|
|
75
|
+
coherence: @coherence.round(10),
|
|
76
|
+
recall_strength: @recall_strength.round(10),
|
|
77
|
+
access_count: @access_count,
|
|
78
|
+
created_at: @created_at,
|
|
79
|
+
size: size,
|
|
80
|
+
hierarchical: hierarchical?,
|
|
81
|
+
coherence_label: coherence_label,
|
|
82
|
+
recall_label: recall_label,
|
|
83
|
+
size_label: size_label
|
|
84
|
+
}
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Executive
|
|
7
|
+
module Chunking
|
|
8
|
+
module Helpers
|
|
9
|
+
class ChunkingEngine
|
|
10
|
+
include Constants
|
|
11
|
+
|
|
12
|
+
attr_reader :items, :chunks, :working_memory
|
|
13
|
+
|
|
14
|
+
def initialize
|
|
15
|
+
@items = {}
|
|
16
|
+
@chunks = {}
|
|
17
|
+
@working_memory = []
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def add_item(content:, domain: :general)
|
|
21
|
+
return { success: false, error: :capacity_exceeded } if @items.size >= MAX_ITEMS
|
|
22
|
+
|
|
23
|
+
item = InformationItem.new(content: content, domain: domain)
|
|
24
|
+
@items[item.id] = item
|
|
25
|
+
{ success: true, item_id: item.id, item: item.to_h }
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def create_chunk(label:, item_ids:)
|
|
29
|
+
return { success: false, error: :capacity_exceeded } if @chunks.size >= MAX_CHUNKS
|
|
30
|
+
return { success: false, error: :empty_item_ids } if item_ids.empty?
|
|
31
|
+
|
|
32
|
+
valid_ids = item_ids.select { |id| @items.key?(id) }
|
|
33
|
+
return { success: false, error: :no_valid_items } if valid_ids.empty?
|
|
34
|
+
|
|
35
|
+
chunk = Chunk.new(label: label, item_ids: valid_ids)
|
|
36
|
+
@chunks[chunk.id] = chunk
|
|
37
|
+
valid_ids.each { |id| @items[id]&.assign_to_chunk!(chunk_id: chunk.id) }
|
|
38
|
+
|
|
39
|
+
{ success: true, chunk_id: chunk.id, chunk: chunk.to_h }
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def merge_chunks(chunk_ids:, label:)
|
|
43
|
+
return { success: false, error: :capacity_exceeded } if @chunks.size >= MAX_CHUNKS
|
|
44
|
+
return { success: false, error: :insufficient_chunks } if chunk_ids.size < 2
|
|
45
|
+
|
|
46
|
+
valid_chunk_ids = chunk_ids.select { |id| @chunks.key?(id) }
|
|
47
|
+
return { success: false, error: :no_valid_chunks } if valid_chunk_ids.size < 2
|
|
48
|
+
|
|
49
|
+
merged_item_ids = valid_chunk_ids.flat_map { |id| @chunks[id].item_ids }.uniq
|
|
50
|
+
parent = Chunk.new(label: label, item_ids: merged_item_ids)
|
|
51
|
+
valid_chunk_ids.each { |id| parent.add_sub_chunk!(chunk_id: id) }
|
|
52
|
+
@chunks[parent.id] = parent
|
|
53
|
+
|
|
54
|
+
{ success: true, chunk_id: parent.id, chunk: parent.to_h, merged_from: valid_chunk_ids }
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def load_to_working_memory(chunk_id:)
|
|
58
|
+
return { success: false, error: :chunk_not_found } unless @chunks.key?(chunk_id)
|
|
59
|
+
return { success: false, error: :already_loaded } if @working_memory.include?(chunk_id)
|
|
60
|
+
return { success: false, error: :capacity_exceeded } if @working_memory.size >= WORKING_MEMORY_CAPACITY
|
|
61
|
+
|
|
62
|
+
@working_memory << chunk_id
|
|
63
|
+
@chunks[chunk_id].reinforce!
|
|
64
|
+
{ success: true, chunk_id: chunk_id, working_memory_size: @working_memory.size }
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def unload_from_working_memory(chunk_id:)
|
|
68
|
+
return { success: false, error: :not_in_working_memory } unless @working_memory.include?(chunk_id)
|
|
69
|
+
|
|
70
|
+
@working_memory.delete(chunk_id)
|
|
71
|
+
{ success: true, chunk_id: chunk_id, working_memory_size: @working_memory.size }
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def working_memory_load
|
|
75
|
+
return 0.0 if WORKING_MEMORY_CAPACITY.zero?
|
|
76
|
+
|
|
77
|
+
(@working_memory.size.to_f / WORKING_MEMORY_CAPACITY).round(10)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def working_memory_overloaded?
|
|
81
|
+
@working_memory.size > WORKING_MEMORY_CAPACITY
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def decay_all!
|
|
85
|
+
@chunks.each_value(&:decay!)
|
|
86
|
+
{ success: true, chunks_decayed: @chunks.size }
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def reinforce_chunk(chunk_id:)
|
|
90
|
+
return { success: false, error: :chunk_not_found } unless @chunks.key?(chunk_id)
|
|
91
|
+
|
|
92
|
+
@chunks[chunk_id].reinforce!
|
|
93
|
+
{ success: true, chunk_id: chunk_id, chunk: @chunks[chunk_id].to_h }
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def strongest_chunks(limit: 10)
|
|
97
|
+
@chunks.values
|
|
98
|
+
.sort_by { |c| -c.recall_strength }
|
|
99
|
+
.first(limit)
|
|
100
|
+
.map(&:to_h)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def unchunked_items
|
|
104
|
+
@items.values.reject(&:chunked?).map(&:to_h)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def chunking_efficiency
|
|
108
|
+
return 0.0 if @items.empty?
|
|
109
|
+
|
|
110
|
+
chunked_count = @items.values.count(&:chunked?)
|
|
111
|
+
(chunked_count.to_f / @items.size).round(10)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def chunking_report
|
|
115
|
+
wm_load = working_memory_load
|
|
116
|
+
capacity_label = CAPACITY_LABELS.find { |range, _| range.cover?(wm_load) }&.last || :empty
|
|
117
|
+
|
|
118
|
+
{
|
|
119
|
+
total_items: @items.size,
|
|
120
|
+
total_chunks: @chunks.size,
|
|
121
|
+
unchunked_items: unchunked_items.size,
|
|
122
|
+
chunking_efficiency: chunking_efficiency,
|
|
123
|
+
working_memory: {
|
|
124
|
+
current: @working_memory.size,
|
|
125
|
+
capacity: WORKING_MEMORY_CAPACITY,
|
|
126
|
+
load: wm_load,
|
|
127
|
+
label: capacity_label,
|
|
128
|
+
chunk_ids: @working_memory.dup
|
|
129
|
+
},
|
|
130
|
+
strongest_chunks: strongest_chunks(limit: 5)
|
|
131
|
+
}
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def to_h
|
|
135
|
+
{
|
|
136
|
+
items: @items.transform_values(&:to_h),
|
|
137
|
+
chunks: @chunks.transform_values(&:to_h),
|
|
138
|
+
working_memory: @working_memory.dup
|
|
139
|
+
}
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Executive
|
|
7
|
+
module Chunking
|
|
8
|
+
module Helpers
|
|
9
|
+
module Constants
|
|
10
|
+
MAX_ITEMS = 500
|
|
11
|
+
MAX_CHUNKS = 200
|
|
12
|
+
WORKING_MEMORY_CAPACITY = 7 # Miller's magic number
|
|
13
|
+
CAPACITY_VARIANCE = 2 # +/- 2
|
|
14
|
+
DEFAULT_COHERENCE = 0.5
|
|
15
|
+
COHERENCE_BOOST = 0.08
|
|
16
|
+
COHERENCE_DECAY = 0.03
|
|
17
|
+
RECALL_DECAY = 0.02
|
|
18
|
+
RECALL_BOOST = 0.1
|
|
19
|
+
|
|
20
|
+
CHUNK_SIZE_LABELS = {
|
|
21
|
+
(7..) => :large,
|
|
22
|
+
(5...7) => :medium,
|
|
23
|
+
(3...5) => :small,
|
|
24
|
+
(..3) => :micro
|
|
25
|
+
}.freeze
|
|
26
|
+
|
|
27
|
+
COHERENCE_LABELS = {
|
|
28
|
+
(0.8..) => :tightly_chunked,
|
|
29
|
+
(0.6...0.8) => :well_chunked,
|
|
30
|
+
(0.4...0.6) => :loosely_chunked,
|
|
31
|
+
(0.2...0.4) => :weakly_chunked,
|
|
32
|
+
(..0.2) => :unchunked
|
|
33
|
+
}.freeze
|
|
34
|
+
|
|
35
|
+
RECALL_LABELS = {
|
|
36
|
+
(0.8..) => :instant,
|
|
37
|
+
(0.6...0.8) => :easy,
|
|
38
|
+
(0.4...0.6) => :moderate,
|
|
39
|
+
(0.2...0.4) => :difficult,
|
|
40
|
+
(..0.2) => :forgotten
|
|
41
|
+
}.freeze
|
|
42
|
+
|
|
43
|
+
CAPACITY_LABELS = {
|
|
44
|
+
(0.8..) => :overloaded,
|
|
45
|
+
(0.6...0.8) => :near_capacity,
|
|
46
|
+
(0.4...0.6) => :comfortable,
|
|
47
|
+
(0.2...0.4) => :spacious,
|
|
48
|
+
(..0.2) => :empty
|
|
49
|
+
}.freeze
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Executive
|
|
7
|
+
module Chunking
|
|
8
|
+
module Helpers
|
|
9
|
+
class InformationItem
|
|
10
|
+
attr_reader :id, :content, :domain, :chunk_id, :created_at
|
|
11
|
+
|
|
12
|
+
def initialize(content:, domain: :general)
|
|
13
|
+
@id = ::SecureRandom.uuid
|
|
14
|
+
@content = content
|
|
15
|
+
@domain = domain
|
|
16
|
+
@chunked = false
|
|
17
|
+
@chunk_id = nil
|
|
18
|
+
@created_at = Time.now.utc
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def chunked?
|
|
22
|
+
@chunked
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def assign_to_chunk!(chunk_id:)
|
|
26
|
+
@chunked = true
|
|
27
|
+
@chunk_id = chunk_id
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def unchunk!
|
|
31
|
+
@chunked = false
|
|
32
|
+
@chunk_id = nil
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def to_h
|
|
36
|
+
{
|
|
37
|
+
id: @id,
|
|
38
|
+
content: @content,
|
|
39
|
+
domain: @domain,
|
|
40
|
+
chunked: @chunked,
|
|
41
|
+
chunk_id: @chunk_id,
|
|
42
|
+
created_at: @created_at
|
|
43
|
+
}
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Executive
|
|
7
|
+
module Chunking
|
|
8
|
+
module Runners
|
|
9
|
+
module CognitiveChunking
|
|
10
|
+
include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers) &&
|
|
11
|
+
Legion::Extensions::Helpers.const_defined?(:Lex)
|
|
12
|
+
|
|
13
|
+
def add_item(content:, domain: :general, engine: nil, **)
|
|
14
|
+
eng = engine || chunking_engine
|
|
15
|
+
result = eng.add_item(content: content, domain: domain)
|
|
16
|
+
Legion::Logging.debug "[cognitive_chunking] add_item: domain=#{domain} success=#{result[:success]}"
|
|
17
|
+
result
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def create_chunk(label:, item_ids:, engine: nil, **)
|
|
21
|
+
eng = engine || chunking_engine
|
|
22
|
+
result = eng.create_chunk(label: label, item_ids: item_ids)
|
|
23
|
+
Legion::Logging.debug "[cognitive_chunking] create_chunk: label=#{label} items=#{item_ids.size} success=#{result[:success]}"
|
|
24
|
+
result
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def merge_chunks(chunk_ids:, label:, engine: nil, **)
|
|
28
|
+
eng = engine || chunking_engine
|
|
29
|
+
result = eng.merge_chunks(chunk_ids: chunk_ids, label: label)
|
|
30
|
+
Legion::Logging.debug "[cognitive_chunking] merge_chunks: label=#{label} sources=#{chunk_ids.size} success=#{result[:success]}"
|
|
31
|
+
result
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def load_to_working_memory(chunk_id:, engine: nil, **)
|
|
35
|
+
eng = engine || chunking_engine
|
|
36
|
+
result = eng.load_to_working_memory(chunk_id: chunk_id)
|
|
37
|
+
Legion::Logging.debug "[cognitive_chunking] load_wm: chunk_id=#{chunk_id} wm_size=#{result[:working_memory_size]} success=#{result[:success]}"
|
|
38
|
+
result
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def unload_from_working_memory(chunk_id:, engine: nil, **)
|
|
42
|
+
eng = engine || chunking_engine
|
|
43
|
+
result = eng.unload_from_working_memory(chunk_id: chunk_id)
|
|
44
|
+
Legion::Logging.debug "[cognitive_chunking] unload_wm: chunk_id=#{chunk_id} success=#{result[:success]}"
|
|
45
|
+
result
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def working_memory_status(engine: nil, **)
|
|
49
|
+
eng = engine || chunking_engine
|
|
50
|
+
load = eng.working_memory_load
|
|
51
|
+
label = Helpers::Constants::CAPACITY_LABELS.find { |range, _| range.cover?(load) }&.last || :empty
|
|
52
|
+
|
|
53
|
+
Legion::Logging.debug "[cognitive_chunking] wm_status: load=#{load.round(2)} label=#{label}"
|
|
54
|
+
{
|
|
55
|
+
success: true,
|
|
56
|
+
size: eng.working_memory.size,
|
|
57
|
+
capacity: Helpers::Constants::WORKING_MEMORY_CAPACITY,
|
|
58
|
+
load: load,
|
|
59
|
+
label: label,
|
|
60
|
+
overloaded: eng.working_memory_overloaded?
|
|
61
|
+
}
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def decay_all(engine: nil, **)
|
|
65
|
+
eng = engine || chunking_engine
|
|
66
|
+
result = eng.decay_all!
|
|
67
|
+
Legion::Logging.debug "[cognitive_chunking] decay_all: chunks_decayed=#{result[:chunks_decayed]}"
|
|
68
|
+
result
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def reinforce_chunk(chunk_id:, engine: nil, **)
|
|
72
|
+
eng = engine || chunking_engine
|
|
73
|
+
result = eng.reinforce_chunk(chunk_id: chunk_id)
|
|
74
|
+
Legion::Logging.debug "[cognitive_chunking] reinforce_chunk: chunk_id=#{chunk_id} success=#{result[:success]}"
|
|
75
|
+
result
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def chunking_report(engine: nil, **)
|
|
79
|
+
eng = engine || chunking_engine
|
|
80
|
+
report = eng.chunking_report
|
|
81
|
+
eff = report[:chunking_efficiency].round(2)
|
|
82
|
+
Legion::Logging.debug "[cognitive_chunking] report: items=#{report[:total_items]} chunks=#{report[:total_chunks]} efficiency=#{eff}"
|
|
83
|
+
{ success: true, report: report }
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def strongest_chunks(limit: 10, engine: nil, **)
|
|
87
|
+
eng = engine || chunking_engine
|
|
88
|
+
chunks = eng.strongest_chunks(limit: limit)
|
|
89
|
+
Legion::Logging.debug "[cognitive_chunking] strongest_chunks: count=#{chunks.size}"
|
|
90
|
+
{ success: true, chunks: chunks }
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def unchunked_items(engine: nil, **)
|
|
94
|
+
eng = engine || chunking_engine
|
|
95
|
+
items = eng.unchunked_items
|
|
96
|
+
Legion::Logging.debug "[cognitive_chunking] unchunked_items: count=#{items.size}"
|
|
97
|
+
{ success: true, items: items }
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
private
|
|
101
|
+
|
|
102
|
+
def chunking_engine
|
|
103
|
+
@chunking_engine ||= Helpers::ChunkingEngine.new
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'securerandom'
|
|
4
|
+
require 'legion/extensions/agentic/executive/chunking/version'
|
|
5
|
+
require 'legion/extensions/agentic/executive/chunking/helpers/constants'
|
|
6
|
+
require 'legion/extensions/agentic/executive/chunking/helpers/information_item'
|
|
7
|
+
require 'legion/extensions/agentic/executive/chunking/helpers/chunk'
|
|
8
|
+
require 'legion/extensions/agentic/executive/chunking/helpers/chunking_engine'
|
|
9
|
+
require 'legion/extensions/agentic/executive/chunking/runners/cognitive_chunking'
|
|
10
|
+
require 'legion/extensions/agentic/executive/chunking/client'
|
|
11
|
+
|
|
12
|
+
module Legion
|
|
13
|
+
module Extensions
|
|
14
|
+
module Agentic
|
|
15
|
+
module Executive
|
|
16
|
+
module Chunking
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'legion/extensions/agentic/executive/cognitive_debt/helpers/constants'
|
|
4
|
+
require 'legion/extensions/agentic/executive/cognitive_debt/helpers/debt_item'
|
|
5
|
+
require 'legion/extensions/agentic/executive/cognitive_debt/helpers/debt_engine'
|
|
6
|
+
require 'legion/extensions/agentic/executive/cognitive_debt/runners/cognitive_debt'
|
|
7
|
+
|
|
8
|
+
module Legion
|
|
9
|
+
module Extensions
|
|
10
|
+
module Agentic
|
|
11
|
+
module Executive
|
|
12
|
+
module CognitiveDebt
|
|
13
|
+
class Client
|
|
14
|
+
include Runners::CognitiveDebt
|
|
15
|
+
|
|
16
|
+
def initialize(engine: nil, **)
|
|
17
|
+
@default_engine = engine || Helpers::DebtEngine.new
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
attr_reader :default_engine
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Executive
|
|
7
|
+
module CognitiveDebt
|
|
8
|
+
module Helpers
|
|
9
|
+
module Constants
|
|
10
|
+
MAX_DEBTS = 300
|
|
11
|
+
INTEREST_RATE = 0.05
|
|
12
|
+
DEFAULT_PRINCIPAL = 0.3
|
|
13
|
+
REPAYMENT_RATE = 0.1
|
|
14
|
+
|
|
15
|
+
SEVERITY_LABELS = {
|
|
16
|
+
(0.0...0.2) => :negligible,
|
|
17
|
+
(0.2...0.4) => :minor,
|
|
18
|
+
(0.4...0.6) => :moderate,
|
|
19
|
+
(0.6...0.8) => :severe,
|
|
20
|
+
(0.8..Float::INFINITY) => :critical
|
|
21
|
+
}.freeze
|
|
22
|
+
|
|
23
|
+
DEBT_TYPES = %i[
|
|
24
|
+
deferred_decision
|
|
25
|
+
unprocessed_input
|
|
26
|
+
incomplete_analysis
|
|
27
|
+
pending_integration
|
|
28
|
+
unresolved_conflict
|
|
29
|
+
].freeze
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Executive
|
|
7
|
+
module CognitiveDebt
|
|
8
|
+
module Helpers
|
|
9
|
+
class DebtEngine
|
|
10
|
+
def initialize
|
|
11
|
+
@debts = {}
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def create_debt(label:, debt_type:, principal: Constants::DEFAULT_PRINCIPAL, domain: 'general')
|
|
15
|
+
return { created: false, reason: :debt_type_invalid } unless Constants::DEBT_TYPES.include?(debt_type.to_sym)
|
|
16
|
+
return { created: false, reason: :limit_reached } if @debts.size >= Constants::MAX_DEBTS
|
|
17
|
+
|
|
18
|
+
item = DebtItem.new(
|
|
19
|
+
label: label,
|
|
20
|
+
debt_type: debt_type,
|
|
21
|
+
principal: principal,
|
|
22
|
+
domain: domain
|
|
23
|
+
)
|
|
24
|
+
@debts[item.id] = item
|
|
25
|
+
{ created: true, debt_id: item.id, debt: item.to_h }
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def repay_debt(debt_id:, amount: Constants::REPAYMENT_RATE)
|
|
29
|
+
item = @debts[debt_id]
|
|
30
|
+
return { found: false } unless item
|
|
31
|
+
return { found: true, repaid: false, reason: :already_repaid } if item.repaid?
|
|
32
|
+
|
|
33
|
+
item.repay!(amount: amount)
|
|
34
|
+
{ found: true, repaid: true, debt_id: debt_id, debt: item.to_h }
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def accrue_all_interest
|
|
38
|
+
count = 0
|
|
39
|
+
@debts.each_value do |item|
|
|
40
|
+
next if item.repaid?
|
|
41
|
+
|
|
42
|
+
item.accrue!
|
|
43
|
+
count += 1
|
|
44
|
+
end
|
|
45
|
+
{ accrued: count, total_debt: total_debt }
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def total_debt
|
|
49
|
+
@debts.values.reject(&:repaid?).sum(&:total_cost).round(10)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def debt_by_type(debt_type:)
|
|
53
|
+
type = debt_type.to_sym
|
|
54
|
+
items = @debts.values.select { |d| d.debt_type == type && !d.repaid? }
|
|
55
|
+
{ debt_type: type, count: items.size, items: items.map(&:to_h) }
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def debt_by_domain(domain:)
|
|
59
|
+
items = @debts.values.select { |d| d.domain == domain && !d.repaid? }
|
|
60
|
+
{ domain: domain, count: items.size, items: items.map(&:to_h) }
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def most_costly(limit: 10)
|
|
64
|
+
items = @debts.values
|
|
65
|
+
.reject(&:repaid?)
|
|
66
|
+
.sort_by { |d| -d.total_cost }
|
|
67
|
+
.first(limit)
|
|
68
|
+
{ count: items.size, items: items.map(&:to_h) }
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def oldest_debts(limit: 10)
|
|
72
|
+
items = @debts.values
|
|
73
|
+
.reject(&:repaid?)
|
|
74
|
+
.sort_by(&:created_at)
|
|
75
|
+
.first(limit)
|
|
76
|
+
{ count: items.size, items: items.map(&:to_h) }
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def debt_report
|
|
80
|
+
active = @debts.values.reject(&:repaid?)
|
|
81
|
+
by_type = Constants::DEBT_TYPES.to_h do |type|
|
|
82
|
+
typed = active.select { |d| d.debt_type == type }
|
|
83
|
+
[type, { count: typed.size, total_cost: typed.sum(&:total_cost).round(10) }]
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
priority = active.sort_by { |d| -d.total_cost }.first(5)
|
|
87
|
+
|
|
88
|
+
{
|
|
89
|
+
total_debt: total_debt,
|
|
90
|
+
active_count: active.size,
|
|
91
|
+
repaid_count: @debts.values.count(&:repaid?),
|
|
92
|
+
by_type: by_type,
|
|
93
|
+
recommended_priority: priority.map(&:to_h)
|
|
94
|
+
}
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def prune_repaid
|
|
98
|
+
before = @debts.size
|
|
99
|
+
@debts.delete_if { |_id, item| item.repaid? }
|
|
100
|
+
pruned = before - @debts.size
|
|
101
|
+
{ pruned: pruned, remaining: @debts.size }
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def to_h
|
|
105
|
+
{
|
|
106
|
+
total_debt: total_debt,
|
|
107
|
+
active_count: @debts.values.reject(&:repaid?).size,
|
|
108
|
+
total_count: @debts.size,
|
|
109
|
+
debts: @debts.values.map(&:to_h)
|
|
110
|
+
}
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|