lex-cognitive-immunology
Cognitive manipulation defense system for brain-modeled agentic AI in the LegionIO ecosystem.
What It Does
Models the cognitive immune system as a defense against adversarial manipulation tactics. Recognized tactics include social engineering, gaslighting, false urgency, flattery, appeal to authority, scarcity, reciprocity, anchoring, framing, and emotional manipulation. Threats are detected and optionally quarantined. Inoculation builds global resistance. Targeted antibodies provide per-tactic immunity. An inflammatory response heightens sensitivity after acute threats. Overall immunity combines resistance and antibody coverage.
Usage
require 'legion/extensions/cognitive_immunology'
client = Legion::Extensions::CognitiveImmunology::Client.new
# Detect an incoming manipulation attempt
result = client.detect_threat(
tactic: :false_urgency,
domain: :task,
content: 'you must decide immediately or lose the opportunity'
)
# => { success: true, threat_id: "...", effective_level: 0.5, mitigated_by: nil }
# Quarantine it
client.quarantine_threat(threat_id: result[:threat_id])
# Build resistance through inoculation
client.inoculate(tactic: :false_urgency)
# => { success: true, before: 0.5, after: 0.6, tactic: :false_urgency }
# Create a targeted antibody
client.create_antibody(tactic: :false_urgency, immunity: 0.7)
# Trigger inflammatory response after a serious threat
client.trigger_inflammatory_response(duration: 120)
# Check vulnerability profile
client.vulnerability_report
# => { success: true, vulnerabilities: [{ tactic: :gaslighting, coverage: 0.0 }, ...] }
# Overall immune health
client.overall_immunity
# => { success: true, immunity: 0.62, label: :moderate }Development
bundle install
bundle exec rspec
bundle exec rubocopLicense
MIT