Skip to content

refactor: make shared helpers public and dedupe the git -z reader - #1527

Merged
napetrov merged 9 commits into
intel:mainfrom
napetrov:arch/r10-567
Dec 3, 2026
Merged

napetrov merged 9 commits into
intel:mainfrom
napetrov:arch/r10-567

Conversation

@napetrov

@napetrov napetrov commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Summary

eval/stats.py          round_p, wilson, apply_correction, describe_deltas,
                       finalize_result, paired_differences   (now public)
  used by interactions.py, binary_stats.py, model_compare.py, tests
  judge_validity.py    keeps importing _wilson (alias, removed after #1416)

report/eval_io.py      NEW: eval-file, answers and Q&A sidecar readers
  used by eval_report.py and single_condition_report.py

scripts/_git_z.py      NEW: one git_z(*args, cwd) for the -z reader
  used by check_changelog_fragment.py, check_comment_blocks.py,
         check_docs_review_triggers.py

Also: the duplicate baseline entry d3dc645dd2cc is removed (stale), and deptry's DEP001 list gains _git_z.

Evidence

  • Before: three copies of the -z reader; helpers with underscore names used across modules.
    After: one reader, public helper names, same outputs.
  • ci-local (push hook): 17 passed, 0 failed, 3 skipped.
  • ruff check ., deptry, mypy: clean.
  • The "Repeat changed tests" run hit a PytestUnraisableExceptionWarning (ScandirIterator) under --randomly-seed=19; the exact replay passed (220 passed). Treated as a flake, not a change in behaviour.

Merge Danger

Door: two-way (internal refactor, revert is a plain revert)

Blast Radius: internal helpers only; no output, CLI, or file-format change. Changelog fragment is ### Changed, labelled skip-changelog.

Reviewer note: _wilson alias in eval/stats.py must go when #1416 lands.

🤖 Generated with Claude Code

- eval/stats: round_p, wilson, apply_correction, describe_deltas,
  finalize_result and paired_differences lose their underscore; their
  users (interactions, binary_stats, model_compare, tests) follow.
  judge_validity keeps importing the old _wilson alias until intel#1416.
- report/eval_io: the eval-file, answers and Q&A sidecar readers the
  paired and one-condition reports share, moved out of eval_report.
- scripts/_git_z: one git_z(*args, cwd) for the three check scripts
  that carried identical copies; the duplicate baseline entry goes.

No output changes.

Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
@napetrov
napetrov requested a review from a team as a code owner December 2, 2026 07:15
Copilot AI balanced review requested due to automatic review settings December 2, 2026 07:15
@napetrov napetrov added the skip-changelog No user-visible change: bypasses the changelog fragment check label Dec 2, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues block the refactor that exposes shared helpers and consolidates duplicated readers.

No open issues 🎉

What changed in this PR

0 new findings; nothing to fix.

This refactor makes dokimi’s shared helpers public and consolidates duplicated readers without changing report outputs or file formats.

Changes:

  • Publish statistics helpers and update callers, retaining _wilson compatibility until #1416.
  • Extract shared report input and sidecar helpers into eval_io.py.
  • Consolidate the Git NUL-separated reader and update tests and tooling configuration.
File Description
dokimi/​tests/​test_writers_save_artifact.py Update the answer-reader patch target.
dokimi/​tests/​test_stats_float_range.py Use public paired differences.
dokimi/​tests/​test_stats_exact.py Use public correction and rounding helpers.
dokimi/​tests/​test_stats_correction.py Update correction helper calls.
dokimi/​tests/​test_single_condition_arms_report.py Import the shared answers-path helper.
dokimi/​tests/​test_sign_flip_float_range.py Use public delta descriptions.
dokimi/​tests/​test_report_writers_surrogate.py Update the sidecar-writer patch target.
dokimi/​tests/​test_holm_floor_family.py Use public statistics helpers.
dokimi/​tests/​test_docs_review_triggers.py Enable sibling helper imports.
dokimi/​tests/​test_check_comment_blocks.py Enable sibling helper imports.
dokimi/​tests/​test_check_changelog_fragment.py Enable sibling helper imports.
dokimi/​tests/​test_binary_stats.py Update a helper name in a docstring.
dokimi/​scripts/​duplicates_baseline.json Remove the obsolete reader duplication entry.
dokimi/​scripts/​check_docs_review_triggers.py Use the shared Git reader.
dokimi/​scripts/​check_comment_blocks.py Use the shared Git reader.
dokimi/​scripts/​check_changelog_fragment.py Use the shared Git reader.
dokimi/​scripts/​_git_z.py Add the common NUL-separated Git reader.
dokimi/​pyproject.toml Exempt the sibling import from dependency checks.
dokimi/​dokimi/​subjects/​evidence.py Update a helper reference in a comment.
dokimi/​dokimi/​report/​single_condition_report.py Consume shared report I/O helpers.
dokimi/​dokimi/​report/​model_compare.py Use public correction and finalization helpers.
dokimi/​dokimi/​report/​eval_report.py Delegate shared I/O to eval_io.
dokimi/​dokimi/​report/​eval_io.py House shared report readers and sidecar writing.
dokimi/​dokimi/​eval/​stats.py Publish six helpers and retain _wilson compatibility.
dokimi/​dokimi/​eval/​sign_flip.py Update a helper reference in a docstring.
dokimi/​dokimi/​eval/​interactions.py Use public statistics helpers.
dokimi/​dokimi/​eval/​binary_stats.py Use public rounding and Wilson helpers.
dokimi/​changelog.d/​20261201_120000_napetrov_arch-r10-567.md Document the internal refactor.

Review effort: Balanced

@exai-bot

exai-bot commented Dec 2, 2026 •

Copy link
Copy Markdown

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

CI at 3d60d2d: 29 passing, 5 skipped.

Test notes (2)
  • dokimi/dokimi/eval/stats.py:334: With (None, None) if adj is None else (round_p(adj), adj < ALPHA) changed to (None, None) if adj is None else (round_p(adj), adj <= ALPHA), the tests still pass: dokimi/tests/test_binary_stats.py, dokimi/tests/test_check_changelog_fragment.py, dokimi/tests/test_check_comment_blocks.py, dokimi/tests/test_docs_review_triggers.py, dokimi/tests/test_holm_floor_family.py, dokimi/tests/test_report_writers_surrogate.py, dokimi/tests/test_stats.py. A value exactly at the boundary gives the same result either way here, so no test says which one is meant.
  • dokimi/dokimi/eval/interactions.py:139: With return describe_deltas(deltas, confidence=confidence, seed=seed, magnitudes=magnitudes)["delta_mean"] changed to return None, the tests still pass: dokimi/tests/test_binary_stats.py, dokimi/tests/test_check_changelog_fragment.py, dokimi/tests/test_check_comment_blocks.py, dokimi/tests/test_docs_review_triggers.py, dokimi/tests/test_holm_floor_family.py, dokimi/tests/test_report_writers_surrogate.py. If this condition matters, a test should pin it.
Review details
  • Commit reviewed: 3d60d2d against merge base ed7a4e2
  • Coverage: 28 files in 4 groups
  • Engine: OpenCodeReview v1.13.5-exai.4.8f73eada, us.openai.gpt-6.1-sol
  • Usage: 334k tokens (166k from cache), 36s
  • Tool calls: 37 (22 file_read, 4 code_search, 3 file_read_diff, 3 local_check_results, 2 ci_log_search, 2 ci_status, 1 file_find)
  • Binary statistics and sign-flip evaluation: 4 files
  • Statistical corrections, interactions, and evidence handling: 7 files
  • Report I/O refactoring and writer coverage: 9 files
  • Repository checks and shared Git parsing: 8 files

@codecov-commenter

codecov-commenter commented Dec 2, 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.47%. Comparing base (ed7a4e2) to head (3d60d2d).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1527      +/-   ##
==========================================
- Coverage   96.50%   96.47%   -0.03%     
==========================================
  Files         534      535       +1     
  Lines       71550    71556       +6     
  Branches    12362    12362              
==========================================
- Hits        69046    69037       -9     
- Misses       1530     1538       +8     
- Partials      974      981       +7     
Files with missing lines Coverage Δ
dokimi/dokimi/eval/binary_stats.py 100.00% <100.00%> (ø)
dokimi/dokimi/eval/interactions.py 98.55% <100.00%> (ø)
dokimi/dokimi/eval/sign_flip.py 98.97% <ø> (ø)
dokimi/dokimi/eval/stats.py 97.90% <100.00%> (+<0.01%) ⬆️
dokimi/dokimi/report/eval_io.py 100.00% <100.00%> (ø)
dokimi/dokimi/report/eval_report.py 95.34% <100.00%> (-0.66%) ⬇️
dokimi/dokimi/report/model_compare.py 96.43% <100.00%> (ø)
dokimi/dokimi/report/single_condition_report.py 98.88% <100.00%> (+0.01%) ⬆️
dokimi/dokimi/subjects/evidence.py 100.00% <ø> (ø)

... and 6 files with indirect coverage changes

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

@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Mutation of changed lines

⚠️ Tests miss 12 of 67 small breaks of the lines this PR changes, and the check was not complete

At 3d60d2d: 55 caught · 12 missed

Each row is a small deliberate break (a mutant) of a line this PR changes that every test reaching that line still passes. Add a test that fails on it or, if it cannot change behaviour, put # mutation-ok[<operator>]: <reason> at the end of the line or alone on the line above.

Where Operator Change no test notices Tests reaching the line
dokimi/dokimi/report/eval_io.py:52 delete-statement continue → pass 1
dokimi/dokimi/report/eval_io.py:66 drop-clause not isinstance(data, dict) or not isinstance(data.get("evaluations"), list) → (not isinstance(data, dict)) 45
dokimi/dokimi/report/eval_io.py:75 drop-clause e.question_text or (raw if isinstance(raw, str) else None) → (e.question_text) 42
dokimi/dokimi/report/single_condition_report.py:71 delete-statement groups[difficulty(q, "unknown")].append(q) → pass 16
dokimi/dokimi/report/eval_io.py:36 take-branch data.get("answers") if isinstance(data, dict) else data → (data.get("answers")) 12
dokimi/dokimi/report/eval_io.py:66 drop-clause not isinstance(data, dict) or not isinstance(data.get("evaluations"), list) → (not isinstance(data.get("evaluations"), list)) 45
dokimi/dokimi/report/eval_io.py:84 flip-bool False → True 40
dokimi/dokimi/report/eval_io.py:92 bump-int 1 → 2 44
dokimi/dokimi/report/eval_io.py:66 swap-boolop not isinstance(data, dict) or not isinstance(data.get("evaluations"), list) → not isinstance(data, dict) and (not isinstance(data.get('evaluations'), list)) 45
dokimi/dokimi/report/eval_io.py:75 take-branch raw if isinstance(raw, str) else None → (None) 42
dokimi/dokimi/report/eval_io.py:75 take-branch raw if isinstance(raw, str) else None → (raw) 42
dokimi/dokimi/report/eval_io.py:75 negate-condition isinstance(raw, str) → not (isinstance(raw, str)) 42

Not the whole picture:

  • 1 candidate test file was not run
  • 11 changed lines were not mutated

Warning only: a missed break does not fail the job. Updated on every push; the full report is in the ci run summary.

@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)? I'll approve once that's done.

Optional, non-blocking (1)
  • dokimi/dokimi/report/eval_report.py:482: A question set where one record has "difficulty": null and another has "difficulty": "easy" stops the eval report with a TypeError in the Q&A table: the sort at this line compares None with a string (main has it too).

What I checked on b567fa3:

  • When I changed the code on purpose, the tests still passed for 3 of 12 changes, and no test pins these down yet (non-blocking): dokimi/dokimi/report/eval_io.py:21 (it returns None), dokimi/dokimi/report/eval_io.py:34 (the handled error is raised again) and dokimi/dokimi/report/eval_io.py:50 (the handled error is raised again).
  • The 270 changed tests pass, and fail on main as expected.
  • The full test suite passes with main merged in (37,849 tests), apart from failures main has too.
  • It merges cleanly onto main.

Comment thread dokimi/dokimi/eval/stats.py Resolved
…EPATH

Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
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 1cbdcf3 · nothing required from @napetrov

🔀 Merge: safe now · merges cleanly into current main, 1 commit behind (no shared files) · after it, #1406 and #1523 need a rebase (report/eval_report.py, report/single_condition_report.py)

✅ make ci-local --offline: 33,319 passed · ⚠️ "Repeat changed tests": every repeat passed, then pytest's own tmp-dir cleanup raised a ResourceWarning; not from this PR · ✅ each new test fails with its fix reverted

