from __future__ import annotations from django.db import models from control_plane.common import TimestampedModel class VerificationLevel(models.TextChoices): TASK = "TASK" MILESTONE = "MILESTONE" PROJECT = "PROJECT" class VerificationResult(models.TextChoices): PASS = "PASS" FAIL = "FAIL" BLOCKED = "BLOCKED" class TestRun(TimestampedModel): project = models.ForeignKey("projects.Project", on_delete=models.CASCADE, related_name="test_runs") task = models.ForeignKey("projects.Task", on_delete=models.SET_NULL, null=True, blank=True, related_name="test_runs") command = models.TextField() status = models.CharField(max_length=32) output_artifact = models.ForeignKey("projects.Artifact", on_delete=models.SET_NULL, null=True, blank=True) duration_seconds = models.FloatField(default=0) class Review(TimestampedModel): task = models.ForeignKey("projects.Task", on_delete=models.CASCADE, related_name="reviews") reviewer = models.ForeignKey("agents.AgentVersion", on_delete=models.PROTECT, related_name="reviews") status = models.CharField(max_length=32) findings = models.JSONField(default=list, blank=True) summary = models.TextField(blank=True) class Verification(TimestampedModel): project = models.ForeignKey("projects.Project", on_delete=models.CASCADE, related_name="verifications") task = models.ForeignKey("projects.Task", on_delete=models.SET_NULL, null=True, blank=True) milestone = models.ForeignKey("projects.Milestone", on_delete=models.SET_NULL, null=True, blank=True) level = models.CharField(max_length=32, choices=VerificationLevel.choices) judge = models.ForeignKey("agents.AgentVersion", on_delete=models.PROTECT, null=True, blank=True) result = models.CharField(max_length=32, choices=VerificationResult.choices) contract = models.JSONField(default=dict, blank=True) evidence = models.JSONField(default=list, blank=True) summary = models.TextField(blank=True)