Skip to content

[stacked on #1190] refactor(commands): route the JSON file flags through read_json_input - #1247

Draft
napetrov wants to merge 6 commits into
intel:mainfrom
napetrov:arch/r6-6
Draft

napetrov wants to merge 6 commits into
intel:mainfrom
napetrov:arch/r6-6

Conversation

@napetrov

Copy link
Copy Markdown
Contributor

Stacked on #1190 (arch/c14, not merged yet). Review only the commits after bee121240; this PR is one commit, 5d9f231841.

Summary

read_json_input(path, flag=...)          dokimi/files.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.
  • Local make ci-local --offline: test, coverage, mutation and fidelity pass. The one red step, "Repeat changed tests", exited 1 from a pytest temp-dir teardown race in tests/test_repo_run.py; the same seed replays green (385 and 94 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.

🤖 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_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
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>

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.

1 participant