From 851e8888b50a8780da1dd5e0228bab2d428d5195 Mon Sep 17 00:00:00 2001 From: x Date: Thu, 3 Dec 2026 22:23:49 +0800 Subject: [PATCH] =?UTF-8?q?fix(spatial):=20=E5=87=AD=E8=AF=81=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E8=87=AA=E5=B7=B1=E5=A4=8D=E6=A0=B8=E6=8E=A5=E8=A7=A6?= =?UTF-8?q?=EF=BC=8C=E4=B8=8D=E5=86=8D=E7=9B=B8=E4=BF=A1=E8=BE=B9=E4=B8=8A?= =?UTF-8?q?=E7=9A=84=E6=A0=87=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit validate_evidence 对稳定性只检查"凭证链能不能够到地面",从不复核每一步是不是真的 接触。于是 provider 只要吐出一条假接触,就能伪造出能通过校验的支撑——容差 1 格 (0.25mm)时,每一对相隔 0.25mm 的零件都产生了这种假边,而且全部通过。 现在按盒子几何重新推导每一步:面必须相接、投影必须有重叠、接地必须等高。 --- spatial/checker.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/spatial/checker.py b/spatial/checker.py index ca82af3..be2a7c4 100644 --- a/spatial/checker.py +++ b/spatial/checker.py @@ -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: