Skip to content

fix(repo): first_useful_rate leaves out a cell whose steps is past the measure bound (#922) - #1018

Merged
antonwolfy merged 5 commits into
intel:mainfrom
antonwolfy:fix/useful-rate-past-bound
Nov 20, 2026
Merged

antonwolfy merged 5 commits into
intel:mainfrom
antonwolfy:fix/useful-rate-past-bound

Conversation

@antonwolfy

@antonwolfy antonwolfy commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

repo compare's first_useful_rate counted a cell whose first_useful.steps is no measure (past the 1e150 bound, NaN, inf) as a non-hit, in the rate and in its n. Every other measure leaves a past-bound value out of the mean and of n, as a value that is absent.

cells (kind edit, reason null unless noted) first_useful_rate on main after
steps 5, 1e200 [0.5], n 2 [1.0], n 1
steps 5, 1e200, and a never cell (steps null) [0.333...], n 3 [0.5], n 2

The compare header's "first useful observed: arm X of Y (Z unmeasured)" counted the same cell as measured: useful_counts gave {'observed': 1, 'measured': 2, 'unmeasured': 0} for steps 5 and 1e200, so the header said "1 of 2" while the rate was 0.5 of 2. It now gives {'observed': 1, 'measured': 1, 'unmeasured': 1}.

Of the issue's three options (count it as a non-hit, drop it, count it as a hit) this takes dropping: the contract's "The measure bound" already leaves every other past-bound value out as absent. Counting it as a hit is not taken: first_useful() stores an enumerate int, so a steps of 1e200 is a corrupt record, and the repo's rule for a corrupt measure is "no measurement", not a trusted verdict. A cell whose steps is null (never) is still a miss.

Closes #922

Changes

  • dokimi/dokimi/repos/useful.py: a new _rated keeps the cells with a verdict less those whose steps is set but is no measure. useful_task_values, useful_task_counts and useful_counts read it, so the rate, its n and the header's observed-of-measured count agree. Their docstrings, and _rated's, say such a cell is neither a hit nor a miss. first_useful(), useful_summary (repo report's row) and the medians are unchanged: the row's total counts every declared cell, so a past-bound cell is in the total and not observed (steps 5 and steps 1e200 give 1 of 2 observed), and the contract's repo report paragraph now says so.
  • dokimi/docs/repo-evaluation-contract.md ("The measure bound" and the two first_useful_rate paragraphs) and the dokimi/dokimi/repos/compare.py module docstring say a cell whose steps is past the bound is left out of the rate and its n, and shows as unmeasured in the header.
  • tests/test_repo_compare_overflow.py: test_first_useful_rate_keeps_a_cell_with_steps_past_the_bound_as_a_non_hit is renamed test_first_useful_rate_leaves_out_a_cell_with_steps_past_the_bound, its expectation reversed (rate [1.0], n 1) and parametrized over 1e200, NaN and inf. New tests: a never cell beside a past-bound one stays a miss (rate [0.5], n 2); steps of 1e150 (SCORE_BOUND) is still a hit; useful_counts shows the cell as unmeasured.
  • tests/test_repo_useful.py::test_a_stored_non_finite_or_huge_number_is_no_measure pinned a lone past-bound cell as rate 0.0 and measured 1; it now expects rate None, n 0, measured 0 and unmeasured 1.
  • Changelog fragment (Fixed).

Risk

repo compare output changes for a batch whose result.json holds a first_useful.steps past 1e150, NaN or inf, which the writer does not produce: the task's first_useful_rate rises (or is absent when that was its only cell) and its n drops, and the header counts the cell as unmeasured. No other input changes: cells with steps null, unobserved or timeout are handled as before.

Open PRs on the same files: #779 changes useful.py too, but only first_useful(), the module docstring and the import block, none of which this PR touches, so the two merge apart. #779, #781, #787, #898, #952, #953, #956, #958, #977 and #1003 edit repo-evaluation-contract.md in other sections than "The measure bound" and the first_useful_rate paragraph near §4.1, and #781's compare.py change is not in its module docstring's first_useful_rate item.

Testing

On a Linux review host, at 5da94f70 (on main 52160e9c):

  • make ci-local: 0 failed, 36 passed, 14 skipped (skipped: jobs for other platforms, matrix legs, docker, and tools not on the PATH). The pytest step had 23964 passed, 19 skipped.
  • On main's code the new and rewritten tests of tests/test_repo_compare_overflow.py fail (5 failed, 40 passed), e.g. assert [0.5] == [1.0] for steps 5 and 1e200.
  • Mutants, each failing the tests named: _rated returning _measured(have) fails the past-bound rate tests, the never test and the useful_counts test (5 failed); _rated dropping the steps is None part fails the never test; _rated with a < 1e150 bound fails the at-the-bound test; useful_counts reading _measured fails the useful_counts test and test_a_stored_non_finite_or_huge_number_is_no_measure.
  • Not run: the matrix legs on Python 3.11, 3.12 and 3.14.

Open questions

None.

Revert

A plain revert restores counting a past-bound steps cell as a non-hit. Nothing is stored.

Checklist

  • Tests added/updated and pytest passes
  • ruff, mypy, and schema checks pass
  • Docs updated (or N/A) — see the docs-drift checklist in CONTRIBUTING.md
  • Self-reviewed per "Before opening a PR" in AGENTS.md
  • Each new raise/exit and test names the doc, contract or issue it traces to
  • No ad-hoc run artifacts committed
  • New files carry the SPDX license header (or are exempt in .github/.licenserc.yaml)

…e measure bound (intel#922)

first_useful_rate counted a cell whose first_useful.steps is no measure (past the 1e150 bound, NaN, inf) as a non-hit, in the rate and in its n, so steps 5 and 1e200 gave 0.5 with n 2. Every other measure leaves such a value out as absent, and the compare header counted the same cell as measured.

A new helper, _rated, keeps the cells with a verdict less those whose steps is set but is no measure; a cell with steps None (never) stays a miss. useful_task_values, useful_task_counts and useful_counts all read it, so the rate, its n and the header's observed-of-measured count agree: steps 5 and 1e200 now give 1.0 with n 1, and the header shows the cell as unmeasured. The contract's "The measure bound" and the compare module docstring say so.

The old expectation of test_first_useful_rate_keeps_a_cell_with_steps_past_the_bound_as_a_non_hit (rate 0.5, n 2) and the rate and count lines of test_a_stored_non_finite_or_huge_number_is_no_measure (rate 0.0, measured 1) are reversed because intel#922 asks for it.

Test-narrowed: test_first_useful_rate_keeps_a_cell_with_steps_past_the_bound_as_a_non_hit is renamed test_first_useful_rate_leaves_out_a_cell_with_steps_past_the_bound and its assertion reversed to the behaviour intel#922 asks for; no check is dropped.
Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@antonwolfy
antonwolfy requested a review from a team as a code owner November 19, 2026 18:40
@antonwolfy antonwolfy self-assigned this Nov 19, 2026
@exai-bot

exai-bot commented Nov 19, 2026 •

Copy link
Copy Markdown

✅ OpenCodeReview: Review complete: 0 finding(s) across 3 selected item(s).

CI at a682950: 25 passing, 3 skipped.

Review details
  • Commit reviewed: a682950 against merge base 5da94f7
  • Coverage: 3 files in 1 groups
  • Engine: OpenCodeReview v1.13.5-exai.4.8f73eada, us.openai.gpt-6.1-sol
  • Usage: 57k tokens (32k from cache), 8s
  • Tool calls: 8 (7 file_read, 1 code_search)
  • small change set: 3 files

@codecov-commenter

codecov-commenter commented Nov 19, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.90%. Comparing base (52160e9) to head (a682950).
⚠️ Report is 13 commits behind head on main.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #1018    +/-   ##
========================================
  Coverage   95.89%   95.90%            
========================================
  Files         448      448            
  Lines       59289    59390   +101     
  Branches    10224    10238    +14     
========================================
+ Hits        56857    56957   +100     
+ Misses       1511     1509     -2     
- Partials      921      924     +3     
Files with missing lines Coverage Δ
dokimi/dokimi/repos/compare.py 99.53% <ø> (ø)
dokimi/dokimi/repos/useful.py 98.18% <100.00%> (+0.03%) ⬆️

... and 25 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>

@vchamarthi vchamarthi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Not approved yet · reviewed 2fe7e2e

Next: @antonwolfy: settle 1 open question (below).

Blocking

  • Open question for @antonwolfy: repo report's row counts a cell whose steps is past the bound in n but not in observed: steps 5 and steps 1e200 give 1 of 2 observed with no reason on the head, while the compare header now shows that cell as unmeasured. State in the repo report paragraph of dokimi/docs/repo-evaluation-contract.md whether a past-bound cell is counted in n, or leave it out of n in useful_summary as the compare side now does.

Verified on 2fe7e2e: ✅ changed tests: 162 passed, fail on main · ✅ full suite with main merged in: 23936 passed · ✅ merges onto main · ✅ 2 broken variants of the changed code: 2 caught by the tests · 2 mutations tried · 6 edge inputs tried

12 checks behind it, each with its evidence
Area What holds How
Changed tests The 162 tests in the two changed test files pass on the head, including the new past-bound, never, at-bound and header-count cases tests on the head
Tests pin the change Seven changed tests fail on main: the past-bound rate tests for 1e200, NaN and inf, the never-beside-past-bound case, the header count, and the rewritten lone-cell test same tests on main
make ci-local make ci-local passes on the head merged with main: 23936 passed, 0 failed, no new failures full suite, main merged in
Merge The PR merges onto main with no conflict merge onto main
Rate past the bound Steps 5 and steps 1e200 give first_useful_rate [1.0] with n 1, and the header counts the cell as unmeasured ran it, edge input (numbers)
Never beside past bound Steps 5, steps 1e200 and a never cell give a rate of 0.5 with n 2: the never cell stays a miss ran it, edge input (numbers)
Steps at the bound Steps 1e150 (SCORE_BOUND) is still a hit: steps 5 and steps 1e150 give a rate of 1.0 with n 2 ran it, edge input (numbers)
Steps that are no measure NaN, inf, -inf, the float maximum, 10400 and True as steps are left out of the rate and n ran it, edge input (numbers)
No records An empty record list gives a rate of [None], a count of 0, and no header line ran it, edge input (numbers)
Steps zero and negative Steps 0 and -1 count as hits in the rate, since as_measure takes any finite number within the bound; first_useful() never stores them (enumerate(known, 1), useful.py:72) ran it, edge input (numbers)
Rate tests Removing the steps is None clause from _rated (useful.py:112) fails the changed tests broke the code, tests caught it
Header count Counting unmeasured from _measured in useful_counts (useful.py:205) fails the changed tests broke the code, tests caught it

…s is past the bound (intel#922)

Settles the review question on `repo report`: a cell whose `first_useful.steps` is past the measure bound stays in the row's total (`n`) and is not counted as observed, with no reason, so steps 5 and steps 1e200 give `1 of 2 observed`. The `repo report` paragraph of the repo evaluation contract now says so; `repo compare` leaves such a cell out of the rate, as documented beside it.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@antonwolfy

Copy link
Copy Markdown
Contributor Author

(commented) 🟡 Not approved yet · reviewed 2fe7e2e

@vchamarthi (#1018 (review)): A past-bound cell is counted in n and not as observed: repo report keeps n as every declared cell (an unobserved or timeout cell is in it too, with its reason), so steps 5 and steps 1e200 give 1 of 2 observed (ran useful_summary on those two cells: n 2, observed 1, no reasons). I did not change that count, since repo compare's rate is a share of cells with a verdict and repo report's row is a tally of all declared cells. Commit 5da94f7 states it in the repo report paragraph of dokimi/docs/repo-evaluation-contract.md (§4.1), next to the compare rule.

@antonwolfy

Copy link
Copy Markdown
Contributor Author

Ready for another look at 5da94f7; 3 checks still pending (Test Linux Python 3.14, Tests (py3.14), self / repo scan); every other check passed.

codecov has not reported on this head yet.

…or never

Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>

@vlad-perevezentsev vlad-perevezentsev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 LGTM · checked a682950 · nothing required from @antonwolfy

🔀 Merge: safe now · merges cleanly into current main, 12 commits behind, and main has not touched its files · no open PR conflicts with it

✅ make ci-local --offline: 23,914 passed · ⚠️ schema_compat fails from the base (removed v1 schemas on main), not from this PR · ✅ 7 of the changed tests fail on the base · ✅ the new steps-None test fails with the fix reverted

A broken steps is now neither a hit nor a miss in first_useful_rate, its n and the header, and the docs match.

Fixed in this branch, up to a682950:

  • A hit with steps None (untimed or no reason) counted as a miss: fc731a9 keeps such a cell as a miss only for never; a test covers both.
  • No test for a bool steps: a682950 adds True to the no-measure test.

@antonwolfy
antonwolfy merged commit b25b71c into intel:main Nov 20, 2026
28 checks passed
@antonwolfy
antonwolfy deleted the fix/useful-rate-past-bound branch November 20, 2026 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

first_useful_rate counts a cell whose steps is past the 1e150 bound as a non-hit: drop it, or count the hit?

5 participants