fix(P3): 3 priority-3 fixes — timezone, decay rounding, rate limiter

#16  Timezone consistency — added TZ=Europe/Sofia to docker-compose.yml
     so datetime.now() returns local time inside the container. Removed
     the +3 hour hack from get_time_of_day(). All three time-of-day
     consumers (autonomous_v1_legacy, moods, autonomous_engine) now
     use the same correct local hour automatically.

#17  Decay truncation — replaced int() with round() in decay_events()
     so a counter of 1 survives one more 15-minute cycle instead of
     being immediately zeroed (round(0.841)=1 vs int(0.841)=0).

#20  Unpersisted rate limiter — _last_action_execution dict in
     autonomous.py is now seeded from the engine's persisted
     server_last_action on import, so restarts don't bypass the
     30-second cooldown.

Note: #18 (dead config fields) was a false positive — autonomous_interval_minutes
IS used by the scheduler. #19 deferred to bipolar mode rework.
This commit is contained in:
2026-02-23 13:53:22 +02:00
parent 2b743ed65e
commit 615dd4a5ef
4 changed files with 7 additions and 4 deletions

View File

@@ -565,8 +565,8 @@ class AutonomousEngine:
# Decay user events (half-life of 1 hour)
# For 15-minute intervals: decay_factor = 0.5^(1/4) ≈ 0.841
decay_factor = 0.5 ** (1/4) # ≈ 0.8408964...
ctx.users_joined_recently = int(ctx.users_joined_recently * decay_factor)
ctx.users_status_changed = int(ctx.users_status_changed * decay_factor)
ctx.users_joined_recently = round(ctx.users_joined_recently * decay_factor)
ctx.users_status_changed = round(ctx.users_status_changed * decay_factor)
# Clean up old activities (older than 1 hour)
self._clean_old_activities(guild_id, max_age_seconds=3600)