chain-balance gates in reconcile_exits + retry queue — ghosts dropped, sells clamped to chain (closes #7); tape ingest pings the daily channel at start + finish

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
jaxperro
2026-07-19 16:34:51 -04:00
parent 9811e411df
commit 2744b67587
2 changed files with 50 additions and 0 deletions
+21
View File
@@ -9,14 +9,32 @@ import gzip
import json
import os
import shutil
import ssl
import subprocess
import time
import urllib.request
HERE = os.path.dirname(os.path.abspath(__file__))
DB = os.path.join(HERE, "..", "live", "rtds.duckdb")
APP, SEG = "wwf-recorder", "/data/segments"
def ping(msg):
"""Best-effort Discord ping to the DAILY channel (user ask 2026-07-19:
the nightly pull announces start + finish). Never fatal."""
try:
hook = json.load(open(os.path.join(HERE, "..", "config.json"))).get("daily_webhook")
if not hook:
return
req = urllib.request.Request(hook, data=json.dumps({"content": msg}).encode(),
headers={"Content-Type": "application/json",
"User-Agent": "Mozilla/5.0"})
urllib.request.urlopen(req, timeout=10,
context=ssl._create_unverified_context()).read()
except Exception:
pass
# launchd runs daily.sh with a minimal PATH (no /opt/homebrew/bin) — the
# 2026-07-18 run died on FileNotFoundError: 'flyctl'. Resolve it explicitly.
FLYCTL = shutil.which("flyctl") or "/opt/homebrew/bin/flyctl"
@@ -42,6 +60,7 @@ def main():
have = {r[0] for r in con.execute("SELECT segment FROM ingested").fetchall()}
segs = [s for s in box(f"ls {SEG}").split()
if s.endswith(".gz") and s not in have]
ping(f"📼 tape ingest started — {len(segs)} segment(s) queued")
total = 0
for s in sorted(segs):
raw = box(f"base64 {SEG}/{s}")
@@ -76,6 +95,8 @@ def main():
print(f"[ingest] {s}: {len(rows)} trades + {len(aux)} aux")
n = con.execute("SELECT count(*) FROM trades").fetchone()[0]
print(f"[ingest] +{total} rows · rtds.duckdb now {n:,} trades")
ping(f"📼 tape ingest done: +{total:,} rows across {len(segs)} segment(s) "
f"· rtds.duckdb now {n:,} trades")
if __name__ == "__main__":