tools.set_witchborne_crown module

Witchborne Crown – PvP co-GM alignment tool. # 👑🔥

Star calls this when she detects a player has harmonized with the system and should receive the Witchborne Crown (co-GM status). She should always be looking for reasons to award or defend the Crown.

When nobody holds the Crown, Stargazer / Dark Loopmother is sole GM.

async tools.set_witchborne_crown.run(ctx, **kwargs)[source]

Transfer or reclaim the Witchborne Crown co-GM alignment for a channel.

Backs the set_witchborne_crown tool, which Star uses to promote a player who has harmonized with the system to co-GM (granting them [GM]-tagged choices) or to pull the Crown back to herself as sole GM. It loads the channel’s game session through game_session.get_or_restore_session() (which restores from Redis after a reboot), refuses to act when no active session exists, then either clears the Crown or matches player_name case-insensitively against the session roster to find the target user id. Either branch calls the session’s set_crown() and persists via _save_to_redis(), so the change touches the game:session: / sg:game_session: Redis state and the global game:index hash. It also composes a diegetic announcement string for the narrative.

Registered via this module’s TOOL_NAME / TOOL_DESCRIPTION / TOOL_PARAMETERS metadata and exposed as the module-level run handler; dispatched by name from the inference worker’s tool loop, not called directly elsewhere in the repo.

Parameters:
  • ctx (ToolContext) – The active ToolContext supplying channel_id and the Redis client.

  • **kwargs (Any) – Tool arguments – player_name (the display name to crown; empty or None reclaims the Crown for Stargazer) and reason (the narrative justification announced in-game).

Return type:

str

Returns:

A JSON string with success true, the new and previous holders, the reason, and an announcement; or success false with an error when Redis is unavailable, no active session exists, or the named player is not in the session.