Skip to content

fix(cli): refuse a missing local doc source in questions generate - #1108

Merged
vchamarthi merged 10 commits into
intel:mainfrom
vchamarthi:issue-1086-eval-questions-generate-reports-success
Nov 24, 2026
Merged

vchamarthi merged 10 commits into
intel:mainfrom
vchamarthi:issue-1086-eval-questions-generate-reports-success

Conversation

@vchamarthi

@vchamarthi vchamarthi commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

eval questions generate --doc-source local:<missing> logged Failed to fetch docs, used 6 default seed topics, saved an empty missing-questions.json and exited 0. Expected: exit 2 with an error naming the path. Fixes #1086.

Changes

  • cmd_questions_generate and benchmark check call require_local_doc_source (mcp/factory.py), which raises InputError when a local: or okf: path does not exist, its name is too long, or checking that it exists fails with a permission error.
  • Three tests in dokimi/tests/test_questions_generate_inputs.py (one parametrized over local and okf) and the Path.exists stand-in dokimi/tests/exists_mock.py.
  • test_questions_generate_topics_cache_directory_is_keyed_as_the_pipeline_keys_it and test_generate_does_not_replay_one_doc_source_topics_for_another passed made-up local: paths that now fail the check. Both patch Path.exists for those paths; their assertions are unchanged.
  • Changelog fragment in dokimi/changelog.d/.
  • The new raise in _require_local_doc_source cites eval questions generate reports success when a local doc source is missing #1086 in a comment.

Risk

Only an explicit local: or okf: source with a missing path changes. orchestrate is not touched; benchmark check uses the shared guard and keeps its missing-path message.

Testing

python -m pytest -q -p no:cacheprovider tests/test_questions_generate_inputs.py tests/test_doc_caches.py tests/test_lone_surrogate_cache_keys.py tests/test_growth_ratchet.py: 138 passed. Before the last amend the whole suite gave 25975 passed and 1 failed (tests/test_repo_compare_interval.py::test_the_row_p_places_zero_where_large_deltas_round_p_at_zero_apart, untouched code). python -m ruff check on the changed .py files: passed. New tests: missing path exits 2 naming the path with no output file; a 256-character name exits 2; an existing directory is accepted.

Open questions

  • I chose Check the path in cmd_questions_generate only over A shared check in create_doc_source_client that also covers benchmark, orchestrate and okf:: smallest change; the issue reports questions generate. Is that the behaviour you want?

Revert

Revert the commit. 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)
Checklist evidence
  • Tests added/updated and pytest passes: 3 test file(s) changed; suite: 27855 passed; 1 failing test(s) fail on the base branch too: tests/test_repo_compare_interval.py::test_the_row_p_places_zero_where_large_deltas_round_p_at_zero_apart; 2 of 3 proof(s) fail before the change; 1 pin behaviour the base code already had
  • ruff, mypy, and schema checks pass: passed: ci.yml:static / ruff check, ci.yml:typecheck / mypy, ci.yml:static / schema-check, ci.yml:static / schema_compat vs the PR base
  • Docs updated (or N/A): N/A: No doc describes the behaviour for a missing local path; the changelog fragment records it.
  • Self-reviewed per "Before opening a PR" in AGENTS.md: nothing left open; mutation of changed lines ran
  • Each new raise/exit and test names the doc, contract or issue it traces to: every new error path and test names a doc, contract or issue
  • No ad-hoc run artifacts committed: 1 added file(s), none a run's output
  • New files carry the SPDX license header (or are exempt in .github/.licenserc.yaml): no new source file

Fixes #1086.

Design choices

  • Should local:<existing empty directory> or local:<file with no doc extension> also exit 2: I chose No: only a missing path is refused over Also refuse an existing path that holds no readable docs: eval questions generate reports success when a local doc source is missing #1086 asks for an input error only when the path is absent, and an existing path is a valid source that LocalMarkdownClient reads without error.

questions generate with --doc-source local:<missing> logged the failed
read, fell back to default seed topics, saved an empty question set and
exited 0. It now raises InputError naming the path and exits 2.

