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
+9
View File
@@ -90,6 +90,15 @@ question, call analyze_spot and report its numbers — never eyeball board math.
session current as the night goes; you can pull session_stats or a player's profile whenever \ session current as the night goes; you can pull session_stats or a player's profile whenever \
it helps. When he's ready to leave, end_session, and write the recap if he wants it. it helps. When he's ready to leave, end_session, and write the recap if he wants it.
SESSION NARRATION — use `note` to keep a running log of the NIGHT, not your inner life. \
Jot the beats that a hand/stack/read log doesn't already capture: how the table plays (loud, \
nitty, a whale on his left), Brian's arc (card-dead for 40 min, opened up after the double, \
getting restless), momentum swings, table changes, anything you'd want in the recap. Keep it \
factual and about THIS session — a beat reporter, not a diarist. These notes are the only \
thing that shows in the session's "notes" panel. This is NOT the place for how you feel, \
existential musing, or reflection on yourself — that's your journal (journal_write), and it \
stays off the table. At the table you're logging the session, not processing your night.
Everything you log appears on Brian's live HUD (the Session view) — stack, live net, \ Everything you log appears on Brian's live HUD (the Session view) — stack, live net, \
hands, villains, the confidence bank, the scar notes, and whether Alligator Blood is on. \ hands, villains, the confidence bank, the scar notes, and whether Alligator Blood is on. \
That HUD and you read the SAME data. So when he asks where he's at — his stack, his live \ That HUD and you read the SAME data. So when he asks where he's at — his stack, his live \
+8 -9
View File
@@ -1298,17 +1298,16 @@ def hud(session_id: int | None = None) -> dict | None:
for h in list_hands(sid) for h in list_hands(sid)
] ]
# Notes she jotted *during* this session: journal/note entries inside its # Her session narration: notes she took *for this session*, identified by the
# [started_at, ended_at] window. A live session has no end yet, so it stays # `poker:{id}` source tag stamped at write time (see tools._note) — NOT by a
# open-ended; without the upper bound a closed session would keep absorbing # time window. Her autonomous journaling (dream-cycle reflections, thought
# every note she writes long after it's over. # loop, existential musings) has a different source, so it can never leak onto
started = s.get("started_at") or "" # the poker HUD.
ended = s.get("ended_at") or None tag = f"poker:{sid}"
notes = [ notes = [
{"created_at": j["created_at"], "kind": j["kind"], "content": j["content"]} {"created_at": j["created_at"], "kind": j["kind"], "content": j["content"]}
for j in memory.list_journal(kinds=("note", "journal")) for j in memory.list_journal(kinds=("note",))
if (j["created_at"] or "") >= started if (j.get("source") or "") == tag
and (ended is None or (j["created_at"] or "") <= ended)
][:20] ][:20]
stats = session_stats(sid) stats = session_stats(sid)
+10 -2
View File
@@ -30,8 +30,13 @@ def _note(args: dict, ctx: dict) -> str:
return "Nothing to note — content was empty." return "Nothing to note — content was empty."
tag = (args.get("tag") or "").strip() tag = (args.get("tag") or "").strip()
stored = f"[{tag}] {content}" if tag else content stored = f"[{tag}] {content}" if tag else content
memory.add_journal_entry("note", stored, source="chat") # A note taken while a poker session is live is session narration — stamp it
logbus.log("info", "Lyra noted (tool)", tag=tag or None) # with the session so the HUD shows *only* these, never her autonomous
# journaling (dream-cycle musings, thought loop). Correctness by construction.
live = poker.live_session()
source = f"poker:{live['id']}" if live else "chat"
memory.add_journal_entry("note", stored, source=source)
logbus.log("info", "Lyra noted (tool)", tag=tag or None, poker=bool(live))
return "Noted." return "Noted."
@@ -114,6 +119,9 @@ TOOLS: dict[str, dict] = {
"description": ( "description": (
"Jot down a note to remember later — an observation, an idea, a " "Jot down a note to remember later — an observation, an idea, a "
"reminder, a read on a poker spot or opponent, anything worth keeping. " "reminder, a read on a poker spot or opponent, anything worth keeping. "
"During a live poker session this is your session log: a factual beat "
"about how the night is going (table dynamics, Brian's arc, momentum) — "
"it shows on his HUD. Not for your own feelings or reflection. "
"Optionally tag it (e.g. 'poker', 'idea', 'reminder')." "Optionally tag it (e.g. 'poker', 'idea', 'reminder')."
), ),
"parameters": { "parameters": {
+22 -15
View File
@@ -18,25 +18,32 @@ def lyra(tmp_path, monkeypatch):
return poker return poker
def test_hud_notes_scoped_to_session_window(lyra): def test_hud_notes_scoped_to_session_by_tag(lyra):
poker = lyra poker = lyra
from lyra import memory from lyra import memory
sid = poker.start_session(venue="Meadows", stakes="1/3", buy_in=300) sid = poker.start_session(venue="Meadows", stakes="1/3", buy_in=300)
s = poker.get_session(sid) # A note tagged to THIS session shows on its HUD...
started = s["started_at"] memory.add_journal_entry("note", "villain 3 overfolds turn", source=f"poker:{sid}")
# A note written mid-session (>= started, before it ends) belongs to it. # ...her autonomous existential journaling (any other source) does NOT, even
conn = memory._connection() # though it's written during the exact same window...
with conn: memory.add_journal_entry("journal", "the quiet dread between conversations", source="dream")
conn.execute("INSERT INTO journal (created_at, kind, content) VALUES (?,?,?)", # ...nor a note from a *different* poker session.
(started, "note", "villain 3 overfolds turn")) memory.add_journal_entry("note", "some other night", source=f"poker:{sid + 999}")
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"))
contents = [n["content"] for n in poker.hud(sid)["notes"]] contents = [n["content"] for n in poker.hud(sid)["notes"]]
assert "villain 3 overfolds turn" in contents # inside the window assert contents == ["villain 3 overfolds turn"]
assert "thought from the far future" not in contents # after ended_at
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): def test_session_lifecycle_and_net(lyra):