Coverage for backend/django/diagnostics/schemas.py: 100%
18 statements
« prev ^ index » next coverage.py v7.10.7, created at 2026-02-12 01:47 +0000
« prev ^ index » next coverage.py v7.10.7, created at 2026-02-12 01:47 +0000
1"""
2Shared Pydantic schemas for the diagnostics module.
4These models define the JSON shapes we persist (DiagnosticRun.summary) and return
5to the frontend. Keeping them here avoids drifting "finding" definitions across:
6- rules engine output (RuleFinding)
7- orchestrator findings (bounds, blocked reasons, etc.)
8"""
10from __future__ import annotations
12from typing import Literal
14from pydantic import BaseModel, JsonValue
16# Severity levels expected by the frontend.
17Severity = Literal["error", "warning", "info", "suggestion"]
20class DiagnosticsFinding(BaseModel):
21 """
22 A single diagnostics finding in the shape the UI expects.
24 Notes:
25 - This is intentionally permissive: different finding sources attach different
26 subsets of fields (rules engine vs IDAES bounds vs orchestration errors).
27 """
29 id: str | None = None
30 severity: Severity = "info"
31 title: str
32 description: str
33 ruleReference: str | None = None
35 componentName: str | None = None
36 componentId: int | None = None
37 propertyKey: str | None = None
38 propertyId: int | None = None
40 suggestedFix: str | None = None
41 suggestedValue: float | None = None
42 fixAction: JsonValue | None = None
44 ignored: bool | None = None