diff --git a/scripts/dream.py b/scripts/dream.py index 41a78a5..0234e10 100644 --- a/scripts/dream.py +++ b/scripts/dream.py @@ -47,6 +47,7 @@ MODE_RANGES = { "late-rem": (0.22, 0.42), "lucid": (0.32, 0.72), } +DREAMER_VERSION = "1.1" # 1.0=original exclusion logic; 1.1=score-band exclusion # ─── Prompt versioning ────────────────────────────────────────────────────── # Bump the relevant constant manually when changing a prompt. @@ -158,6 +159,7 @@ def retrieve(mode, task=None, n_results=8, excluded_sources=None): "source": source or "unknown", "content": doc, "relevance": similarity, + "similarity": similarity, }) seen_sources.add(source) if len(chunks) >= n_results: @@ -366,6 +368,7 @@ def write_manifest(date_str, stage_data, corpus_data): manifest = { "date": date_str, "prompt_sig": prompt_signature(), + "dreamer_version": DREAMER_VERSION, "prompt_hash": prompt_hash([ synthesize_nrem.__doc__ or "", synthesize_early_rem.__doc__ or "", @@ -406,6 +409,8 @@ def dream_pipeline(): print("\n[NREM] Retrieving...") nrem_chunks = retrieve("nrem", excluded_sources=previously_retrieved | session_retrieved) session_retrieved.update(c["source"] for c in nrem_chunks) + # Track sources that scored above Early REM ceiling — these are the only ones Early REM should exclude + nrem_high_sources = {c["source"] for c in nrem_chunks if c["similarity"] > 0.55} if not nrem_chunks: print("[NREM] No suitable chunks — aborting pipeline") return None @@ -431,7 +436,9 @@ def dream_pipeline(): # ── Stage 2: Early REM — informed by NREM ────────────────────────────── print("\n[Early REM] Retrieving...") - early_chunks = retrieve("early-rem", excluded_sources=previously_retrieved | session_retrieved) + # Early REM excludes previously retrieved + NREM high-scorers only (not full session_retrieved) + # Sources that scored in Early REM band during NREM remain available + early_chunks = retrieve("early-rem", excluded_sources=previously_retrieved | nrem_high_sources) session_retrieved.update(c["source"] for c in early_chunks) if not early_chunks: print("[Early REM] No suitable chunks — skipping")