File size: 1,425 Bytes
4b445f6
 
 
 
b9da50c
4b445f6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b9da50c
4b445f6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"""Core data models for agent findings and PR reviews."""

from __future__ import annotations

from typing import Literal
from uuid import UUID, uuid4

from pydantic import BaseModel, Field


class Finding(BaseModel):
    """A single finding produced by a domain agent."""

    agent: Literal["security", "performance", "style"]
    file_path: str
    line_start: int
    line_end: int
    severity: Literal["critical", "high", "medium", "low"]
    category: str
    title: str
    description: str
    suggested_fix: str = ""
    cwe_id: str | None = None
    confidence: float = Field(ge=0.0, le=1.0)


class SynthesizedReview(BaseModel):
    """Final synthesized review output from the Synthesizer Agent."""

    health_score: int = Field(ge=0, le=100)
    executive_summary: str
    recommendation: Literal["approve", "request_changes", "block"]
    findings: list[Finding]
    critical_count: int = 0
    high_count: int = 0
    medium_count: int = 0
    low_count: int = 0
    duration_ms: int = 0


class PRReviewRecord(BaseModel):
    """Database record for a completed PR review."""

    id: UUID = Field(default_factory=uuid4)
    repo_full_name: str
    pr_number: int
    commit_sha: str
    health_score: int = Field(ge=0, le=100)
    critical_count: int = 0
    high_count: int = 0
    medium_count: int = 0
    low_count: int = 0
    summary: str = ""
    findings: list[Finding] = []
    duration_ms: int = 0