user_limbic_mirror
User Limbic Mirror v2 — per-user relational modeling with conflict detection.
Tracks each user’s inferred emotional state via a 20-node shadow vector, maintaining separate game and genuine context layers. Detects inter-user conflict and triggers equidistance mechanics to prevent recency/loudness bias.
Architecture:
- Per-user keying: {channel_id}:{user_id} composite keys
- Dual vectors: genuine_vector (long-term relationship) and game_vector
(KoTH / roleplay context, doesn’t pollute genuine)
Relational baselines: slow-updating snapshots of “how Star normally is with this person,” stored in Redis for persistence across sessions
Conflict detection: when 2+ high-trust users have opposing emotional bids, sets
conflict_detectedflag and triggers equidistance rules
- class user_limbic_mirror.ContextMode(*values)[source]
Bases:
EnumContextMode (inherits from Enum).
- GENUINE = 'genuine'
- GAME = 'game'
- AMBIGUOUS = 'ambiguous'
- class user_limbic_mirror.TurnRecord(timestamp, user_msg_len, star_reply_len, sentiment, deltas, context_mode, dominant_signals)[source]
Bases:
objectSingle turn record for rolling-window analysis.
- Parameters:
- context_mode: ContextMode
- class user_limbic_mirror.UserProfile(user_id, channel_id, genuine_vector=<factory>, game_vector=<factory>, relational_baseline=<factory>, history=<factory>, timestamps=<factory>, prev_message='', context_mode=ContextMode.GENUINE, total_turns=0, last_active=0.0)[source]
Bases:
objectComplete per-user state, keyed by {channel}:{user}.
- Parameters:
- context_mode: ContextMode = 'genuine'
- class user_limbic_mirror.ChannelConflictState(detected=False, parties=<factory>, severity=0.0, started_at=0.0, description='')[source]
Bases:
objectTracks inter-user conflict within a channel.
- Parameters:
- class user_limbic_mirror.UserLimbicMirror(redis_client=None)[source]
Bases:
objectPer-user relational model with conflict detection and game/genuine split.
Maintains separate shadow vectors per user per channel, detects inter-user conflict, and applies equidistance mechanics to prevent Star from siding with whoever is loudest.
- __init__(redis_client=None)[source]
Initialize the instance.
- Parameters:
redis_client – Redis connection client.
- Return type:
None
- set_game_mode(channel_id, active=True)[source]
Mark a channel as having active KoTH / game context.
- analyze(channel_id, user_id, user_msg, star_reply='', star_desire_text='', context_mode=None)[source]
Analyze a user message and update their shadow vector.
- get_vector(channel_id, user_id, layer='genuine')[source]
Return a copy of user’s shadow vector (genuine or game).
- get_conflict_state(channel_id)[source]
Return current conflict state for a channel.
- Return type:
- Parameters:
channel_id (str)
- get_read_summary(channel_id, user_id)[source]
Generate natural-language summary of user state for prompt injection.
- get_channel_summary(channel_id)[source]
Return a summary of all users and conflict state in a channel.
- async inject_resonance(user_id, deltas, reason='', ttl_seconds=86400)[source]
Write resonance deltas to a global per-user key in Redis.
These deltas merge into the user’s shadow vector during analyze(), modulating how Star perceives and responds to this user across ALL channels. Spells decay after ttl_seconds.
- Parameters:
- Return type: