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

+19
View File
@@ -40,6 +40,13 @@ def digest(obj) -> str:
return hashlib.sha256(canonical(obj).encode("utf-8")).hexdigest()
def _canonical_scope(scope: dict) -> dict:
out = {}
for k, v in sorted((scope or {}).items()):
out[k] = dict(sorted(v.items())) if isinstance(v, dict) else sorted(v)
return out
@dataclass
class Entity:
eid: str
@@ -110,6 +117,17 @@ class Observation:
hidden_faces: list = field(default_factory=list)
hidden: dict = field(default_factory=lambda: {"entity": {}, "edge": {}})
dangling: list = field(default_factory=list)
# What the source says it has, versus what it actually handed over. Counts
# and layer names only: no endpoints, no "who supports whom". This is the
# part of "I did not see everything" that a real provider can state without
# leaking the answer -- a BOM knows how many parts exist, a netlist knows
# how many conductors exist and on which layers, and neither of them knows
# which part ends up holding the load.
scope: dict = field(default_factory=lambda: {
"parts": {}, "rendered": {},
"relations": {}, "rendered_relations": {},
"layers": [], "rendered_layers": [],
})
def entity_ids(self) -> set:
return {e.eid for e in self.entities}
@@ -124,6 +142,7 @@ class Observation:
"hidden_faces": sorted(self.hidden_faces),
"hidden": {k: dict(sorted(v.items())) for k, v in sorted(self.hidden.items())},
"dangling": [e.to_dict() for e in sorted(self.dangling, key=lambda x: x.eid)],
"scope": _canonical_scope(self.scope),
}