Improve retrieval of deep workspace evidence
This commit is contained in:
@@ -133,6 +133,49 @@ class KnowledgeIndexTests(unittest.TestCase):
|
||||
self.assertEqual(results[0]["path"], "docs/guide.md")
|
||||
self.assertIn("Whisper", str(results[0]["text"]))
|
||||
|
||||
def test_skill_permission_query_retrieves_allowed_tools_identifier(self) -> None:
|
||||
self._index(
|
||||
"if tool_name not in selected_skill.allowed_tools: "
|
||||
"raise PermissionError('tool is not allowed')"
|
||||
)
|
||||
|
||||
results = self._search(
|
||||
"How is a tool call blocked when it is outside the selected skill permissions?"
|
||||
)
|
||||
|
||||
self.assertTrue(results)
|
||||
self.assertIn("allowed_tools", str(results[0]["text"]))
|
||||
|
||||
def test_search_clamps_global_and_per_document_result_limits(self) -> None:
|
||||
with patch.object(knowledge.database, "DATABASE_PATH", self.database):
|
||||
for index in range(5):
|
||||
relative_path = f"docs/repeated-{index}.md"
|
||||
text = "sharedphrase " * 220
|
||||
path = self.workspace / relative_path
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_text(text, encoding="utf-8")
|
||||
knowledge.index_document(
|
||||
user_id="local-user",
|
||||
workspace_path=self.workspace,
|
||||
relative_path=relative_path,
|
||||
text=text,
|
||||
content_hash=hashlib.sha256(text.encode("utf-8")).hexdigest(),
|
||||
)
|
||||
|
||||
results = knowledge.search(
|
||||
"sharedphrase",
|
||||
user_id="local-user",
|
||||
workspace_path=self.workspace,
|
||||
limit=100,
|
||||
)
|
||||
|
||||
self.assertEqual(len(results), knowledge.MAX_SEARCH_RESULTS)
|
||||
for path in {str(item["path"]) for item in results}:
|
||||
self.assertLessEqual(
|
||||
sum(item["path"] == path for item in results),
|
||||
knowledge.MAX_CHUNKS_PER_DOCUMENT,
|
||||
)
|
||||
|
||||
def test_chunking_preserves_overlap_for_boundary_context(self) -> None:
|
||||
text = "a" * (knowledge.CHUNK_SIZE - 2) + " boundaryphrase " + "b" * 80
|
||||
chunks = knowledge._chunks(text)
|
||||
|
||||
Reference in New Issue
Block a user