fix(spatial): 凭证校验自己复核接触,不再相信边上的标签

validate_evidence 对稳定性只检查"凭证链能不能够到地面",从不复核每一步是不是真的
接触。于是 provider 只要吐出一条假接触,就能伪造出能通过校验的支撑——容差 1 格
(0.25mm)时,每一对相隔 0.25mm 的零件都产生了这种假边,而且全部通过。

现在按盒子几何重新推导每一步:面必须相接、投影必须有重叠、接地必须等高。
This commit is contained in:
x committed 2026-12-03 22:23:49 +08:00
1 parent b46c76ce9a
commit 851e8888b5
1 file changed
+27
+27
View File
@@ -215,6 +215,30 @@ def evidence_for(full: FullState, query: Query) -> list:
return []
def _contact_is_real(ents: dict, e: Edge) -> bool:
"""Re-derive a contact from the boxes instead of trusting the edge label.
A certificate is only worth something if the thing it cites can be checked
independently. Until this existed, `validate_evidence` walked the claimed
chain and stopped as soon as it reached anything sitting on the ground -- so
a provider that emitted one bogus contact edge could forge support that
validated. Measured: with a distance tolerance of one grid unit (0.25mm)
every part pair separated by 0.25mm produced an edge that passed.
"""
a, b = ents.get(e.a), ents.get(e.b)
if a is None or b is None:
return False
ba, bb = _box(a), _box(b)
if ba and bb:
if not (ba[5] == bb[2] or bb[5] == ba[2]):
return False # faces do not meet: no load path
return _overlap(ba, bb) is not None # and they must share a footprint
box, other = (ba, b) if ba else (bb, a)
if box is None or other.kind != "ground":
return False
return box[2] == float(other.attrs.get("plane", 0))
def validate_evidence(full: FullState, query: Query, evidence) -> bool:
"""Independent re-check of a claimed certificate."""
evidence = list(evidence or [])
@@ -235,6 +259,9 @@ def validate_evidence(full: FullState, query: Query, evidence) -> bool:
ents = _index(full.entities)
if query.a not in ents:
return False
# every cited step has to be a contact that the geometry actually shows
if not all(_contact_is_real(ents, e) for e in edges):
return False
reached = {query.a}
for _ in range(len(edges) + 1):
for e in edges: