From e483ae933f1ad88ef329daf5e364f74dbc6e5e92 Mon Sep 17 00:00:00 2001 From: "yeonjin.roh" Date: Mon, 9 Nov 2026 19:32:17 +0900 Subject: [PATCH] fix: pass file filters to the wiki structure step by keyword _determine_structure called read_repo_file_tree with the filters in (excluded_dirs, excluded_files, included_dirs, included_files) order, but the function takes (included_files, included_dirs, excluded_files, excluded_dirs). Exclusions were applied as inclusions and vice versa when building the file tree sent to the LLM. Co-Authored-By: Claude Opus 5.5 (1M context) --- api/services/wiki/tasks.py | 8 +++--- tests/backend/services/test_wiki_task.py | 36 ++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/api/services/wiki/tasks.py b/api/services/wiki/tasks.py index 351bec138..8762ebea0 100644 --- a/api/services/wiki/tasks.py +++ b/api/services/wiki/tasks.py @@ -328,10 +328,10 @@ async def _determine_structure(task: WikiTask) -> WikiStructureModel: file_tree, readme = await asyncio.to_thread( read_repo_file_tree, repo.save_path, - r.excluded_dirs, - r.excluded_files, - r.included_dirs, - r.included_files, + excluded_dirs=r.excluded_dirs, + excluded_files=r.excluded_files, + included_dirs=r.included_dirs, + included_files=r.included_files, ) prompt = build_structure_prompt( diff --git a/tests/backend/services/test_wiki_task.py b/tests/backend/services/test_wiki_task.py index 937926d37..dd9ac55d4 100644 --- a/tests/backend/services/test_wiki_task.py +++ b/tests/backend/services/test_wiki_task.py @@ -255,6 +255,42 @@ async def fake_save(task, pages): assert "[README.md:1](https://github.com/o/r/blob/main/README.md#L1)" in content +async def test_determine_structure_passes_file_filters(monkeypatch): + monkeypatch.setattr(wt, "Repo", _FakeRepo) + monkeypatch.setattr(wt, "detect_default_branch", lambda p: "main") + + seen: dict = {} + + def fake_tree(path, **filters): + seen.update(filters) + return ["README.md"], "readme" + + monkeypatch.setattr(wt, "read_repo_file_tree", fake_tree) + + async def fake_research(request): + async def gen(): + yield _STRUCT_XML + + return gen() + + monkeypatch.setattr(wt, "research_chat", fake_research) + + task = _req( + excluded_dirs=["ex_dir"], + excluded_files=["ex_file"], + included_dirs=["in_dir"], + included_files=["in_file"], + ) + await wt._determine_structure(task) + + assert seen == { + "excluded_dirs": ["ex_dir"], + "excluded_files": ["ex_file"], + "included_dirs": ["in_dir"], + "included_files": ["in_file"], + } + + # --------------------------------------------------------------------------- # # serialization # --------------------------------------------------------------------------- #