Coverage for backend/django/diagnostics/constants.py: 100%
17 statements
« prev ^ index » next coverage.py v7.10.7, created at 2026-02-11 21:43 +0000
« prev ^ index » next coverage.py v7.10.7, created at 2026-02-11 21:43 +0000
1"""Constants for diagnostics module using StrEnum for better IDE support."""
3from django.db import models
6class DiagnosticRunStatus(models.TextChoices):
7 """Status values for DiagnosticRun model."""
9 CREATED = "CREATED"
10 COLLECTING = "COLLECTING" # Reserved for future async data gathering
11 GATING = "GATING"
12 # LLM_TRIAGE = "LLM_TRIAGE" # Reserved for future LLM-based triage feature
13 SUMMARISING = "SUMMARISING"
14 COMPLETE = "COMPLETE"
15 FAILED = "FAILED"
16 BLOCKED = "BLOCKED"
19# Tuple accessors for backward compatibility
20TERMINAL_STATES = (DiagnosticRunStatus.COMPLETE, DiagnosticRunStatus.FAILED, DiagnosticRunStatus.BLOCKED)
21IN_PROGRESS_STATES = (
22 DiagnosticRunStatus.COLLECTING,
23 DiagnosticRunStatus.GATING,
24 # DiagnosticRunStatus.LLM_TRIAGE, # Reserved for future use
25 DiagnosticRunStatus.SUMMARISING,
26)
29class DiagnosticTrigger(models.TextChoices):
30 """Trigger types for diagnostic runs."""
32 SOLVE_FAILURE = "solve_failure"
33 MANUAL = "manual"
34 PRE_SOLVE = "pre_solve"
36# Summary truncation limits
37# These caps keep the DiagnosticRun.summary JSON bounded for DB storage and UI payload size.
38# Full details remain available in events/logs, but the summary provides enough evidence
39# to show diagnostic patterns without bloating the stored snapshot.
40#
41# MAX_VARIABLES_OUTSIDE_BOUNDS_IN_SUMMARY (50):
42# Applied when storing the summary in DiagnosticRun.summary field.
43# This is what the UI fetches and displays. 50 variables is enough to reveal patterns
44# (e.g., "many variables are outside bounds") without bloating the DB or API payloads.
45#
46# MAX_VARIABLES_OUTSIDE_BOUNDS_IN_RULESET_DATA (25):
47# Applied when storing variables in individual ruleset event payloads.
48# Events are primarily for debugging and detailed "evidence trails", not for showing
49# every single item. The more conservative limit (25) keeps event payloads smaller
50# since there can be many events per run, while the summary is a single document.
51#
52# These are heuristics, not hard technical constraints. If users frequently need to see
53# more variables, these values can be adjusted based on real-world usage patterns.
54MAX_VARIABLES_OUTSIDE_BOUNDS_IN_SUMMARY = 50
55MAX_VARIABLES_OUTSIDE_BOUNDS_IN_RULESET_DATA = 25