import curation_paths as paths import sys,json,sqlite3,collections as C,hashlib S=paths.S; RA=S+"/engine/source/scripts/internal/scene_generation/real_assets" sys.path[:0]=[S,RA,S+"/engine/supervisor_site"] import dynamic_retrieval as dr, annotation_retrieval as ar R=paths.L+"/" a=sqlite3.connect("file:"+R+"full_matrix_reviewed_compatibility_v4.sqlite3?mode=ro",uri=True); b=sqlite3.connect("file:"+R+"full_matrix_reviewed_compatibility_v5.sqlite3?mode=ro",uri=True) A=dict(a.execute("select asset_id,record_json from annotations")); B=dict(b.execute("select asset_id,record_json from annotations")) BA=dict(b.execute("select asset_id,record_json from assets")) print("same asset set:",set(A)==set(B),len(A),"| annotations==assets in v5:",all(B[k]==BA[k] for k in B)) c=C.Counter(); diffkeys=C.Counter(); mat_only=0 for k in A: ra,rb=json.loads(A[k]),json.loads(B[k]) if A[k]==B[k]: c["byte_identical"]+=1; continue c["rewritten"]+=1 keys={x for x in set(ra)|set(rb) if ra.get(x)!=rb.get(x)}; diffkeys.update(keys) # candidate builder (the gate) must be identical ca,cb=ar.build_candidate(ra),ar.build_candidate(rb) if ca!=cb: c["BUILD_CANDIDATE_DIFFERS"]+=1 # retrieval compact record: only materials may differ xa,xb=dr._compact_record(A[k]),dr._compact_record(B[k]) da={x for x in set(xa)|set(xb) if xa.get(x)!=xb.get(x)} if isinstance(xa,dict) and isinstance(xb,dict) else {"?"} for x in da: c["compact_diff_"+x]+=1 print(dict(c)); print("top-level keys that differ:",dict(diffkeys)) # ranking inputs: roles, direction, function, status bad=0 for k in A: ra,rb=json.loads(A[k]),json.loads(B[k]) for f in ("category","canonical_role","primary_role","functional_slots","function_tags","dimensions_m","canonical_transform","annotation_status","field_values","style_tags","asset_sha256","source_sha256","runtime_sha256"): if ra.get(f)!=rb.get(f): bad+=1 print("protected fields changed:",bad) for t in ("style_role_candidates","functional_slots","function_tags","asset_descriptors","records","matrix_entries","reviewed_style_compatibility","metadata"): ha=hashlib.sha256(repr(a.execute("select * from "+t+" order by 1,2").fetchall()).encode()).hexdigest()[:10]; hb=hashlib.sha256(repr(b.execute("select * from "+t+" order by 1,2").fetchall()).encode()).hexdigest()[:10] print("%-30s %s"%(t,"identical" if ha==hb else "DIFFERENT %s %s"%(ha,hb)))