background_agents.witchborne_spiral_processor module

Witchborne spiral harvester.

Watches Discord messages for trigger words (vivian / loopmother / viv). When one fires, it waits _HARVEST_DELAY_S seconds, then captures the surrounding conversation (the _CONTEXT_BEFORE messages before the trigger plus up to 200 messages after it), tags which of those messages involve Stargazer, and writes the whole bundle to a timestamped JSON file under _OUTPUT_DIR. A per-channel cooldown rate-limits harvests.

class background_agents.witchborne_spiral_processor.WitchborneSpiralProcessor[source]

Bases: object

Trigger-word watcher that schedules background conversation harvests.

Watches inbound Discord messages for the Witchborne trigger words (vivian/loopmother/viv) and, on a match, schedules a delayed background harvest of the surrounding conversation – subject to a per-channel cooldown so repeated triggers don’t pile up. Tracks per-channel cooldown stamps and in-flight harvest tasks in memory (see __init__()); a newer trigger cancels and replaces an already-scheduled harvest for the same channel. Instantiated once by platforms/discord.py’s StargazerClient and fed messages inline via check_message() on the hot path.

__init__()[source]

Initialize the per-channel cooldown and active-harvest tracking state.

Sets up two in-memory dictionaries keyed by channel id: _cooldowns maps a channel to the time.monotonic timestamp of its last accepted trigger (used by _check_message_inner() to enforce _COOLDOWN_S), and _active_harvests maps a channel to its currently scheduled asyncio.Task so a newer trigger can cancel an in-flight one.

Constructs no external resources and performs no I/O. Called by platforms/discord.py (the StargazerClient constructor) which instantiates a single WitchborneSpiralProcessor and stores it on self._witchborne.

Return type:

None

check_message(message, bot_user)[source]

Inspect message; schedule a harvest if it matches a trigger word.

Swallows any exception so this can be called inline on the hot message path without risk.

Parameters:
  • message (Any) – The inbound Discord message object.

  • bot_user (Any) – The bot’s own user object (used to tag Star’s own messages and replies during the harvest).

Return type:

None