Coverage for src/domain/validation/result.py: 81%

1"""Validation result types.

2

3 These are used by SpecValidationRunner to return validation outcomes.

4"""

5

6 from __future__ import annotations

7

8 from dataclasses import dataclass, field

9 from typing import TYPE_CHECKING

10

11 if TYPE_CHECKING:

12 from .coverage import CoverageResult

13 from .e2e import E2EResult

14 from .spec import ValidationArtifacts

15

16

17@dataclass

18 class ValidationStepResult:

19 """Result of a single validation step."""

20

21 name: str

22 command: str

23 ok: bool

24 returncode: int

25 stdout_tail: str = ""

26 stderr_tail: str = ""

27 duration_seconds: float = 0.0

28

29

30@dataclass

31 class ValidationResult:

32 """Result of a validation run."""

33

34 passed: bool

35 steps: list[ValidationStepResult] = field(default_factory=list)

36 failure_reasons: list[str] = field(default_factory=list)

37 retriable: bool = True

38 artifacts: ValidationArtifacts | None = None

39 coverage_result: CoverageResult | None = None

40 e2e_result: E2EResult | None = None # E2E result if E2E was executed

41

42 def short_summary(self) -> str:

43 """One-line summary for logs/prompts."""

44 if self.passed:

45 return "passed"

46 if not self.failure_reasons:

47 return "failed"

48 return "; ".join(self.failure_reasons)