The moves into eval_io.py and the renames in stats.py are exact; report output is unchanged.

Agreed with @vchamarthi on the untested 0.05 boundary (now pinned below); the difficulty: null sort crash is on main too, so it goes to a separate issue.

Fixed in this branch, up to 1cbdcf3:

  • The check scripts failed under PYTHONSAFEPATH=1: 74f1d83 puts their own directory on sys.path, as check_duplicates.py does; a test per script.
  • The shared-answers-path test called one function twice: 8ea9626 checks both reports use eval_io's.
  • An adjusted p of exactly 0.05 was untested: 1cbdcf3 pins it as not significant.

Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRRT_kwDOVBg7g86-f3wf: already fixed in 1cbdcf3
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
@napetrov

napetrov commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Re: review by vchamarthi

A question set where one record has "difficulty": null and another has "difficulty": "easy" stops the eval report with a TypeError
I reproduced this on main and on this branch and filed #1538. The 0.05 boundary is covered by 1cbdcf3.

Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
(cherry picked from commit e249323eb321bbc70ac425c03170071d835a143c)
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>

# Conflicts:
#	dokimi/dokimi/report/eval_report.py
#	dokimi/dokimi/report/single_condition_report.py
@napetrov
napetrov merged commit b512b7e into intel:main Dec 3, 2026
35 of 36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changelog No user-visible change: bypasses the changelog fragment check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants