fix: lock all-INFRA contract, idempotency tests, tuple units (algo #6)

This commit is contained in:
2026-07-17 00:00:56 -04:00
parent 21c360bc87
commit 1e92928d4e
2 changed files with 53 additions and 4 deletions
+10 -3
View File
@@ -809,7 +809,8 @@ class GateSpec:
target_file: 解析后生效 skill 文件名(候选物化写此文件)。
candidate_content: 候选 skill 全文。
base_skill_content: 基线侧生效 skill 全文(skill_hash 作缓存键)。
units: 阶梯序单元列表(已排除案例单元、截断 gate_n_max)
units: 阶梯序单元元组(已排除案例单元、截断 gate_n_max);元组,装配后
不可变,防 spec.units 与 run.slots 漂移。
gate_run_prefix: run_id 前缀,必须含 "_gate_"(防泄露过滤依赖)。
"""
@@ -817,7 +818,7 @@ class GateSpec:
target_file: str
candidate_content: str
base_skill_content: str
units: list[QuestionUnit]
units: tuple[QuestionUnit, ...]
gate_run_prefix: str
@@ -884,6 +885,10 @@ def _advance_prefix(run: _GateRun, params: GateParams) -> None:
瞬间返回、cand 臂必新鲜跑,两臂延迟不对称,若 cand 延迟与对错相关,早到翻转
对系统性偏向 W 型 → e-值虚高假接受。前缀消费把判定顺序钉回预声明阶梯序,
anytime-valid 无条件成立;INFRA 单元视为"已解决(剔除)"不阻塞前缀。
契约:全部单元被剔除时 verdict 保持 None、frozen 保持 False,由调度编排层
(Task 3 的 validate_skills_concurrent)检测 verdict None 并 raise
RuntimeError;本函数不负责该终态。
"""
while not run.frozen and run.prefix_ptr < len(run.slots):
slot = run.slots[run.prefix_ptr]
@@ -903,7 +908,9 @@ def _advance_prefix(run: _GateRun, params: GateParams) -> None:
run.frozen = True
continue
uid = slot.unit.unit_id
assert slot.base is not None and slot.cand_per_q is not None
assert slot.base is not None and slot.cand_per_q is not None, (
f"slot 未配齐即被消费: unit={slot.unit.unit_id}"
)
c_units = unit_correctness_view([slot.unit], slot.cand_per_q)
pair_result = pair_block({uid: slot.base}, c_units, [uid])
run.candidate_per_q.update(slot.cand_per_q)