Skip to content

[stacked on #1650] fix: refuse a deeply nested, non-UTF-8 or unreadable subject, promptfoo or arms file - #1666

Draft
napetrov wants to merge 4 commits into
intel:mainfrom
napetrov:arch/r15-2
Draft

napetrov wants to merge 4 commits into
intel:mainfrom
napetrov:arch/r15-2

Conversation

@napetrov

@napetrov napetrov commented Dec 6, 2026

Copy link
Copy Markdown
Contributor

review commits after a06b406 (the #1645 and #1650 commits are below it; merge after #1650)

Summary

subjects/loader.py         _read_toml(path)  UTF-8 / OSError / RecursionError -> InputError naming the file
subjects/run_plan.py       record_awareness  arms.v1 read: deep / non-UTF-8 / unreadable -> InputError
task_formats/imports/promptfoo.py _code_config  RecursionError -> InputError naming the config

Malformed TOML, malformed arms JSON and a missing descriptor keep their current errors.

Evidence

  • Before: tests/test_deep_user_inputs.py at a06b406: 7 of the 8 new cases fail (deep TOML, deep arms, deep promptfoo output, non-UTF-8 TOML and arms, unreadable TOML and arms). The eighth, the promptfoo non-UTF-8 output case, is already refused and is pinned as is.
  • After: same file at cc9893d: all green; deep-input, run_plan and answer_imports tests pass.
  • Local make ci-local (cc9893d): exit 2 on three gates, none from this diff's code:
    • schema_compat: 5 BREAKING schema changes come from the stack base (a06b406 vs intel/main); this diff touches no schema file.
    • Repeat changed tests: seed 8 failed once on a ScandirIterator ResourceWarning at pytest unconfigure; rerun of repeat_changed_tests.py --repeats 8 passes all seeds.
    • pip-audit: CVEs on filelock in the environment; the lock file is untouched.

Merge Danger

Door: two-way. Exit codes change for three input kinds: exit 5 (traceback) becomes exit 2 with a named file. Revertible by reverting the commit.

Blast Radius: subjects show, subjects run and subjects list error text and exit codes for deep, non-UTF-8 or unreadable TOML and arms files; promptfoo import for deeply nested node output. No change for valid input.

🤖 Generated with Claude Code

…ceback

json.loads and yaml.safe_load raise RecursionError, not ValueError, past the
interpreter's nesting limit. The user-file readers that caught only ValueError
(repo compare --ledger, the batch stamp, eval and answers files, repair
receipts, --resume and --jsonl rows, task source lines, skill, eval-coverage
and upstream manifests, the runtime config) let it escape as a traceback. The
ledger now goes through the shared reader in dokimi.files, which already
refuses deep nesting; the others catch RecursionError with the handler they
already have.

Tests: tests/test_deep_user_inputs.py (16 cases, red on the base, green here).
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
…ell or ideal

The readers that intel#1645 did not reach still let a RecursionError escape on
deeply nested input: the native log (eval native-import), the subject
descriptor (catalog show --kind subject), a SWE-bench FAIL_TO_PASS cell, and
a json_match ideal. The log and the descriptor now go through the shared
reader in dokimi.files, which refuses deep nesting as InputError. The cell
and the ideal are not files: a cell nested too deeply is not a list, and an
ideal nested too deeply is dropped with the note an ideal that is not JSON
already gets.

batch_stamp and answers_by_id stay as they are: both already read any
unparseable file, deep or not, as a missing stamp or answers file, and
tests/test_deep_user_inputs.py pins that.

Tests: tests/test_deep_user_inputs.py (4 new cases, red on the base).
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
The four eval native-import log rows (missing, directory, unreadable,
dangling-link) exit 2 with an input error now, so the allowlist names
them as known failures that pass. Rows and digest follow the list.

Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
…oo or arms file

A TOML subject descriptor nested past the parser's limit, or one that
cannot be read, and an awareness arms.v1 file nested past the limit, not
UTF-8 or unreadable, still let a RecursionError or a decode or OS error
escape as a traceback. Each is now an InputError naming the file: the
descriptor is read by a helper, the arms file is read with its JSON error
still reported as before. A promptfoo code config whose node output nests
past the parser's limit is refused the same way, naming the config; its
other output failures keep their ValueError and exit code. A malformed
TOML or arms file keeps its current error.

Tests: tests/test_deep_user_inputs.py (8 new cases, 5 red on the base).
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
@github-actions

github-actions Bot commented Dec 6, 2026

Copy link
Copy Markdown

Mutation of changed lines

⚠️ Tests miss 6 of 21 small breaks of the lines this PR changes

At cc9893d: 15 caught · 6 missed

Each row is a small deliberate break (a mutant) of a line this PR changes that every test reaching that line still passes. Add a test that fails on it or, if it cannot change behaviour, put # mutation-ok[<operator>]: <reason> at the end of the line or alone on the line above.

Where Operator Change no test notices Tests reaching the line
dokimi/dokimi/subjects/loader.py:113 drop-clause getattr(exc, "strerror", None) or exc → (exc) 1
dokimi/dokimi/subjects/run_plan.py:127 drop-clause getattr(exc, "strerror", None) or exc → (exc) 1
dokimi/dokimi/subjects/loader.py:113 drop-clause getattr(exc, "strerror", None) or exc → (getattr(exc, "strerror", None)) 1
dokimi/dokimi/subjects/run_plan.py:127 drop-clause getattr(exc, "strerror", None) or exc → (getattr(exc, "strerror", None)) 1
dokimi/dokimi/subjects/loader.py:113 swap-boolop getattr(exc, "strerror", None) or exc → getattr(exc, 'strerror', None) and exc 1
dokimi/dokimi/subjects/run_plan.py:127 swap-boolop getattr(exc, "strerror", None) or exc → getattr(exc, 'strerror', None) and exc 1

Warning only: a missed break does not fail the job. Updated on every push; the full report is in the ci run summary.

@codecov-commenter

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.44%. Comparing base (1f4baa1) to head (cc9893d).
⚠️ Report is 22 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    #1666      +/-   ##
==========================================
- Coverage   96.49%   96.44%   -0.05%     
==========================================
  Files         569      585      +16     
  Lines       75249    76625    +1376     
  Branches    12980    13174     +194     
==========================================
+ Hits        72611    73904    +1293     
- Misses       1615     1665      +50     
- Partials     1023     1056      +33     
Files with missing lines Coverage Δ
dokimi/dokimi/commands/catalog_scan.py 97.34% <100.00%> (ø)
dokimi/dokimi/commands/opportunities.py 86.58% <100.00%> (ø)
dokimi/dokimi/commands/repair_receipt.py 100.00% <100.00%> (ø)
dokimi/dokimi/eval_coverage.py 99.22% <100.00%> (+0.05%) ⬆️
dokimi/dokimi/external/upstream.py 91.77% <100.00%> (ø)
dokimi/dokimi/mcp/factory.py 97.52% <100.00%> (ø)
dokimi/dokimi/novelty/sweep.py 94.83% <100.00%> (ø)
dokimi/dokimi/report/eval_io.py 100.00% <100.00%> (ø)
dokimi/dokimi/repos/compare.py 99.53% <100.00%> (ø)
dokimi/dokimi/repos/conformance.py 99.21% <100.00%> (ø)
... and 10 more

... and 76 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

2 participants