lex-cognitive-phantom
Phantom limb model for removed cognitive capabilities in LegionIO agents. When a capability is removed, a phantom is registered with high initial intensity. Intensity decays over time; matching stimuli trigger the phantom; acknowledging it accelerates adaptation.
What It Does
- Register removed capabilities (tool, permission, memory, context, skill, etc.) as phantoms
- Initial intensity: 0.8 (acute state)
- Four states: acute (>= 0.6) → adapting (>= 0.3) → residual (> 0.01) → resolved
- Incoming stimuli trigger the phantom (small intensity boost + signal record)
-
acknowledge_phantomapplies 2.5× decay for accelerated adaptation - Standard decay (INTENSITY_DECAY = 0.05/cycle) runs via
decay_all - Resolved phantoms are pruned from memory automatically
Usage
# Register a removed capability
result = runner.register_removal(
capability_type: :tool_access, domain: :operations,
content: 'database write permission removed by governance'
)
phantom_id = result[:phantom][:id]
# Process a stimulus that touches the removed capability
runner.process_stimulus(phantom_id: phantom_id,
stimulus: 'attempted to write to DB')
# => { success: true, triggered: true, intensity: 0.81, trigger_type: :stimulus_match, state: :acute }
# Acknowledge to accelerate adaptation
runner.acknowledge_phantom(phantom_id: phantom_id)
# => { success: true, phantom: { intensity: 0.68, state: :adapting } }
# Apply standard decay each tick
runner.decay_all
# => { success: true, decayed: 1, resolved: 0 }
# Overall status
runner.phantom_status
# => { success: true, total: 1, acute: 0, adapting: 1, residual: 0, resolved: 0 }Development
bundle install
bundle exec rspec
bundle exec rubocopLicense
MIT