Repository navigation
medium verifier: exact and ordered_list reject bool-as-int (fixes #47) - #106
Open
bluzername wants to merge 1 commit into
Open
bluzername wants to merge 1 commit into
bluzername wants to merge 1 commit into
Conversation
…ixes TIGER-AI-Lab#47) Python's == treat True as 1 and False as 0 even inside a dict or a list. exact only check type() at the top level, then fall back to ==, so a dict that differ only by bool-vs-int somewhere inside it still compare equal. ordered_list have the same problem for a list. json_contract's own equal() already guard this one rule - now exact and ordered_list use a small standalone _type_strict_equal that keep the same rule (recurse through dict/list, number drift between int and float still OK, bool is never a number). Scoped to medium only, same as issue TIGER-AI-Lab#47 - the other 69 tasks keep their own copy of judge.py untouched.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is wrong
In
tasks/medium/tests/websitebench/harbor/judge.py,exactonly checktype(actual) is type(expected)at the top level, then fall back to plain==. Python sayTrue == 1andFalse == 0, even for a value sitting inside a dict or a list, so this type check at the top never catch it:json_contract's ownequal()already has the right rule (bool and int/float are never the same type, but int and float can still match each other for serialization drift like2500vs2500.0). A candidate API that return1where the reference returntruewould pass everyexactcheck on the 9api_jsonobservations inmedium, which is exactly the hole issue #47 describe.The fix
Added a small standalone
_type_strict_equal()(same recursion/number rule asjson_contract'sequal(), just without its field-rule matching, sinceexact/ordered_listdo not declare fields) and use it for bothexactandordered_listinstead of a bare==.Scoped to
mediumonly, same as the issue - the other 69 tasks each keep their own copy ofjudge.py, not touched here.Test
New
tests/test_medium_judge_comparators.py, loadingjudge.pythe same dynamic waytests/test_check_tasks.pyalready loadscripts/check_tasks.py. 6 cases: bool-vs-int at top level and inside a dict/list for both comparators (2 of them are RED on the old==code, GREEN after), plus 3 confirming a true match and the int/float drift case still pass.I was not able to execute the suite in my sandbox (no pytest/unittest access on a freshly cloned repo here), so I hand traced
_type_strict_equalagainst every new case and against the existingexact/ordered_list/json_contractcall sites incompare_valuesline by line.python3 -m py_compileon both changed files is clean. Sorry for the extra load on review, happy to adjust if CI see something I miss.