Dreamer: manifest writer, Late REM v1.2 (remove coherence pull)

This commit is contained in:
2026-04-27 16:54:18 +00:00
parent 03b3f012c3
commit a1f732fc9e
+65 -3
View File
@@ -52,7 +52,7 @@ MODE_RANGES = {
# Bump the relevant constant manually when changing a prompt. # Bump the relevant constant manually when changing a prompt.
PROMPT_VERSION_NREM = "1.0" PROMPT_VERSION_NREM = "1.0"
PROMPT_VERSION_EREM = "1.1" PROMPT_VERSION_EREM = "1.1"
PROMPT_VERSION_LREM = "1.0" PROMPT_VERSION_LREM = "1.2"
PROMPT_VERSION_SYN = "1.0" PROMPT_VERSION_SYN = "1.0"
def prompt_signature(): def prompt_signature():
@@ -226,8 +226,9 @@ Something stranger is possible now — let the accumulated
material from the night find its own shape. Compressed, material from the night find its own shape. Compressed,
associative, slightly off. Let the strangeness stand. associative, slightly off. Let the strangeness stand.
No headers. No bullet points. No hedging. 150-250 words. No headers. No bullet points. No hedging. No resolution.
Something at the end that he could follow if he wanted to.""" No offer. End mid-thought if that is where the material ends.
150-250 words."""
return _call_claude(prompt) return _call_claude(prompt)
@@ -345,6 +346,32 @@ def save_dreamer_state(state):
# ─── Orchestrators ─────────────────────────────────────────────────────────── # ─── Orchestrators ───────────────────────────────────────────────────────────
def write_manifest(date_str, stage_data, corpus_data):
import requests
manifest = {
"date": date_str,
"prompt_sig": prompt_signature(),
"prompt_hash": prompt_hash([
synthesize_nrem.__doc__ or "",
synthesize_early_rem.__doc__ or "",
synthesize_late_rem.__doc__ or "",
synthesize_final.__doc__ or "",
]),
"stages": stage_data,
"corpus": corpus_data,
"rating": None,
"notes": "",
}
content = json.dumps(manifest, indent=2)
auth = (NEXTCLOUD_USER, NEXTCLOUD_PASSWORD)
url = f"{DREAMS_WEBDAV}/dream-manifest-{date_str}.json"
try:
requests.put(url, data=content.encode("utf-8"), auth=auth, timeout=30)
print(f"Manifest written: Journal/Dreams/dream-manifest-{date_str}.json")
except Exception as e:
print(f"Manifest write failed (non-critical): {e}")
def dream_pipeline(): def dream_pipeline():
""" """
Full nightly pipeline — interdependent stages. Full nightly pipeline — interdependent stages.
@@ -365,6 +392,15 @@ def dream_pipeline():
print(f"[NREM] Retrieved {len(nrem_chunks)} chunks. Synthesizing...") print(f"[NREM] Retrieved {len(nrem_chunks)} chunks. Synthesizing...")
nrem_output = synthesize_nrem(nrem_chunks) nrem_output = synthesize_nrem(nrem_chunks)
nrem_file = deliver(nrem_output, "nrem") nrem_file = deliver(nrem_output, "nrem")
stage_data = {
"nrem": {
"chunks_retrieved": len(nrem_chunks),
"avg_similarity": round(sum(c["relevance"] for c in nrem_chunks) / len(nrem_chunks), 3),
"query": "research fabrication teaching practice recent work",
"word_count": len(nrem_output.split()),
"status": "ok",
}
}
print(f"[NREM] Done.\n{nrem_output[:200]}...") print(f"[NREM] Done.\n{nrem_output[:200]}...")
# ── Stage 2: Early REM — informed by NREM ────────────────────────────── # ── Stage 2: Early REM — informed by NREM ──────────────────────────────
@@ -377,6 +413,13 @@ def dream_pipeline():
print(f"[Early REM] Retrieved {len(early_chunks)} chunks. Synthesizing with NREM context...") print(f"[Early REM] Retrieved {len(early_chunks)} chunks. Synthesizing with NREM context...")
early_rem_output = synthesize_early_rem(early_chunks, nrem_output) early_rem_output = synthesize_early_rem(early_chunks, nrem_output)
deliver(early_rem_output, "early-rem") deliver(early_rem_output, "early-rem")
stage_data["early_rem"] = {
"chunks_retrieved": len(early_chunks),
"avg_similarity": round(sum(c["relevance"] for c in early_chunks) / len(early_chunks), 3),
"query": "career decision personal change what matters next",
"word_count": len(early_rem_output.split()),
"status": "ok",
}
print(f"[Early REM] Done.\n{early_rem_output[:200]}...") print(f"[Early REM] Done.\n{early_rem_output[:200]}...")
# ── Stage 3: Late REM — informed by NREM + Early REM ────────────────── # ── Stage 3: Late REM — informed by NREM + Early REM ──────────────────
@@ -389,18 +432,37 @@ def dream_pipeline():
print(f"[Late REM] Retrieved {len(late_chunks)} chunks. Synthesizing with full context...") print(f"[Late REM] Retrieved {len(late_chunks)} chunks. Synthesizing with full context...")
late_rem_output = synthesize_late_rem(late_chunks, nrem_output, early_rem_output) late_rem_output = synthesize_late_rem(late_chunks, nrem_output, early_rem_output)
deliver(late_rem_output, "late-rem") deliver(late_rem_output, "late-rem")
stage_data["late_rem"] = {
"chunks_retrieved": len(late_chunks),
"avg_similarity": round(sum(c["relevance"] for c in late_chunks) / len(late_chunks), 3),
"query": "practice place memory making",
"word_count": len(late_rem_output.split()),
"status": "ok",
}
print(f"[Late REM] Done.\n{late_rem_output[:200]}...") print(f"[Late REM] Done.\n{late_rem_output[:200]}...")
# ── Stage 4: Synthesis — all three stages ───────────────────────────── # ── Stage 4: Synthesis — all three stages ─────────────────────────────
print("\n[Synthesis] Integrating all stages...") print("\n[Synthesis] Integrating all stages...")
synthesis_output = synthesize_final(nrem_output, early_rem_output, late_rem_output) synthesis_output = synthesize_final(nrem_output, early_rem_output, late_rem_output)
synthesis_file = deliver(synthesis_output, "synthesis") synthesis_file = deliver(synthesis_output, "synthesis")
stage_data["synthesis"] = {
"word_count": len(synthesis_output.split()),
"status": "ok",
}
print(f"\n{'='*60}") print(f"\n{'='*60}")
print("SYNTHESIS:") print("SYNTHESIS:")
print(synthesis_output) print(synthesis_output)
print(f"{'='*60}") print(f"{'='*60}")
# Write manifest
corpus_data = {
"total_chunks": delta.get("new_chunks", 0),
"new_chunks_since_last_dream": delta.get("new_chunks", 0),
"days_since_last_dream": round(delta.get("days_since_dream", 0), 2),
}
write_manifest(datetime.now().strftime("%Y-%m-%d"), stage_data, corpus_data)
# Update state and notify # Update state and notify
state = load_dreamer_state() state = load_dreamer_state()
state["last_dream_timestamp"] = datetime.now().timestamp() state["last_dream_timestamp"] = datetime.now().timestamp()