feat: scouting desk — proactive villain recall injected before she replies

Phase 2. On every poker-context turn, detect players named or described in the
message and slide their structured history into her prompt as a SCOUTING DESK
note (cite-don't-invent). Fail-safe: any desk error is swallowed, never breaks
the turn; silence is the default.

- poker.villain_recall(id): episodic brief — times/where seen, last seen, notable
  hands (linkable ids), reads, stats (Gap 1: the when/where/which-hand narrative).
- scouting.scout(): named hits (deterministic word match) + descriptor spans
  (regex → resolve_villain). High → surface + "confirm it's the same guy";
  ambiguous → file needs_clarification to the queue instead of interrupting;
  generic → stay silent.
- mind.build_messages wires it in, gated to poker modes (poker_cash/study).

5 tests. Full suite 146 green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-03 22:49:40 +00:00
parent 8a6b11c56a
commit 9cd962625d
4 changed files with 252 additions and 1 deletions
+16 -1
View File
@@ -16,12 +16,16 @@ from __future__ import annotations
from dataclasses import dataclass, field
from lyra import clock, config, llm, logbus, memory, modes, perceive, persona, self_state, thoughts
from lyra import (
clock, config, llm, logbus, memory, modes, perceive, persona, scouting,
self_state, thoughts,
)
from lyra.llm import Backend, Message
RECALL_K = 3 # raw cross-session "sharp detail" hits
RECENT_N = 10 # raw turns of the current session
SUMMARY_K = 3 # other-session gists
_POKER_MODES = {"poker_cash", "study"} # where the scouting desk runs
# --- prompt parts (compose) ----------------------------------------------
@@ -167,6 +171,17 @@ def build_messages(session_id: str, user_msg: str,
if moment and moment.get("note"):
messages.append({"role": "system", "content": moment["note"]})
# Scouting desk: proactive poker recall — if he names/describes a known player,
# slide his structured history in before she replies. Poker context only, and
# fully fail-safe (a desk error must never break the turn).
if mode and mode.key in _POKER_MODES:
try:
desk = scouting.scout(user_msg)
if desk:
messages.append({"role": "system", "content": desk})
except Exception as exc:
logbus.log("error", "scouting desk skipped", error=str(exc)[:160])
# When she is: current time + the gap since Brian last spoke (she has no clock).
messages.append(_now_note())