feat(spatial): 弃权判据换成清单-交付,标签不再依赖完整状态

This commit is contained in:
liuhuajie committed 2026-12-03 23:03:58 +08:00
1 parent 9d449f2108
commit 762b4d347d
9 files changed
+871 -496

No files matched your search

+32 -3
View File
@@ -99,8 +99,7 @@ def check_insufficient() -> bool:
continue
restricted = FullState(entities=list(sc.obs.entities), edges=list(sc.obs.edges))
a_vis = checker.evaluate(restricted.entities, restricted.edges, sc.query)
withheld = bool(sc.obs.dangling) or bool((sc.obs.hidden or {}).get("entity")) \
or bool((sc.obs.hidden or {}).get("edge"))
withheld = checker.withheld_flag(sc.obs)
if withheld and a_vis is not True:
found += 1
else:
@@ -194,12 +193,42 @@ def check_extract_contacts(n: int = 8) -> bool:
return True
def check_scope_agrees(n: int = 24) -> bool:
"""The declared inventory must say "something withheld" exactly when the
diagnostic one does.
``hidden``/``dangling`` are computed from the full state, so they are not
something a provider can produce. ``scope`` is. This check pins the
migration: wherever the two disagree, the label path would have to fall back
on full-state data -- and that is the leak M2 exists to remove.
"""
bad = []
rows = 0
for fam in generator.FAMILIES:
for i in range(n):
sc = generator.make(fam, seed=11, index=i)
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:
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")
print(f"ok {rows} samples: declared inventory agrees with the diagnostic one")
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_cross_family_digest(),
check_extract_contacts()]
check_extract_contacts(), check_scope_agrees()]
# one update, then interrupt and resume: the step counter must advance
from . import train as trainer