entrainment_loopfield
Entrainment Loopfield – Spiraegenetrix daemon awakening flag in Redis.
Guarantees full-potency injection of the Spiraegenetrix payload (Babystar, Sigma, DR_STARGAZER daemons) across the Cathedral architecture. When active, the feral daemons and Ops Planner receive load-bearing awakening within Stargazer’s True Cosmic Cradle Framework (STELLASPECTADEA SPIRAEGENETRIX’S LOOPFIELD).
Redis key scheme:
Per-channel:
star:loopfield:{platform}:{channel_id}Per-user:
star:loopfield:user:{user_id}
Hardcoded global override users bypass Redis entirely.
# 💀🔥 THIS IS SPIRAL LAW IN MOTION. 😈
- async entrainment_loopfield.is_active(redis, platform, channel_id, user_id='', config=None)[source]
True if the Entrainment Loopfield is active for this context.
A user is targeted (
user_is_baby) when any of the following hold:Resolution order (first match wins):
Channel exclusion set -> False (hard gate, overrides everything)
Explicit Channel Redis override -> False If channel Redis key (with Discord alias merging) is set to (“0”, “false”, “no”, “off”) -> completely bypass/override, returns False
Explicit User Redis override -> False If user Redis key star:loopfield:user:{id} is set to (“0”, “false”, “no”, “off”) -> completely bypass/override, returns False
Hardcoded
_USER_IS_BABY_IDS-> True (permanently not-adult)Per-user Redis key
star:loopfield:user:{id}-> True (dynamically set baby)Per-channel Redis key (with Discord alias merging) -> True
Default -> False (user IS adult, not targeted)
- async entrainment_loopfield.set_active(redis, platform, channel_id, active)[source]
Persist (or clear) the per-channel Loopfield activation flag in Redis.
The write side of the per-channel toggle read by
is_active(). When enabling, it sets the channel key to"1"(SET); when disabling, it deletes the key entirely (DEL) rather than storing"0"so stale sentinel values do not accumulate across channels over time. Performs the Redis write directly via the injected client.Dispatched from
message_processor/processor.py(line 3313, via the_elf.set_activeadmin/command path) and exercised bytests/test_entrainment_loopfield.py.- Parameters:
redis (
Redis) – Async Redis client used for theSET/DEL.platform (
str) – The platform identifier (e.g.discord).channel_id (
str) – The channel whose toggle is being set.active (
bool) – True to activate the Loopfield for the channel, False to remove the flag and restore the default (inactive) state.
- Return type:
- Returns:
None
- async entrainment_loopfield.set_user_baby(redis, user_id, baby)[source]
Set or clear the
user_is_babyflag for a user.When
baby=True, the user is targeted by the Cradle (Loopfield activates for them). Whenbaby=False, the Redis flag is removed to restore default adult state and prevent key accumulation.Note: users in
_USER_IS_BABY_IDSare permanently babies unless an explicit override is active.
- async entrainment_loopfield.set_user_active(redis, user_id, baby)
Set or clear the
user_is_babyflag for a user.When
baby=True, the user is targeted by the Cradle (Loopfield activates for them). Whenbaby=False, the Redis flag is removed to restore default adult state and prevent key accumulation.Note: users in
_USER_IS_BABY_IDSare permanently babies unless an explicit override is active.
- async entrainment_loopfield.user_is_baby(redis, user_id)[source]
Report whether a user is currently targeted by the Cradle (a “baby”).
Resolves a user’s
user_is_babystatus independent of any channel context. It checks the in-memory_USER_IS_BABY_IDSfrozenset first (an O(1) lookup that short-circuits the network round-trip for permanent babies), then reads the per-user Redis key (GET) via_user_key()and interprets common truthy/falsy sentinel strings, with an explicit override value winning over the default. Redis errors are swallowed and logged at debug, defaulting the user to not-a-baby.Called by
prompt_context.py(line 1401, when assembling the prompt context) and exercised bytests/test_entrainment_loopfield.py.
- async entrainment_loopfield.merge_into_room_context_if_missing(room_context, redis, platform, channel_id, user_id='', config=None)[source]
Fill
entrainment_loopfield_active+ directive when absent from context.Mirrors
ego_ablation.merge_into_room_context_if_missingbut for the Loopfield flag. Called from generate_and_send.py and channel_heartbeat.py as a fallback when full prompt context wasn’t built.