Classes
CheckStatus
Status of a health check.
Severity levels (from most to least critical):
- ERROR: Blocks builds, m…
CheckStatus
Status of a health check.
Severity levels (from most to least critical):
- ERROR: Blocks builds, must fix
- WARNING: Don't block, but should fix
- SUGGESTION: Quality improvements (collapsed by default)
- INFO: Contextual information (hidden unless verbose)
- SUCCESS: Check passed
Enum
CheckResult
dataclass
Result of a single health check.
CheckResult
dataclass Result of a single health check.
Attributes
| Name | Type | Description |
|---|---|---|
status |
CheckStatus |
Status level (success, info, warning, error) |
message |
str |
Human-readable description of the check result |
recommendation |
str | None |
Optional suggestion for how to fix/improve (shown for warnings/errors) |
details |
list[str] | None |
Optional additional context (list of strings) |
validator |
str |
Name of validator that produced this result |
metadata |
dict[str, Any] | None |
Methods 9
success
classmethod
Create a success result.
success
classmethod def success(cls, message: str, validator: str = '') -> CheckResult
Create a success result.
Parameters 2
message |
str |
|
validator |
str |
Returns
CheckResult
info
classmethod
Create an info result.
info
classmethod def info(cls, message: str, recommendation: str | None = None, details: list[str] | None = None, validator: str = '', metadata: dict[str, Any] | None = None) -> CheckResult
Create an info result.
Parameters 5
message |
str |
|
recommendation |
str | None |
|
details |
list[str] | None |
|
validator |
str |
|
metadata |
dict[str, Any] | None |
Returns
CheckResult
suggestion
classmethod
Create a suggestion result (quality improvement, not a problem).
suggestion
classmethod def suggestion(cls, message: str, recommendation: str | None = None, details: list[str] | None = None, validator: str = '', metadata: dict[str, Any] | None = None) -> CheckResult
Create a suggestion result (quality improvement, not a problem).
Parameters 5
message |
str |
|
recommendation |
str | None |
|
details |
list[str] | None |
|
validator |
str |
|
metadata |
dict[str, Any] | None |
Returns
CheckResult
warning
classmethod
Create a warning result.
warning
classmethod def warning(cls, message: str, recommendation: str | None = None, details: list[str] | None = None, validator: str = '', metadata: dict[str, Any] | None = None) -> CheckResult
Create a warning result.
Parameters 5
message |
str |
|
recommendation |
str | None |
|
details |
list[str] | None |
|
validator |
str |
|
metadata |
dict[str, Any] | None |
Returns
CheckResult
error
classmethod
Create an error result.
error
classmethod def error(cls, message: str, recommendation: str | None = None, details: list[str] | None = None, validator: str = '', metadata: dict[str, Any] | None = None) -> CheckResult
Create an error result.
Parameters 5
message |
str |
|
recommendation |
str | None |
|
details |
list[str] | None |
|
validator |
str |
|
metadata |
dict[str, Any] | None |
Returns
CheckResult
is_problem
Check if this is a warning or error (vs success/info/suggestion).
is_problem
def is_problem(self) -> bool
Check if this is a warning or error (vs success/info/suggestion).
Returns
bool
is_actionable
Check if this requires action (error, warning, or suggestion).
is_actionable
def is_actionable(self) -> bool
Check if this requires action (error, warning, or suggestion).
Returns
bool
to_cache_dict
Serialize CheckResult to JSON-serializable dict for caching.
to_cache_dict
def to_cache_dict(self) -> dict[str, Any]
Serialize CheckResult to JSON-serializable dict for caching.
Returns
Dictionary with all fields as JSON-serializable typesdict[str, Any]
—
from_cache_dict
classmethod
Deserialize CheckResult from cached dict.
from_cache_dict
classmethod def from_cache_dict(cls, data: dict[str, Any]) -> CheckResult
Deserialize CheckResult from cached dict.
Parameters 1
data |
dict[str, Any] |
Dictionary from cache |
Returns
CheckResult instanceCheckResult
—
ValidatorStats
dataclass
Observability metrics for a validator run.
These stats help diagnose performance issues and valida…
ValidatorStats
dataclass Observability metrics for a validator run.
These stats help diagnose performance issues and validate that optimizations (like caching) are working correctly.
This class follows the ComponentStats pattern from bengal.utils.observability but maintains page-specific naming for validator contexts.
Attributes
| Name | Type | Description |
|---|---|---|
pages_total |
int |
Total pages in site |
pages_processed |
int |
Pages actually validated |
pages_skipped |
dict[str, int] |
Dict of skip reasons and counts |
cache_hits |
int |
Number of cache hits (if applicable) |
cache_misses |
int |
Number of cache misses (if applicable) |
sub_timings |
dict[str, float] |
Dict of sub-operation names to duration_ms |
metrics |
dict[str, int | float | str] |
Custom metrics (component-specific) |
Methods 5
cache_hit_rate
property
Cache hit rate as percentage (0-100).
cache_hit_rate
property def cache_hit_rate(self) -> float
Cache hit rate as percentage (0-100).
Returns
float
skip_rate
property
Skip rate as percentage (0-100).
skip_rate
property def skip_rate(self) -> float
Skip rate as percentage (0-100).
Returns
float
total_skipped
property
Total number of skipped items across all reasons.
total_skipped
property def total_skipped(self) -> int
Total number of skipped items across all reasons.
Returns
int
format_summary
Format stats for debug output.
format_summary
def format_summary(self) -> str
Format stats for debug output.
Returns
str
to_log_context
Convert to flat dict for structured logging.
to_log_context
def to_log_context(self) -> dict[str, int | float | str]
Convert to flat dict for structured logging.
Returns
Flat dictionary suitable for structured logging kwargs.dict[str, int | float | str]
—
ValidatorReport
dataclass
Report for a single validator's checks.
ValidatorReport
dataclass Report for a single validator's checks.
Attributes
| Name | Type | Description |
|---|---|---|
validator_name |
str |
Name of the validator |
results |
list[CheckResult] |
List of check results from this validator |
duration_ms |
float |
How long the validator took to run |
stats |
ValidatorStats | None |
Optional observability metrics |
Methods 7
passed_count
property
Count of successful checks.
passed_count
property def passed_count(self) -> int
Count of successful checks.
Returns
int
info_count
property
Count of info messages.
info_count
property def info_count(self) -> int
Count of info messages.
Returns
int
warning_count
property
Count of warnings.
warning_count
property def warning_count(self) -> int
Count of warnings.
Returns
int
suggestion_count
property
Count of suggestions (quality improvements).
suggestion_count
property def suggestion_count(self) -> int
Count of suggestions (quality improvements).
Returns
int
error_count
property
Count of errors.
error_count
property def error_count(self) -> int
Count of errors.
Returns
int
has_problems
property
Check if this validator found any warnings or errors.
has_problems
property def has_problems(self) -> bool
Check if this validator found any warnings or errors.
Returns
bool
status_emoji
property
Get emoji representing overall status.
status_emoji
property def status_emoji(self) -> str
Get emoji representing overall status.
Returns
str
HealthReport
dataclass
Complete health check report for a build.
HealthReport
dataclass Complete health check report for a build.
Attributes
| Name | Type | Description |
|---|---|---|
validator_reports |
list[ValidatorReport] |
Reports from each validator |
timestamp |
datetime |
When the health check was run |
build_stats |
dict[str, Any] | None |
Optional build statistics |
Methods 13
total_passed
property
Total successful checks across all validators.
total_passed
property def total_passed(self) -> int
Total successful checks across all validators.
Returns
int
total_info
property
Total info messages across all validators.
total_info
property def total_info(self) -> int
Total info messages across all validators.
Returns
int
total_warnings
property
Total warnings across all validators.
total_warnings
property def total_warnings(self) -> int
Total warnings across all validators.
Returns
int
total_suggestions
property
Total suggestions (quality improvements) across all validators.
total_suggestions
property def total_suggestions(self) -> int
Total suggestions (quality improvements) across all validators.
Returns
int
total_errors
property
Total errors across all validators.
total_errors
property def total_errors(self) -> int
Total errors across all validators.
Returns
int
total_checks
property
Total number of checks run.
total_checks
property def total_checks(self) -> int
Total number of checks run.
Returns
int
has_errors
Check if any errors were found.
has_errors
def has_errors(self) -> bool
Check if any errors were found.
Returns
bool
has_warnings
Check if any warnings were found.
has_warnings
def has_warnings(self) -> bool
Check if any warnings were found.
Returns
bool
has_problems
Check if any errors or warnings were found.
has_problems
def has_problems(self) -> bool
Check if any errors or warnings were found.
Returns
bool
build_quality_score
Calculate build quality score (0-100).
Uses a penalty-based system where:
- Ba…
build_quality_score
def build_quality_score(self) -> int
Calculate build quality score (0-100).
Uses a penalty-based system where:
- Base score is 100 (no problems = perfect)
- Errors subtract significantly (blockers)
- Warnings subtract moderately (should fix)
- Diminishing returns prevent extreme scores for many small issues
This ensures same problems always give the same score, regardless of how many checks ran.
Returns
Score from 0-100 (100 = perfect)int
—
quality_rating
Get quality rating based on score.
Thresholds aligned with penalty-based scori…
quality_rating
def quality_rating(self) -> str
Get quality rating based on score.
Thresholds aligned with penalty-based scoring:
- Excellent (90+): No errors, 0-2 warnings
- Good (75-89): 1 error or 3-5 warnings
- Fair (50-74): 2-3 errors or many warnings
- Needs Improvement (<50): 4+ errors
Returns
str
format_console
Format report for console output.
format_console
def format_console(self, mode: str = 'auto', verbose: bool = False, show_suggestions: bool = False) -> str
Format report for console output.
Parameters 3
mode |
str |
Display mode - "auto", "quiet", "normal", "verbose" auto = quiet if no problems, normal if warnings/errors |
verbose |
bool |
Legacy parameter, sets mode to "verbose" |
show_suggestions |
bool |
Whether to show suggestions (quality improvements) |
Returns
Formatted string ready to printstr
—
format_json
Format report as JSON-serializable dictionary.
format_json
def format_json(self) -> dict[str, Any]
Format report as JSON-serializable dictionary.
Returns
Dictionary suitable for json.dumps()dict[str, Any]
—
Internal Methods 3
_format_quiet
Minimal output - perfect builds get one line, problems shown clearly.
_format_quiet
def _format_quiet(self, show_suggestions: bool = False) -> str
Minimal output - perfect builds get one line, problems shown clearly.
Parameters 1
show_suggestions |
bool |
Whether to show suggestions (ignored in quiet mode) |
Returns
str
_format_normal
Balanced output with progressive disclosure - problems first, then successes.
R…
_format_normal
def _format_normal(self, show_suggestions: bool = False) -> str
Balanced output with progressive disclosure - problems first, then successes. Reduces cognitive load by prioritizing actionable information.
Parameters 1
show_suggestions |
bool |
Whether to show suggestions (collapsed by default) |
Returns
str
_format_verbose
Full audit trail with progressive disclosure - problems first, then all details.
_format_verbose
def _format_verbose(self, show_suggestions: bool = True) -> str
Full audit trail with progressive disclosure - problems first, then all details.
Parameters 1
show_suggestions |
bool |
Whether to show suggestions (default True in verbose mode) |
Returns
str