chore: snapshot in-progress question-gen work before preflight fixes

This commit is contained in:
2026-07-16 04:12:21 -04:00
parent 11a5545f57
commit a4c429b247
39 changed files with 738 additions and 283 deletions
+19 -8
View File
@@ -96,24 +96,33 @@ def validate_units(units: list[QuestionUnit]) -> list[QuestionUnit]:
return units
def unit_correctness(unit: QuestionUnit, per_q: dict[str, bool]) -> bool:
def unit_correctness(unit: QuestionUnit, per_q: dict[str, bool], *, strict: bool = True) -> bool:
"""计算单元级正确性:AR pair 走双向 AND,single 即单题正确性。
参数:
unit: 目标单元。
per_q: 题目 question_id → 该题是否作答正确的映射。
strict: 缺键策略。True(默认)时以 per_q[q.question_id] 取值,缺任一题
触发 KeyError(防静默兜底,强制上游先补齐全部单题结果);False 时以
per_q.get(q.question_id, False) 取值,缺键计 False(宽松口径,供池
构建 / gate 冷启动 / 采样等"缺基线对错即视为未答对"的调用点复用)。
返回:
单元内所有题目均正确时为 True,否则 False。
关键实现:
直接以 per_q[q.question_id] 取值,缺任一题触发 KeyError(防静默兜底),
强制上游先补齐全部单题结果再计单元正确性。
pool 构建(pools)、gate 冷启动(gate_ladder)、分层采样(loader)三处
原各自持有的 loose 版 _unit_correct 副本统一收敛到本函数 strict=False 分支,
消除重复逻辑与 missing-key 策略分叉。
"""
return all(per_q[q.question_id] for q in unit.questions)
if strict:
return all(per_q[q.question_id] for q in unit.questions)
return all(per_q.get(q.question_id, False) for q in unit.questions)
def unit_correctness_view(units: list[QuestionUnit], per_q: dict[str, bool]) -> dict[str, bool]:
def unit_correctness_view(
units: list[QuestionUnit], per_q: dict[str, bool], *, strict: bool = True
) -> dict[str, bool]:
"""把逐题对错折叠成单元级视图:unit_id → 单元是否整体正确。
进化引擎(gate e-process / quadrant / probation / pair_block / compute_accuracy
@@ -123,13 +132,15 @@ def unit_correctness_view(units: list[QuestionUnit], per_q: dict[str, bool]) ->
参数:
units: 目标单元列表(single 或 pair)。
per_q: 题目 question_id → 该题是否作答正确(唯一逐题溯源来源)。
strict: 缺键策略,透传给 unit_correctness。True(默认)缺任一题 raise
KeyErrorFalse 缺键计 False(宽松口径)。
返回:
unit_id → 单元级正确性。single 的 unit_id 等于其 question_id
pair 的 unit_id 等于共享 pair_id。
关键实现:
逐单元复用 unit_correctness内部以 per_q[q.question_id] 取值,缺任一题
触发 KeyError),禁静默兜底、强制上游先补齐全部单题结果。
逐单元复用 unit_correctnessstrict 透传),默认 strict 禁静默兜底、
强制上游先补齐全部单题结果。
"""
return {u.unit_id: unit_correctness(u, per_q) for u in units}
return {u.unit_id: unit_correctness(u, per_q, strict=strict) for u in units}