feat(spatial): 契约加 conflicts——两份来源打架时,只有两个世界都成立的答案才算答案
This commit is contained in:
1 parent
e799e02e22
commit
a01ca7eab7
9 files changed
+206
-27
No files matched your search
+23
-6
@@ -97,8 +97,14 @@ def check_insufficient() -> bool:
|
||||
sc = generator.make(fam, seed=5, index=i)
|
||||
if sc.label.answer != "unknown":
|
||||
continue
|
||||
restricted = FullState(entities=list(sc.obs.entities), edges=list(sc.obs.edges))
|
||||
a_vis = checker.evaluate(restricted.entities, restricted.edges, sc.query)
|
||||
# "visible proves it" must mean *undisputed* visible structure: a
|
||||
# relation two sources disagree on cannot carry a proof, so it is
|
||||
# excluded here exactly as the label rule excludes it.
|
||||
disputed = {(c.get("kind"), frozenset((c.get("a"), c.get("b"))))
|
||||
for c in (sc.obs.conflicts or [])}
|
||||
kept = [e for e in sc.obs.edges
|
||||
if (e.kind, frozenset((e.a, e.b))) not in disputed]
|
||||
a_vis = checker.evaluate(list(sc.obs.entities), kept, sc.query)
|
||||
withheld = checker.withheld_flag(sc.obs)
|
||||
if withheld and a_vis is not True:
|
||||
found += 1
|
||||
@@ -107,7 +113,8 @@ def check_insufficient() -> bool:
|
||||
f"visible proof; label is not justified")
|
||||
if found == 0:
|
||||
return _fail("no insufficient-evidence sample was produced")
|
||||
print(f"ok {found} unknown samples are undecided by the observation")
|
||||
print(f"ok {found} unknown samples are undecided by the observation "
|
||||
f"(undisputed part)")
|
||||
return True
|
||||
|
||||
|
||||
@@ -210,15 +217,25 @@ def check_scope_agrees(n: int = 24) -> bool:
|
||||
old = bool(sc.obs.dangling) or bool((sc.obs.hidden or {}).get("entity")) or bool((sc.obs.hidden or {}).get("edge"))
|
||||
new = checker.withheld_flag(sc.obs)
|
||||
rows += 1
|
||||
if old != new:
|
||||
# conflicts are a second, independent reason to suspend: they are
|
||||
# declared by the sources, not derived from the full state, so they
|
||||
# have no diagnostic analogue. Two ways to be wrong, both checked:
|
||||
# a withheld fact the scope cannot express, or a declared conflict
|
||||
# the scope forgot to count.
|
||||
# scope must equal the diagnostic *plus* the declared conflicts: the
|
||||
# full state has no way to know that two sources disagree, so the
|
||||
# union is what "something is not settled" should mean.
|
||||
declared = bool(sc.obs.conflicts)
|
||||
forgot = declared and not (sc.obs.scope or {}).get("conflicts")
|
||||
if new != (old or declared) or forgot:
|
||||
bad.append((fam, i, old, new))
|
||||
if bad:
|
||||
fams = sorted({f for f, _, _, _ in bad})
|
||||
print(f" {len(bad)}/{rows} samples disagree, families {fams}")
|
||||
for f, i, o, nn in bad[:4]:
|
||||
print(f" {f}[{i}] diagnostic={o} scope={nn}")
|
||||
return _fail("scope cannot express what was withheld; the label path still "
|
||||
"needs full-state data")
|
||||
return _fail("scope cannot express what was withheld, or a conflict went "
|
||||
"undeclared")
|
||||
print(f"ok {rows} samples: declared inventory agrees with the diagnostic one")
|
||||
return True
|
||||
|
||||
|
||||
Reference in new issue
Block a user