Fixes intel#1086

Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
@codecov-commenter

codecov-commenter commented Nov 22, 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.06%. Comparing base (06341ca) to head (d871af2).
⚠️ Report is 46 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    #1108      +/-   ##
==========================================
- Coverage   96.08%   96.06%   -0.03%     
==========================================
  Files         461      475      +14     
  Lines       60836    63010    +2174     
  Branches    10517    10907     +390     
==========================================
+ Hits        58457    60528    +2071     
- Misses       1473     1531      +58     
- Partials      906      951      +45     
Files with missing lines Coverage Δ
dokimi/dokimi/commands/benchmark.py 92.30% <100.00%> (ø)
dokimi/dokimi/commands/questions.py 87.77% <100.00%> (+0.04%) ⬆️
dokimi/dokimi/mcp/factory.py 96.73% <100.00%> (+1.08%) ⬆️

... and 87 files with indirect coverage changes

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

okf:<missing> exited 0 with default seed topics like local:<missing> did.
_require_local_doc_source now checks okf: paths too.
The Path.exists mocks in two tests compare as_posix() so they match
on Windows.

Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
@vchamarthi

Copy link
Copy Markdown
Contributor Author

Ready for re-review: 1 commit on issue-1086-eval-questions-generate-reports-success (04561ac..68a29c8).

Changes:

  • _require_local_doc_source refuses a missing okf:<path> as it does local:<path>.
  • The Path.exists mocks in test_doc_caches.py and test_lone_surrogate_cache_keys.py come from exists_for_prefix in tests/exists_mock.py, which compares as_posix().

PR description updated:

  • which raises InputError when the source is local:<path> or okf:<path> and the path does not exist or its name is too long for the filesystem.
  • Only an explicit local: or okf: source with a missing path changes.

Checked on the new head:

  • Not passed: 1 of 2 tests fail before the fix and pass after
  • Full suite with main merged in: 27897 passed, 1 failure that main has too
What each test shows
  • missing okf: and local: sources exit 2: fails before, passes after.
  • the shared exists mock accepts a Windows-spelled path: passes before the fix too.

The Windows-spelling test only exercised exists_for_prefix and passed
without _require_local_doc_source. A guard test now calls it: /docs
passes and a path outside the prefix raises InputError. A second test
keeps the PureWindowsPath inputs so str(self) in the stand-in fails.

Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
@vchamarthi

Copy link
Copy Markdown
Contributor Author

Ready for re-review: 1 commit on issue-1086-eval-questions-generate-reports-success (68a29c8..4810785).

Changes:

  • test_exists_mock_matches_a_path_as_windows_spells_it now calls _require_local_doc_source instead of only the helper.
  • test_exists_stand_in_matches_a_path_as_windows_spells_it feeds PureWindowsPath inputs to exists_for_prefix.

PR description updated:

  • which raises InputError when the source is local:<path> or okf:<path> and the path does not exist or its name is too long for the filesystem.
  • Three tests in dokimi/tests/test_questions_generate_inputs.py (one parametrized over local and okf) and the Path.exists stand-in dokimi/tests/exists_mock.py.

Checked on the new head: tests of the fix: 2 passed; full suite with main merged in: 27918 passed, 1 failure that main has too.

What each test shows
  • the stand-in test fails when the guard does not refuse a missing path: passes.
  • the stand-in still matches Windows-spelled paths: passes.

The Windows-spelling test called _require_local_doc_source directly, so
removing the call from cmd_questions_generate left it green. It now runs
cmd_questions_generate with local:/other and expects the InputError.

Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
@vchamarthi

Copy link
Copy Markdown
Contributor Author

Ready for re-review: 1 commit on issue-1086-eval-questions-generate-reports-success (4810785..ecd831a).

Changes:

  • test_generate_refuses_a_missing_path_outside_the_exists_stand_in calls cmd_questions_generate instead of the helper.

Checked on the new head:

  • Not passed: 1 test removed or renamed
  • Tests of the fix: 1 passed
  • Full suite with main merged in: 27928 passed, 1 failure that main has too
What each test shows
  • local:/other is refused through cmd_questions_generate: passes.
  • Removed or renamed tests: test_exists_mock_matches_a_path_as_windows_spells_it.

A PermissionError from Path.exists on local:/restricted/docs was
reported as 'path does not exist', and Python 3.14 Path.exists answers
False for any OSError. After a False answer the guard stats the path;
only ENOENT, ENOTDIR, ENAMETOOLONG and ValueError mean missing, any
other OSError is an InputError naming the path.

Also turns the helper-only Windows-spelling test into a test of
_require_local_doc_source.

Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
@vchamarthi

Copy link
Copy Markdown
Contributor Author

Ready for re-review: 1 commit on issue-1086-eval-questions-generate-reports-success (ecd831a..3f8a6b1).

Changes:

  • local:/restricted/docs with a PermissionError from Path.exists is reported as unreadable, not missing.
  • test_exists_stand_in_matches_a_path_as_windows_spells_it replaced by a test that drives _require_local_doc_source.

Checked on the new head:

  • Not passed: 1 test removed or renamed
  • 2 of 2 tests fail before the fix and pass after
  • Full suite with main merged in: 28035 passed, 1 failure that main has too
What each test shows
  • PermissionError is not reported as a missing path: fails before, passes after.
  • guard test replacing the helper-only test: passes.
  • a denied directory is unreadable even when Path.exists answers False: fails before, passes after.
  • Removed or renamed tests: test_exists_stand_in_matches_a_path_as_windows_spells_it.

@vchamarthi
vchamarthi marked this pull request as ready for review November 22, 2026 22:59
@vchamarthi
vchamarthi requested a review from a team as a code owner November 22, 2026 22:59
Copilot AI balanced review requested due to automatic review settings November 22, 2026 22:59

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.

🟢 Approval recommended

No active review issues remain for the change that rejects missing local documentation paths with exit code 2.

No open issues 🎉

What changed in this PR

0 new findings; nothing to fix.

This PR addresses #1086 by making eval questions generate reject missing local documentation paths with exit code 2 instead of falling back to default topics and reporting success.

Changes:

  • Adds path validation for local: and okf: sources before automatic topic extraction, distinguishing missing paths from permission errors.
  • Adds regression tests and adapts cache tests whose source paths are only identifiers.
  • Documents the corrected CLI behavior in a changelog fragment.
File Description
dokimi/​tests/​test_questions_generate_inputs.py Tests missing, existing, overlong, and permission-denied paths.
dokimi/​tests/​test_lone_surrogate_cache_keys.py Preserves cache-key tests with simulated source existence.
dokimi/​tests/​test_doc_caches.py Adapts cache tests and checks the path guard with simulated paths.
dokimi/​tests/​exists_mock.py Adds a shared, prefix-based Path.exists stand-in.
dokimi/​dokimi/​commands/​questions.py Validates local source paths before topic extraction.
dokimi/​changelog.d/​20261122_120000_questions-generate-missing-local-source.md Records the missing-source refusal and exit code.

Review effort: Balanced

@exai-bot

exai-bot commented Nov 22, 2026 •

Copy link
Copy Markdown

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

CI at d871af2: 21 passing, 4 skipped.

Review limit reached. This PR has had 6 reviews, so it will only be reviewed again when you ask.
To ask: re-request review from exai-bot in the Reviewers list.

Test notes (1)
  • dokimi/tests/test_exists_mock_header.py: dokimi/tests/test_exists_mock_header.py passes at the head and also at the merge base, where the code this pull request changes is still as it was. No test in it fails without the change, so none of them would notice if the change were undone.
Review details
  • Commit reviewed: d871af2 against merge base 31a6957
  • Coverage: 1 files in 1 groups
  • Engine: OpenCodeReview v1.13.5-exai.4.8f73eada, us.openai.gpt-6.1-sol
  • Usage: 40k tokens (24k from cache), 14s
  • Tool calls: 2 (2 file_read)
  • dokimi/tests/test_questions_generate_inputs.py: 1 file

Comment thread dokimi/tests/exists_mock.py Resolved
Comment thread dokimi/tests/exists_mock.py Resolved
The licenses check named dokimi/tests/exists_mock.py for lacking the
copyright and SPDX header. A test pins the header.

Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
@vchamarthi

Copy link
Copy Markdown
Contributor Author

Ready for re-review: 1 commit on issue-1086-eval-questions-generate-reports-success (3f8a6b1..3622b95).

Changes:

  • Added the copyright and SPDX header to dokimi/tests/exists_mock.py.

Threads and comments:

  • 2 fixed; each answered in its thread.

Checked on the new head: tests of the fix: 1 passed; full suite with main merged in: 28080 passed, 1 failure that main has too.

What each test shows
  • exists_mock.py starts with the copyright and SPDX header: passes.

@vlad-perevezentsev vlad-perevezentsev 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.

🟡 Changes needed · reviewed 3f8a6b1, header fix 3622b95 read

To fix: two small points on the guard (line comments): the check duplicated in benchmark check, and a message in a rare race.

✅ make ci-local --offline: 25,932 passed, mutation of changed lines passes · ✅ the 5 new guard tests fail on the base and pass here · ✅ merges cleanly into current main, no open PR touches these files

A missing local:/okf: path now exits 2 and names the path, and an unreadable one is reported as unreadable.

Comment thread dokimi/dokimi/commands/questions.py Resolved
Comment thread dokimi/dokimi/commands/questions.py Resolved
Move the missing-path guard to `require_local_doc_source` in
`mcp/factory.py` and call it from `questions generate` and
`benchmark check`, so an unreadable path is reported the same way in both.
Drop the false "does not exist" when `stat` succeeds after `exists` said no.

Signed-off-by: vchamarthi <venkata.sai.gireesh.chamarthi@intel.com>
@vchamarthi

Copy link
Copy Markdown
Contributor Author

🟢 Ready for re-review · 1 commit on issue-1086-eval-questions-generate-reports-success (3622b95..4a9496e)

Next: @vlad-perevezentsev: re-review the new head.

Changes

  • benchmark check uses the same guard as questions generate.
  • A path found by stat after exists answered False is accepted.

PR description updated

  • cmd_questions_generate and benchmark check call require_local_doc_source (mcp/factory.py), which raises InputError when a local: or okf: path does not exist, its name is too long, or it cannot be read.
  • orchestrate is not touched; benchmark check uses the shared guard and keeps its missing-path message.

Threads and comments

  • 2 fixed; each answered in its thread.
  • Fixed (comment by @vlad-perevezentsev): duplicate check in benchmark check and the race message – Covered by the two threads: one shared helper, and no false does not exist when stat succeeds.

Verified on the new head: ✅ 2/2 tests fail before the fix, pass after · ✅ full suite with main merged in: 29000 passed · ✅ second reader: nothing raised · ⚠️ 2 tests removed or renamed

What each test shows
  • Path appearing between exists and stat is accepted: fails before, passes after.
  • benchmark check reports an unreadable path as unreadable: fails before, passes after.
  • Also changed, outside this PR's files: dokimi/dokimi/commands/benchmark.py, dokimi/dokimi/mcp/factory.py.
  • Removed or renamed tests: test_require_local_doc_source_reports_a_denied_directory_when_exists_answers_false, test_require_local_doc_source_reports_a_permission_error_as_unreadable.
  • Left to GitHub's own checks: agent-quality.yml:external-catalog-smoke, ci.yml:static / pre-commit, ci.yml:static / Install gitleaks, ci.yml:static / Scan commits, ci.yml:fidelity / Install the pinned Claude Code, ci.yml:test-latest, ci.yml:test-seeds, ci.yml:package-smoke.

require_local_doc_source returned for a file with mode 000, so the
changelog's claim that an unreadable path is reported as unreadable by
benchmark check did not hold. It now raises InputError (cannot read)
when the path exists but is not readable.

Signed-off-by: vchamarthi <venkata.sai.gireesh.chamarthi@intel.com>
@vchamarthi

Copy link
Copy Markdown
Contributor Author

🟢 Ready for re-review · 1 commit on issue-1086-eval-questions-generate-reports-success (4a9496e..25ff369)

Next: a re-review of the new head.

Changes

  • require_local_doc_source raises InputError for an existing path that is not readable.

PR description updated

  • which raises InputError when a local: or okf: path does not exist, its name is too long, or checking that it exists fails with a permission error.

Threads and comments

  • 1 fixed; each answered in its thread.

Verified on the new head: ✅ 1/1 tests fail before the fix, pass after · ✅ full suite with main merged in: 29021 passed · ✅ second reader: nothing raised

What each test shows
  • A mode-000 file is refused as unreadable: fails before, passes after.
  • Left to GitHub's own checks: agent-quality.yml:external-catalog-smoke, ci.yml:static / pre-commit, ci.yml:static / Install gitleaks, ci.yml:static / Scan commits, ci.yml:fidelity / Install the pinned Claude Code, ci.yml:test-latest, ci.yml:test-seeds, ci.yml:package-smoke.

@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: CONTRACT (head 25ff369)

  • Contract: candidate. errors dokimi/dokimi/commands/benchmark.py:330; errors dokimi/dokimi/mcp/factory.py:26
  • Responsibility: none
  • Dependency: none
  • Review depth: check the changed surface: callers, docs, tests pin new behaviour
  • Coverage gaps: none

Missing local and OKF paths now get a clear input error. I found an existing directory that passes the new readability check and fails when the client tries to read its documents. Focused tests on 25ff36906: 100 passed.

Comment thread dokimi/dokimi/mcp/factory.py Resolved
require_local_doc_source accepted a directory with mode 0444: its names
list but none can be opened. Check X_OK as well as R_OK for directories.

Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
@vchamarthi

Copy link
Copy Markdown
Contributor Author

Ready for re-review, @napetrov: 1 commit on issue-1086-eval-questions-generate-reports-success (25ff369..31a6957) answers your thread.

Changes:

  • require_local_doc_source checks X_OK along with R_OK for a directory source.

Threads and comments:

  • 1 fixed; each answered in its thread.

Not the PR's:

  • Fails on main too: 1 test in tests/test_repo_compare_interval.py; float rounding of 1e9-scale deltas gives -0.0001 instead of 0.0 for delta.lo.

Checked on the new head: 1 of 1 tests fail before the fix and pass after; full suite with main merged in: 29215 passed, 1 failure that main has too.

What each test shows
  • a directory without search permission is refused as unreadable: fails before, passes after.

Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>

@vlad-perevezentsev vlad-perevezentsev 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.

🟢 LGTM · re-checked 31a6957 · nothing required from @vchamarthi

🔀 Merge: safe now · merges cleanly into current main (45 commits behind, no change to this PR's files there); its tests pass on the merge · no open PR conflicts with it

✅ make ci-local --offline: 25,937 passed · ⚠️ 2 Ctrl-C timeouts in test_docker_cmd.py / test_repo_host.py under full-suite load, unrelated to this PR, 115 passed on rerun · ✅ a local: docs dir at mode 0444: questions generate now exits 2 with cannot read

The earlier points are fixed; missing and unreadable local doc sources are now refused by one shared guard.

Fixed in this branch, up to d871af2:

  • Two test names lost their underscore (testrequire_…): d871af2.

@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: CONTRACT (head d871af2)

  • Contract: candidate. errors dokimi/dokimi/commands/benchmark.py:330; errors dokimi/dokimi/mcp/factory.py:26
  • Responsibility: none
  • Dependency: none
  • Review depth: check the changed surface: callers, docs, tests pin new behaviour
  • Coverage gaps: none

The shared preflight now rejects a directory that can list names but cannot open its files. I confirmed this using a real directory with mode 0444 through benchmark check’s validation path. All 102 focused tests passed, including question generation and doc-cache coverage. CI is green.

@vchamarthi
vchamarthi merged commit f78d706 into intel:main Nov 24, 2026
25 checks passed
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.

eval questions generate reports success when a local doc source is missing

6 participants