Source code for structum_lab.plugins.bootstrap.core

# src/structum_lab/plugins/bootstrap/core.py
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: 2025 PythonWoods

"""Core implementation of the bootstrap validation context.

This module provides the concrete implementation of the ValidationContext
protocol, used to collect and report validation results during bootstrap.
"""


[docs] class BootstrapContextImpl: """Implementation of ValidationContext."""
[docs] def __init__(self) -> None: """Initialize an empty validation context.""" self.checks_passed: dict[str, bool] = {} self.check_results: dict[str, str] = {} self.errors: list[str] = [] self.warnings: list[str] = []
[docs] def add_check(self, name: str, passed: bool, message: str = "") -> None: """Record a validation check result.""" self.checks_passed[name] = passed if message: self.check_results[name] = message if not passed: self.errors.append(f"{name}: {message}")
[docs] def add_warning(self, message: str) -> None: """Add a non-fatal warning.""" self.warnings.append(message)
[docs] def is_valid(self) -> bool: """Check if all validations passed.""" return all(self.checks_passed.values())