generated from coulomb/repo-seed
optional semantic retrieval
This commit is contained in:
@@ -3,6 +3,7 @@ import subprocess
|
||||
from repo_registry.core.service import RegistryService
|
||||
from repo_registry.llm_extraction import ExtractedAbility, ExtractedCapability
|
||||
from repo_registry.repo_ingestion.git import GitIngestionService
|
||||
from repo_registry.semantic import HashingEmbeddingProvider
|
||||
from repo_registry.storage.sqlite import NotFoundError, RegistryStore
|
||||
|
||||
|
||||
@@ -290,6 +291,60 @@ def test_search_filters_by_status_language_and_framework(tmp_path):
|
||||
assert wrong_capability_results == []
|
||||
|
||||
|
||||
def test_semantic_search_adds_hybrid_matches_without_changing_text_default(tmp_path):
|
||||
source = tmp_path / "repo"
|
||||
source.mkdir()
|
||||
(source / "README.md").write_text(
|
||||
"# Queue Worker\n\nHandles postponed customer jobs.\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
text_service = make_service(tmp_path)
|
||||
repository = text_service.register_repository(
|
||||
name="Queue Worker",
|
||||
url=str(source),
|
||||
description="Processes deferred customer work.",
|
||||
)
|
||||
ability_id = text_service.add_ability(
|
||||
repository.id,
|
||||
name="Background Job Processing",
|
||||
description="Run deferred work outside request handling.",
|
||||
confidence=0.8,
|
||||
)
|
||||
capability_id = text_service.add_capability(
|
||||
repository.id,
|
||||
ability_id,
|
||||
name="Process Customer Tasks",
|
||||
description="Execute queued customer tasks asynchronously.",
|
||||
confidence=0.7,
|
||||
)
|
||||
text_service.add_feature(
|
||||
repository.id,
|
||||
capability_id,
|
||||
name="worker task loop",
|
||||
type="background worker",
|
||||
location="worker.py",
|
||||
confidence=0.6,
|
||||
)
|
||||
text_service.analyze_repository(repository.id)
|
||||
|
||||
assert text_service.search("customer queued") == []
|
||||
|
||||
semantic_service = RegistryService(
|
||||
text_service.store,
|
||||
ingestion=GitIngestionService(tmp_path / "checkouts"),
|
||||
embedding_provider=HashingEmbeddingProvider(),
|
||||
)
|
||||
results = semantic_service.search("customer queued")
|
||||
|
||||
assert results
|
||||
assert results[0].match_type in {"capability", "content_chunk"}
|
||||
assert results[0].matched_field == "semantic"
|
||||
assert results[0].vector_score > 0
|
||||
assert results[0].hybrid_score >= results[0].vector_score * 0.35
|
||||
assert any(result.match_type == "content_chunk" for result in results)
|
||||
|
||||
|
||||
def test_register_repository_imports_metadata_when_name_is_omitted(tmp_path):
|
||||
source = tmp_path / "metadata-source"
|
||||
source.mkdir()
|
||||
|
||||
Reference in New Issue
Block a user