generated from coulomb/repo-seed
Validate structured agentic review decisions
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
import pytest
|
||||
|
||||
from repo_registry.acceptance import (
|
||||
AgenticReviewDecision,
|
||||
validate_agentic_review_decision,
|
||||
)
|
||||
from repo_registry.core.service import RegistryService
|
||||
from repo_registry.repo_ingestion.git import GitIngestionService
|
||||
from repo_registry.storage.sqlite import RegistryStore
|
||||
@@ -12,6 +18,29 @@ class RecordingAgenticReviewer:
|
||||
|
||||
def review(self, request):
|
||||
self.requests.append(request)
|
||||
return []
|
||||
|
||||
|
||||
class ApprovingAgenticReviewer:
|
||||
reviewer_id = "approving-agent"
|
||||
policy_version = "agentic-review-policy/test"
|
||||
|
||||
def __init__(self):
|
||||
self.requests = []
|
||||
|
||||
def review(self, request):
|
||||
self.requests.append(request)
|
||||
graph = request.candidate_graph
|
||||
return [
|
||||
AgenticReviewDecision(
|
||||
action="approve",
|
||||
target_type="candidate_graph",
|
||||
target_id=graph.analysis_run.id,
|
||||
rationale="API source and README support the generated repository interface claim.",
|
||||
criterion_ids=["RREG-QC-004"],
|
||||
evidence_refs=["README.md", "app.py"],
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
def test_configured_agentic_reviewer_receives_graph_gates_and_criteria(tmp_path):
|
||||
@@ -46,3 +75,58 @@ def test_configured_agentic_reviewer_receives_graph_gates_and_criteria(tmp_path)
|
||||
assert graph.abilities[0].capabilities[0].status == "candidate"
|
||||
assert decisions[0].action == "agentic_review_completed"
|
||||
assert "reviewer=test-agent" in decisions[0].notes
|
||||
assert "decisions=0" in decisions[0].notes
|
||||
|
||||
|
||||
def test_agentic_approval_requires_rationale_criteria_and_evidence():
|
||||
with pytest.raises(ValueError, match="evidence refs"):
|
||||
validate_agentic_review_decision(
|
||||
AgenticReviewDecision(
|
||||
action="approve",
|
||||
target_type="candidate_graph",
|
||||
target_id=1,
|
||||
rationale="Looks supported.",
|
||||
criterion_ids=["RREG-QC-004"],
|
||||
evidence_refs=[],
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def test_agentic_reviewer_can_approve_candidate_graph_with_rationale(tmp_path):
|
||||
source = tmp_path / "repo"
|
||||
source.mkdir()
|
||||
(source / "README.md").write_text(
|
||||
"# Agentic Approval\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 = ApprovingAgenticReviewer()
|
||||
service = RegistryService(
|
||||
store,
|
||||
ingestion=GitIngestionService(tmp_path / "checkouts"),
|
||||
agentic_reviewer=reviewer,
|
||||
)
|
||||
repository = service.register_repository(name="Agentic Approval", url=str(source))
|
||||
|
||||
summary = service.analyze_repository(
|
||||
repository.id,
|
||||
use_llm_assistance=False,
|
||||
agentic_review=True,
|
||||
)
|
||||
|
||||
ability_map = service.ability_map(repository.id)
|
||||
graph = service.candidate_graph(repository.id, summary.analysis_run.id)
|
||||
decisions = service.list_review_decisions(repository.id, summary.analysis_run.id)
|
||||
assert ability_map.abilities
|
||||
assert graph.abilities[0].status == "approved"
|
||||
assert decisions[1].action == "agentic_approve_candidate_graph"
|
||||
assert "rationale=API source and README support" in decisions[1].notes
|
||||
assert "criteria=RREG-QC-004" in decisions[1].notes
|
||||
assert "evidence=README.md, app.py" in decisions[1].notes
|
||||
assert decisions[0].action == "agentic_review_completed"
|
||||
assert "decisions=1" in decisions[0].notes
|
||||
|
||||
Reference in New Issue
Block a user