Skip to content

refactor(utils): split dokimi/utils.py into frontmatter, files, digest, model_names - #1190

Open
napetrov wants to merge 5 commits into
intel:mainfrom
napetrov:arch/c14
Open

napetrov wants to merge 5 commits into
intel:mainfrom
napetrov:arch/c14

Conversation

@napetrov

@napetrov napetrov commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Splits the 800-line dokimi/utils.py by concern. Pure move, no logic edits.

New module Holds
dokimi.frontmatter frontmatter parsing (parse_frontmatter, parse_frontmatter_strict, describe_yaml_error)
dokimi.files InputError, read_json_input, refuse_device, symlink-loop and rmtree-retry helpers
dokimi.digest text, file and git-aware tree digests (tree_digest, GitTree, key_bytes, ...)
dokimi.model_names model identity, same-model checks, judge-independence warnings
dokimi.records gains question_id

dokimi.utils keeps compatibility imports for the moved names. Importers in the package, scripts, fuzz targets and tests point at the new homes. The changelog lists the new import locations.

Evidence

  • Each moved definition compared with HEAD~1: 45/45 verbatim.
  • ruff check clean; check_growth.py passes (pipeline.py stays at 800 lines).
  • tests/test_import_architecture.py 54 passed; full pytest 28290 passed, one monkeypatch target fixed in this PR.
  • Self-review (local mode, 3 passes): fixed stale doc and comment references and the fuzz path filter; no blocking findings left.

Merge danger

  • The compatibility module keeps external and in-flight imports working. Architecture tests require new package code to import from the defining modules.
  • .github/workflows/fuzz.yml paths now list files.py, records.py, digest.py, model_names.py, so changes to them start the fuzz job as utils.py changes did.
  • Pre-existing gap, not fixed here: yaml_unique.py (imported by frontmatter.py) is not in the fuzz path filter.

🤖 Generated with Claude Code

@napetrov
napetrov requested a review from a team as a code owner November 25, 2026 07:07
@exai-bot

exai-bot commented Nov 25, 2026 •

Copy link
Copy Markdown

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

CI at bee1212: 27 passing, 4 skipped.

Test notes (2)
  • dokimi/dokimi/digest.py:244: With if rel is None or (batch and size + len(os.fsencode(rel)) + 1 > _ARG_BUDGET): changed to if rel is None or (batch and size + len(os.fsencode(rel)) + 1 >= _ARG_BUDGET):, the tests still pass: dokimi/tests/test_687_low.py, dokimi/tests/test_agent_profiles.py, dokimi/tests/test_arm_runner.py, dokimi/tests/test_arm_runner_incremental.py, dokimi/tests/test_artifacts.py, dokimi/tests/test_atoms_partial_status.py. A value exactly at the boundary gives the same result either way here, so no test says which one is meant.
  • dokimi/dokimi/model_names.py:63: With while len(parts) > 1 and parts[0] in _ROUTES: changed to while len(parts) >= 1 and parts[0] in _ROUTES:, the tests still pass: dokimi/tests/test_687_low.py, dokimi/tests/test_agent_profiles.py, dokimi/tests/test_arm_runner.py, dokimi/tests/test_arm_runner_incremental.py, dokimi/tests/test_artifacts.py, dokimi/tests/test_atoms_partial_status.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: bee1212 against merge base 2568a42
  • Coverage: 264 files in 55 groups
  • Engine: OpenCodeReview v1.13.5-exai.4.8f73eada, us.openai.gpt-6.1-sol
  • Usage: 3.97M tokens (2.42M from cache), 7m55s
  • Tool calls: 360 (298 file_read, 47 code_search, 10 file_read_diff, 5 local_check_results)
  • Architecture and utility-module extraction: 4 files
  • Fuzz workflow and targets: 3 files
  • Digest generation and cache keys: 5 files
  • File utilities and cache-directory validation: 9 files
  • Frontmatter, skill loading, and coverage: 9 files
  • Agent profiles and synchronization: 5 files
  • Artifacts, records, and run envelopes: 6 files
  • CLI output and input refusal handling: 7 files
  • Answer formats and answer generation: 3 files
  • Arm execution and treatment integration: 10 files
  • Baselines and regression checks: 4 files
  • Benchmark execution: 3 files
  • Catalog listing and serialization: 6 files
  • Catalog scanning and scan gates: 3 files
  • Catalog evaluation and trigger probing: 3 files
  • Catalog novelty integration: 2 files
  • Catalog provenance and upstream findings: 5 files
  • External listing and online validation: 6 files
  • Trigger-set readers: 2 files
  • Context, memory, and session tracing: 8 files
  • Dashboards and reports: 3 files
  • Dataset ingestion and inputs: 4 files
  • Evaluation execution and coverage: 7 files
  • Exploration tracking: 2 files
  • Headroom analysis: 2 files
  • Judge configuration and reliability: 8 files
  • Leak detection and red teaming: 3 files
  • Novelty commands and artifacts: 8 files
  • Novelty atoms, labels, and verdicts: 9 files
  • Novelty client, costs, and budget limits: 6 files
  • Novelty grounding and symbols: 4 files
  • Novelty retesting: 3 files
  • Novelty routing and gap analysis: 10 files
  • Novelty input views and routing comparison: 3 files
  • Novelty measurement and judging: 10 files
  • Novelty sweeps and settings parity: 3 files
  • Opportunity analysis: 3 files
  • Orchestration pipeline: 2 files
  • Question generation and normalization: 7 files
  • Repository commands and execution: 5 files
  • Repository hit judging: 2 files
  • Repository and skill reach: 4 files
  • Repository scanning and budgets: 4 files
  • Repository security: 2 files
  • Saved-run management: 6 files
  • Subject scorecards: 4 files
  • Task generation and formats: 7 files
  • Tool selection: 2 files
  • Harness execution and network policy: 5 files
  • MCP clients and factory: 2 files
  • Model identifiers and caller identity: 7 files
  • Plugin loading: 1 file
  • Repository configuration, globs, and links: 5 files
  • Model and run comparisons: 6 files
  • Repository source handling: 2 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

