fix check_names false positives from server steam_id collisions

When a server folder's meta.cpp publishedid appears in a local folder
that has a completely different name, the steam_id lookup was returning
a wrong MISMATCH. Added a two-pass classification: any proposed rename
target that is already an exact OK match for another folder is
reclassified as NOT_ON_SERVER (steam_id collision) instead of MISMATCH.

_resolve_status moved to module level and takes ok_disk_names as a
parameter so it can be unit-tested independently.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
revernomad17
2026-04-07 17:15:30 +07:00
parent e706e71f29
commit 2ab6d87532
2 changed files with 83 additions and 18 deletions

View File

@@ -1064,7 +1064,7 @@ test("all exported symbols are callable or types", _test_exports_are_callable)
group("check_names helpers")
from check_names import _server_name_from_url, _read_local_steam_id, _lookup_server_name
from check_names import _server_name_from_url, _read_local_steam_id, _lookup_server_name, _resolve_status
def _test_server_name_from_url():
@@ -1143,6 +1143,36 @@ test("_lookup_server_name: falls back to name", _test_lookup_server_name_by_name
test("_lookup_server_name: steam_id beats name fallback", _test_lookup_server_name_steam_id_beats_name)
test("_lookup_server_name: not found -> None", _test_lookup_server_name_not_found)
# _resolve_status tests (the false-positive filter)
def _test_resolve_status_ok():
status, col = _resolve_status("@ace", "@ace", ok_disk_names={"@ace"})
assert_eq(status, "OK")
assert_eq(col, "@ace")
def _test_resolve_status_mismatch():
status, col = _resolve_status("@ACE3", "@ace3", ok_disk_names={"@cba_a3"})
assert_eq(status, "MISMATCH")
assert_eq(col, "@ace3")
def _test_resolve_status_not_found():
status, col = _resolve_status("@Unknown", None, ok_disk_names=set())
assert_eq(status, "NOT_ON_SERVER")
def _test_resolve_status_steam_id_collision():
# server_name is already correctly held by another folder → false positive
ok = {"@Realistic Ragdoll Physics"}
status, col = _resolve_status("@NIArms All in One- ACE Compatibility",
"@Realistic Ragdoll Physics",
ok_disk_names=ok)
assert_eq(status, "NOT_ON_SERVER", "Should be reclassified due to collision")
assert "collision" in col
test("_resolve_status: OK match", _test_resolve_status_ok)
test("_resolve_status: genuine mismatch", _test_resolve_status_mismatch)
test("_resolve_status: not found", _test_resolve_status_not_found)
test("_resolve_status: steam_id collision reclassified as NOT_ON_SERVER", _test_resolve_status_steam_id_collision)
# ---------------------------------------------------------------------------
# 10. Integration: parse → compare → reporter (offline)