From 1e0dcd6fb496dc66ce52dbed28690dba22c2fa9e Mon Sep 17 00:00:00 2001 From: lhj <403133128@qq.com> Date: Thu, 3 Dec 2026 18:29:29 +0800 Subject: [PATCH] =?UTF-8?q?test(spatial):=20=E8=B7=A8=E5=AE=B6=E6=97=8F=20?= =?UTF-8?q?digest=20=E4=B8=80=E8=87=B4=E6=80=A7=E6=A3=80=E6=9F=A5=E2=80=94?= =?UTF-8?q?=E2=80=94=E5=90=8C=E4=B8=80=E8=A7=82=E6=B5=8B=E4=B8=8D=E8=AE=B8?= =?UTF-8?q?=E6=9C=89=E4=B8=A4=E4=B8=AA=E6=A0=87=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "没有隐藏支路"和"有隐藏支路但看不见"产生完全相同的观测,于是前者标可判、 后者标 unknown,是模型永远无法复现的标签:证据缺失不等于不存在。原来的 hidden_pair 只在一个家族内部查,查不到这件事。 --- spatial/cli.py | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/spatial/cli.py b/spatial/cli.py index 2174f35..8e8da56 100644 --- a/spatial/cli.py +++ b/spatial/cli.py @@ -121,11 +121,47 @@ def check_invariances() -> bool: return True +def check_cross_family_digest() -> bool: + """Two samples with the same ``input_digest`` must carry the same label. + + This is the whole contract, and it has to hold *across* families, not only + inside one: "no hidden branch exists" and "a hidden branch exists but is not + visible" produce the same observation, so a label that says "decidable" in + the first case and "unknown" in the second is a label the model can never + reproduce -- absence of evidence is not evidence of absence. Samples whose + scores differ are still a bug, just a quieter one. + """ + seen = {} + bad = [] + n = 0 + for fam in generator.FAMILIES: + for i in range(40): + sc = generator.make(fam, seed=71, index=i) + n += 1 + d = sc.input_digest() + prev = seen.get(d) + if prev is None: + seen[d] = (fam, sc.label.answer, sc.label.change) + elif (prev[1], prev[2]) != (sc.label.answer, sc.label.change): + bad.append((prev, (fam, sc.label.answer, sc.label.change))) + if bad: + # collapse to the distinct family pairs, the list itself is long + pairs = sorted({(a[0], b[0]) for a, b in bad}) + print(f" {len(bad)} samples share an input digest with a different label") + for a, b in pairs[:6]: + print(f" {a:11s} vs {b:11s}") + return _fail("same input, different label -- the observation does not " + "determine the answer, so both cannot be decidable") + print(f"ok {n} samples: no two families assign different labels to " + f"the same observation ({len(seen)} distinct inputs)") + return True + + def cmd_smoke(args) -> int: cfg = _load_config(args.config) print(f"config {args.config} out {cfg['out_dir']}") results = [check_splits(cfg), check_determinism(), check_labels(), - check_insufficient(), check_invariances()] + check_insufficient(), check_invariances(), check_cross_family_digest()] # one update, then interrupt and resume: the step counter must advance from . import train as trainer