❌ Patch coverage is 96.88525% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.08%. Comparing base (2568a42) to head (bee1212).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
dokimi/dokimi/digest.py 93.23% 15 Missing and 4 partials ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1190      +/-   ##
==========================================
- Coverage   96.08%   96.08%   -0.01%     
==========================================
  Files         495      499       +4     
  Lines       65330    65362      +32     
  Branches    11327    11327              
==========================================
+ Hits        62775    62802      +27     
- Misses       1580     1582       +2     
- Partials      975      978       +3     
Files with missing lines Coverage Δ
dokimi/dokimi/agent_profiles/loader.py 84.61% <100.00%> (ø)
dokimi/dokimi/artifacts.py 95.91% <100.00%> (ø)
dokimi/dokimi/cli_output.py 100.00% <100.00%> (ø)
dokimi/dokimi/commands/answer_formats.py 87.64% <100.00%> (ø)
dokimi/dokimi/commands/answers.py 96.29% <100.00%> (ø)
dokimi/dokimi/commands/arms.py 97.72% <100.00%> (+<0.01%) ⬆️
dokimi/dokimi/commands/baseline.py 95.52% <100.00%> (ø)
dokimi/dokimi/commands/baseline_regression.py 100.00% <100.00%> (ø)
dokimi/dokimi/commands/benchmark.py 92.53% <100.00%> (+0.01%) ⬆️
dokimi/dokimi/commands/cache_dir.py 100.00% <100.00%> (ø)
... and 125 more

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

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

To fix: removing dokimi.utils outright breaks open PRs that merge without a conflict (line comment); the import-style nit is optional. The branch also needs a rebase: it conflicts with current main in repos/source.py (one import line, from #1139).

✅ make ci-local --offline: 28,236 passed, mutation and changed-line coverage pass · ✅ all 45 definitions of the old utils.py are AST-identical in the new modules, one home each · ✅ no dokimi.utils left in code or docs

The split is clean and the new module names say what each one holds.

The @exai-bot test notes on model_names.py:63 and :67 are about code moved here unchanged, so they belong to a separate test change, not to this PR.

Comment thread dokimi/dokimi/orchestrator/pipeline.py Resolved
…t, model_names

Pure move, no logic edits. The 800-line utils module is split by concern:

- dokimi.frontmatter: markdown frontmatter parsing
- dokimi.files: InputError, device refusal, JSON input reads, symlink-loop
  and rmtree-retry helpers
- dokimi.digest: text, file and git-aware tree digests
- dokimi.model_names: model identity, same-model/evaluator checks and the
  judge-independence warnings
- dokimi.records: question_id moves here beside the record helpers

Importers in the package, scripts, fuzz targets and tests point at the new
homes directly. dokimi.utils has no shim: it is not public API. The layer
map in tests/test_import_architecture.py lists the new foundation modules.

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

# Conflicts:
#	dokimi/dokimi/repos/reach.py
@napetrov

Copy link
Copy Markdown
Contributor Author

Re: review by vlad-perevezentsev

The branch also needs a rebase: it conflicts with current main in repos/source.py
I merged current main and kept both the source refactor and the new module for key_bytes. The line replies link the compatibility and pipeline changes.

This branch has not been deployed

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

4 participants