feat: dream-cycle merge scan + pattern desk (leak recall)

Phases 5 & 6, completing the scouting desk.

Phase 5 — the nightly consolidation (dream cycle, coherence block) now runs
poker.scan_merge_candidates(), filing likely same-person merges to the review
queue off the hot path. Fail-safe: a scan error never sinks the cycle.

Phase 6 — "you've hit this leak before". Scar/confidence notes are embedded on
write; recall_similar_rituals() finds past ones close to the current spot,
excluding tonight. The scouting desk adds a pattern pass that surfaces them — but
ONLY on genuine strategy/tilt talk (a length + cue gate), so routine logging like
"stack 350" never pays for an embed. Respects the per-turn latency concern.

7 tests (deterministic embed stub to keep threshold assertions stable). Full
suite 153 green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-03 23:01:53 +00:00
parent 056578ac75
commit d5c80f6153
4 changed files with 154 additions and 10 deletions
+11 -1
View File
@@ -25,7 +25,9 @@ import argparse
import time
from datetime import datetime, timezone
from lyra import config, era, feeds, logbus, memory, narrative, profile, self_state, summary, thoughts
from lyra import (
config, era, feeds, logbus, memory, narrative, poker, profile, self_state, summary, thoughts,
)
from lyra.llm import Backend
from lyra.summary import SUMMARIZE_AFTER
@@ -112,6 +114,14 @@ def dream_cycle(backend: Backend | None = None, force: bool = False) -> dict:
narrative.rebuild_narrative(backend=backend)
actions.append("integrated knowledge (profile/eras/narrative)")
drives["coherence"] = 0.0
# Off-hot-path villain identity housekeeping: propose likely same-person
# merges for Brian to confirm on the Players page. Never sinks the cycle.
try:
filed = poker.scan_merge_candidates()
if filed:
actions.append(f"flagged {filed} possible villain merge(s)")
except Exception as exc:
logbus.log("error", "villain merge scan failed", error=str(exc)[:200])
# --- curiosity: reflect and evolve the self, then advance the thought loop ---
if force or drives["curiosity"] >= THRESHOLD: