Skip to content

fix(answers): refuse a missing local:/okf: doc source (#1368) - #1466

Merged
antonwolfy merged 2 commits into
intel:mainfrom
antonwolfy:fix/answers-missing-doc-source
Dec 1, 2026
Merged

antonwolfy merged 2 commits into
intel:mainfrom
antonwolfy:fix/answers-missing-doc-source

Conversation

@antonwolfy

@antonwolfy antonwolfy commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

eval questions generate and benchmark preflight refuse a --doc-source local:<path> or okf:<path> that does not exist, but answers generate, evaluate and a docs:/agent: arm on such a source only built a client, which never looks at the path. On main:

Command Input Result on main
answers generate --doc-source local:<missing> prints Documentation source: ... and Generating answers for ..., then builds the Answerer: nothing refuses the path before the run
create_treatment("docs:local:<missing>").prepare(...) missing path metadata {'arm_kind': 'docs', 'raw_count': 0, 'after_rerank': 0, 'top_score': None, 'error': 'retrieval_failed'} and the MCPConnectionError traceback in the log
evaluate --doc-source local:<missing> the pipeline starts and builds its client in the question and answer steps with the same effect

Each question of such a run is answered with no documents and retrieval_failed in its metadata.

Taken: the issue's first option, require_local_doc_source at the call sites, so each exits 2 as eval questions generate does. Not taken: stopping a run whose every question records retrieval_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 inside create_doc_source_client, because test_mcp_factory.py pins that it builds a client for a missing path and benchmark preflight relies on that to report it as its own refusal.

Closes #1368

Changes

  • commands/answers.py: cmd_answers_generate calls require_local_doc_source in the branch that builds the client (--doc-source none has no client and needs no check).
  • orchestrator/pipeline.py: EvaluationPipeline.run calls it before its first step; one refusal covers _generate_questions and _generate_answers, which run always reaches.
  • commands/orchestrate.py: cmd_evaluate re-raises an InputError from the pipeline instead of printing Pipeline failed and exiting 1, so the refusal reaches exit 2 (any other InputError raised inside run, such as No questions to answer, now exits 2 there too). It also calls require_local_doc_source before it builds the pipeline, whose constructor creates the output directories: --out-dir run --doc-source local:run (or okf:run/questions) would otherwise find the source it names already created and pass.
  • treatments/factory.py: _build calls it before it builds the client of a docs:, agent: or mcp: arm; the create_treatment docstring lists the InputError (a ValueError, so the documented ValueError stays true). Callers of create_treatments (eval arms, subjects run, the matrix refusals) already let an InputError through to exit 2, so a doc-source subject with a missing path exits 2 too.
  • docs/adding-doc-source.md: the list of commands that refuse a missing path names them.
  • Tests: new tests/test_missing_doc_source_refused.py (it also covers a source that overlaps the output directory, a plain ValueError from run still exiting 1, an InputError from run exiting 2, and compares the path in the InputError message literally with re.escape). Tests that built an arm or ran subjects run on a missing path now use an existing one: 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.
  • Changelog fragment (Fixed).

Risk

A local: or okf: path that does not exist, given to answers generate, evaluate, benchmark run (its pipeline), subjects run, or an arm spec of eval arms and the other commands that build arms, is refused with exit 2 and Error: doc source path does not exist: <source>. It was taken before, with every question answered without documents. context7, url:, mcp: and none sources and a path that exists (a directory with no doc files too) run as before. evaluate also exits 2, not 1, on any InputError raised inside the pipeline. A merge with the open PR that moves _load_runtime_config out of commands/answers.py may need a trivial rebase of the import hunk (one name added to the from dokimi.mcp.factory import (...) list in cmd_answers_generate). The open PRs that split dokimi/utils.py (#1190, and #1416 stacked on it) conflict with this branch in orchestrator/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 (on main e1f774049b300d23ef0565f625248076c301e47b):

  • 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.
  • The new tests on main's code: 12 failed, 8 passed; first failure assert 1 == 2 (evaluate exits 1 after Pipeline failed), assert 5 == 2 for answers generate (the Answerer is reached), and a doc-source client was reached for a missing doc source for the arms.
  • Seven mutants, one break each, each fails its test: no refusal in 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_evaluate swallowing the InputError (1).
  • Four more mutants, each fails its test: no pre-check in cmd_evaluate (4 tests, the source that overlaps the output directory); except ValueError: raise in cmd_evaluate (1, a plain ValueError from run must exit 1); the check in run dropped (1); except InputError dropped (1, an InputError from run must exit 2). The literal path comparison is proved by running the four arm cases under a pytest base directory named a(b without re.escape (4 failed) and with it (4 passed).
  • Not run: the matrix legs on Python 3.11, 3.12 and 3.14; a real model or doc source (the Answerer and 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

  • Tests added/updated and pytest passes
  • ruff, mypy, and schema checks pass
  • Docs updated (or N/A) — see the docs-drift checklist in CONTRIBUTING.md
  • Self-reviewed per "Before opening a PR" in AGENTS.md
  • Each new raise/exit and test names the doc, contract or issue it traces to
  • No ad-hoc run artifacts committed
  • New files carry the SPDX license header (or are exempt in .github/.licenserc.yaml)

`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>
@antonwolfy
antonwolfy requested a review from a team as a code owner December 1, 2026 01:35
@antonwolfy antonwolfy self-assigned this Dec 1, 2026
Copilot AI balanced review requested due to automatic review settings December 1, 2026 01:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 InputError exceptions 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

Comment thread dokimi/dokimi/orchestrator/pipeline.py Resolved
@exai-bot

exai-bot commented Dec 1, 2026 •

Copy link
Copy Markdown

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

CI at `506dd42`: 1 failing, 20 passing, 4 skipped

Not fully read: job Tests (py3.14): HTTP 404: The specified blob does not exist.

Check Status
Tests (py3.14) failing
Review details
  • Commit reviewed: 506dd42 against merge base e1f7740
  • Coverage: 12 files in 2 groups
  • Engine: OpenCodeReview v1.13.5-exai.4.8f73eada, us.openai.gpt-6.1-sol
  • Usage: 349k tokens (246k from cache), 56s
  • Tool calls: 35 (24 file_read, 5 code_search, 2 file_read_diff, 2 local_check_results, 1 ci_status, 1 pr_threads)
  • Reject missing document sources in commands and treatment pipelines: 7 files
  • Update existing test fixtures for document-source requirements: 5 files

@codecov-commenter

codecov-commenter commented Dec 1, 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.30%. Comparing base (e1f7740) to head (506dd42).
⚠️ Report is 8 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    #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     
Files with missing lines Coverage Δ
dokimi/dokimi/commands/answers.py 96.33% <100.00%> (+0.03%) ⬆️
dokimi/dokimi/commands/orchestrate.py 100.00% <100.00%> (ø)
dokimi/dokimi/orchestrator/pipeline.py 94.65% <100.00%> (+0.01%) ⬆️
dokimi/dokimi/treatments/factory.py 100.00% <100.00%> (ø)

... and 14 files with indirect coverage changes

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

@vchamarthi vchamarthi 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.

@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, because Path("") 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.

Comment thread dokimi/dokimi/commands/orchestrate.py Resolved
…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>
@antonwolfy

Copy link
Copy Markdown
Contributor Author

(commented) @antonwolfy, could you fix the small thing I've marked fix before merge (in the line comments) and fix what the bot's [thread](#1466 (comment)

@vchamarthi (#1466 (review)): The review points at the threads 4748522401, 4748043089 and 4748043143; each is answered above in 506dd42. The two optional items (an empty local: path, directories left behind by a refused run) are present on main too and are not changed here.

@antonwolfy

Copy link
Copy Markdown
Contributor Author

Ready for another look at 506dd42; CI is green.

Declined, with the evidence in the reply:

  • dokimi/dokimi/orchestrator/pipeline.py:289 (Copilot) (fixed in part): Not moved into EvaluationPipeline.init: a constructor check refuses the pipelines that tests/test_lone_surrogate_cache_keys.py builds over a missing local: path; the benchmark path stays open, tracked in f1.

Follow-up issues opened:

@antonwolfy
antonwolfy requested a review from vchamarthi December 1, 2026 12:07

@napetrov napetrov 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.

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.

@antonwolfy
antonwolfy merged commit 32561b8 into intel:main Dec 1, 2026
33 of 34 checks passed
@antonwolfy
antonwolfy deleted the fix/answers-missing-doc-source branch December 1, 2026 16:08
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.

answers generate, evaluate and a local:/okf: treatment arm accept a missing doc-source path and record retrieval_failed per question

6 participants