0.0
Repository is archived
No release in over 3 years
Models resilience as the capacity to recover from setbacks and grow stronger from adversity
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

 Project Readme

lex-resilience

Cognitive resilience and adversity recovery model for the LegionIO cognitive architecture. Based on Masten's resilience framework with antifragility support.

What It Does

Automatically detects adversity events from tick results (prediction failures, trust violations, conflict escalation, resource depletion, emotional shock) and tracks their recovery over time. Four resilience dimensions — elasticity (recovery speed), robustness (resistance to disruption), adaptability (strategy adjustment), and growth (improving from adversity) — are updated via EMA. After enough consecutive recoveries, a growth bonus builds, enabling antifragile classification.

Usage

client = Legion::Extensions::Resilience::Client.new

# Update on each tick (auto-detects adversities from tick results)
result = client.update_resilience(
  tick_results: {
    prediction_engine:    { error_rate: 0.8 },
    emotional_evaluation: { arousal: 0.95 }
  }
)
# => { active_adversities: 2, resolved_this_tick: 0,
#      composite_score: 0.48, classification: :fragile, growth_bonus: 0.0 }

# Register adversity manually
client.register_adversity(type: :trust_violation, severity: :major)

# Check resilience status
client.resilience_status
# => { dimensions: { elasticity: 0.45, robustness: 0.52, adaptability: 0.48, growth: 0.50 },
#      composite: 0.49, class: :fragile, trend: :stable, ... }

# Dimension detail
client.dimension_detail(dimension: :elasticity)

# Adversity report
client.adversity_report
# => { active: [...], by_type: {...}, total: 5, worst: 0.5, avg_speed: 0.03 }

client.resilience_stats

Classifications

Class Composite Score
:antifragile >= 0.7
:resilient >= 0.5
:fragile >= 0.3
:brittle < 0.3

Adversity Types

:prediction_failure, :trust_violation, :conflict_escalation, :resource_depletion, :communication_failure, :goal_failure, :emotional_shock, :system_error

Development

bundle install
bundle exec rspec
bundle exec rubocop

License

MIT