Skip to content

refactor(report): render the arms report one section helper per block - #1568

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

napetrov merged 8 commits into
intel:mainfrom
napetrov:arch/r12-3

Conversation

@napetrov

@napetrov napetrov commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

refactor(report): render the arms report one section helper per block

Problem

render_arms_report (dokimi/report/arms_report.py) was one 147-line function
(cyclomatic complexity 32) that wrote the header, summary, cost, agentic,
skill-selection and per-question blocks in one body. Hard to read and hard to
change one block without touching the others.

Change

  • One helper per block: _section_header, _section_summary, _section_cost,
    _section_agentic, _section_selection, _section_per_question.
  • render_arms_report joins them in the same order.
  • The agentic fallback that rebuilds per-arm stats from the answers moves into
    _agentic_from_answers. It still runs only when agentic_usage_summary is
    empty, so an older artifact renders as before.
  • Changelog fragment added for the pre-push hook; the PR also carries the
    skip-changelog label because no output changes.

Evidence

  • Differential probe (outside the repo, in the review scratch dir): 55,000
    seeded artifacts, half with malformed top-level fields. Old and new output,
    exception type and message, and the input dict after the call are compared.
    0 mismatches; every executable line of the new body ran.
  • pytest on the arms, ask, report, skill-selection and records tests: 380 passed.
  • ruff check and mypy clean on the module.

Merge danger

🤖 Generated with Claude Code

render_arms_report was one 147-line body (cyclomatic 32) for the header,
summary, cost, agentic, skill-selection and per-question blocks. Each block
is now a _section_<name> helper and render_arms_report joins them in the
same order. The agentic fallback that rebuilds stats from answers moves to
_agentic_from_answers and runs only when agentic_usage_summary is empty, as
before.

The Markdown is unchanged: a differential probe over 55,000 seeded artifacts
(including malformed top-level fields) matches the previous output, the
exception type and message, and the input dict after the call.

Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
render_arms_report has no branches after the section split, so the
growth ratchet reports its baseline entry as back under the cap and
tests/test_growth_ratchet fails on the PR. check_growth.py --update
removes the entry; it is the only line that changes.

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

There are no active review issues for the arms-report section-helper refactor.

No open issues 🎉

What changed in this PR

0 new findings; nothing to fix.

Refactors arms-report rendering into section helpers while preserving the public signature, section order, and Markdown output.

Changes:

  • Extracts six section helpers and the older-artifact agentic fallback.
  • Removes the renderer’s complexity-baseline entry.
  • Adds a changelog fragment documenting the internal refactor.
File Description
dokimi/​scripts/​growth_baseline.json Removes the renderer’s complexity exception.
dokimi/​dokimi/​report/​arms_report.py Splits rendering into focused section helpers.
dokimi/​changelog.d/​20261202_130000_arms-report-sections.md Documents the refactor and unchanged output.

Review effort: Balanced

@exai-bot

exai-bot commented Dec 3, 2026 •

Copy link
Copy Markdown

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

CI at `02c900c`: 2 cancelled, 19 passing, 4 skipped

CI is incomplete: two checks were cancelled, while the other 23 passed or were skipped. The diff and current renderer were inspected, and local lint and type checks passed; however, the available CI logs do not explain either cancellation, so no change-caused failure or exact fix can be established.

Check Status Assessment
Test Linux Python 3.14 cancelled at step Install the package and run ci/test.py Cause unclear. The job was cancelled during 'Install the package and run ci/test.py'. No cancellation reason or diagnostic log lines are available, so the evidence does not establish whether this change caused it.
Test Linux Wheels Python 3.14 cancelled at step Install the wheel and run ci/test.py Cause unclear. The job was cancelled during 'Install the wheel and run ci/test.py'. No cancellation reason or diagnostic log lines are available, so the evidence does not establish whether this change caused it.
Test notes (2)
  • dokimi/dokimi/report/arms_report.py:222: With if cost is not None and known is not None and n is not None and known < n: changed to if cost is not None and known is not None and n is not None and known <= n:, the tests still pass: dokimi/tests/test_arms_report.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/arms_report.py:250: With "tool_use_rate": sum(1 for c in s["calls"] if c > 0) / n, changed to "tool_use_rate": sum(1 for c in s["calls"] if c >= 0) / n,, the tests still pass: dokimi/tests/test_arms_report.py. A value exactly at the boundary gives the same result either way here, so no test says which one is meant.
