37 lines
1.4 KiB
Python
37 lines
1.4 KiB
Python
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass
|
|
|
|
from control_plane.agents.models import AgentVersion
|
|
from control_plane.projects.models import Task
|
|
from control_plane.verification.models import Review
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class ReviewDecision:
|
|
status: str
|
|
findings: list[dict[str, object]]
|
|
summary: str
|
|
|
|
|
|
class Reviewer:
|
|
def review(self, task: Task, reviewer: AgentVersion, diff: str, test_status: str) -> Review:
|
|
findings: list[dict[str, object]] = []
|
|
status = "PASS"
|
|
if test_status != "PASS":
|
|
status = "REWORK_REQUIRED"
|
|
findings.append({"type": "tests_failed", "severity": "high", "message": "Deterministic tests failed"})
|
|
if not diff.strip():
|
|
status = "REJECTED"
|
|
findings.append({"type": "empty_diff", "severity": "high", "message": "No implementation diff exists"})
|
|
if "health" in task.goal.lower() and "/health" not in diff and "path('health'" not in diff and 'path("health"' not in diff:
|
|
status = "REWORK_REQUIRED"
|
|
findings.append({"type": "missing_health_route", "severity": "high", "message": "Diff does not add /health"})
|
|
review = Review.objects.create(
|
|
task=task,
|
|
reviewer=reviewer,
|
|
status=status,
|
|
findings=findings,
|
|
summary="Implementation quality accepted" if status == "PASS" else "Reviewer requested rework",
|
|
)
|
|
return review
|