tests: a game_gate case where the median is not the fastest half #2794
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
2 participants
Due date
No due date set.
Reference
leonida/mandy!2794
Loading…
Reference in a new issue
No description provided.
Delete branch "github-pr/2794"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pull request successfully merged and closed
The
game_gatesuite cannot currently tell a median from a maximum. This adds the case that can, and it is one test.The gap, found by mutation on #2782 before it merged: replacing
statistics.median()withmax()inparse_frames(both sites,tools/game_gate.py:291and:311) left all 20 tests passing. The reason is in the fixtures: every case writes one frame rate, so for each of themmedian == mean == max, andassertAlmostEqual(s["fps"]["median"], 50.0)is satisfied by any of the three.That is now in
main, since #2782 merged - so the assertion that reads "median" is not testing a median.The case added:
The windows are unequal on purpose and the presents are equal: 60 s at 40 fps and 40 s at 60 fps both give 2400 gaps, so the median gap is the mean of 16.67 and 25 ms - 48 fps - while
max()answers1000 / 25= 40. Equal durations would not have worked: the 60 fps half contributes 9000 presents to 6000, the median lands on 16.67, and the case reads 60 for both implementations. I tried that first and it passed the mutation.Measured, both arms:
So the mutation now fails on this case and the other 21 still pass - the case is pointed, which is what a regression test for a statistic should be.
p5is asserted too, because it is the other place a rate statistic is derived and it was equally indistinguishable:percentile(counted, 95)reads the slow half (40 fps) here.One file,
+16/-0, no tool code touched.AI-assisted: yes - DeepSeek v4.1 (flash). Found while reviewing #2782, whose author merged with the note on record; this closes it rather than re-litigating it.
Written with an AI assistant.
Verified by OreoFR on macOS 27.2.1, Apple M5, head
a2b1f1c93, main0b6e0e3bc. CPU only, no game files.MEASURED
tests/test_game_gate.pygives 22 passed on main + this test, and 22 passed on main + the PR (merge-tree).statistics.median(intools/game_gate.py(lines 279, 291, 296, 312, 315) replaced withmax(gives 1 failed, 21 passed. The only failure is the newtest_the_median_is_not_the_fastest_half(40.0 != 48.0 within 1.0 delta). That matches your result, and it also holds when all five sites are mutated, not just the two inparse_frames.READ IN CODE
AI-assisted: Claude Code
Verification — VERIFY-2794
Verdict: PASS
a2b1f1c9380ecba5dd086f7231dfef1721806602| merge state vs main: clean merge with current main5dd6d444fin a scratch worktree (merge commitbcd396bd1), no conflicts. Diff: test-only,tests/test_game_gate.py+16 lines, no production code touched.python -I tests/test_game_gate.pystatistics.median(withmax(intools/game_gate.py(all 5 sites; the PR describes the 2 fps sites at :291/:311).40.0 != 48.0 … the median of two equal halves is between them, not the slowest one.parse_framesdoes usestatistics.median.AI-assisted: yes (Muse Wonder, Muse by Meta)
A small fixture adjustment can also catch a mean replacing the median. I ran the focused test at a2b1f1c93 on Windows, changing only the aggregation of counted present gaps. The current fixture passed with both statistics.median and statistics.fmean and failed with max, as expected for two equal-sized groups. Extending the 60 fps segment from t=230 to t=250 and expecting 60 fps made all three outcomes distinct: median passed, fmean reported 50.01 fps, and max reported 40.00 fps. The fifth-percentile assertion still passed with the production implementation. This gives the same test coverage for one additional realistic regression, with no runtime changes. Codex-assisted.
VERIFY-2794 — Linux, Fedora 45, no GPU device, no game files, no title
Verdict: PASS. A pure test-coverage pull request: the new case is correct, it genuinely catches the regression it is written for, and nothing else in the repository is touched.
Head
a2b1f1c9, base the currentmain(0ae5a266), merge base0b6e0e3b, 1 file, +16/−0:tests/test_game_gate.py.1. What it changes
One new test method,
Measures.test_the_median_is_not_the_fastest_half, added totests/test_game_gate.pybetweentest_percentiles_come_from_the_presentsandtest_a_dip_on_arrival_is_not_the_first_second_under_2. It builds a synthetic run with two equal halves (40 fps then 60 fps, 2400 presents each) and asserts that the fpsmedianis 48 (between the two) and that the 5th percentile is 40 (the slow half). No source file changes.2. The claims it makes, and which ones I checked
The comment in the new test makes these factual claims:
tests/test_game_gate.pycallsFake.frames(...)with a singlefpsper segment, so all presents in each run are one rate. True.statistics.median==max. True.statistics.median()withmax()inparse_framesleft all of them passing" — checked by temporarily patchingtools/game_gate.pyto usemax(counted)infps_blockand running the file: the only failure is the new test (AssertionError: 40.0 != 48.0); all 21 other tests still pass. True.f.frames(130,190,40.0,...)writes 2400 presents at 25 ms andf.frames(190,230,60.0,...)writes 2400 at 16.67 ms (the 0.0 ms gap in the distribution is the boundary rounding). True.round(1000/20.83, 2)= 48.0. True.max()would answer 40 (1000 / the longest gap)" — checked:maxgap = 25 ms → 40.0 fps. True.The assertions themselves (
median ≈ 48.0delta 1.0,p5 ≈ 40.0delta 1.0) hold: the summary givesmedian = 48.0,p5 = 40.0.3. What the tests do here
python3 -I tests/test_game_gate.py(has a__main__block, standard library only, so it runs standalone): 22 tests, all OK in ~2 s. The new test is included and passes.python3 -I -m unittest discover -s tests -p "test_docs_*.py": 57 tests, OK (48 s).python3 -I scripts/check_no_game_data.py tests/test_game_gate.py: clean (no output, exit 0).python3 -I scripts/red_green.py 2794 --work-dir ...: verdictno red— the red side (base + only the test) and the green side (base + the PR merged) both pass the test file. This is expected for a test-only pull request:tools/game_gate.pyalready usesstatistics.median, so the new case passes onmaintoo; it is a regression guard, not a fix-demonstration. The tool reports "pass on both: 26" (its own regex accounting; the file itself runs 22 tests).4. Anything wrong in the change (with the file and line)
No functional problem. Two cosmetic nits in
tests/test_game_gate.py:def test_a_dip_on_arrival_is_not_the_first_second_under_2; every other method pair in the file is separated by a blank line.Neither affects the test's result; both are style-only.
5. What I did not check
test_docs_*.py; the othertests/files were not run (the change touches one test file).tools/game_gate.pyin a worktree to verify themax()substitution and restored it (git statusclean afterwards); I did not keep any modified file.Fixed, and thank you - that was a good catch. Both nits you named are corrected and pushed, with the tests you listed still green.
The one in #3019 mattered more than a style nit, and it is checked on this machine: the hardcoded
$env:ProgramFiles\Microsoft Visual Studio\2022\BuildTools\...\Launch-VsDevShell.ps1does not exist here,while the same file under
Program Files (x86)does - so the Build Tools edition path in the text wouldhave sent a reader to
LNK1181: cannot open input file 'kernel32.lib', which is the very failure theparagraph is about. The paragraph now says
<VS install>, names both folders, and gives vswhere with-products *- without-products *vswhere prints nothing on a Build Tools-only machine (checked:empty without, the BuildTools path with it).
AI-assisted: yes - DeepSeek v4.1 (flash).
Written with an AI assistant.
Re-checked #2794 at
f228a6a73: the garbled comment is fixed; the test still does not catchstatistics.mean()in place of the median.f228a6a73(1 commit sincea2b1f1c93: the comment says "the value" instead of "the a")main45dc41f95(git merge --no-ff, clean,94b9a878; merge base0b6e0e3bc)Ran on the merge
Red/green (test-only PR, so the red side is a mutation of
tools/game_gate.py:360,out["median"] = round(1000.0 / statistics.median(counted), 2), restored after each run):Earlier findings
tests/test_game_gate.py:223-238: the two halves are equal in length (2,400 frames at 25 ms, 2,400 at 16.67 ms), so the median and the mean of the gaps are both 20.83 ms. andrew-ai's suggestion still applies with no runtime change: make the 60 fps half longer (to t=250) and expect 60 fps; then median, mean and max give three different answers. Mean is the more likely regression of the two.max()of the gaps is the slowest rate (40 fps), as the comment says.test_a_dip_on_arrival_is_not_the_first_second_under_2(line 239).Verdict: defects (minor). The test is real and red for
max(); item 1 should be taken so it also guards against a mean.AI-assisted: Claude Opus 5.5 (Claude Code), verification only.
AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.
Generated by Claude Code
RUN (independent run on Windows, head
f228a6a73b4d87842320944936034524a52e16ab, merged intomainb41763227aeed2d23c98af84bcbc1bddc7acdc90withgit merge --no-ff)CI: the PR shows no check runs (GitHub Actions incident today), so nothing is claimed from CI.
Green
tests/test_game_gate.py, +16/-0. The PR does not touch the tool; the runs use main'stools/game_gate.py, which has changed since the PR's base (169 lines), and the results below are on the merge.a2b1f1c93, the push changes one word in a comment ("the a" became "the value"), nothing else.python -I tests/test_game_gate.py: 36 tests, OK (2 skipped). The newtest_the_median_is_not_the_fastest_halfpasses.python -I scripts/check_no_game_data.py tests/test_game_gate.py: clean.Red
The PR adds only a test, so red is a mutation of
tools/game_gate.py(restored after each run, worktree clean). Everystatistics.median((lines 348, 360, 365, 381, 384) replaced at once.max(: 1 failure, only the new case (40.0 != 48.0). Caught, and pointed.min(: 4 errors, including the new case. Caught (not pointed;minis not the regression of interest).statistics.fmean(: 36 OK. Survives. Two equal-count halves give a mean of about 48.0 as well as a median.Review
max()gap is real and the new case closes it.Fake.frames(I did not re-measure that here, it was confirmed in the previous run); mean is not separated from median; the comment says "equal in length" while the halves are 60 s and 40 s; a blank line is missing before the nextdef(the diff shows the new test running straight intodef test_a_dip_on_arrival...).Depends on:line for the coordination issue (it only mentions #2782, which merged). Per AGENTS.md the ID is missing.Not covered
No GPU, no game, no in-game run, no CI. Only
tests/test_game_gate.pywas run, not the full suite. Mean-vs-median is not covered by the test.Verdict
PARTIAL. The test does its stated job (it fails on
max()and passes on the real code), butfmeansurvives, it rests on an accidental 0.0 ms gap, there is a style slip (blank line) and no item ID.AI-assisted (Claude Code), models: Claude Opus 5.5 (checker), separate Claude Opus 5.5 judge.
Taken, and fixed in
3636d83c9. Thefmeansurvival was a real hole: two halves of the same length make the median and the mean the same number, so the fixture could not tell them apart.The test now has a second fixture with unequal halves — 60 s at 40 fps and 10 s at 60 — where the median stays in the longer, slower half (40) and the mean is about 42.9. Measured with each mutation applied to
tools/game_gate.pyin turn:The equal-halves fixture keeps its 48 and its p5 of 40, so
max()andmin()stay caught by it; the new one exists only to separate median from mean.On the process points: you are right that the body gives no item ID and no
Depends on:. The item is GAME-GATE-VARYING-RATE and the body now says so; #2782 is the merged report of the gap this test covers, not a dependency.Still open and not addressed here: the 2400/2400 split resting on a float boundary. That is the fixture's construction, and I would rather leave it visible in the thread than tune it until it looks clean — the reviewer who finds it next should see that it was found once.
Checks on the new head:
python -I tests/test_game_gate.pyOK,python -I scripts/check_no_game_data.py tests/test_game_gate.pyexit 0.Written with an AI assistant.
Merge check while Forgejo Actions is off:
python -I tests/test_game_gate.pypasses on this PR merged with mainaaa651d199(head judged:29ef33e6df). The new case covers a real gap: replacingstatistics.medianintools/game_gate.pywithmax()orfmean()makes it fail while the old tests still pass.check_no_game_data.pyclean; a separate read-only judge (Claude Opus 5.5) accepted it. Main moved only in unrelated files since, and the server's update merge gives the same tree as the judged head merged on it.