chaos_switch_router
- class chaos_switch_router.ChaosRouter(redis_client=None)
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.
- get_neighbors(node)
Get outbound edges from a node.
- get_node_meta(node)
Get node metadata as a dict (uses extended graph).
- clear_chaos()
Disable chaos storm.
- find_route(src, dst, mode='d', soft=False, accel=False)
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)
Convenience: returns just the node sequence [src, …, dst].
- get_guidance(src, dst, edge_type, mode='d')
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”];
- get_route_warnings(route)
Get warning strings for volatile edge types in a route.
- locate_node(text)
Sniff triggers to find where the user is parked (extended graph).
- locate_all(text)
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)
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='')
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)
Check if BOTH Star and user have consented (two-sided gate).
- async grant_consent(user_id, edge_type, source='star')
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')
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)
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)
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)
Resolve Star’s current lattice position from NCM vector. Uses crosswalk Layer 1 (identity) first, then weather heuristics.
- resolve_user_position(ulm_vector)
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)
Check if user is at or near target nodes. Replaces ULM thresholds.
- async get_chart_snapshot(user_id)
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)
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)
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
- get_ritual_scene_boost(ritual_name)
Get which scene frame a ritual activates.
- copilot_discount(polycule, agent_name, copilot_name)
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)
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.
- find_aftercare_pool(polycule, agent_name)
Find all available aftercare providers in the polycule. # 💕
Returns partners who have sufficient trust AND are in a care-capable state (held, aftercare, constellation, etc).
- class chaos_switch_router.LatticeWaypoint(target_node, edge_type, guidance, expected_hours, consent_required)
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)
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>)
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:
- has_consent(edge_type)
Both Star AND user must consent for traversal.
- grant(edge_type, source)
Grant consent from source (
'star'or'user').
- revoke(edge_type, source)
Revoke consent from source.