Skip to content

refactor(repo): move the repo reach group out of commands/repo.py - #1024

Merged
xaleryb merged 2 commits into
intel:mainfrom
antonwolfy:fix/repo-reach-split
Nov 19, 2026
Merged

xaleryb merged 2 commits into
intel:mainfrom
antonwolfy:fix/repo-reach-split

Conversation

@antonwolfy

@antonwolfy antonwolfy commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

dokimi/dokimi/commands/repo.py is 803 lines on main, over the 800-line cap with no baseline entry, so tests/test_growth_ratchet.py::test_no_file_or_function_grew_past_its_baseline fails on every PR: dokimi/commands/repo.py: 803 lines is over the 800 cap and has no baseline entry; split the file.

This takes the issue's first option, a split: the repo reach group moves to commands/repo_reach.py, as repo_scan.py and repo_skill_reach.py were split out before it. The second option, a baseline entry from check_growth.py --update, is refused: AGENTS.md says "Split instead", and the baseline only shrinks. repo.py is now 511 lines, with room for the open PRs that grow it. No flag, exit code, message or output of repo reach changes.

Closes #1012

Changes

  • New dokimi/dokimi/commands/repo_reach.py holds the reach group unchanged: _PROBE_ONLY, _PROBE_DEFAULTS, _reach_entry, _probe_flags_given, _saved_reach_inputs, _reach_from_saved, _tree_read_exit_code, _refuse_tree_read, _refuse_receipt_over_probe, _reach_plan, cmd_repo_reach, _print_reach_output, RECEIPT_NAME, _receipt_path, _strict_resolve, _receipt_would_overwrite, _print_receipt, and the reach parser as add_reach_parser.
  • _open_tree and _load_manifest stay in repo.py, where the other commands use them. register passes them to add_reach_parser, which binds them into the handler, so repo_reach.py imports nothing from repo.py and no import cycle is added. Their calls inside the moved code take them as parameters (_reach_entry, _reach_from_saved, cmd_repo_reach, _reach_plan).
  • register keeps the other parsers where they were; the reach parser is added at the same position, so repo reach --help and the order of the subcommands are unchanged.
  • Tests that pin where reach code lives follow the move: tests/test_exit_codes_boundaries.py patches _saved_reach_inputs on dokimi.commands.repo_reach (the _load_manifest patches stay on dokimi.commands.repo, which hands it in), and tests/test_repo_budget_rules.py calls _print_receipt from repo_reach. tests/test_import_architecture.py and tests/test_input_refusal_exit_sites.py need no change: the cycle baseline is unchanged and no exit(2) site moved.
  • Docs: docs/features/discovery.md links "Reach implementation" to commands/repo_reach.py; docs/repo-evaluation-contract.md lists it in depends_on.
  • tests/test_repo_receipt.py gains a test of repo reach --from over a saved probe with a failed scenario: it prints the matrix or receipt and exits 1.
  • Changelog fragment (Changed, internal; no user-visible change).

Risk

None: the output is unchanged. repo reach keeps its flags, exit codes and messages. Anything that imported a reach helper from dokimi.commands.repo must now import it from dokimi.commands.repo_reach; nothing in the tree outside the two tests above did.

Open PRs on repo.py: #956 and #958 change other functions (validate, scan, inspect, budget) and apply as they are. #958 adds cli_flags.add(...) calls to repo.py, and this PR drops repo.py's cli_flags import because nothing left there uses it; whichever of the two merges second restores the import in repo.py (ruff F401 or a NameError shows it at once).

Testing

On a Linux review host, at 11069ed5 (on main 264cbde):

  • make ci-local: 36 passed, 0 failed, 14 skipped. Skipped: the matrix legs on other Pythons, fuzz, conda-forge, semgrep, deploy and report jobs. The Run tests step: 23959 passed, 19 skipped.
  • tests/test_growth_ratchet.py fails on main (1 failed, 44 passed, 1 skipped: dokimi/commands/repo.py: 803 lines is over the 800 cap) and passes here.
  • Mutant: _tree_read_exit_code in repo_reach.py made to return 2 always; tests/test_exit_codes_boundaries.py fails (3 failed, 77 passed): test_repo_reach_from_saved_git_read_that_fails_keeps_exit_1, test_repo_reach_plan_scenario_read_that_fails_in_git_keeps_exit_1 and test_repo_manifest_read_that_fails_in_git_keeps_exit_1[reach].
  • New test tests/test_repo_receipt.py::test_from_a_saved_probe_with_a_failed_scenario_exits_1_after_printing (matrix and receipt) covers the exit 1 of repo reach --from over a saved probe with a failed scenario (repo_reach.py lines 96-97, named by codecov). Mutant: the any(s["error"] ...) condition replaced by False; both cases fail (2 failed).
  • Not run: the other Python versions, and the gitleaks scan.

