Skip to content

refactor(report): split _format_markdown into section helpers - #1525

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

napetrov merged 7 commits into
intel:mainfrom
napetrov:arch/r10-4

Conversation

@napetrov

@napetrov napetrov commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Summary

ReportGenerator._format_markdown (now a join of sections)
  _md_header            title, question count, set id, trust block
  _md_overall           overall means, unpaired note, improvement counts
  _md_integrity_warning (only when the answer and judge models match)
  _md_top_scores / _md_bottom_scores
  _md_top_deltas / _md_bottom_deltas
      _delta_rows       shared row formatter
  _md_topics
  _md_sources           (only when sources_summary)
  _md_failures          (only when failure_summary)
  _md_recommendations

The method keeps its signature and the class and report/__init__.py are unchanged. Helpers are module-level and underscored, so no public name changes.

Evidence

  • Before: _format_markdown is one 228-line method; the golden tests pass on intel/main.
    After: the same golden and label tests pass unchanged (test_gate_golden, test_report_generator_labels, test_report_fmt, test_report_cli_inputs, test_record_readers, test_trust_gate: 273 passed, plus 335 in the wider report set). make ci-local --offline --jobs static,typecheck: 0 failed.
  • Differential probe, old method vs new, same arguments: 4000 randomized direct calls (every conditional branch, None and boundary values, pipes in question text) and 400 end-to-end generate_report runs. Mismatches: 0, two seeds.

Merge Danger

Door: two-way. Pure extraction, no persisted format, no CLI or API change; reverting restores the same output.

Blast Radius: the Markdown report text from ReportGenerator only (report generate, markdown output). JSON output and every other report path are not touched.

Known gap, not changed here: the integrity-warning block has no in-tree assertion; the differential probe covers it. Question text containing | still breaks table rows, as on intel/main; that is a behaviour change for a separate PR.

🤖 Generated with Claude Code

The Markdown report builder was one 228-line method. Each section now has
its own module-level _md_<section> helper, and _format_markdown joins them
in the same order. The output is byte-identical: the golden and label
tests pass unchanged, and a differential probe of the old and new method
over randomized arguments and end-to-end generate_report runs found no
difference. The top and bottom delta tables share one row formatter.

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 06:39
Copilot AI balanced review requested due to automatic review settings December 2, 2026 06:39
@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 approval of the Markdown report-generation refactor.

No open issues 🎉

What changed in this PR

0 new findings; nothing to fix.

Refactors Markdown report generation into private section helpers while preserving report text, section order, and the existing interface.

Changes:

  • Extracts section rendering from _format_markdown.
  • Shares delta-row formatting between improvement and degradation tables.
  • Adds a changelog entry documenting the behavior-preserving refactor.
File Description
dokimi/​dokimi/​report/​generator.py Extracts section helpers and shared delta-row formatting.
dokimi/​changelog.d/​20261201_160000_napetrov_r10-4-format-markdown.md Documents the internal refactor and unchanged output.

Review effort: Balanced

@exai-bot

exai-bot commented Dec 2, 2026 •

Copy link
Copy Markdown

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

CI at 581fa12: 21 passing, 4 skipped.

Test notes (2)
  • dokimi/dokimi/report/generator.py:550: With worst_clusters = [c for c in clusters if c["delta_avg"] is not None and c["delta_avg"] < -1] changed to worst_clusters = [c for c in clusters if c["delta_avg"] is not None and c["delta_avg"] <= -1], the tests still pass: dokimi/tests/test_report_generator_labels.py. A value exactly at the boundary gives the same result either way here, so no test says which one is meant.
  • dokimi/dokimi/report/generator.py:297: With if evaluator_independence_warning: changed to if not (evaluator_independence_warning):, the tests still pass: dokimi/tests/test_report_generator_labels.py. If this condition matters, a test should pin it.
Review details
  • Commit reviewed: 581fa12 against merge base 2664550
  • Coverage: 5 files in 1 groups
  • Engine: OpenCodeReview v1.13.5-exai.4.8f73eada, us.openai.gpt-6.1-sol
  • Usage: 160k tokens (96k from cache), 15s
  • Tool calls: 9 (6 file_read, 2 code_search, 1 local_check_results)
  • Markdown report formatting and related tests, baseline, and changelog: 5 files

…rkdown

The method is now 4 complexity, under its cap, so the ratchet asks for the stale entry to go (check_growth.py --update). Nothing else in the baseline moved.

Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
@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