Review details
  • Commit reviewed: 02c900c against merge base 0db63b5
  • Coverage: 3 files in 3 groups
  • Engine: OpenCodeReview v1.13.5-exai.4.8f73eada, us.openai.gpt-6.1-sol
  • Usage: 133k tokens (57k from cache), 20s
  • Tool calls: 21 (8 ci_log_search, 7 file_read, 3 file_read_diff, 2 ci_status, 1 local_check_results)
  • dokimi/changelog.d/20261202_130000_arms-report-sections.md: 1 file
  • dokimi/dokimi/report/arms_report.py: 1 file
  • dokimi/scripts/growth_baseline.json: 1 file

@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Mutation of changed lines

⚠️ Tests miss 11 of 80 small breaks of the lines this PR changes, and not every break was tried

At 02c900c: 69 caught · 11 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/arms_report.py:180 drop-element ["_No evaluations available (answers were not judged)._", ""] → [""] 18
dokimi/dokimi/report/arms_report.py:222 drop-clause cost is not None and known is not None and n is not None and known < n → (cost is not None and known is not None and (known < n)) 8
dokimi/dokimi/report/arms_report.py:228 bump-int 0 → 1 8
dokimi/dokimi/report/arms_report.py:270 bump-int 0 → 1 6
dokimi/dokimi/report/arms_report.py:271 bump-int 0 → 1 6
dokimi/dokimi/report/arms_report.py:272 bump-int 0 → 1 6
dokimi/dokimi/report/arms_report.py:308 bump-int 0 → 1 4
dokimi/dokimi/report/arms_report.py:309 bump-int 0 → 1 4
dokimi/dokimi/report/arms_report.py:180 drop-element ["_No evaluations available (answers were not judged)._", ""] → ["_No evaluations available (answers were not judged)._"] 18
dokimi/dokimi/report/arms_report.py:242 bump-int 0 → 1 2
dokimi/dokimi/report/arms_report.py:246 drop-clause len(s["calls"]) or 1 → (len(s["calls"])) 2

Not checked:

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

@codecov-commenter

codecov-commenter commented Dec 3, 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.52%. Comparing base (49981f9) to head (02c900c).
⚠️ Report is 1 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    #1568      +/-   ##
==========================================
- Coverage   96.53%   96.52%   -0.02%     
==========================================
  Files         550      550              
  Lines       73183    73188       +5     
  Branches    12623    12622       -1     
==========================================
- Hits        70645    70642       -3     
- Misses       1553     1557       +4     
- Partials      985      989       +4     
Files with missing lines Coverage Δ
dokimi/dokimi/report/arms_report.py 100.00% <100.00%> (ø)

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

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

🔀 Merge: safe now · merges cleanly into current main, 5 commits behind; the arms report and growth ratchet tests pass on the merge · after it, #1573 needs a rebase (report/arms_report.py, growth_baseline.json), and #1525 and #1558 need one for growth_baseline.json

✅ make ci-local --offline: 34,218 passed, 1 failed (test_cli_fault_contract[eval score ragas], ⚠️ fails on the base too, from the local env) · ✅ the same Markdown as at 26cb154 for 10 artifacts (full fixture, each section removed in turn, empty agentic summary, {})

The split keeps the section order, the old-artifact agentic fallback and the output byte for byte.

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

# Conflicts:
#	dokimi/scripts/growth_baseline.json
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>

# Conflicts:
#	dokimi/dokimi/report/arms_report.py
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>

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

The refactor itself holds up, but the merge waits on one red GitHub check. CodeQL (python) fails at this head and passes on main. I could not reproduce it on this Python: it needs CodeQL's own tooling, and the log quoted in the PR says it failed while extracting the downloaded CLI bundle, before any analysis. The PR changes no workflow. A re-run should settle it.

What I ran, on a Linux review host at 0a14d28:

  • make ci-local: 37 passed, 1 failed, 16 skipped. 34,907 tests passed, 1 failed.
  • The one failure is test_no_file_or_function_grew_past_its_baseline: dokimi/repos/manifest.py (807 lines) and dokimi/repos/workspace.py (803 lines) are over the 800 cap. This PR touches neither file, and its only baseline edit removes the render_arms_report complexity entry. The failure is not the PR's.
  • Read the diff of arms_report.py against the base, block by block.

Checked, no issues

  • Order and fallback: render_arms_report joins header, summary, cost, agentic, selection and per-question in the old order. _agentic_from_answers runs only when agentic_usage_summary is falsy, as before, and it still reads answers after the cost block, so the order of any raised error is unchanged.
  • Baseline entry: removing render_arms_report from growth_baseline.json is right; its complexity is now 1.
  • Changelog and DCO: the fragment is present and skip-changelog is set. Both non-merge commits carry Signed-off-by.

@napetrov

napetrov commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

Re: review by antonwolfy

A re-run should settle it.
CodeQL passed on attempt 2. #1603 fixes the growth failure on main.

Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
@napetrov
napetrov merged commit f4509fb into intel:main Dec 4, 2026
30 of 33 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