diff --git a/scripts/dream_observation.py b/scripts/dream_observation.py index d51dc5f..9ba7ff4 100644 --- a/scripts/dream_observation.py +++ b/scripts/dream_observation.py @@ -209,9 +209,14 @@ def select_mode(signal, task=None, explicit_mode=None): new_journal = signal["new_journal_entries"] days_since = signal["days_since_dream"] - # Spec line 67: nothing changed → quiet - if new_chunks < NEW_CHUNK_THRESHOLD and not new_journal: - return None + # Spec line 72: corpus unchanged ≥3 days → Late REM ("shake things loose"). + # This rule has to win against the "go quiet" rule below — the spec uses + # quiet as the default for 1-2 days of silence, then deliberately fires + # Late REM at 3+ days to break the stasis. Checking staleness first is + # what implements that intent. (Previous version checked "go quiet" first + # and never reached this branch.) + if days_since >= STALENESS_TRIGGER_DAYS: + return "late-rem" # Spec line 71: journal entry → Early REM # We treat "any new journal entry" as the trigger. Refining to detect @@ -220,9 +225,9 @@ def select_mode(signal, task=None, explicit_mode=None): if new_journal: return "early-rem" - # Spec line 72: corpus unchanged 3+ days → Late REM - if days_since >= STALENESS_TRIGGER_DAYS: - return "late-rem" + # Spec line 67: nothing changed within the staleness window → quiet + if new_chunks < NEW_CHUNK_THRESHOLD and not new_journal: + return None # Default: new chunks above threshold → NREM return "nrem"