fix: idempotent ladder_rank migration for legacy gate_evidence tables

This commit is contained in:
2026-07-17 05:29:20 -04:00
parent 1930ad32a4
commit eb12006d38
2 changed files with 42 additions and 0 deletions
+6
View File
@@ -358,6 +358,12 @@ def write_gate_evidence(
with HarnessLog(db_path, run_id) as log:
log.create_table("gate_evidence", _GATE_EVIDENCE_COLS)
# 幂等迁移(对齐 question_gen/run_store 先例):块序贯时代的旧表只有
# block_idx 列,CREATE TABLE IF NOT EXISTS 不补列,直接插 ladder_rank
# 会 OperationalError——为旧 workspace 复用补列,新表恒为 no-op。
cols = {r["name"] for r in log.query("PRAGMA table_info(gate_evidence)")}
if "ladder_rank" not in cols:
log.execute("ALTER TABLE gate_evidence ADD COLUMN ladder_rank INTEGER")
for row in rows:
log.insert("gate_evidence", {"epoch": epoch, "step": step, **row})