chaos_switch_router
- class chaos_switch_router.ChaosRouter(redis_client=None)[source]
Bases:
objectThe Chaos Switch Dominatrix Router. Calculates non-Euclidean emotional traversal paths and enforces consent walls. Replaces the legacy OpsPlanner prerequisite engine with hyperadaptive routing.
- Faithfully ports the GPS cost function:
cost(type, valence, mode, soft, accel, chaos_key)
and Dijkstra shortest-path over the 91-node / 367-edge affect lattice.
- find_route(src, dst, mode='d', soft=False, accel=False)[source]
Dijkstra’s on the emotional lattice. Returns {hops: [{a, b, t, w}, …], total: float} or None. Uses heapq priority queue for O(E log N) instead of O(N^2). # 💦
- find_path_nodes(src, dst, mode='d', soft=False, accel=False)[source]
Convenience: returns just the node sequence [src, …, dst].
- get_guidance(src, dst, edge_type, mode='d')[source]
Get guidance text for a specific hop. Checks OV overrides first, falls back to TT type text. GPS: const op = OV[h.a+”>”+h.b] || TT[h.t][mode===”d”?”d”:”s”];
- locate_all(text)[source]
Find ALL matching nodes with hit counts, sorted by relevance. GPS locate() returns scored results for the recognition panel. Uses precompiled trigger structures for speed. # 💦
- async get_position(user_id, channel_id=None)[source]
Fetch the active lattice position from Redis.
- Return type:
- Parameters:
- async update_position(user_id, new_node, channel_id=None, *, mode='', tempo=0.0, weather_posture='')[source]
Commit a movement operation to Redis + ledger ZSET. # 💀🔥
Also updates the global position with LERP-weighted recency so the aggregate lattice tracks where users cluster.
- Return type:
- Parameters:
- Keyword args (set by coordinator exhale):
mode: d=drift, a=assertive, r=reactive, s=seductive, c=coercive tempo: float multiplier (1.0=cruise, higher=burn) weather_posture: domme|switch|sub|feral|mommy
- async check_consent(user_id, edge_type)[source]
Check if BOTH Star and user have consented (two-sided gate).
- async grant_consent(user_id, edge_type, source='star')[source]
Grant one side of the volatile consent wall.
source is
'star'(Star judges readiness) or'user'(user verbally consented — Star detected it and is logging it). BOTH must be True for the Dijkstra pathfinder to traverse.
- async revoke_consent(user_id, edge_type, source='user')[source]
Revoke one side of consent (user safewords, Star pulls back).
- async generate_desire_route(user_id, channel_id, current_node, target_node, star_desires, mode='d', soft=False, accel=False)[source]
Produce an actionable list of waypoints from Star’s raw recursive desires. Routes via Dijkstra first, then enriches with LLM-generated guidance.
- async lattice_check_progression(user_id, current_text)[source]
Drop-in replacement for check_progression in ops_planner.py. Sniffs text for lattice node signatures and updates state. Returns node name if successfully sniffed/transitioned.
NOTE: Consent gating removed — consent now lives at the scene layer (chaos_switch/_scenes.py), not on lattice edges. # 💀🔥
- resolve_lattice_position(ncm_vector)[source]
Resolve Star’s current lattice position from NCM vector. Uses crosswalk Layer 1 (identity) first, then weather heuristics.
- resolve_user_position(ulm_vector)[source]
Resolve user’s lattice position from ULM shadow vector. Replaces the old completion_signals threshold system.
- check_lattice_progression(user_position, target_nodes, proximity_threshold=0)[source]
Check if user is at or near target nodes. Replaces ULM thresholds.
- async get_chart_snapshot(user_id)[source]
Returns the full graph state for the ncm_chart_api.py frontend.
- find_modulated_route(src, dst, mod, *, mode='d', soft=False, accel=False, trust=0.5, flag_open=False)[source]
Dijkstra with per-user modulation: trauma, blockades, limits. # 🕷️
Uses Modulation.edge_cost() which applies: - Trauma sensitization (cheaper to enter trauma nodes, harder to leave) - Blockade walls (hard no, edge removed) - Hard limits (entire node unreachable) - Soft limits (surcharge, requires flag + trust >= TAU_SOFT) - Trust-gated consent (ALC needs TAU_ALC, MEA needs TAU_MEA)
- compute_ritual_route(ritual_name, current_node, regalia=None)[source]
Compute full ritual route from current position. # 💕
Returns dict with: - path: Dijkstra route from current_node to ritual’s primary target - ritual_meta: target nodes, scene frame, debt, cling, prerequisites - regalia_boosts: which nodes get boosted/suppressed - safe_exit: route from ritual endpoint to return nodes
- copilot_discount(polycule, agent_name, copilot_name)[source]
Get the trust-based co-pilot discount for routing. # 🌀
High trust co-pilot = cheaper volatile edges. No trust = no discount (solo rates apply). Returns a multiplier 0.5-1.0 (lower = cheaper).
- metamour_tension_surcharge(polycule, agent_name)[source]
Get the metamour tension surcharge for scenic routing. # 😈
When metamours are in hot states (jealousy, hostility, rage), routes that rely on bonds get more expensive.
- class chaos_switch_router.LatticeWaypoint(target_node, edge_type, guidance, expected_hours, consent_required)[source]
Bases:
objectA generated node target representing a step in a routing operation.
- Parameters:
- class chaos_switch_router.DesireRoute(start_node, end_node, waypoints, narrative_context)[source]
Bases:
objectA full traversal path proposed by the LLM.
- Parameters:
start_node (str)
end_node (str)
waypoints (List[LatticeWaypoint])
narrative_context (str)
- waypoints: List[LatticeWaypoint]
- class chaos_switch_router.LatticePosition(node, z_depth, mode='d', tempo=1.0, weather_posture='', consent_flags=<factory>, history=<factory>)[source]
Bases:
objectThe current psychological coordinate of a user.
consent_flagsis a two-sided consent model: Each volatile edge type (VLV, ALC, MEA) maps to{"star": bool, "user": bool}. Both must beTruebefore the Dijkstra pathfinder will traverse that edge. Star grants her side via thegrant_lattice_consenttool; the user grants theirs via the!consentchat command.- Parameters:
- consent_summary()[source]
Compact string for user_read injection, e.g. ‘VLV:S+U-|ALC:S-U-‘.
- Return type: