Repository navigation
fix(cli): refuse a missing local doc source in questions generate - #1108
vchamarthi merged 10 commits into
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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
🚀 New features to boost your workflow:
|
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>
|
Ready for re-review: 1 commit on Changes:
PR description updated:
Checked on the new head:
What each test shows
|
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>
|
Ready for re-review: 1 commit on Changes:
PR description updated:
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 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>
|
Ready for re-review: 1 commit on Changes:
Checked on the new head:
What each test shows
|
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>
|
Ready for re-review: 1 commit on Changes:
Checked on the new head:
What each test shows
|
There was a problem hiding this comment.
🟢 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:andokf: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
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 1 selected item(s). CI at Review limit reached. This PR has had 6 reviews, so it will only be reviewed again when you ask. Test notes (1)
Review details
|
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>
|
Ready for re-review: 1 commit on Changes:
Threads and comments:
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
|
vlad-perevezentsev
left a comment
There was a problem hiding this comment.
🟡 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.
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>
|
🟢 Ready for re-review · 1 commit on Next: @vlad-perevezentsev: re-review the new head. Changes
PR description updated
Threads and comments
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 · What each test shows
|
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>
|
🟢 Ready for re-review · 1 commit on Next: a re-review of the new head. Changes
PR description updated
Threads and comments
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
|
napetrov
left a comment
There was a problem hiding this comment.
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.
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>
|
Ready for re-review, @napetrov: 1 commit on Changes:
Threads and comments:
Not the PR's:
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
|
Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
vlad-perevezentsev
left a comment
There was a problem hiding this comment.
🟢 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 · 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
left a comment
There was a problem hiding this comment.
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.
Summary
eval questions generate --doc-source local:<missing>loggedFailed to fetch docs, used 6 default seed topics, saved an emptymissing-questions.jsonand exited 0. Expected: exit 2 with an error naming the path. Fixes #1086.Changes
cmd_questions_generateandbenchmark checkcallrequire_local_doc_source(mcp/factory.py), which raisesInputErrorwhen alocal:orokf:path does not exist, its name is too long, or checking that it exists fails with a permission error.dokimi/tests/test_questions_generate_inputs.py(one parametrized overlocalandokf) and thePath.existsstand-indokimi/tests/exists_mock.py.test_questions_generate_topics_cache_directory_is_keyed_as_the_pipeline_keys_itandtest_generate_does_not_replay_one_doc_source_topics_for_anotherpassed made-uplocal:paths that now fail the check. Both patchPath.existsfor those paths; their assertions are unchanged.dokimi/changelog.d/.raisein_require_local_doc_sourcecites eval questions generate reports success when a local doc source is missing #1086 in a comment.Risk
Only an explicit
local:orokf:source with a missing path changes.orchestrateis not touched;benchmark checkuses 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 checkon the changed.pyfiles: 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
cmd_questions_generateonly over A shared check increate_doc_source_clientthat also coversbenchmark,orchestrateandokf:: smallest change; the issue reportsquestions generate. Is that the behaviour you want?Revert
Revert the commit. 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)Checklist evidence
pytestpasses: 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 hadruff,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 baseAGENTS.md: nothing left open; mutation of changed lines ranraise/exit and test names the doc, contract or issue it traces to: every new error path and test names a doc, contract or issue.github/.licenserc.yaml): no new source fileFixes #1086.
Design choices
local:<existing empty directory>orlocal:<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 thatLocalMarkdownClientreads without error.