@@ -43,6 +43,45 @@ def hard(msg: str) -> None:
4343 HARD .append (msg )
4444 print (msg )
4545
46+ # Era-vs-score: catch wrong-variant contamination (an old chip carrying a score
47+ # that belongs to a newer part). The original rule used a flat per-chip ceiling
48+ # (PassMark>1500 before 2006, R23>3000 before 2011) and ignored core/thread count.
49+ # That mis-fires on legitimate pre-2011 high-core enthusiast parts: Cinebench R23
50+ # and PassMark run on the physical silicon regardless of launch date, so a 6c/12t
51+ # Gulftown (i7-980X/990X) genuinely posts ~6,000-6,500 R23 today and a 4c/8t
52+ # Bloomfield (i7-920) ~3,000-3,800 — all above a flat 3,000 gate. The fix scales
53+ # the ceiling by thread count: pre-2011 microarchitectures (Nehalem/Westmere/K10)
54+ # top out around ~600 R23 and ~450 PassMark *per thread*, whereas a genuinely
55+ # implausible "old chip, modern score" combo (e.g. a 2c/2009 part claiming 20,000
56+ # R23 = 10,000/thread) sits far above the per-thread ceiling and still flags.
57+ ERA_R23_PER_THREAD = 1000 # R23 multi per thread; pre-2011 real parts are ~400-600
58+ ERA_PASSMARK_PER_THREAD = 900 # PassMark per thread; pre-2006 real parts are well under this
59+
60+ def era_score_outliers (rec : dict ) -> list [str ]:
61+ """Return era-vs-score finding messages for one CPU record (empty if none).
62+
63+ Cores/threads-aware: the score ceiling scales with thread count so that
64+ high-core-for-their-era chips are not flagged, while a per-thread score that
65+ is implausible for the release era still is. Threads default to cores, then 1.
66+ """
67+ findings : list [str ] = []
68+ year = (rec .get ("release_date" ) or "0" )[:4 ]
69+ threads = rec .get ("threads" ) or rec .get ("cores" ) or 1
70+ name = rec .get ("name" , "?" )
71+ pm = rec .get ("passmark_cpu_mark" )
72+ r23 = rec .get ("cinebench_r23_multi" )
73+ if year < "2006" and pm and pm > ERA_PASSMARK_PER_THREAD * threads :
74+ findings .append (
75+ f" { name !r} ({ year } ): passmark { pm } too high for era "
76+ f"({ pm / threads :.0f} /thread over { ERA_PASSMARK_PER_THREAD } , { threads } T)"
77+ )
78+ if year < "2011" and r23 and r23 > ERA_R23_PER_THREAD * threads :
79+ findings .append (
80+ f" { name !r} ({ year } ): r23 { r23 } too high for era "
81+ f"({ r23 / threads :.0f} /thread over { ERA_R23_PER_THREAD } , { threads } T)"
82+ )
83+ return findings
84+
4685def load (comp ):
4786 recs = []
4887 for dp , _ , fs in os .walk (os .path .join (ROOT , comp )):
@@ -63,89 +102,91 @@ def mad_outliers(pairs, lo=0.34, hi=3.0):
63102
64103def section (t ): print (f"\n ### { t } " )
65104
66- records = {category : load (category ) for category in CATEGORIES }
67- cpus = records ["cpu" ]; gpus = records ["gpu" ]
68- print (f"scope: { len (CATEGORIES )} /12 categories ? { sum (map (len , records .values ()))} records" )
69- print (f"loaded CPU={ len (cpus )} GPU={ len (gpus )} " )
70-
71- # --- 1. duplicates + slug/file + verified-no-source ---
72- section ("structural" )
73- for comp , recs in records .items ():
74- slugs , names = {}, {}
75- for p , fn , d in recs :
76- if d .get ("verified" ) is True and not d .get ("source_urls" ):
77- hard (f" [{ comp } ] verified without sources: { fn } " )
78- slugs .setdefault (d .get ("slug" ), []).append (fn )
79- names .setdefault (d .get ("name" ), []).append (fn )
80- if d .get ("slug" ) != fn :
81- hard (f" [{ comp } ] slug!=file: { fn } slug={ d .get ('slug' )} " )
82- for s , fl in slugs .items ():
83- if len (fl ) > 1 : hard (f" [{ comp } ] DUP slug { s } : { sorted (fl )} " )
84- for n , fl in names .items ():
85- if comp in ("cpu" , "gpu" ) and len (fl ) > 1 : hard (f" [{ comp } ] DUP name { n !r} : { sorted (fl )} " )
86-
87- # --- 2. AMD Ryzen line vs DESKTOP model tier-digit (2nd digit); APU/mobile excepted ---
88- section ("CPU name/tier consistency (desktop mainstream only)" )
89- TIERMAP = {"6" : "5" , "7" : "7" , "8" : "7" , "9" : "9" } # 2nd model digit -> expected line
90- for p , fn , d in cpus :
91- n = d .get ("name" , "" )
92- # mainstream desktop: 4-digit model, no G/U/H/HS/HX (APU/mobile) suffix
93- m = re .match (r"AMD Ryzen (\d) (\d)(\d)\d\d(X3D|X|XT)?$" , n )
94- if m :
95- line , _gen , tier = m .group (1 ), m .group (2 ), m .group (3 )
96- exp = TIERMAP .get (tier )
97- if exp and exp != line :
98- print (f" [tier] { n !r} : line Ryzen { line } but tier-digit { tier } → expect Ryzen { exp } " )
99-
100- # --- 3. benchmark sanity: single>multi (consistent-scale benches) ---
101- section ("CPU single>multi (cinebench/geekbench — should be multi>=single)" )
102- for p , fn , d in cpus :
103- for s , mu in [("cinebench_r23_single" ,"cinebench_r23_multi" ),
104- ("geekbench_single" ,"geekbench_multi" ),
105- ("cinebench_2024_single" ,"cinebench_2024_multi" )]:
106- a , b = d .get (s ), d .get (mu )
107- if a and b and a > b and (d .get ("threads" ) or 1 ) > 1 :
108- hard (f" { d ['name' ]!r} : { s } ={ a } > { mu } ={ b } " )
109-
110- # --- 4. era vs score (catch wrong-variant: old chip w/ modern score) ---
111- section ("CPU era-vs-score outliers" )
112- for p , fn , d in cpus :
113- y = (d .get ("release_date" ) or "0" )[:4 ]
114- pm = d .get ("passmark_cpu_mark" ); r23 = d .get ("cinebench_r23_multi" )
115- if y < "2006" and pm and pm > 1500 :
116- print (f" { d ['name' ]!r} ({ y } ): passmark { pm } too high for era" )
117- if y < "2011" and r23 and r23 > 3000 :
118- print (f" { d ['name' ]!r} ({ y } ): r23 { r23 } too high for era" )
119-
120- # --- 5. cross-source correlation outliers (KEY contamination detector) ---
121- section ("CPU cross-source ratio outliers (possible wrong-variant)" )
122105def collect (recs , fa , fb ):
123106 return [(d ["name" ], d [fa ], d [fb ]) for p , fn , d in recs if d .get (fa ) and d .get (fb )]
124- for fa , fb in [("passmark_cpu_mark" ,"cinebench_r23_multi" ),
125- ("passmark_cpu_mark" ,"geekbench_multi" ),
126- ("cinebench_r23_multi" ,"geekbench_multi" ),
127- ("cinebench_2024_multi" ,"cinebench_r23_multi" )]:
128- out = mad_outliers (collect (cpus , fa , fb ))
129- for label , ratio in out :
130- print (f" [{ fa } /{ fb } ] { label !r} : ratio={ ratio } " )
131-
132- # --- 6. GPU cross-source + sanity ---
133- section ("GPU cross-source ratio outliers + sanity" )
134- for fa , fb in [("passmark_g3d_mark" ,"timespy_score" ),
135- ("timespy_score" ,"blender_score" ),
136- ("fp32_tflops" ,"timespy_score" ),
137- ("passmark_g3d_mark" ,"fp32_tflops" )]:
138- for label , ratio in mad_outliers (collect (gpus , fa , fb )):
139- print (f" [{ fa } /{ fb } ] { label !r} : ratio={ ratio } " )
140-
141- print ("\n (no lines under a section = clean)" )
142-
143- if HARD_REPORT :
144- with open (HARD_REPORT , "w" , encoding = "utf-8" ) as report :
145- json .dump (sorted (set (HARD )), report , ensure_ascii = False , indent = 2 )
146-
147- if STRICT and HARD :
148- print (f"\n ❌ integrity gate: { len (HARD )} hard anomaly(ies) — blocking refresh." )
149- sys .exit (1 )
150- if STRICT :
151- print ("\n ✅ integrity gate: no hard anomalies." )
107+
108+ def main () -> None :
109+ records = {category : load (category ) for category in CATEGORIES }
110+ cpus = records ["cpu" ]; gpus = records ["gpu" ]
111+ print (f"scope: { len (CATEGORIES )} /12 categories ? { sum (map (len , records .values ()))} records" )
112+ print (f"loaded CPU={ len (cpus )} GPU={ len (gpus )} " )
113+
114+ # --- 1. duplicates + slug/file + verified-no-source ---
115+ section ("structural" )
116+ for comp , recs in records .items ():
117+ slugs , names = {}, {}
118+ for p , fn , d in recs :
119+ if d .get ("verified" ) is True and not d .get ("source_urls" ):
120+ hard (f" [{ comp } ] verified without sources: { fn } " )
121+ slugs .setdefault (d .get ("slug" ), []).append (fn )
122+ names .setdefault (d .get ("name" ), []).append (fn )
123+ if d .get ("slug" ) != fn :
124+ hard (f" [{ comp } ] slug!=file: { fn } slug={ d .get ('slug' )} " )
125+ for s , fl in slugs .items ():
126+ if len (fl ) > 1 : hard (f" [{ comp } ] DUP slug { s } : { sorted (fl )} " )
127+ for n , fl in names .items ():
128+ if comp in ("cpu" , "gpu" ) and len (fl ) > 1 : hard (f" [{ comp } ] DUP name { n !r} : { sorted (fl )} " )
129+
130+ # --- 2. AMD Ryzen line vs DESKTOP model tier-digit (2nd digit); APU/mobile excepted ---
131+ section ("CPU name/tier consistency (desktop mainstream only)" )
132+ TIERMAP = {"6" : "5" , "7" : "7" , "8" : "7" , "9" : "9" } # 2nd model digit -> expected line
133+ for p , fn , d in cpus :
134+ n = d .get ("name" , "" )
135+ # mainstream desktop: 4-digit model, no G/U/H/HS/HX (APU/mobile) suffix
136+ m = re .match (r"AMD Ryzen (\d) (\d)(\d)\d\d(X3D|X|XT)?$" , n )
137+ if m :
138+ line , _gen , tier = m .group (1 ), m .group (2 ), m .group (3 )
139+ exp = TIERMAP .get (tier )
140+ if exp and exp != line :
141+ print (f" [tier] { n !r} : line Ryzen { line } but tier-digit { tier } → expect Ryzen { exp } " )
142+
143+ # --- 3. benchmark sanity: single>multi (consistent-scale benches) ---
144+ section ("CPU single>multi (cinebench/geekbench — should be multi>=single)" )
145+ for p , fn , d in cpus :
146+ for s , mu in [("cinebench_r23_single" ,"cinebench_r23_multi" ),
147+ ("geekbench_single" ,"geekbench_multi" ),
148+ ("cinebench_2024_single" ,"cinebench_2024_multi" )]:
149+ a , b = d .get (s ), d .get (mu )
150+ if a and b and a > b and (d .get ("threads" ) or 1 ) > 1 :
151+ hard (f" { d ['name' ]!r} : { s } ={ a } > { mu } ={ b } " )
152+
153+ # --- 4. era vs score (catch wrong-variant: old chip w/ modern score) ---
154+ section ("CPU era-vs-score outliers" )
155+ for p , fn , d in cpus :
156+ for msg in era_score_outliers (d ):
157+ print (msg )
158+
159+ # --- 5. cross-source correlation outliers (KEY contamination detector) ---
160+ section ("CPU cross-source ratio outliers (possible wrong-variant)" )
161+ for fa , fb in [("passmark_cpu_mark" ,"cinebench_r23_multi" ),
162+ ("passmark_cpu_mark" ,"geekbench_multi" ),
163+ ("cinebench_r23_multi" ,"geekbench_multi" ),
164+ ("cinebench_2024_multi" ,"cinebench_r23_multi" )]:
165+ out = mad_outliers (collect (cpus , fa , fb ))
166+ for label , ratio in out :
167+ print (f" [{ fa } /{ fb } ] { label !r} : ratio={ ratio } " )
168+
169+ # --- 6. GPU cross-source + sanity ---
170+ section ("GPU cross-source ratio outliers + sanity" )
171+ for fa , fb in [("passmark_g3d_mark" ,"timespy_score" ),
172+ ("timespy_score" ,"blender_score" ),
173+ ("fp32_tflops" ,"timespy_score" ),
174+ ("passmark_g3d_mark" ,"fp32_tflops" )]:
175+ for label , ratio in mad_outliers (collect (gpus , fa , fb )):
176+ print (f" [{ fa } /{ fb } ] { label !r} : ratio={ ratio } " )
177+
178+ print ("\n (no lines under a section = clean)" )
179+
180+ if HARD_REPORT :
181+ with open (HARD_REPORT , "w" , encoding = "utf-8" ) as report :
182+ json .dump (sorted (set (HARD )), report , ensure_ascii = False , indent = 2 )
183+
184+ if STRICT and HARD :
185+ print (f"\n ❌ integrity gate: { len (HARD )} hard anomaly(ies) — blocking refresh." )
186+ sys .exit (1 )
187+ if STRICT :
188+ print ("\n ✅ integrity gate: no hard anomalies." )
189+
190+
191+ if __name__ == "__main__" :
192+ main ()
0 commit comments