fix: predictions row carries arm run_id under shared gate_log; drain evolve gather on failure (algo #6)
This commit is contained in:
@@ -117,8 +117,9 @@ def harness_log(tmp_path: Any, request: Any) -> HarnessLog:
|
||||
"""创建临时 HarnessLog 实例。
|
||||
|
||||
使用 test 节点名称的 hash 作为 db 文件名,避免冲突。
|
||||
run_id 固定为 "test-run",实际 run_inference 中传入的 run_id
|
||||
由 HarnessLog.insert 自动覆盖为 HarnessLog 构造时的值。
|
||||
实例 run_id 固定为 "test-run";predictions 行的 run_id 由 inference
|
||||
record 显式携带(run_inference 传入值),不回落实例 run_id——
|
||||
连续并发 gate 共享单一 HarnessLog 的契约。
|
||||
"""
|
||||
db_name = f"harness_{id(request)}.db"
|
||||
db_path = str(tmp_path / db_name)
|
||||
@@ -528,8 +529,9 @@ class TestPredictionAlwaysWritten:
|
||||
assert result.correct == 0
|
||||
assert result.stop_reason_counts.get("error") == 1
|
||||
|
||||
# 验证 DB 中的记录(HarnessLog.insert 使用构造时的 run_id)
|
||||
rows = harness_log.query("SELECT * FROM predictions WHERE run_id = ?", ("test-run",))
|
||||
# 验证 DB 中的记录(record 显式携带 run_inference 的 run_id,
|
||||
# 不再回落 HarnessLog 实例 run_id——连续并发 gate 共享 log 的契约)
|
||||
rows = harness_log.query("SELECT * FROM predictions WHERE run_id = ?", ("run-error",))
|
||||
assert len(rows) == 1
|
||||
assert rows[0]["stop_reason"] == "error"
|
||||
assert rows[0]["prediction"] is None
|
||||
@@ -553,8 +555,8 @@ class TestPredictionAlwaysWritten:
|
||||
)
|
||||
|
||||
assert result.total == 1
|
||||
# HarnessLog.insert 使用构造时的 run_id
|
||||
rows = harness_log.query("SELECT * FROM predictions WHERE run_id = ?", ("test-run",))
|
||||
# record 显式携带 run_inference 的 run_id(共享 log 契约)
|
||||
rows = harness_log.query("SELECT * FROM predictions WHERE run_id = ?", ("run-parse-err",))
|
||||
assert len(rows) == 1
|
||||
assert rows[0]["prediction"] is None
|
||||
|
||||
@@ -612,7 +614,7 @@ class TestNonScalarPrediction:
|
||||
)
|
||||
|
||||
assert result.total == 1
|
||||
rows = harness_log.query("SELECT * FROM predictions WHERE run_id = ?", ("test-run",))
|
||||
rows = harness_log.query("SELECT * FROM predictions WHERE run_id = ?", ("run-nonscalar",))
|
||||
assert len(rows) == 1
|
||||
# prediction 被 JSON 序列化为字符串,不再是 Python list
|
||||
assert rows[0]["prediction"] == '["B"]'
|
||||
|
||||
Reference in New Issue
Block a user