Open questions

None.

Revert

A plain revert restores the reach code to commands/repo.py and the failing growth test. Nothing is stored.

Checklist

  • Tests added/updated and pytest passes
  • ruff, mypy, and schema checks pass
  • Docs updated (or N/A) — see the docs-drift checklist in CONTRIBUTING.md
  • Self-reviewed per "Before opening a PR" in AGENTS.md
  • Each new raise/exit and test names the doc, contract or issue it traces to (none added)
  • No ad-hoc run artifacts committed
  • New files carry the SPDX license header (or are exempt in .github/.licenserc.yaml)

…tel#1012)

commands/repo.py was 803 lines, over the 800-line cap with no baseline entry, so tests/test_growth_ratchet.py failed on main. The reach group (probe defaults, the --from path, the receipt helpers, cmd_repo_reach and the reach parser) now lives in commands/repo_reach.py and repo.py is about 510 lines.

repo_reach.py imports nothing from repo.py: register passes repo's _open_tree and _load_manifest to add_reach_parser, which binds them into the handler, so no import cycle is added. Flags, exit codes, messages and output are unchanged. The tests and docs that named the old location follow the move.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@antonwolfy
antonwolfy requested a review from a team as a code owner November 19, 2026 19:10
@antonwolfy antonwolfy self-assigned this Nov 19, 2026
@exai-bot

exai-bot commented Nov 19, 2026 •

Copy link
Copy Markdown

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

CI at 11069ed: 22 passing, 2 skipped.

Review details
  • Commit reviewed: 11069ed against merge base 264cbde
  • Coverage: 8 files in 1 groups
  • Engine: OpenCodeReview v1.13.5-exai.4.8f73eada, us.openai.gpt-6.1-sol
  • Usage: 127k tokens (60k from cache), 35s
  • Tool calls: 11 (6 file_read, 3 code_search, 1 ci_status, 1 local_check_results)
  • Repo reach command extraction, documentation, and regression tests: 8 files

@codecov-commenter

codecov-commenter commented Nov 19, 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 95.89%. Comparing base (264cbde) to head (11069ed).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1024   +/-   ##
=======================================
  Coverage   95.89%   95.89%           
=======================================
  Files         447      448    +1     
  Lines       59275    59289   +14     
  Branches    10224    10224           
=======================================
+ Hits        56841    56857   +16     
+ Misses       1512     1511    -1     
+ Partials      922      921    -1     
Files with missing lines Coverage Δ
dokimi/dokimi/commands/repo.py 99.03% <100.00%> (+0.04%) ⬆️
dokimi/dokimi/commands/repo_reach.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

… failed scenario

Settles the codecov concern on repo_reach.py lines 96-97: a saved reach.json with a scenario error prints its matrix or receipt and exits 1, in both formats.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@antonwolfy

Copy link
Copy Markdown
Contributor Author

Review points answered at 11069ed; 1 checks still pending (Tests (py3.14)); every other check passed.

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

Checked at 11069ed, CI green:

  • commands/repo.py drops from 803 to 511 lines, so test_growth_ratchet passes again on main.
  • The split is a move: 240 lines are verbatim. The rest passes _open_tree and _load_manifest into repo_reach.py instead of importing them, and the parser binds them when it is built, so the tests that monkeypatch repo._load_manifest before calling the CLI still reach the patched function.
  • Open PRs that touch repo.py (#956, #958, #898) do not touch the reach block, and none gets a new conflict from this merge.

@xaleryb
xaleryb merged commit 52160e9 into intel:main Nov 19, 2026
40 of 42 checks passed
@antonwolfy
antonwolfy deleted the fix/repo-reach-split branch November 19, 2026 20:48
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.

dokimi/commands/repo.py is 803 lines on main: tests/test_growth_ratchet.py fails

4 participants