feat: poker-session notes are session narration, tagged by construction

The HUD's "her notes" panel showed any journal/note entry in the session's time
window — which swept in her *autonomous* journaling (dream-cycle reflections,
thought loop, existential musings) that merely overlapped in time. So a poker
session displayed her feelings, not the night.

Fix both halves:
- Identity: the `note` tool stamps `source=poker:{id}` when a session is live, so
  a session note is identifiable by construction. The HUD filters on that tag
  (kind='note' only) instead of a time window — her journaling has a different
  source and can never leak onto the poker HUD. `journal_write` stays her private
  journal and never shows here.
- Behavior: the Cash card now tells her to use `note` as a running SESSION LOG —
  factual beats a hand/stack log misses (table dynamics, Brian's arc, momentum),
  beat-reporter not diarist — and explicitly keeps feelings/reflection off the
  table. The note tool spec echoes this for the live-session case.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-03 19:41:35 +00:00
parent 71bbe07220
commit 7f23aeae17
4 changed files with 49 additions and 26 deletions
+22 -15
View File
@@ -18,25 +18,32 @@ def lyra(tmp_path, monkeypatch):
return poker
def test_hud_notes_scoped_to_session_window(lyra):
def test_hud_notes_scoped_to_session_by_tag(lyra):
poker = lyra
from lyra import memory
sid = poker.start_session(venue="Meadows", stakes="1/3", buy_in=300)
s = poker.get_session(sid)
started = s["started_at"]
# A note written mid-session (>= started, before it ends) belongs to it.
conn = memory._connection()
with conn:
conn.execute("INSERT INTO journal (created_at, kind, content) VALUES (?,?,?)",
(started, "note", "villain 3 overfolds turn"))
poker.end_session(cash_out=540, session_id=sid)
# A note written well after the session closed must NOT show up on it.
with conn:
conn.execute("INSERT INTO journal (created_at, kind, content) VALUES (?,?,?)",
("2999-01-01T00:00:00+00:00", "note", "thought from the far future"))
# A note tagged to THIS session shows on its HUD...
memory.add_journal_entry("note", "villain 3 overfolds turn", source=f"poker:{sid}")
# ...her autonomous existential journaling (any other source) does NOT, even
# though it's written during the exact same window...
memory.add_journal_entry("journal", "the quiet dread between conversations", source="dream")
# ...nor a note from a *different* poker session.
memory.add_journal_entry("note", "some other night", source=f"poker:{sid + 999}")
contents = [n["content"] for n in poker.hud(sid)["notes"]]
assert "villain 3 overfolds turn" in contents # inside the window
assert "thought from the far future" not in contents # after ended_at
assert contents == ["villain 3 overfolds turn"]
def test_note_tool_tags_live_poker_session(lyra):
poker = lyra
from lyra import tools
sid = poker.start_session(stakes="1/3", buy_in=300)
tools.dispatch("note", {"content": "whale just sat down seat 4"}, {})
assert poker.hud(sid)["notes"][0]["content"] == "whale just sat down seat 4"
poker.end_session(cash_out=300, session_id=sid)
# With no live session, a note falls back to the general journal (source=chat),
# so it does NOT attach to the just-closed session's HUD.
tools.dispatch("note", {"content": "random afternoon idea"}, {})
assert all(n["content"] != "random afternoon idea" for n in poker.hud(sid)["notes"])
def test_session_lifecycle_and_net(lyra):