dream_observation: reorder select_mode so 3-day staleness wins over the quiet rule
Bug: the previous order checked the "nothing changed → return None" rule first, so the spec's "corpus unchanged 3+ days → Late REM (shake things loose)" branch could never fire. Stasis was permanent — quiet would just keep returning None forever as long as no new chunks or journals appeared, regardless of how stale the corpus got. Fix: check staleness first. Quiet remains the default within the 1-2-day window the spec implicitly grants for the dreamer to "go quiet rather than manufacturing novelty." At day 3+, Late REM fires automatically — the spec's mechanism for breaking out of the silence when the corpus isn't delivering new material. Observed symptom that triggered this: dreamer fired 2026-05-21 08:00 and 2026-05-22 08:00, both went quiet. Real cause was no new content (which is correct quiet behavior for days 1-2), but the bug would have made it stay quiet indefinitely had we not fixed it before day 3.
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user