Skip to content

Commit 34216a6

Browse files
committed
fix(verify): don't penalise devices for placeholder SoC dates
`soc_not_after_device` compared the device's release year against the SoC's exactly. 1,954 of the 2,104 SoC records (92.9%) carry a placeholder "YYYY-01-01" date whose year itself runs up to ~2 years late, so for almost every phone that check measured the placeholder rather than the device: it fails 5,488 otherwise-sound smartphones, costing each ~5.8 consistency points and holding a large near-miss pool just under the green threshold. Where the SoC date is a placeholder we now allow 2 years of slack and only flag a gross mismatch. A real, day-precise SoC date keeps the strict comparison, so the genuine signal is preserved. Refs #1
1 parent 28e836e commit 34216a6

2 files changed

Lines changed: 36 additions & 4 deletions

File tree

app/verify/signals.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@ def _year_of(value: Any) -> int | None:
7777
return None
7878

7979

80+
# A bulk-imported record with no known day is stored as January 1st. The year on
81+
# such a date is an approximation, not a measurement.
82+
_PLACEHOLDER_SOC_YEAR_SLACK = 2
83+
84+
85+
def _is_placeholder_date(value: Any) -> bool:
86+
return isinstance(value, str) and value[5:10] == "01-01"
87+
88+
8089
def parse_resolution(value: Any) -> tuple[int, int] | None:
8190
if not isinstance(value, str):
8291
return None
@@ -209,11 +218,19 @@ def mobile_signals(
209218
# (e.g. Snapdragon 888 stored as 2022-01-01), so a mismatch usually means the
210219
# *SoC* record's date is wrong, not the device. We flag + penalize but don't
211220
# force-red the device on the strength of a second record's bad date.
221+
#
222+
# 92.9% of SoC records (1,954/2,104) carry a placeholder date, and their year
223+
# is itself imprecise by up to ~2 years, so comparing years exactly against
224+
# one measures the placeholder, not the device: it fails 5,488 otherwise-sound
225+
# phones. Where the SoC date is a placeholder we only fail a gross mismatch;
226+
# a real, day-precise SoC date is still compared exactly.
212227
soc = rec.get("soc")
228+
soc_date = soc_release.get(soc) if isinstance(soc, str) else None
213229
dev_year = _year_of(rec.get("release_date"))
214-
soc_year = _year_of(soc_release.get(soc)) if isinstance(soc, str) else None
230+
soc_year = _year_of(soc_date)
215231
if dev_year is not None and soc_year is not None:
216-
ok = soc_year <= dev_year
232+
slack = _PLACEHOLDER_SOC_YEAR_SLACK if _is_placeholder_date(soc_date) else 0
233+
ok = soc_year <= dev_year + slack
217234
out.append(Signal("soc_not_after_device", "pass" if ok else "fail", hard=False))
218235
else:
219236
out.append(Signal("soc_not_after_device", "na", hard=False))

tests/verify/test_signals.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,27 @@ def test_storage_must_be_sorted_positive_unique():
7777

7878

7979
def test_soc_not_after_device_is_soft():
80-
rec = {"soc": "chip-x", "release_date": "2020-01-01"}
81-
soc_release = {"chip-x": "2022-01-01"}
80+
rec = {"soc": "chip-x", "release_date": "2020-06-01"}
81+
soc_release = {"chip-x": "2024-01-01"}
8282
s = _named(signals.mobile_signals(rec, NOW, soc_release), "soc_not_after_device")
8383
assert s.failed and not s.hard # flagged but never forces red
8484

8585

86+
def test_placeholder_soc_date_gets_year_slack():
87+
"""A "YYYY-01-01" SoC date is an approximation — 93% of the SoC set has one,
88+
and its year runs up to ~2 years late, so a small gap is not evidence."""
89+
soc_release = {"chip-x": "2022-01-01"}
90+
rec = {"soc": "chip-x", "release_date": "2020-09-01"}
91+
assert _named(signals.mobile_signals(rec, NOW, soc_release), "soc_not_after_device").result == "pass"
92+
93+
94+
def test_real_soc_date_is_compared_exactly():
95+
"""A day-precise SoC date is a measurement, so it keeps the strict check."""
96+
soc_release = {"chip-x": "2022-11-16"}
97+
rec = {"soc": "chip-x", "release_date": "2021-09-01"}
98+
assert _named(signals.mobile_signals(rec, NOW, soc_release), "soc_not_after_device").result == "fail"
99+
100+
86101
def test_soc_process_nm_era():
87102
rec = {"process_nm": 5.0, "release_date": "2010-01-01", "gpu_name": "x"}
88103
assert _named(signals.soc_signals(rec, NOW), "process_nm_era").result == "fail"

0 commit comments

Comments
 (0)