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