31 lines
2.1 KiB
Python
31 lines
2.1 KiB
Python
"""cheap_gates.py — 便宜档九门收口的同步包装(供 Service 续修 check 闭包经 to_thread 调用)。
|
|
|
|
归并后便宜档收敛判据从「check+build 绿」升为「九门绿」:RepairMiddleware 的 check 闭包在 finish 点
|
|
把工程收口跑一遍九门(stage→smoke→ensure_play_spec→play),经 worker.gate_judge.judge_cheap_verdict 归一。
|
|
本模块只做「同步 pipeline + 端口透传」,不做判据归一(那在 gate_judge,与 tier2 并列)。
|
|
端口由调用方按 session 派生传入(决策③ 并发避撞);shell-out/subprocess 阻塞,故封在同步函数里给 to_thread 跑。
|
|
"""
|
|
|
|
import cheap_run
|
|
|
|
|
|
def run_cheap_gates(game_id: str, port: int, cdp_port: int) -> dict:
|
|
"""同步跑便宜档九门收口 stage→smoke→ensure_play_spec→play,返回九门 verdict({pass, guards})或 {}(未跑出)。
|
|
|
|
任一段失败(stage 打包不出 / play 没产 verdict)→ 返 {}(judge_cheap_verdict 判未过、feedback 落 harness 说明,
|
|
不伪造门绿)。端口按 session 派生传入,避免并发多局撞固定 4320/9222(决策③)。
|
|
"""
|
|
st = cheap_run.stage(game_id)
|
|
if not st["ok"]:
|
|
print(f"[cheap-gates] game={game_id} stage 失败(判未过):{st['output'][:300]}", flush=True)
|
|
return {}
|
|
sm = cheap_run.smoke(game_id, port=port, cdp_port=cdp_port)
|
|
# ensure_play_spec 据 smoke 抓的 state 产 driver(已存在不覆盖),让九门 driven=true、E_live/H_progress 由 advisory 升致命,
|
|
# 根治「裸 harness 无 driver → 假绿」。smoke 失败(state=None)时按保守 key-cycle 薄 spec,play 仍照跑。
|
|
cheap_run.ensure_play_spec(game_id, sm.get("state"))
|
|
# 红线③(封陈旧 verdict 假绿,镜像 tier2 run.py:866):起 play 前清残留 verdict,保证 judge 拿到的恒是本次真门产出。
|
|
# serve-and-play.sh 早退路径(chrome/serve/cdp 未就绪)+ 超时都不写新 verdict 也不删旧的,不清则 play 读回上一局绿 verdict → 假绿放行。
|
|
(cheap_run.wg1_game_dir(game_id) / "evidence" / "verdict.json").unlink(missing_ok=True)
|
|
pr = cheap_run.play(game_id, port=port, cdp_port=cdp_port)
|
|
return pr.get("verdict") or {}
|