Repository navigation
fix(answers): refuse a missing local:/okf: doc source (#1368) - #1466
Conversation
`eval questions generate` and `benchmark preflight` refuse a missing `local:`/`okf:` doc-source path through `require_local_doc_source`, but `answers generate`, `evaluate` and a `docs:`/`agent:` arm on such a source only built a client, which never looks at the path. Each question was then answered with no documents and `retrieval_failed` in its metadata, and the run exited 0. `cmd_answers_generate` now calls `require_local_doc_source` before it builds the client, `EvaluationPipeline.run` calls it before its first step, and the treatment factory calls it before it builds the client of a `docs:`, `agent:` or `mcp:` arm; each exits 2 with `doc source path does not exist: <source>` (an `InputError`, which is a `ValueError`, so `create_treatment` still raises `ValueError` for an unusable spec). `subjects run` builds its arms through the same factory, so a `doc-source` subject whose path is missing exits 2 too. `cmd_evaluate` re-raises an `InputError` from the pipeline instead of printing `Pipeline failed` and exiting 1, so the refusal reaches exit 2. `create_doc_source_client` keeps building a client for a missing path, as `benchmark preflight` and its tests need. `context7`, `url:`, `mcp:` and `none` sources, and a path that exists, run as before. Tests that built an arm or ran `subjects run` on a path that does not exist now use one that does: `test_pr26_properties.py` (`agent:local:./d`), `test_arm_specs.py` (`docs:local:./whatever`), and `local:docs` in `test_subjects.py`, `test_subjects_run_input.py` and `test_report_writers_surrogate.py`. Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
There was a problem hiding this comment.
🟡 Changes recommended
Overlapping source and output paths bypass missing-documentation validation and allow model calls without documentation, while unescaped path regexes cause test failures on Windows.
2 open issues
What changed in this PR
2 new findings.
This PR extends Dokimi’s existing missing-doc-source validation to answer generation, evaluation pipelines, and treatment arms, addressing #1368.
Changes:
- Add
local:/okf:path checks before client construction or pipeline steps. - Let pipeline
InputErrorexceptions reach the CLI’s exit-2 handler. - Add regression tests, update fixtures to use existing paths, and document the refusal behavior.
| File | Description |
|---|---|
dokimi/tests/test_subjects.py |
Use an existing source path in the subject test. |
dokimi/tests/test_subjects_run_input.py |
Create the documentation directory for input tests. |
dokimi/tests/test_report_writers_surrogate.py |
Create the source directory for report tests. |
dokimi/tests/test_pr26_properties.py |
Use a temporary directory for the agent arm. |
dokimi/tests/test_missing_doc_source_refused.py |
Test missing-path refusals and existing-path acceptance. |
dokimi/tests/test_arm_specs.py |
Point the local arm at an existing directory. |
dokimi/dokimi/treatments/factory.py |
Validate local sources before constructing arm clients. |
dokimi/dokimi/orchestrator/pipeline.py |
Add source validation before pipeline steps. |
dokimi/dokimi/commands/orchestrate.py |
Preserve input errors for CLI exit-2 handling. |
dokimi/dokimi/commands/answers.py |
Validate sources before constructing answer-generation clients. |
dokimi/docs/adding-doc-source.md |
Expand the documented missing-path refusal coverage. |
dokimi/changelog.d/20261201_100000_missing-doc-source-answers-evaluate-arms.md |
Describe the validation and exit-code changes. |
Review effort: Balanced
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 12 selected item(s). CI at `506dd42`: 1 failing, 20 passing, 4 skippedNot fully read: job Tests (py3.14): HTTP 404: The specified blob does not exist.
Review details
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1466 +/- ##
=======================================
Coverage 96.30% 96.30%
=======================================
Files 515 515
Lines 68905 68935 +30
Branches 11932 11933 +1
=======================================
+ Hits 66360 66389 +29
+ Misses 1568 1567 -1
- Partials 977 979 +2
🚀 New features to boost your workflow:
|
vchamarthi
left a comment
There was a problem hiding this comment.
@antonwolfy, could you fix the small thing I've marked fix before merge (in the line comments) and fix what the bot's thread on dokimi/dokimi/orchestrator/pipeline.py:289 and the bot's thread on dokimi/tests/test_missing_doc_source_refused.py:133 still point out? I'll approve once that's done.
I'll approve once that's done.
Optional, non-blocking (2)
dokimi/dokimi/mcp/factory.py:35:--doc-source local:with an empty path passes the check, becausePath("")is the current directory (main has it too).dokimi/dokimi/orchestrator/pipeline.py:272: A refused run leaves its output directories behind (main has it too).
What I checked on 7d2974b: the 149 changed tests pass, and fail on main as expected; the full test suite passes with main merged in (35,034 tests), apart from failures main has too; it merges cleanly onto main; when I changed the code on purpose, the tests caught all 3 changes.
…ies exist Settles the review points on the evaluate check and its tests. - `cmd_evaluate` calls `require_local_doc_source` before it builds `EvaluationPipeline`, whose constructor creates the output directories: `--doc-source local:<out-dir>` or `local:<out-dir>/questions` (a path the constructor would create) was accepted because `run` checked after the directory existed. The check in `run` stays for other callers. - Tests: a regression for a source that overlaps the output directory (`local:` and `okf:`, the directory itself and a generated subdirectory, which must not be created), a case pinning that a plain `ValueError` from `run` still exits 1, one that an `InputError` from `run` exits 2, one that `run` itself refuses a missing source, and `re.escape` on the path in the `pytest.raises` match so a Windows path is compared literally. Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@vchamarthi (#1466 (review)): The review points at the threads |
|
Ready for another look at Declined, with the evidence in the reply:
Follow-up issues opened:
|
napetrov
left a comment
There was a problem hiding this comment.
Change class: LOCAL (head 506dd42)
- Contract: none
- Responsibility: none
- Dependency: none
- Review depth: skim: local change, check diff + tests
- Coverage gaps: none
Checked source validation before the evaluate CLI constructs output directories, treatment construction, and error propagation. All 22 focused tests passed. Direct pipeline callers with overlapping inputs and outputs still reach the first step; this pre-existing limitation is tracked separately in #1477.


Summary
eval questions generateandbenchmark preflightrefuse a--doc-source local:<path>orokf:<path>that does not exist, butanswers generate,evaluateand adocs:/agent:arm on such a source only built a client, which never looks at the path. Onmain:mainanswers generate--doc-source local:<missing>Documentation source: ...andGenerating answers for ..., then builds theAnswerer: nothing refuses the path before the runcreate_treatment("docs:local:<missing>").prepare(...){'arm_kind': 'docs', 'raw_count': 0, 'after_rerank': 0, 'top_score': None, 'error': 'retrieval_failed'}and theMCPConnectionErrortraceback in the logevaluate--doc-source local:<missing>Each question of such a run is answered with no documents and
retrieval_failedin its metadata.Taken: the issue's first option,
require_local_doc_sourceat the call sites, so each exits 2 aseval questions generatedoes. Not taken: stopping a run whose every question recordsretrieval_failed, which would still spend the run's model calls before it refused and would change what a partly failing run records. Not taken either: the check insidecreate_doc_source_client, becausetest_mcp_factory.pypins that it builds a client for a missing path andbenchmark preflightrelies on that to report it as its own refusal.Closes #1368
Changes
commands/answers.py:cmd_answers_generatecallsrequire_local_doc_sourcein the branch that builds the client (--doc-source nonehas no client and needs no check).orchestrator/pipeline.py:EvaluationPipeline.runcalls it before its first step; one refusal covers_generate_questionsand_generate_answers, whichrunalways reaches.commands/orchestrate.py:cmd_evaluatere-raises anInputErrorfrom the pipeline instead of printingPipeline failedand exiting 1, so the refusal reaches exit 2 (any otherInputErrorraised insiderun, such asNo questions to answer, now exits 2 there too). It also callsrequire_local_doc_sourcebefore it builds the pipeline, whose constructor creates the output directories:--out-dir run --doc-source local:run(orokf:run/questions) would otherwise find the source it names already created and pass.treatments/factory.py:_buildcalls it before it builds the client of adocs:,agent:ormcp:arm; thecreate_treatmentdocstring lists theInputError(aValueError, so the documentedValueErrorstays true). Callers ofcreate_treatments(eval arms,subjects run, the matrix refusals) already let anInputErrorthrough to exit 2, so adoc-sourcesubject with a missing path exits 2 too.docs/adding-doc-source.md: the list of commands that refuse a missing path names them.tests/test_missing_doc_source_refused.py(it also covers a source that overlaps the output directory, a plainValueErrorfromrunstill exiting 1, anInputErrorfromrunexiting 2, and compares the path in theInputErrormessage literally withre.escape). Tests that built an arm or ransubjects runon a missing path now use an existing one:test_pr26_properties.py(agent:local:./d),test_arm_specs.py(docs:local:./whatever), andlocal:docsintest_subjects.py,test_subjects_run_input.pyandtest_report_writers_surrogate.py.Risk
A
local:orokf:path that does not exist, given toanswers generate,evaluate,benchmark run(its pipeline),subjects run, or an arm spec ofeval armsand the other commands that build arms, is refused with exit 2 andError: doc source path does not exist: <source>. It was taken before, with every question answered without documents.context7,url:,mcp:andnonesources and a path that exists (a directory with no doc files too) run as before.evaluatealso exits 2, not 1, on anyInputErrorraised inside the pipeline. A merge with the open PR that moves_load_runtime_configout ofcommands/answers.pymay need a trivial rebase of the import hunk (one name added to thefrom dokimi.mcp.factory import (...)list incmd_answers_generate). The open PRs that splitdokimi/utils.py(#1190, and #1416 stacked on it) conflict with this branch inorchestrator/pipeline.py, whose import block each of them edits next to the line this branch changes; the resolution is to keep both import edits. The other open PRs on these files (#1197, #1406, #1413) merge cleanly.Testing
On Linux, at
506dd42eb8f03a4d7e12118c91c4c09bfa7e3230(onmaine1f774049b300d23ef0565f625248076c301e47b):make ci-local: 38 passed, 0 failed, 16 skipped (docker and network steps, micromamba, semgrep, the fuzz run, the jobs that need a PR or another job's matrix). 32024 tests passed, 27 skipped; changed-line coverage 100% (9 lines); the mutation job killed 5 of 5 mutants.main's code:12 failed, 8 passed; first failureassert 1 == 2(evaluateexits 1 afterPipeline failed),assert 5 == 2foranswers generate(theAnswereris reached), anda doc-source client was reached for a missing doc sourcefor the arms.answers generate(2 tests),run(1), the arm factory (5); a refusal of an existing path in each of the three (2, 1, 4);cmd_evaluateswallowing theInputError(1).cmd_evaluate(4 tests, the source that overlaps the output directory);except ValueError: raiseincmd_evaluate(1, a plainValueErrorfromrunmust exit 1); the check inrundropped (1);except InputErrordropped (1, anInputErrorfromrunmust exit 2). The literal path comparison is proved by running the four arm cases under a pytest base directory nameda(bwithoutre.escape(4 failed) and with it (4 passed).Answererand the clients are stubbed).Open questions
None.
Revert
A plain revert restores the old behaviour: a missing
local:/okf:path is taken and answered without documents. Nothing is stored.Checklist
pytestpassesruff,mypy, and schema checks passAGENTS.mdraise/exit and test names the doc, contract or issue it traces to.github/.licenserc.yaml)