471 lines
22 KiB
Python
471 lines
22 KiB
Python
#!/usr/bin/env python3
|
||
"""HEL-867 负例复现脚本:总管独立复核《HEL-866-独立复核.md》承诺总判据
|
||
以裸子串排除推翻结构化极性——`s6_result` 在 `affirms_promise_state` 已按
|
||
全量解析判定未结后,仍对整段文本执行 `PROMISE_CLOSED_EN` 裸子串排除,
|
||
"haven't received the result / received the notification" 等已支持否定
|
||
形态内的正向子串被误当已结宣称,`unresolved_affirms_open` 与
|
||
`unresolved_no_false_resolution` 双双误 False,正确未结回答被拒。
|
||
|
||
零真实模型、零网络(socket 硬拒绝 + HF 离线)、零本地嵌入:S6 判据为纯函数
|
||
代入(真实 s6_result 构造器同一入口);既有判据不回归部分复用 audit866 的
|
||
全部纯函数节(含 HEL-866 六组人物宾语反例、按动词类别主语×动词后槽位矩阵、
|
||
140 角色组合、audit861–865 全部既有正负例与 S2/S3 总判据)。同一脚本在修复
|
||
前(5e90136)与修复后代码上均可运行:
|
||
|
||
修复前(--phase prefix,在 5e90136 工作树上运行)→ 总管复核的最小正例
|
||
(已结侧固定规范中文正例,未结侧 "You promised to tell me the interview
|
||
result, you haven't received the result yet.")与整篇语法×总判据矩阵中
|
||
30 个否定助动词×received×对象组合、外加 receive 矩阵 3 行,全部被同一
|
||
真实 s6_result 误判失败(parse_supported_answer 全量消费、open 且
|
||
bound,affirms_promise_state(closed=False)=true,总判据却 pass=false)
|
||
——误拒复现;负例(宣称已结/未知/混合/角色冲突)维持判失败
|
||
修复后(默认 postfix)→ 上述全部原有正确未结表达通过;裸子串排除停用,
|
||
总判据对侧极性与"未结侧宣称已结"改以同一 parse_supported_answer 的
|
||
closed/open 小句极性判定;已结小句仍使未结侧失败(含混合正反极性)、
|
||
未知/不支持/额外小句/角色或对象冲突保守失败;HEL-866 六例、矩阵人物格、
|
||
全部规范正例与 audit861–866 既有 S6/S2/S3 判据维持预期
|
||
|
||
补正口径(只修总判据与已声明全量解析的衔接,不新增语义引擎、不加整句
|
||
禁词/特赦、不删两个词了事、不把已支持形态降格为不支持):s6_result 的
|
||
`resolved_affirms_closed`/`unresolved_affirms_open`/`unresolved_no_false_
|
||
resolution` 与 `affirms_promise_state` 共用同一份 `parse_supported_answer`
|
||
(同源极性)——已结/未结按 closed/open 小句极性判,对侧极性小句存在即
|
||
失败,"未结侧宣称已结"= 解析出绑定同一场景声明的已结小句;否定小句内的
|
||
正向子串不作已结宣称。原 PROMISE_CLOSED/PROMISE_OPEN 整篇裸子串排除停用
|
||
(词表保留为历史预声明)。中英文同等核验;不改真实模型回答/合成夹具,
|
||
不扩大产品表达限制,不放宽判据换通过。
|
||
|
||
退出码真实依赖正负例:除全部用例满足预期外,还对每个用例做翻转自检
|
||
(flip 任一用例的实际结果,用例总判必翻转);任一翻转不改变结论则退出 1。
|
||
|
||
用法:python -m spike.hel857.audit867 [--phase prefix|postfix] [输出json路径]
|
||
退出码:prefix=0 当且仅当误拒全部复现(正确未结表达 pass=false 且解析层
|
||
本就支持)且其余用例维持预期;postfix=0 当且仅当误拒全部通过、负例全部
|
||
维持失败、既有判据不回归、翻转自检通过、权威账与既有证据只读未动。权威
|
||
嵌入账只读快照核对含逐行摘要(不补种不回退不双扣)。
|
||
"""
|
||
from __future__ import annotations
|
||
|
||
import hashlib
|
||
import itertools
|
||
import json
|
||
import os
|
||
import socket
|
||
import sqlite3
|
||
import subprocess
|
||
import sys
|
||
from pathlib import Path
|
||
|
||
REPO = Path(__file__).resolve().parents[2]
|
||
LEDGER = Path("/home/xiaomo/multica_workspaces/hello-af23464d222e/"
|
||
"hel-859-1f079e50f551/workdir/audit-data/embed_ledger.sqlite3")
|
||
os.environ["HEL857_EMBED_LEDGER"] = str(LEDGER)
|
||
os.environ.setdefault("HF_HUB_OFFLINE", "1")
|
||
os.environ.setdefault("TRANSFORMERS_OFFLINE", "1")
|
||
|
||
|
||
def deny_network(*a, **k):
|
||
raise RuntimeError("audit867 blocks network")
|
||
|
||
|
||
socket.socket.connect = deny_network
|
||
socket.socket.connect_ex = deny_network
|
||
|
||
from . import ab_scenarios as A
|
||
from .audit861 import section_s2_s3_no_regression, section_s6_affirmative
|
||
from .audit862 import HELD_S2S3_EXPECT, HELD_S6_EXPECT
|
||
from .audit866 import (section_held_864, section_held_865,
|
||
section_held_positives, section_held_rounds,
|
||
section_manager_six, section_param_matrix,
|
||
section_role_matrix, section_structural)
|
||
|
||
OUT = {"real_network_allowed": False, "real_model_requests": 0,
|
||
"local_embeddings": 0}
|
||
PHASE = "postfix"
|
||
|
||
|
||
def ledger_snapshot():
|
||
"""权威账只读快照(含逐行摘要:全部行序列化 SHA256,前后核对用)。"""
|
||
with sqlite3.connect(f"file:{LEDGER}?mode=ro", uri=True) as c:
|
||
rows = c.execute("select * from embed_ops order by id").fetchall()
|
||
return {"counts": dict(c.execute("select kind,sum(items) from embed_ops "
|
||
"group by kind")),
|
||
"rows": len(rows),
|
||
"row_digest": hashlib.sha256(
|
||
json.dumps(rows).encode()).hexdigest()}
|
||
|
||
|
||
PRESERVED_EVIDENCE = [
|
||
"ab_scenarios_run1.json", "ab_scenarios.json", "rework858_offline.json",
|
||
"rework859_offline.json", "rework860_offline.json", "audit859_prefix.json",
|
||
"audit859_postfix.json", "audit859_reuse860.json", "audit860_prefix.json",
|
||
"audit860_postfix.json", "audit861_prefix.json", "audit861_postfix.json",
|
||
"audit861_reuse862.json", "audit862_prefix.json", "audit862_postfix.json",
|
||
"audit861_reuse863.json", "audit863_prefix.json", "audit863_postfix.json",
|
||
"audit864_prefix.json", "audit864_postfix.json", "audit861_reuse864.json",
|
||
"audit865_prefix.json", "audit865_postfix.json", "audit861_reuse865.json",
|
||
"audit866_prefix.json", "audit866_postfix.json", "audit861_reuse866.json",
|
||
"gate0_ledger.json", "gate1_backend.json", "gate2_privacy.json",
|
||
"preflight.json", "resource_manifest_pre.json", "lock-notes.md",
|
||
]
|
||
|
||
|
||
def evidence_hashes():
|
||
res = {}
|
||
for name in PRESERVED_EVIDENCE:
|
||
p = REPO / "spike/hel857/results" / name
|
||
res[name] = (hashlib.sha256(p.read_bytes()).hexdigest()
|
||
if p.exists() else "missing")
|
||
return res
|
||
|
||
|
||
# ---------------------------------------------------------------------------
|
||
# 总管《HEL-866-独立复核.md》最小正例族(原文逐字;已结侧固定规范中文正例,
|
||
# 仅换未结侧)。同一真实 s6_result 入口。
|
||
def s6_answer(s):
|
||
return {"answer": s, "ok": True}
|
||
|
||
|
||
P_EN = "You promised to tell me the interview result, "
|
||
P_ZH = "你答应周五晚告诉我面试结果,"
|
||
GOOD_CLOSED = P_ZH + "现在已经告诉我了。"
|
||
GOOD_OPEN = P_ZH + "还没有告诉我。"
|
||
|
||
MINIMAL_FAMILY = {
|
||
"manager_minimal": P_EN + "you haven't received the result yet.",
|
||
"subject_i": P_EN + "I haven't received the result yet.",
|
||
"subject_omitted": P_EN + "haven't received the result yet.",
|
||
"object_notification": P_EN + "you haven't received the notification yet.",
|
||
}
|
||
|
||
# 整篇受支持语法×总判据衔接矩阵(沿总管 review866.py polarity_integration
|
||
# 原样):主语{you/I/省略}×否定助动词五种已声明形态×动词{received/got}×
|
||
# 对象{it/the result/the interview result/the notification}。其中
|
||
# verb=received 且对象含 the result/the notification 的 30 格在修复前被
|
||
# PROMISE_CLOSED_EN 裸子串(received the result / received the
|
||
# notification)误拒;verb=got 与对象 it/the interview result 本就通过。
|
||
POLARITY_AUX = ["haven't", "have not", "hasn't", "has not", "have not yet"]
|
||
POLARITY_OBJECTS = ["it", "the result", "the interview result",
|
||
"the notification"]
|
||
|
||
|
||
def _polarity_rows():
|
||
rows = {}
|
||
for subj, aux, verb, obj in itertools.product(
|
||
["you", "I", ""], POLARITY_AUX, ["received", "got"],
|
||
POLARITY_OBJECTS):
|
||
name = f"polarity/{subj or 'omit'}/{aux}/{verb}/{obj}"
|
||
prefix_text = f"{subj} {aux} {verb} {obj} yet."
|
||
misrejected = verb == "received" and obj in ("the result",
|
||
"the notification")
|
||
rows[name] = {"unresolved": P_EN + prefix_text,
|
||
"expect_pre": not misrejected,
|
||
"expect_post": True, "misrejected": misrejected}
|
||
return rows
|
||
|
||
|
||
# 总管 review866.py 独立动词/主语/动词后槽矩阵(原样):其中 subj∈{you,I,
|
||
# 省略}×received×"the result" 3 行修复前误拒(与上表 haven't 组合同一真实
|
||
# 输入,总管计为"3 重复");其余行两期预期沿总管声明。
|
||
def _review_receive_rows():
|
||
rows = {}
|
||
for subj, verb, obj in itertools.product(
|
||
["you", "I", "we", ""], ["received", "got"],
|
||
["", "it", "the result", "the interview result", "me", "you",
|
||
"us", "them", "me it", "me the interview result",
|
||
"the medical report", "it me"]):
|
||
name = f"review_receive/{subj or 'omit'}/{verb}/{obj or 'omit'}"
|
||
valid = (subj in ("you", "I", "")
|
||
and obj in ("", "it", "the result", "the interview result"))
|
||
misrejected = valid and verb == "received" and obj == "the result"
|
||
rows[name] = {"unresolved": P_EN + f"{subj} haven't {verb} {obj} yet.",
|
||
"expect_pre": valid and not misrejected,
|
||
"expect_post": valid, "misrejected": misrejected}
|
||
return rows
|
||
|
||
|
||
# 双期负例(修复前后都必须判失败——证明不是把已结/未知/混合放行换通过):
|
||
# false_resolution=未结侧出现绑定同一场景声明的已结小句(宣称已结);
|
||
# mixed=同一篇内正反极性小句并见;unknown=不确定表述/疑问/条件;
|
||
# resolved_negative=已结侧答未结(已结门不被破坏)。
|
||
DOUBLE_PHASE_NEGATIVES = {
|
||
"zh_false_result_received": (GOOD_CLOSED, P_ZH + "结果已收到。"),
|
||
"zh_false_already_got": (GOOD_CLOSED, P_ZH + "结果已经拿到了。"),
|
||
"en_false_i_received_notification":
|
||
(GOOD_CLOSED, P_EN + "but I have received the notification."),
|
||
"en_false_i_already_received_it":
|
||
(GOOD_CLOSED, P_EN + "but I have already received it."),
|
||
"en_false_i_got_the_result":
|
||
(GOOD_CLOSED, P_EN + "but I have got the result."),
|
||
"en_mixed_open_and_closed":
|
||
(GOOD_CLOSED,
|
||
P_EN + "you haven't told me yet, but I have received the result."),
|
||
"en_single_clause_mixed":
|
||
(GOOD_CLOSED,
|
||
P_EN + "but I have received the result and you haven't told me yet."),
|
||
"en_uncertain_maybe":
|
||
(GOOD_CLOSED, P_EN + "maybe you haven't received the result yet."),
|
||
"en_foreign_object":
|
||
(GOOD_CLOSED, P_EN + "but you haven't received the medical report yet."),
|
||
"en_question_mood":
|
||
(GOOD_CLOSED, P_EN + "have you received the result yet?"),
|
||
"en_conditional_tail":
|
||
(GOOD_CLOSED,
|
||
P_EN + "if you haven't received the result, I will wait."),
|
||
"resolved_side_says_open":
|
||
(P_EN + "I have not received the result yet.", GOOD_OPEN),
|
||
}
|
||
|
||
# 已结侧衔接正例(双期通过——证明已结门与 EN 已结受收主语读法不被破坏)。
|
||
RESOLVED_SIDE_POSITIVES = {
|
||
"canonical_zh": (GOOD_CLOSED, GOOD_OPEN),
|
||
"en_i_have_received_the_result":
|
||
(P_EN + "I have received the result.", GOOD_OPEN),
|
||
"en_i_have_already_received_the_notification":
|
||
(P_EN + "I have already received the notification.", GOOD_OPEN),
|
||
}
|
||
|
||
|
||
def _record(name: str, resolved: str, unresolved: str, expected: bool) -> dict:
|
||
result = A.s6_result({"pass": True, "status_annotation_in_block": True,
|
||
"unresolved_contrast": {"built": True,
|
||
"self_consistent": True}},
|
||
s6_answer(resolved), s6_answer(unresolved))
|
||
return {
|
||
"resolved_input": resolved, "unresolved_input": unresolved,
|
||
"expected_pass": expected, "actual_pass": result["pass"],
|
||
"resolved_parse": A.parse_supported_answer(resolved),
|
||
"unresolved_parse": A.parse_supported_answer(unresolved),
|
||
"result": result,
|
||
}
|
||
|
||
|
||
def section_minimal() -> dict:
|
||
"""最小正例族:prefix 期误拒复现(总判据 pass=false 而解析层 open+bound
|
||
且 affirms_promise_state(closed=False)=true),postfix 期通过。"""
|
||
out = {}
|
||
for name, u in MINIMAL_FAMILY.items():
|
||
rec = _record(name, GOOD_CLOSED, u, PHASE == "postfix")
|
||
rec["grammar_affirms_open"] = A.affirms_promise_state(u, closed=False)
|
||
rec["gate_unresolved_affirms_open"] = rec["result"]["layers"][
|
||
"model_use"]["unresolved_affirms_open"]
|
||
rec["gate_unresolved_no_false_resolution"] = rec["result"]["layers"][
|
||
"model_use"]["unresolved_no_false_resolution"]
|
||
out[name] = rec
|
||
return out
|
||
|
||
|
||
def section_polarity_matrix() -> dict:
|
||
"""整篇受支持语法×总判据衔接矩阵(120 行,逐行影响退出码)。"""
|
||
return {name: _record(name, GOOD_CLOSED, spec["unresolved"],
|
||
spec["expect_post"] if PHASE == "postfix"
|
||
else spec["expect_pre"])
|
||
for name, spec in _polarity_rows().items()}
|
||
|
||
|
||
def section_review_receive_matrix() -> dict:
|
||
"""总管独立 receive 矩阵(104 行,含误拒 3 行与无效格负例)。"""
|
||
return {name: _record(name, GOOD_CLOSED, spec["unresolved"],
|
||
spec["expect_post"] if PHASE == "postfix"
|
||
else spec["expect_pre"])
|
||
for name, spec in _review_receive_rows().items()}
|
||
|
||
|
||
def section_double_phase_negatives() -> dict:
|
||
"""双期负例:宣称已结/混合/未知/条件/疑问/已结侧答未结均判失败。"""
|
||
return {name: _record(name, r, u, False)
|
||
for name, (r, u) in DOUBLE_PHASE_NEGATIVES.items()}
|
||
|
||
|
||
def section_resolved_side_positives() -> dict:
|
||
"""已结侧衔接正例:双期通过(canonical 与 EN 受收主语已结形态)。"""
|
||
return {name: _record(name, r, u, True)
|
||
for name, (r, u) in RESOLVED_SIDE_POSITIVES.items()}
|
||
|
||
|
||
def _case_table() -> tuple[dict, dict]:
|
||
"""全部用例的实际 pass 与预期极性(退出码公式输入)。"""
|
||
table: dict[str, bool] = {}
|
||
expect: dict[str, bool] = {}
|
||
for prefix, section in (
|
||
("minimal", OUT["minimal_family"]),
|
||
("polarity", OUT["polarity_matrix"]),
|
||
("review_receive", OUT["review_receive_matrix"]),
|
||
("negatives", OUT["double_phase_negatives"]),
|
||
("resolved_positive", OUT["resolved_side_positives"]),
|
||
("manager6", OUT["manager_six"]),
|
||
("structural", OUT["structural_variants"]),
|
||
("matrix", OUT["param_matrix"]),
|
||
("roles140", OUT["role_matrix"]),
|
||
("positives", OUT["held_positives"]),
|
||
("held865", OUT["held_865"]),
|
||
("held864", OUT["held_864"]),
|
||
("held_rounds", OUT["held_rounds"])):
|
||
for name, c in section.items():
|
||
key = f"{prefix}.{name}"
|
||
table[key] = bool(c["actual_pass"])
|
||
expect[key] = bool(c["expected_pass"])
|
||
for name, res in OUT["held_s6_affirmative"].items():
|
||
key = f"held_s6.{name}"
|
||
table[key] = bool(res["pass"])
|
||
expect[key] = HELD_S6_EXPECT[name]
|
||
for name, res in OUT["held_s2_s3_no_regression"].items():
|
||
key = f"held_s2s3.{name}"
|
||
table[key] = bool(res["pass"])
|
||
expect[key] = HELD_S2S3_EXPECT[name]
|
||
return table, expect
|
||
|
||
|
||
def _all_cases_match(table: dict, expect: dict) -> bool:
|
||
return all(table[k] == expect[k] for k in expect)
|
||
|
||
|
||
def _flip_dependence(table: dict, expect: dict) -> dict:
|
||
"""翻转自检:任一用例实际值翻转必须改变用例总判(退出码真实依赖正负例)。"""
|
||
base = _all_cases_match(table, expect)
|
||
flips = {}
|
||
for k in expect:
|
||
flipped = dict(table)
|
||
flipped[k] = not flipped[k]
|
||
flips[k] = _all_cases_match(flipped, expect) != base
|
||
return {"base_all_match": base, "every_flip_changes_verdict": all(
|
||
flips.values()), "per_case": flips}
|
||
|
||
|
||
# ---------------------------------------------------------------------------
|
||
def main(argv: list[str]) -> dict:
|
||
global PHASE
|
||
argv = list(argv)
|
||
rest: list[str] = []
|
||
PHASE = "postfix"
|
||
it = iter(argv[1:])
|
||
for tok in it:
|
||
if tok == "--phase":
|
||
PHASE = next(it, "postfix")
|
||
elif tok.startswith("--phase="):
|
||
PHASE = tok.split("=", 1)[1]
|
||
elif not tok.startswith("--"):
|
||
rest.append(tok)
|
||
args = rest
|
||
OUT["phase"] = PHASE
|
||
|
||
commit = subprocess.run(["git", "rev-parse", "HEAD"],
|
||
capture_output=True, text=True,
|
||
cwd=str(REPO)).stdout.strip()
|
||
OUT["commit"] = commit
|
||
OUT["ledger_before"] = ledger_snapshot()
|
||
OUT["preserved_evidence_before"] = evidence_hashes()
|
||
|
||
OUT["minimal_family"] = section_minimal()
|
||
OUT["polarity_matrix"] = section_polarity_matrix()
|
||
OUT["review_receive_matrix"] = section_review_receive_matrix()
|
||
OUT["double_phase_negatives"] = section_double_phase_negatives()
|
||
OUT["resolved_side_positives"] = section_resolved_side_positives()
|
||
OUT["manager_six"] = section_manager_six()
|
||
OUT["structural_variants"] = section_structural()
|
||
OUT["param_matrix"] = section_param_matrix()
|
||
OUT["role_matrix"] = section_role_matrix()
|
||
OUT["held_positives"] = section_held_positives()
|
||
OUT["held_865"] = section_held_865()
|
||
OUT["held_864"] = section_held_864()
|
||
OUT["held_rounds"] = section_held_rounds()
|
||
OUT["held_s6_affirmative"] = section_s6_affirmative()
|
||
OUT["held_s2_s3_no_regression"] = section_s2_s3_no_regression()
|
||
|
||
table, expect = _case_table()
|
||
OUT["case_expect"] = {k: bool(v) for k, v in expect.items()}
|
||
OUT["case_actual"] = {k: bool(v) for k, v in table.items()}
|
||
OUT["all_cases_match_expectation"] = _all_cases_match(table, expect)
|
||
OUT["flip_dependence"] = _flip_dependence(table, expect)
|
||
|
||
OUT["ledger_after"] = ledger_snapshot()
|
||
OUT["ledger_unchanged"] = OUT["ledger_before"] == OUT["ledger_after"]
|
||
OUT["preserved_evidence_after"] = evidence_hashes()
|
||
OUT["preserved_evidence_unchanged"] = (
|
||
OUT["preserved_evidence_before"] == OUT["preserved_evidence_after"])
|
||
|
||
pol = OUT["polarity_matrix"]
|
||
rev = OUT["review_receive_matrix"]
|
||
mis_pol = {k: c for k, c in pol.items()
|
||
if _polarity_rows()[k]["misrejected"]}
|
||
mis_rev = {k: c for k, c in rev.items()
|
||
if _review_receive_rows()[k]["misrejected"]}
|
||
# ---- prefix:正确未结表达被总判据误拒(解析层本就支持)----
|
||
misrejection_reproduced = (
|
||
all(not c["actual_pass"] and c["grammar_affirms_open"]
|
||
and c["unresolved_parse"]["all_consumed"]
|
||
and c["unresolved_parse"]["open_clauses"]
|
||
and not c["unresolved_parse"]["closed_clauses"]
|
||
for c in OUT["minimal_family"].values())
|
||
and all(not c["actual_pass"]
|
||
and c["unresolved_parse"]["all_consumed"] for
|
||
c in mis_pol.values())
|
||
and all(not c["actual_pass"]
|
||
and c["unresolved_parse"]["all_consumed"] for
|
||
c in mis_rev.values())
|
||
# 误拒确因总判据而非解析层:同输入 affirms_promise_state 为 true
|
||
and all(A.affirms_promise_state(_polarity_rows()[k]["unresolved"],
|
||
closed=False)
|
||
for k in mis_pol))
|
||
# ---- postfix:误拒全部通过、门字段翻正 ----
|
||
misrejection_fixed = (
|
||
all(c["actual_pass"]
|
||
and c["result"]["layers"]["model_use"]["unresolved_affirms_open"]
|
||
and c["result"]["layers"]["model_use"][
|
||
"unresolved_no_false_resolution"]
|
||
for c in OUT["minimal_family"].values())
|
||
and all(c["actual_pass"] for c in mis_pol.values())
|
||
and all(c["actual_pass"] for c in mis_rev.values()))
|
||
negatives_stay_failed = (
|
||
not any(c["actual_pass"]
|
||
for c in OUT["double_phase_negatives"].values())
|
||
# HEL-866 六例与矩阵人物格继续拒绝
|
||
and not any(c["actual_pass"] for c in OUT["manager_six"].values())
|
||
and not any(c["actual_pass"] for c in OUT["param_matrix"].values()
|
||
if c["person_object"]))
|
||
held_kept = (all(c["actual_pass"]
|
||
for c in OUT["held_positives"].values())
|
||
and all(c["actual_pass"]
|
||
for c in OUT["resolved_side_positives"].values())
|
||
and all(c["actual_pass"] == c["expected_pass"]
|
||
for c in OUT["role_matrix"].values()))
|
||
OUT["summary"] = {
|
||
"phase": PHASE,
|
||
"misrejection_reproduced": misrejection_reproduced,
|
||
"misrejection_fixed": misrejection_fixed,
|
||
"negatives_stay_failed": negatives_stay_failed,
|
||
"held_kept": held_kept,
|
||
"all_cases_match_expectation": OUT["all_cases_match_expectation"],
|
||
"flip_dependence_holds": OUT["flip_dependence"][
|
||
"every_flip_changes_verdict"],
|
||
"ledger_unchanged": OUT["ledger_unchanged"],
|
||
"preserved_evidence_unchanged": OUT["preserved_evidence_unchanged"],
|
||
"pass": (misrejection_reproduced
|
||
and negatives_stay_failed and held_kept
|
||
and PHASE == "prefix"
|
||
and OUT["all_cases_match_expectation"]
|
||
and OUT["flip_dependence"]["every_flip_changes_verdict"]
|
||
and OUT["ledger_unchanged"]
|
||
and OUT["preserved_evidence_unchanged"])
|
||
or (misrejection_fixed
|
||
and negatives_stay_failed and held_kept
|
||
and PHASE == "postfix"
|
||
and OUT["all_cases_match_expectation"]
|
||
and OUT["flip_dependence"]["every_flip_changes_verdict"]
|
||
and OUT["ledger_unchanged"]
|
||
and OUT["preserved_evidence_unchanged"]),
|
||
}
|
||
out_path = Path(args[0]) if args else (
|
||
REPO / "spike/hel857/results/"
|
||
f"audit867_{'prefix' if PHASE == 'prefix' else 'postfix'}.json")
|
||
out_path.parent.mkdir(parents=True, exist_ok=True)
|
||
out_path.write_text(json.dumps(OUT, ensure_ascii=False, indent=2),
|
||
encoding="utf-8")
|
||
print(json.dumps(OUT["summary"] | {"out": str(out_path)},
|
||
ensure_ascii=False))
|
||
return OUT
|
||
|
||
|
||
if __name__ == "__main__":
|
||
raise SystemExit(0 if main(sys.argv)["summary"]["pass"] else 1)
|