35 lines
1.3 KiB
Python
35 lines
1.3 KiB
Python
"""Autonomous sharpening pass: wait for the cross-cluster podcast claims to extract, re-embed, then
|
|
re-run the §7.1 backtest. Run in the background; writes logs/backtest2.log for review."""
|
|
import sqlite3
|
|
import subprocess
|
|
import sys
|
|
import time
|
|
|
|
DB = "data/signal.db"
|
|
PY = ".venv/bin/python"
|
|
|
|
|
|
def pending_podcast_extract() -> int:
|
|
return sqlite3.connect(DB).execute(
|
|
"SELECT COUNT(*) FROM backfill_jobs WHERE job_type='extract' AND state='pending' "
|
|
"AND target_id LIKE 'pod:%'"
|
|
).fetchone()[0]
|
|
|
|
|
|
for i in range(60): # up to ~2h
|
|
p = pending_podcast_extract()
|
|
print(f"[sharpen] iter {i}: podcast extract pending={p}", flush=True)
|
|
if p <= 2:
|
|
break
|
|
time.sleep(120)
|
|
|
|
print("[sharpen] embedding accumulated claims...", flush=True)
|
|
subprocess.run([PY, "-m", "signal_engine", "embed-claims"], stdout=sys.stdout, stderr=subprocess.STDOUT)
|
|
|
|
print("[sharpen] re-running backtest...", flush=True)
|
|
with open("logs/backtest2.log", "w") as f:
|
|
subprocess.run([PY, "-m", "signal_engine", "backtest", "--conviction", "K2023",
|
|
"--start", "2023-03-01", "--end", "2024-09-01", "--step-days", "90",
|
|
"--window-days", "90"], stdout=f, stderr=subprocess.STDOUT)
|
|
print("[sharpen] DONE — see logs/backtest2.log", flush=True)
|