generated from coulomb/repo-seed
Route auto review requests to agentic review
This commit is contained in:
48
tests/test_agentic_review.py
Normal file
48
tests/test_agentic_review.py
Normal file
@@ -0,0 +1,48 @@
|
||||
from repo_registry.core.service import RegistryService
|
||||
from repo_registry.repo_ingestion.git import GitIngestionService
|
||||
from repo_registry.storage.sqlite import RegistryStore
|
||||
|
||||
|
||||
class RecordingAgenticReviewer:
|
||||
reviewer_id = "test-agent"
|
||||
policy_version = "agentic-review-policy/test"
|
||||
|
||||
def __init__(self):
|
||||
self.requests = []
|
||||
|
||||
def review(self, request):
|
||||
self.requests.append(request)
|
||||
|
||||
|
||||
def test_configured_agentic_reviewer_receives_graph_gates_and_criteria(tmp_path):
|
||||
source = tmp_path / "repo"
|
||||
source.mkdir()
|
||||
(source / "README.md").write_text("# Agentic Review\nReports health.\n", encoding="utf-8")
|
||||
(source / "app.py").write_text('@app.get("/health")\ndef health():\n return {}\n', encoding="utf-8")
|
||||
store = RegistryStore(tmp_path / "registry.sqlite3")
|
||||
store.initialize()
|
||||
reviewer = RecordingAgenticReviewer()
|
||||
service = RegistryService(
|
||||
store,
|
||||
ingestion=GitIngestionService(tmp_path / "checkouts"),
|
||||
agentic_reviewer=reviewer,
|
||||
)
|
||||
repository = service.register_repository(name="Agentic Review", url=str(source))
|
||||
|
||||
summary = service.analyze_repository(
|
||||
repository.id,
|
||||
use_llm_assistance=False,
|
||||
agentic_review=True,
|
||||
)
|
||||
|
||||
graph = service.candidate_graph(repository.id, summary.analysis_run.id)
|
||||
decisions = service.list_review_decisions(repository.id, summary.analysis_run.id)
|
||||
assert len(reviewer.requests) == 1
|
||||
request = reviewer.requests[0]
|
||||
assert request.repository.id == repository.id
|
||||
assert request.candidate_graph.analysis_run.id == summary.analysis_run.id
|
||||
assert request.criteria_version == "repo-scoping-quality-criteria/v1"
|
||||
assert request.quality_gate_outcomes == []
|
||||
assert graph.abilities[0].capabilities[0].status == "candidate"
|
||||
assert decisions[0].action == "agentic_review_completed"
|
||||
assert "reviewer=test-agent" in decisions[0].notes
|
||||
@@ -1337,7 +1337,7 @@ def test_analyze_repository_falls_back_when_optional_llm_extractor_returns_no_ca
|
||||
assert graph.abilities[0].name == "Support Fallback"
|
||||
|
||||
|
||||
def test_analyze_repository_can_trusted_auto_approve_candidates(tmp_path):
|
||||
def test_analyze_repository_routes_legacy_auto_approve_to_agentic_review(tmp_path):
|
||||
source = tmp_path / "repo"
|
||||
source.mkdir()
|
||||
(source / "README.md").write_text(
|
||||
@@ -1364,20 +1364,17 @@ def test_analyze_repository_can_trusted_auto_approve_candidates(tmp_path):
|
||||
graph = service.candidate_graph(repository.id, summary.analysis_run.id)
|
||||
decisions = service.list_review_decisions(repository.id, summary.analysis_run.id)
|
||||
|
||||
assert service.get_repository(repository.id).status == "indexed"
|
||||
assert service.get_repository(repository.id).status == "analyzed"
|
||||
statuses_by_capability = {
|
||||
capability.name: capability.status
|
||||
for capability in graph.abilities[0].capabilities
|
||||
}
|
||||
assert statuses_by_capability["Expose Repository Interface"] == "approved"
|
||||
assert ability_map.abilities[0].name == "Report Health Over HTTP"
|
||||
assert decisions[0].action == "trusted_auto_approve_candidate_graph"
|
||||
assert statuses_by_capability["Expose Repository Interface"] == "candidate"
|
||||
assert ability_map.abilities == []
|
||||
assert decisions[0].action == "agentic_review_unconfigured"
|
||||
assert "deterministic candidate generation" in decisions[0].notes
|
||||
assert "Auto-approved 1 safe candidate capability(s); left 0 for review." in decisions[0].notes
|
||||
assert (
|
||||
"Approved: Expose Repository Interface: owned interface with sufficient confidence."
|
||||
in decisions[0].notes
|
||||
)
|
||||
assert "Deprecated trusted_auto_approve request was routed" in decisions[0].notes
|
||||
assert "candidates remain pending human review" in decisions[0].notes
|
||||
|
||||
|
||||
def test_rebuild_characteristics_dry_run_preserves_approved_map(tmp_path):
|
||||
|
||||
@@ -1403,7 +1403,7 @@ def test_ui_register_analyze_and_approve_loop(tmp_path):
|
||||
assert "Password or access token" in index_response.text
|
||||
assert "Explore after registration" in index_response.text
|
||||
assert "Use LLM assistance if configured" in index_response.text
|
||||
assert "Trusted auto-populate after analysis" in index_response.text
|
||||
assert "Request agentic review after analysis" in index_response.text
|
||||
assert '<a href="/ui/scope">SCOPE</a>' not in index_response.text
|
||||
|
||||
create_response = client.post(
|
||||
@@ -1428,7 +1428,7 @@ def test_ui_register_analyze_and_approve_loop(tmp_path):
|
||||
assert "Running analysis..." in detail_response.text
|
||||
assert "Analyze cached checkout without fetching upstream" in detail_response.text
|
||||
assert "Use LLM assistance if configured" in detail_response.text
|
||||
assert "Trusted auto-populate after analysis" in detail_response.text
|
||||
assert "Request agentic review after analysis" in detail_response.text
|
||||
assert "Repository Metadata" in detail_response.text
|
||||
assert (
|
||||
f'<a class="button secondary" href="/ui/repos/{repository_id}/scope">SCOPE</a>'
|
||||
@@ -2081,7 +2081,7 @@ def test_ui_register_and_explore_lands_on_analysis_result(tmp_path):
|
||||
"access_password": "",
|
||||
"explore_after_registration": "1",
|
||||
"use_llm_assistance": "",
|
||||
"trusted_auto_approve": "1",
|
||||
"agentic_review": "1",
|
||||
},
|
||||
follow_redirects=False,
|
||||
)
|
||||
@@ -2092,9 +2092,9 @@ def test_ui_register_and_explore_lands_on_analysis_result(tmp_path):
|
||||
result = client.get(response.headers["location"])
|
||||
assert result.status_code == 200
|
||||
assert "Candidate Graph" in result.text
|
||||
assert "approved" in result.text
|
||||
assert "candidate" in result.text
|
||||
assert "Observed Facts" in result.text
|
||||
assert "trusted_auto_approve_candidate_graph" in result.text
|
||||
assert "agentic_review_unconfigured" in result.text
|
||||
|
||||
repository_detail = client.get("/ui/repos/1")
|
||||
assert repository_detail.status_code == 200
|
||||
|
||||
Reference in New Issue
Block a user