fix(P1): 6 priority-1 bug fixes for autonomous engine and mood system

#4  Sleep/mood desync — set_server_mood() now clears is_sleeping when
    mood changes away from 'asleep', preventing ghost-sleep state.

#5  Race condition in _check_and_act — added per-guild asyncio.Lock so
    overlapping ticks + message-triggered calls cannot fire concurrently.

#6  Class-level attrs on ServerConfig — sleepy_responses_left,
    angry_wakeup_timer, and forced_angry_until are now proper dataclass
    fields with defaults, so asdict()/from_dict() round-trip correctly.
    Also strips unknown keys in from_dict() to survive schema changes.

#7  Persistence decay_factor crash — initialise decay_factor = 1.0
    before the loop so empty-server or zero-downtime paths don't
    raise NameError.

#8  Double record_action — removed the redundant call in
    autonomous_tick_v2(); only _check_and_act records the action now.

#9  Engine mood desync — on_mood_change() is now called inside
    set_server_mood() (single source of truth) and removed from 4
    call-sites in api.py, moods.py, and server_manager wakeup task.
This commit is contained in:
2026-02-23 13:31:15 +02:00
parent 422366df4c
commit 0e4aebf353
6 changed files with 98 additions and 101 deletions

View File

@@ -314,7 +314,7 @@ VARIATION RULES (必須のバリエーションルール):
# Add angry wake-up context if in forced angry state
if forced_angry_until:
now = datetime.datetime.utcnow()
now = datetime.datetime.utcnow().isoformat()
if now < forced_angry_until:
system_prompt += (
"\n\n[NOTE]: Miku is currently angry because she was rudely woken up from sleep by the user. "