Skip to content

fix(runner): an integer past the float range is unscored, not a crash - #1191

Merged
napetrov merged 13 commits into
intel:mainfrom
napetrov:arch/r6-1
Nov 26, 2026
Merged

napetrov merged 13 commits into
intel:mainfrom
napetrov:arch/r6-1

Conversation

@napetrov

@napetrov napetrov commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

summarize_task_results / tasks cell state
  reward = as_float(row["reward"])     # was _num -> float(int): OverflowError for 10**400
  None -> unscored

Three private _num copies (runner, evidence_check, commands/tasks) are replaced by the shared dokimi.measure.as_float, which the gate, report and manifest already use. commands/tasks.py stops importing a private name from runner.

Evidence

  • Before: summarize_task_results([{..., "reward": 10**400}]) raises OverflowError: int too large to convert to float (new tests test_summarize_task_results_counts_a_reward_beyond_the_float_range_as_unscored, test_tasks_completion_counts_a_reward_beyond_the_float_range_as_unscored fail: 2 failed).
    After: both pass; the row counts as unscored (1 unscored, exit 1); avg_reward excludes it.
  • Relevant subset (task harnesses, tasks command, evidence protocol and subjects, import architecture, overflow tests): 284 passed.
  • Review: fresh-context self-review, 2 passes (passes: 2), no confirmed blocking; see the change log in the description above.

Merge Danger

Door: two-way. Internal helper swap; no persisted format, CLI flag or public name changes.

Behaviour change: a task row whose reward is an integer beyond the float range is now unscored instead of crashing. evidence_check now gets a float instead of an int for small integer inputs; its verdict logic only compares them, so outputs are unchanged (probed on both trees).

Blast radius: small. Only task-run summaries and the tasks completion check touch the path.

Not in scope, follow-ups: dokimi/records.py _number is a near-copy of as_float with different int handling; eval/panel.py:332 has the same float(int) shape.

Fixes #1231

🤖 Generated with Claude Code

`_num` in harnesses/runner.py converted with float(), which raises
OverflowError for an integer such as 10**400. A reward that large aborted
summarize_task_results and the tasks cell state. Three copies of `_num`
existed; evidence_check's already refused it, but only by accident of
its try/except.

The three call sites now use dokimi.measure.as_float, the shared test
that the gate, report and manifest already use. It refuses bools, nan,
inf and an integer past the float range. commands/tasks.py no longer
imports a private name from runner.

Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
@napetrov
napetrov requested a review from a team as a code owner November 25, 2026 07:20
@exai-bot

exai-bot commented Nov 25, 2026 •

Copy link
Copy Markdown

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

CI at 6e59c29: 21 passing, 4 skipped.

Review limit reached. This PR has had 6 reviews, so it will only be reviewed again when you ask.
To ask: re-request review from exai-bot in the Reviewers list.

Review details
  • Commit reviewed: 6e59c29 against merge base 6d53955
  • Coverage: 6 files in 1 groups
  • Engine: OpenCodeReview v1.13.5-exai.4.8f73eada, us.openai.gpt-6.1-sol
  • Usage: 134k tokens (80k from cache), 28s
  • Tool calls: 10 (7 file_read, 2 code_search, 1 local_check_results)
  • Finite-number overflow handling for task rewards and reporting: 6 files

@codecov-commenter

codecov-commenter commented Nov 25, 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 96.13%. Comparing base (6d53955) to head (6e59c29).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1191      +/-   ##
==========================================
- Coverage   96.14%   96.13%   -0.01%     
==========================================
  Files         498      498              
  Lines       65888    65884       -4     
  Branches    11441    11441              
==========================================
- Hits        63349    63340       -9     
- Misses       1570     1572       +2     
- Partials      969      972       +3     
Files with missing lines Coverage Δ
dokimi/dokimi/commands/tasks.py 96.83% <100.00%> (+0.01%) ⬆️
dokimi/dokimi/harnesses/runner.py 99.20% <100.00%> (+<0.01%) ⬆️
dokimi/dokimi/report/task_runs_report.py 93.50% <100.00%> (ø)
dokimi/dokimi/subjects/evidence_check.py 94.05% <100.00%> (+0.82%) ⬆️

... and 4 files with indirect coverage changes

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

…k report

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

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 7243901 · nothing required from @napetrov

🔀 Merge: safe now · merges cleanly into current main, 3 commits behind, its tests pass on the merge · after it, #1190 needs a rebase (harnesses/runner.py)

