Repository navigation
refactor(report): split _format_markdown into section helpers - #1525
Conversation
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>
There was a problem hiding this comment.
🟢 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
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 5 selected item(s). CI at Test notes (2)
Review details
|
…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 Report❌ Patch coverage is
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
🚀 New features to boost your workflow:
|
Mutation of changed linesAt 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
Not checked:
Warning only: a missed break does not fail the job. Updated on every push; the full report is in the ci run summary. |
vlad-perevezentsev
left a comment
There was a problem hiding this comment.
🟡 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).
| @@ -0,0 +1,3 @@ | |||
| ### Changed | |||
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
|
|
Re: review by vlad-perevezentsev
|
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
left a comment
There was a problem hiding this comment.
🟢 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 · 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.
Summary
The method keeps its signature and the class and
report/__init__.pyare unchanged. Helpers are module-level and underscored, so no public name changes.Evidence
_format_markdownis one 228-line method; the golden tests pass onintel/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.generate_reportruns. 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
ReportGeneratoronly (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 onintel/main; that is a behaviour change for a separate PR.🤖 Generated with Claude Code