chore: format Phase B modules and register Phase B plan in wiki

This commit is contained in:
2026-07-14 17:11:04 -04:00
parent f36eb66c18
commit 441a0aa6c3
6 changed files with 45 additions and 24 deletions
+2 -6
View File
@@ -723,9 +723,7 @@ async def run_adversarial_rounds(
max_steps=config.adversarial_agent_max_steps,
model=agent.model,
)
all_questions: dict[str, GeneratedQuestion] = {
q.question_id: q for q in initial_questions
}
all_questions: dict[str, GeneratedQuestion] = {q.question_id: q for q in initial_questions}
pending = list(initial_questions)
passed_now = 0
for round_no in range(config.adversarial_max_rounds):
@@ -749,9 +747,7 @@ async def run_adversarial_rounds(
session_id=session_id,
)
passed_now = len(write_final_bank(final_path, store, all_questions, cfg_fp))
_report_difficulty(
store, round_no=round_no, threshold=config.difficulty_warn_threshold
)
_report_difficulty(store, round_no=round_no, threshold=config.difficulty_warn_threshold)
deficit = target - passed_now
if deficit <= 0 or round_no + 1 >= config.adversarial_max_rounds:
break
+13 -15
View File
@@ -457,16 +457,20 @@ class QuestionGenStore:
created_at=datetime('now')
""",
(
question_id, question_hash, stage, round, agent_prediction,
question_id,
question_hash,
stage,
round,
agent_prediction,
None if agent_correct is None else int(agent_correct),
verdict, pair_id, agent_config,
verdict,
pair_id,
agent_config,
),
)
self._conn.commit()
def completed_stages(
self, question_id: str, question_hash: str, agent_config: str
) -> set[str]:
def completed_stages(self, question_id: str, question_hash: str, agent_config: str) -> set[str]:
"""返回该题在当前 hash+config 下已完成的 stage 集合(续跑用)。
Parameters
@@ -501,8 +505,7 @@ class QuestionGenStore:
当前 agent 配置指纹;保留该 config 行,其余全部删除。
"""
self._conn.execute(
"DELETE FROM adversarial_verdicts "
"WHERE question_id=? AND agent_config!=?",
"DELETE FROM adversarial_verdicts WHERE question_id=? AND agent_config!=?",
(question_id, agent_config),
)
self._conn.commit()
@@ -521,15 +524,12 @@ class QuestionGenStore:
该轮 stage='cheat' 的 agent_correct 平均值;无数据时返回 0.0。
"""
row = self._conn.execute(
"SELECT AVG(agent_correct) FROM adversarial_verdicts "
"WHERE stage='cheat' AND round=?",
"SELECT AVG(agent_correct) FROM adversarial_verdicts WHERE stage='cheat' AND round=?",
(round_no,),
).fetchone()
return float(row[0]) if row and row[0] is not None else 0.0
def final_passed_question_ids(
self, hash_by_qid: dict[str, str], agent_config: str
) -> set[str]:
def final_passed_question_ids(self, hash_by_qid: dict[str, str], agent_config: str) -> set[str]:
"""在当前 hash+config 下通过两门的 question_id 集合(final JSON 全量重建用)。
终判规则(防 stale 泄漏):仅当该题在 **当前 question_hash + 当前
@@ -559,9 +559,7 @@ class QuestionGenStore:
).fetchall()
if not rows:
continue
cheat_passed = any(
stage == "cheat" and verdict == "passed" for stage, verdict in rows
)
cheat_passed = any(stage == "cheat" and verdict == "passed" for stage, verdict in rows)
no_flip = any(verdict == "filtered_no_flip" for _, verdict in rows)
if cheat_passed and not no_flip:
passed.add(qid)