✅ make ci-local --offline: 28,257 passed · ✅ the new tests fail on the base and with the fixes below reverted · ✅ a row with 10**400 in every numeric field goes through summary, report and completion check: shown as unscored, exit 1

dokimi tasks now counts a reward past the float range as unscored instead of crashing.

Fixed in this branch, up to 7243901:

  • The task report still crashed on such a reward: bf2d544 renders it as null, with a test.
  • elapsed_sec, operation_count and n_skill_invocations still crashed the summary: d71d7bf reads them without float(), with a test per field.

@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.

@napetrov, could you fix the small thing I've marked fix before merge (in the line comments) and answer my question below? I'll approve once that's done.
I'll approve once that's done.

My question before I approve:

  • A reward of nan or inf now shows as null in the per-repeat table of the task report, where main showed nan or inf, and a true reward shows as null where main showed 1. Say the report change in the changelog fragment, or keep showing nan and inf in the report.
Optional, for later (2)
  • dokimi/dokimi/harnesses/runner.py:162: Two rewards of 1e308 make avg_reward inf, where the mean is 1e308: reward_sum overflows before it is divided by reward_n (main has it too).
  • dokimi/dokimi/harnesses/runner.py:164: An elapsed_sec of "12.5" now adds 0 seconds, where main adds 12.5.

What I checked on 7243901: the 19 changed tests pass, and fail on main as expected; the full test suite passes with main merged in (28,818 tests), apart from failures main has too; it merges cleanly onto main; when I broke the changed code on purpose, the tests caught all 3 breakages.

Comment thread dokimi/dokimi/harnesses/runner.py Resolved
A row with n_skill_invocations: 0 was not pinned by the overflow tests:
changing >= 0 to > 0 in _count kept them green. Add a test asserting
skill_invocation_n == 1 for such a row. Also type the overflow test
rows and the as_float result so the type check passes.

Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
@vchamarthi

Copy link
Copy Markdown
Contributor

This is ready for another look: I've pushed 1 commit on arch/r6-1 (7243901..1cf24a7). Nothing is needed from napetrov.

Changes:

  • Added a test that a row with n_skill_invocations: 0 gives skill_invocation_n == 1. Typed two existing test spots so the type check passes.

Threads and comments:

  • I answered each one in its thread: 1 fixed.

What I checked on the new commit: the 1 test of the fix pass; the full test suite passes with main merged in (28,863 tests), apart from 1 failure main has too.

What each test shows
  • zero skill invocation count is a reported row: passes.

Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRR_kwDOVBg7g88AAAABaVwHQA.a
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
@napetrov

Copy link
Copy Markdown
Contributor Author

Re: review by vchamarthi

A reward of nan or inf now shows as null in the per-repeat table
137255b documents that display, including booleans. The finite-reward mean overflow reproduces on main and is tracked in #1231. The task-run schema requires an elapsed_sec number, so valid durations still sum as before.

@napetrov

Copy link
Copy Markdown
Contributor Author

Re: comment by vchamarthi

Added a test that a row with n_skill_invocations: 0 gives skill_invocation_n == 1.
Confirmed the test is on 1cf24a7d. The review reply above covers the remaining report and numeric cases.

@napetrov

Copy link
Copy Markdown
Contributor Author

The changelog now calls out how the report renders non-finite and boolean rewards. The zero-invocation regression is in @vchamarthi’s 1cf24a7d.

@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.

@napetrov, could you fix the 2 earlier problems I raised, which still happen and fix the small thing I've marked fix before merge (in the line comments)? Then push and I'll take another look.

  1. The earlier problem still happens: two rows with reward 1e308 now give avg_reward inf, where the mean is 1e308.
  2. The earlier problem still happens: elapsed_sec "12.5" now gives 0.0, where main gives 12.5.

What I checked on 137255b: the 20 changed tests pass, and fail on main as expected; the full test suite passes with main merged in (29,335 tests), apart from failures main has too; it merges cleanly onto main; when I broke the changed code on purpose, the tests caught all 3 breakages.

Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRR_kwDOVBg7g88AAAABaZa9LA.a
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRR_kwDOVBg7g88AAAABaZa9LA.b
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRRT_kwDOVBg7g868Jzeu
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
@napetrov

Copy link
Copy Markdown
Contributor Author

Re: review by vchamarthi

Two 1e308 rewards give inf, and elapsed_sec "12.5" gives 0.0.
f4e166c keeps means finite. 96c9cec reads durations like "12.5".

Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
@napetrov
napetrov merged commit f8b5e1d into intel:main Nov 26, 2026
25 checks passed
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.

Prevent overflow in task summary average reward

5 participants