Repository navigation
refactor(commands): route the JSON file flags through read_json_input - #1247
Conversation
…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 Report✅ All modified and coverable lines are covered by tests. 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
🚀 New features to boost your workflow:
|
Mutation of changed lines3 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>
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 14 selected item(s). CI at Review details
|
…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
left a comment
There was a problem hiding this comment.
🟢 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 --questionskept thecannot build arms/plugins:prefix: 9781a60 re-raisesInputErrorasmatrix-rundoes.repo scan --staticread a device in full: 117da95 reads it withread_json_input.personas validate --filesaidFile not foundand crashed on an unreachable file: e05c626 drops theexists()check; 5879634 notes it in the changelog.
Summary
Local
_read_json_inputand 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)/dev/zero,/dev/null) is refused with<flag> <path>: not a filebefore any read, on every newly routed flag, includingarms runandmatrix-run --questions.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>.[Errno 2] .... Empty path exits 2 with<flag> "": no file given.questions refineis not routed in this PR.Evidence
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.mainbase, 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