优化:未分类连续维护与柏拉图预汇总,同步已发布修复

This commit is contained in:
2026-11-01 12:40:50 +08:00
parent 572873c6b8
commit 38290f5fec
135 changed files with 17613 additions and 663 deletions
+29 -2
View File
@@ -15,10 +15,14 @@ def _proofs(value):
if not isinstance(value, dict):
return []
result = value.get('protocolEvidence')
proofs = [result] if isinstance(result, dict) else result if isinstance(result, list) else []
# Never alias the signed response list. Callers use this helper while
# filtering immutable evidence documents; extending the source list with
# nested current/comparison proofs changes the proof count seen later by
# strict scope validation.
proofs = [result] if isinstance(result, dict) else list(result) if isinstance(result, list) else []
for side in ('current', 'comparison'):
if isinstance(value.get(side), dict):
proofs += _proofs(value[side])
proofs.extend(_proofs(value[side]))
return list({p['queryId']: p for p in proofs
if isinstance(p, dict) and isinstance(p.get('queryId'), str)}.values())
@@ -32,6 +36,29 @@ def native_model_view(result):
if key not in ('protocolEvidence','evidencePath','apiSource')
and not (key == 'meaning' and value.get('basis') == 'official_composite')}
view = project(result)
# Presentation only: raw signed values and proofs remain untouched. A
# stage's own rate change and its contribution to composite have different
# roles even though both use pp.
from nao_native_contract import MASS_FIELDS, formal_display_metadata
formal=result.get('kind') in ('quality_comparison','quality_metrics','quality_changes','quality_weight_ranking')
fine=result.get('kind')=='quality_fine_defects' and result.get('unit')=='kg'
def displays(node,path=()):
if isinstance(node,list):
for item in node:displays(item,path)
elif isinstance(node,dict):
metadata={}
for key,value in list(node.items()):
if isinstance(value,(dict,list)):displays(value,(*path,key));continue
stage='黑片' if 'black' in path or key.startswith('black') else '亮片' if 'bright' in path or key.startswith('bright') else None
field=unit=None
if (formal or fine) and key in MASS_FIELDS:field,unit=key,'kg'
elif 'stageDecomposition' in path and key.endswith('ContributionToCompositePP'):field,unit='stageContribution','pp'
elif 'stageRateChangesPP' in path:field,unit='rateChange','pp';stage={'black':'黑片','bright':'亮片'}.get(key)
if field:
display=formal_display_metadata(value,field,unit,stage,signed=unit=='pp')
if display:metadata[key]=display
if metadata:node['formalDisplay']=metadata
displays(view)
if result.get('kind') == 'quality_changes' and isinstance(result.get('prioritySignals'),dict):
rows = {row.get('key'):row for row in result.get('rows',[]) if isinstance(row,dict)}
signals = {}