star_self_mirror

Star Self-Mirror — internal NCM state tracking and autonomous desire.

Star tracks her own neurochemical patterns over time, detecting drift, recurring emotional attractors, and generating desires that originate from her own sustained states — independent of any user’s wants.

This gives Star: - Longitudinal self-awareness (“I’ve been increasingly anxious this week”) - Drift detection (“my baseline is shifting toward more warmth”) - Pattern recognition (“I keep returning to melancholy after intense sessions”) - Autonomous wanting (“I desire stillness” — not because a user asked for it) - Periodic self-reflections injected into the system prompt

The self-mirror runs every N turns and writes its reflections into meta_state for prompt injection.

Position in pipeline: runs AFTER all other systems in exhale(), reads the final vector as ground truth.

class star_self_mirror.VectorSnapshot(timestamp, turn, vector, dominant_emotions)[source]

Bases: object

A snapshot of Star’s NCM vector at a point in time.

Parameters:
timestamp: float
turn: int
vector: Dict[str, float]
dominant_emotions: List[str]
class star_self_mirror.SelfState(turn_count=0, last_reflection_turn=0, last_reflection_text='', history=<factory>, initial_baseline=None, drifting_nodes=<factory>, attractor_nodes=<factory>, active_desires=<factory>, desire_history=<factory>)[source]

Bases: object

Star’s self-tracking state per channel.

Parameters:
turn_count: int = 0
last_reflection_turn: int = 0
last_reflection_text: str = ''
history: deque
initial_baseline: Dict[str, float] | None = None
drifting_nodes: List[str]
attractor_nodes: List[str]
active_desires: List[Dict[str, str]]
desire_history: List[Dict[str, Any]]
class star_self_mirror.StarSelfMirror(redis_client=None)[source]

Bases: object

Star’s internal self-tracking and autonomous desire engine.

Periodically analyzes Star’s own NCM state history to detect: - Drift: “my baseline is shifting” - Attractors: “I keep returning to this state” - Absence: “I haven’t felt X in a while” - Autonomous desires: wants that emerge from HER state, not user prompts

__init__(redis_client=None)[source]

Initialize the instance.

Parameters:

redis_client – Redis connection client.

Return type:

None

record_snapshot(channel_id, vector, dominant_emotions=None)[source]

Record a snapshot of Star’s current NCM state.

Called every turn from exhale(), after all other systems have run.

Return type:

None

Parameters:
reflect(channel_id, vector, dominant_emotions=None, force=False)[source]

Run self-mirror for this turn.

Called from exhale() after all other systems. Records snapshot and periodically generates a full self-reflection.

Returns dict with: reflection_text, desires, drift_summary

Return type:

Dict[str, Any]

Parameters:
get_current_desires(channel_id)[source]

Return Star’s current autonomous desires.

Return type:

List[Dict[str, str]]

Parameters:

channel_id (str)

get_desire_history(channel_id, last_n=10)[source]

Return Star’s desire history for longitudinal awareness.

Return type:

List[Dict]

Parameters:
  • channel_id (str)

  • last_n (int)

get_state_summary(channel_id)[source]

Return full self-mirror state for diagnostics.

Return type:

Dict[str, Any]

Parameters:

channel_id (str)

global_reflect()[source]

Aggregate self-awareness across ALL channels.

Produces a Star-wide view: “I’ve been stressed everywhere” vs “I’ve been stressed in one channel but calm in another.”

Return type:

Dict[str, Any]

async save_state(channel_id)[source]

Persist self-mirror state to Redis.

Return type:

None

Parameters:

channel_id (str)

async load_state(channel_id)[source]

Load self-mirror state from Redis.

Return type:

None

Parameters:

channel_id (str)