❌ Patch coverage is 89.88764% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.46%. Comparing base (892f927) to head (581fa12).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
dokimi/dokimi/report/generator.py 89.88% 6 Missing and 3 partials ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1525   +/-   ##
=======================================
  Coverage   96.46%   96.46%           
=======================================
  Files         533      533           
  Lines       71339    71371   +32     
  Branches    12333    12327    -6     
=======================================
+ Hits        68817    68849   +32     
+ Misses       1544     1542    -2     
- Partials      978      980    +2     
Files with missing lines Coverage Δ
dokimi/dokimi/report/generator.py 95.67% <89.88%> (+0.21%) ⬆️

... and 7 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 7 of 80 small breaks of the lines this PR changes, and not every break was tried

At 581fa12: 73 caught · 7 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/generator.py:505 bump-int 1 → 2 19
dokimi/dokimi/report/generator.py:507 bump-int 0 → 1 19
dokimi/dokimi/report/generator.py:554 bump-int 5 → 6 5
dokimi/dokimi/report/generator.py:522 drop-clause x.get("delta") or 0 → (x.get("delta")) 4
dokimi/dokimi/report/generator.py:523 drop-clause e.get("diagnosis") or {} → ({}) 4
dokimi/dokimi/report/generator.py:532 drop-clause e.get('delta') or 0 → (e.get('delta')) 4
dokimi/dokimi/report/generator.py:550 drop-clause c["delta_avg"] is not None and c["delta_avg"] < -1 → (c["delta_avg"] is not None) 19

Not checked:

  • 17 more breaks of covered changed lines were over the limit and not tried
  • 119 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.

What I checked on 07a8e79: the full test suite passes with main merged in (33,449 tests), apart from failures main has too; it merges cleanly onto main.

Comment thread dokimi/dokimi/report/generator.py Resolved

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

🟡 Changes needed · reviewed 07a8e79

To fix: the @vchamarthi thread below; my line comments are small optional cleanups.

✅ make ci-local --offline: 33,315 passed, 0 failed · ✅ old vs new _format_markdown on 600 random inputs: byte-identical output · ✅ growth gate passes without the baseline entry

The split keeps the report text and the section order exactly as before, and each section is now easy to read on its own.

Agreed with @vchamarthi: the Question Set ID line needs a test for both branches (the mutation job shows the same gap).

Comment thread dokimi/dokimi/report/generator.py Resolved
@@ -0,0 +1,3 @@
### Changed

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.

Nit: This fragment describes a change with no user-visible effect, and changelog.d/README.md says such a change gets the skip-changelog label instead of a fragment.

Under ### Changed ("different behavior or defaults") the release notes will list a refactor that changes nothing for a user.

Suggestion: drop the fragment and add the skip-changelog label.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The current entry identifies this as an internal refactor and says the report output is unchanged. The repo's agent guide calls for a fragment on package edits, and the README reserves the label for maintainers.

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.

Nit: Fine with me: the entry says it is an internal refactor with unchanged output, and the label is a maintainer's call. This thread can be resolved.

Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRRT_kwDOVBg7g86-fjkT
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRRT_kwDOVBg7g86-m-iP
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Review: PRR_kwDOVBg7g88AAAABbmKSFA
Review: PRR_kwDOVBg7g88AAAABbqCz2Q
@napetrov

napetrov commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Re: review by vchamarthi

Could you fix the small thing I've marked fix before merge?
9d30097 checks both Question Set ID cases.

@napetrov

napetrov commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Re: review by vlad-perevezentsev

The Question Set ID line needs a test for both branches
9d30097 catches an inverted branch. 177098e shares the row formatters.

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)

@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 · re-checked 581fa12 · nothing required from @napetrov

🔀 Merge: safe now · merges cleanly into current main, 14 commits behind; its tests pass on the merge · after it, #1568 needs a rebase (scripts/growth_baseline.json); #1558 and #1573 are stacked on this branch

✅ make ci-local --offline: 33,894 passed · ⚠️ 3 failures that are not from this PR: two Ctrl-C timeouts under load (pass when run alone) and eval score ragas, which fails on main too · ⚠️ schema_compat flags schemas main changed later; against the PR base it is OK

The earlier points are fixed; the split report renders the same text as before.

@napetrov
napetrov merged commit 958b764 into intel:main Dec 3, 2026
25 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