Skip to content

base

base

Base types and protocols for the validation system.

Defines the core abstractions: - ValidationSeverity: Error/Warning/Info classification - ValidationIssue: A single issue found during validation - ValidationCheck: Protocol for implementing validation checks

Classes

ValidationSeverity

Bases: str, Enum

Severity level for validation issues.

  • ERROR: Must fix before execution - job will fail
  • WARNING: Should fix - may cause runtime failures
  • INFO: Informational - consider reviewing

ValidationIssue dataclass

ValidationIssue(check_id, severity, message, line=None, column=None, context=None, suggestion=None, auto_fixable=False, metadata=dict())

A single validation issue found in the configuration.

Attributes:

Name Type Description
check_id str

Unique identifier for the check (e.g., V001, V101)

severity ValidationSeverity

ERROR, WARNING, or INFO

message str

Human-readable description of the issue

line int | None

Line number in config file (if applicable)

column int | None

Column number (if applicable)

context str | None

Surrounding text for context

suggestion str | None

How to fix the issue

auto_fixable bool

Whether --self-healing can automatically fix this

Functions
format_short
format_short()

Format as a single-line summary.

Source code in src/marianne/validation/base.py
def format_short(self) -> str:
    """Format as a single-line summary."""
    loc = f"Line {self.line}: " if self.line else ""
    return f"[{self.check_id}] {loc}{self.message}"
format_full
format_full()

Format with full details including suggestion.

Source code in src/marianne/validation/base.py
def format_full(self) -> str:
    """Format with full details including suggestion."""
    lines = [self.format_short()]
    if self.context:
        lines.append(f"         Context: {self.context}")
    if self.suggestion:
        lines.append(f"         Suggestion: {self.suggestion}")
    return "\n".join(lines)

ValidationCheck

Bases: Protocol

Protocol for configuration validation checks.

Each check examines a specific aspect of the configuration and returns a list of ValidationIssue objects (empty if check passes).

Checks should be: - Idempotent (safe to run multiple times) - Side-effect free (don't modify anything) - Fast (validation should complete quickly)

Attributes
check_id property
check_id

Unique identifier for this check (e.g., V001).

severity property
severity

Default severity for issues from this check.

description property
description

Human-readable description of what this check does.

Functions
check
check(config, config_path, raw_yaml)

Run the validation check.

Parameters:

Name Type Description Default
config JobConfig

Parsed JobConfig object (already validated by Pydantic)

required
config_path Path

Path to the config file (for resolving relative paths)

required
raw_yaml str

Raw YAML text (for line number extraction)

required

Returns:

Type Description
list[ValidationIssue]

List of ValidationIssue objects (empty if check passes)

Source code in src/marianne/validation/base.py
def check(
    self,
    config: "JobConfig",
    config_path: Path,
    raw_yaml: str,
) -> list[ValidationIssue]:
    """Run the validation check.

    Args:
        config: Parsed JobConfig object (already validated by Pydantic)
        config_path: Path to the config file (for resolving relative paths)
        raw_yaml: Raw YAML text (for line number extraction)

    Returns:
        List of ValidationIssue objects (empty if check passes)
    """
    ...