fix: backfill skips hand extraction by default (prose->replay too lossy)

The auto-extracted hands from narrative logs were garbage (mangled cards/positions,
'unknown' players). Seed sessions + recaps + villain dossiers only; hands come
from clean shorthand going forward. --with-hands re-enables if ever wanted.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-18 06:04:02 +00:00
parent 6761c3f978
commit ce7ede75aa
+11 -3
View File
@@ -79,8 +79,14 @@ def extract(block: str, backend: str = "cloud") -> dict | None:
_real_handle = poker._real_handle # one canonical filter (lives in poker.py) _real_handle = poker._real_handle # one canonical filter (lives in poker.py)
def seed(ex: dict, block: str) -> dict: def seed(ex: dict, block: str, with_hands: bool = False) -> dict:
"""Write one extracted session + its hands + villains to the DB. Returns a summary.""" """Write one extracted session + villains (+ hands only if asked) to the DB.
Hands are OFF by default: reconstructing a clean replayable hand from old
narrative prose is too lossy (mangled cards/positions). Sessions, their
original writeups (recap), and villain dossiers seed cleanly; hands are best
captured fresh from Brian's own shorthand going forward.
"""
sid = poker.import_session( sid = poker.import_session(
date=ex.get("date") or "2026-01-01", venue=ex.get("venue"), game=ex.get("game") or "NLH", date=ex.get("date") or "2026-01-01", venue=ex.get("venue"), game=ex.get("game") or "NLH",
stakes=ex.get("stakes"), fmt=ex.get("format") or "cash", stakes=ex.get("stakes"), fmt=ex.get("format") or "cash",
@@ -88,6 +94,7 @@ def seed(ex: dict, block: str) -> dict:
hours=ex.get("hours"), mood=ex.get("mood"), recap_md=block, hours=ex.get("hours"), mood=ex.get("mood"), recap_md=block,
) )
n_hands = 0 n_hands = 0
if with_hands:
for h in ex.get("hands") or []: for h in ex.get("hands") or []:
hid = poker.store_hand_history(h, session_id=sid) hid = poker.store_hand_history(h, session_id=sid)
poker.link_hand_players(hid, h, session_id=sid) poker.link_hand_players(hid, h, session_id=sid)
@@ -107,6 +114,7 @@ def main() -> int:
args = sys.argv[1:] args = sys.argv[1:]
commit = "--commit" in args commit = "--commit" in args
reset = "--reset" in args reset = "--reset" in args
with_hands = "--with-hands" in args # off by default — prose->hand replay is too lossy
limit = None limit = None
for i, a in enumerate(args): for i, a in enumerate(args):
if a == "--dry" and i + 1 < len(args) and args[i + 1].isdigit(): if a == "--dry" and i + 1 < len(args) and args[i + 1].isdigit():
@@ -127,7 +135,7 @@ def main() -> int:
print(f" ! could not parse a block: {b[:60]!r}") print(f" ! could not parse a block: {b[:60]!r}")
continue continue
if commit: if commit:
print(" seeded:", seed(ex, b)) print(" seeded:", seed(ex, b, with_hands=with_hands))
else: else:
print(f"\n=== {ex.get('date')}{ex.get('venue')} {ex.get('stakes')} " print(f"\n=== {ex.get('date')}{ex.get('venue')} {ex.get('stakes')} "
f"({ex.get('format')}) net {ex.get('net')} ===") f"({ex.get('format')}) net {ex.get('net')} ===")