Module

cache.build_cache.validation_cache

Validation result caching mixin for BuildCache.

Provides methods for caching and retrieving health check validation results. Used as a mixin by the main BuildCache class.

Key Concepts:

  • Caches CheckResult objects per file and validator
  • Invalidates when file content changes
  • Supports partial invalidation (single file or all)

Related Modules:

  • bengal.cache.build_cache.core: Main BuildCache class
  • bengal.health.report: CheckResult dataclass
  • bengal.health.health_check: Health check runner

Classes

ValidationCacheMixin
Mixin providing validation result caching. Requires these attributes on the host class: - vali…
4

Mixin providing validation result caching.

Requires these attributes on the host class:

  • validation_results: dict[str, dict[str, list[dict[str, Any]]]]
  • is_changed: Callable[[Path], bool] (from FileTrackingMixin)

Attributes

Name Type Description
validation_results dict[str, dict[str, list[dict[str, Any]]]]

Methods 4

is_changed
Check if file changed (provided by FileTrackingMixin).
1 bool
def is_changed(self, file_path: Path) -> bool

Check if file changed (provided by FileTrackingMixin).

Parameters 1
file_path Path
Returns

bool

get_cached_validation_results
Get cached validation results for a file and validator.
2 list[dict[str, Any]…
def get_cached_validation_results(self, file_path: Path, validator_name: str) -> list[dict[str, Any]] | None

Get cached validation results for a file and validator.

Parameters 2
file_path Path

Path to file

validator_name str

Name of validator

Returns

list[dict[str, Any]] | None

List of CheckResult dicts if cached and file unchanged, None otherwise

cache_validation_results
Cache validation results for a file and validator.
3 None
def cache_validation_results(self, file_path: Path, validator_name: str, results: list[Any]) -> None

Cache validation results for a file and validator.

Parameters 3
file_path Path

Path to file

validator_name str

Name of validator

results list[Any]

List of CheckResult objects to cache

invalidate_validation_results
Invalidate validation results for a file or all files.
1 None
def invalidate_validation_results(self, file_path: Path | None = None) -> None

Invalidate validation results for a file or all files.

Parameters 1
file_path Path | None

Path to file (if None, invalidate all)