From 3ec9a48151086f71402d24e6d992b48d492e7ccc Mon Sep 17 00:00:00 2001 From: Aaron Nelson Date: Fri, 22 May 2026 23:18:00 +0000 Subject: [PATCH] dream_observation: reorder select_mode so 3-day staleness wins over the quiet rule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- scripts/dream_observation.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) 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"