feat(spatial): 弃权判据换成清单-交付,标签不再依赖完整状态
This commit is contained in:
1 parent
9d449f2108
commit
762b4d347d
9 files changed
+871
-496
No files matched your search
+27
-2
@@ -279,6 +279,32 @@ def validate_evidence(full: FullState, query: Query, evidence) -> bool:
|
||||
# label
|
||||
|
||||
|
||||
def withheld_flag(obs) -> bool:
|
||||
"""Is the inventory bigger than what was handed over.
|
||||
|
||||
Read from ``obs.scope`` only -- counts of parts and relations, and the layer
|
||||
stack. It deliberately does **not** consult ``hidden`` or ``dangling``:
|
||||
those are computed as "full state minus visible", and no real provider can
|
||||
compute them, because knowing that a relation exists with one end off-screen
|
||||
requires seeing both ends.
|
||||
|
||||
What a provider can say is that its inventory is bigger: a BOM lists five
|
||||
parts and three were rendered; a netlist has nine conductors on two layers
|
||||
and one layer was exported. That statement carries no endpoints, so it
|
||||
cannot decide the answer -- only suspend it.
|
||||
"""
|
||||
scope = obs.scope or {}
|
||||
parts = scope.get("parts") or {}
|
||||
rendered = scope.get("rendered") or {}
|
||||
if any(parts.get(k, 0) > rendered.get(k, 0) for k in parts):
|
||||
return True
|
||||
rel = scope.get("relations") or {}
|
||||
rel_r = scope.get("rendered_relations") or {}
|
||||
if any(rel.get(k, 0) > rel_r.get(k, 0) for k in rel):
|
||||
return True
|
||||
return bool(set(scope.get("layers") or []) - set(scope.get("rendered_layers") or []))
|
||||
|
||||
|
||||
def label(obs: Observation, full: FullState, query: Query,
|
||||
alternatives: Iterable[FullState] = ()) -> Label:
|
||||
"""Full state decides; the observation decides whether we may say so.
|
||||
@@ -303,8 +329,7 @@ def label(obs: Observation, full: FullState, query: Query,
|
||||
ans_full = evaluate(full.entities, full.edges, query)
|
||||
alt = list(alternatives)
|
||||
ans_vis = evaluate(alt[0].entities, alt[0].edges, query) if alt else ans_full
|
||||
withheld = bool(obs.dangling) or bool((obs.hidden or {}).get("entity")) \
|
||||
or bool((obs.hidden or {}).get("edge"))
|
||||
withheld = withheld_flag(obs)
|
||||
|
||||
if withheld:
|
||||
if ans_vis is True:
|
||||
|
||||
Reference in new issue
Block a user