Skip to content

refactor(commands): route the JSON file flags through read_json_input - #1247

Merged
napetrov merged 10 commits into
intel:mainfrom
napetrov:arch/r6-6
Nov 30, 2026
Merged

napetrov merged 10 commits into
intel:mainfrom
napetrov:arch/r6-6

Conversation

@napetrov

@napetrov napetrov commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

read_json_input(path, flag=...)          dokimi/utils.py
  arms: _refuse_external_trigger_set, _load_questions   --questions
  questions: _load_questions_json, _load_personas, topics --questions/--personas/--topics
  personas validate                                       --file
  catalog trigger-probe: _labelled_queries                --trigger-set
  report generate                                         --eval
  repo scan: baseline_from                                --baseline
  tools preference                                        --groups

Local _read_json_input and the hand-rolled wrappers are removed. Each site passes its flag, so every file error has one shape: <flag> <path>: <reason>.

Behaviour changes (Changed fragment: changelog.d/20261125_170000_napetrov_arch-r6-6.md)

  • A device or socket (/dev/zero, /dev/null) is refused with <flag> <path>: not a file before any read, on every newly routed flag, including arms run and matrix-run --questions.
  • Messages change: cannot read <path>: <reason> / <path> is not valid JSON: <reason> become <flag> <path>: <reason>; cannot load matrix run inputs: <reason> becomes --questions <path>: <reason>; Cannot read / Cannot parse (personas validate) become --file <path>: <reason>.
  • Reason is the OS error text, not [Errno 2] .... Empty path exits 2 with <flag> "": no file given.
  • Exit code: a JSON file nested past the recursion limit now exits 2 naming the file (was exit 5 with a traceback) in personas validate, report generate, trigger-probe and questions --personas/--topics.
  • questions refine is not routed in this PR.

Evidence

  • Tests pinning the new text: test_report_cli_inputs.py, test_personas_approve.py, test_cli_refusal_parity.py, test_arms_output_errors.py.
  • tests/test_input_devices.py: device refusal per flag (7 argv/flag pairs), arms loader refusal, deep nesting exits 2 with no Traceback.
  • On the current main base, 166 focused CLI and import-architecture tests passed.

Merge Danger

Door: two-way. Error text and one exit code change; no persisted format or flag changes.

Blast radius: CLI error messages of eight commands. Scripts that grep the old text or check exit 5 for deep JSON need updating.

This PR can be reviewed and tested against the current main. It overlaps with #1190 in the command imports. After either PR lands, the other will need a sync to use the shared reader from its new module.

🤖 Generated with Claude Code

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

codecov-commenter commented Nov 29, 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.26%. Comparing base (c5f194d) to head (5879634).
⚠️ Report is 2 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    #1247   +/-   ##
=======================================
  Coverage   96.26%   96.26%           
=======================================
  Files         513      513           
  Lines       68357    68436   +79     
  Branches    11860    11883   +23     
=======================================
+ Hits        65803    65880   +77     
+ Misses       1570     1569    -1     
- Partials      984      987    +3     
Files with missing lines Coverage Δ
dokimi/dokimi/commands/arms.py 97.77% <100.00%> (-0.01%) ⬇️
dokimi/dokimi/commands/catalog_probe.py 91.66% <100.00%> (-1.67%) ⬇️
dokimi/dokimi/commands/personas.py 100.00% <100.00%> (ø)
dokimi/dokimi/commands/questions.py 87.30% <100.00%> (-0.48%) ⬇️
dokimi/dokimi/commands/repo.py 99.67% <100.00%> (-0.01%) ⬇️
dokimi/dokimi/commands/repo_scan.py 89.10% <100.00%> (-0.27%) ⬇️
dokimi/dokimi/commands/report.py 81.93% <100.00%> (-0.68%) ⬇️
dokimi/dokimi/commands/tools.py 97.38% <100.00%> (+0.01%) ⬆️

... and 8 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 Nov 29, 2026 •

Copy link
Copy Markdown

Mutation of changed lines

3 mutants of the lines this PR changes, at 5879634: 3 killed, 0 survived, 0 waived, 0 inconclusive, 0 timed out, 0 errors, 0 not run.

No surviving mutants on the changed lines.

Warn-only: a survivor does not fail the job yet. Updated on every push; the full report is in the ci run summary.

Eight command sites hand-rolled "read JSON or InputError": arms
_refuse_external_trigger_set, questions _load_questions_json and
_read_json_input, personas validate, catalog trigger-probe, report
generate, repo scan --baseline and tools preference --groups. Each now
calls read_json_input(path, flag=...), so a device or socket is refused
with "<flag> <path>: not a file" before it is read, and the messages
share one shape.

Exit codes stay 2 except one: a JSON file nested past the decoder's
recursion limit now exits 2 naming the file. Four of these sites used to
let the RecursionError escape to exit 5 with a traceback.

Messages change; the Changed fragment lists them. Tests pin the new text,
the device refusal for each newly routed flag, and deep nesting.

Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Sync main and adapt the routing commit to the shared reader already on main. Keep the fork history fast-forwardable while the PR diff contains only JSON input routing.

Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
@napetrov napetrov changed the title [stacked on #1190] refactor(commands): route the JSON file flags through read_json_input refactor(commands): route the JSON file flags through read_json_input Nov 29, 2026
@napetrov
napetrov marked this pull request as ready for review November 29, 2026 11:51
@napetrov
napetrov requested a review from a team as a code owner November 29, 2026 11:51
@exai-bot

exai-bot commented Nov 29, 2026 •

Copy link
Copy Markdown

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

CI at 5879634: 25 passing, 4 skipped.

Review details
  • Commit reviewed: 5879634 against merge base c5f194d
  • Coverage: 14 files in 4 groups
  • Engine: OpenCodeReview v1.13.5-exai.4.8f73eada, us.openai.gpt-6.1-sol
  • Usage: 353k tokens (234k from cache), 21s
  • Tool calls: 40 (24 file_read, 8 code_search, 2 ci_status, 2 local_check_results, 2 pr_comments, 1 file_read_diff, 1 pr_threads)
  • Arms command output and error handling: 2 files
  • Persona and question input handling: 4 files
  • Report CLI input handling: 2 files
  • Shared command refusal handling and refactor documentation: 6 files

…ions <path>

Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
…ile by flag

Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>

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

🔀 Merge: safe now · merges cleanly into current main, 2 commits behind; its tests pass on the merge · after it, #1190 and #1416 need a rebase (commands/*.py, tests/test_input_devices.py); #1413 is stacked on it

✅ make ci-local --offline: 31,353 passed, 0 failed · ✅ the new and changed tests for arms run --questions, repo scan --static and personas validate --file fail at d8c3582

The earlier points are fixed; every JSON flag listed in the changelog now shares one reader and one message form.

Fixed in this branch, up to 5879634:

  • arms run --questions kept the cannot build arms/plugins: prefix: 9781a60 re-raises InputError as matrix-run does.
  • repo scan --static read a device in full: 117da95 reads it with read_json_input.
  • personas validate --file said File not found and crashed on an unreachable file: e05c626 drops the exists() check; 5879634 notes it in the changelog.

@napetrov
napetrov merged commit 34fedc3 into intel:main Nov 30, 2026
29 checks passed
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