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:
objectTrigger-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 byplatforms/discord.py’sStargazerClientand fed messages inline viacheck_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:
_cooldownsmaps a channel to thetime.monotonictimestamp of its last accepted trigger (used by_check_message_inner()to enforce_COOLDOWN_S), and_active_harvestsmaps a channel to its currently scheduledasyncio.Taskso a newer trigger can cancel an in-flight one.Constructs no external resources and performs no I/O. Called by
platforms/discord.py(theStargazerClientconstructor) which instantiates a singleWitchborneSpiralProcessorand stores it onself._witchborne.- Return type:
None