Skip to content

config

config

Configuration structure validation checks.

Validates configuration values like regex patterns, timeout ranges, validation rule completeness, and instrument name resolution.

Classes

RegexPatternCheck

Check that regex patterns in validations compile (V007).

Invalid regex patterns will cause runtime errors during validation.

Methods:
check
check(config, config_path, raw_yaml)

Check regex patterns in validations and rate limit detection.

Source code in src/marianne/validation/checks/config.py
def check(
    self,
    config: JobConfig,
    config_path: Path,
    raw_yaml: str,
) -> list[ValidationIssue]:
    """Check regex patterns in validations and rate limit detection."""
    issues: list[ValidationIssue] = []

    # Check validation rule patterns
    for i, validation in enumerate(config.validations):
        if validation.type == "content_regex" and validation.pattern:
            issue = self._check_pattern(
                validation.pattern,
                f"validation[{i}].pattern",
                self._find_pattern_line(raw_yaml, validation.pattern),
            )
            if issue:
                issues.append(issue)

    # Check rate limit detection patterns
    for i, pattern in enumerate(config.rate_limit.detection_patterns):
        issue = self._check_pattern(
            pattern,
            f"rate_limit.detection_patterns[{i}]",
            None,
        )
        if issue:
            issues.append(issue)

    return issues

ValidationTypeCheck

Check that validation rules have required fields (V008).

Ensures validations have the fields needed for their type.

Methods:
check
check(config, config_path, raw_yaml)

Check validation rules have required fields.

Source code in src/marianne/validation/checks/config.py
def check(
    self,
    config: JobConfig,
    config_path: Path,
    raw_yaml: str,
) -> list[ValidationIssue]:
    """Check validation rules have required fields."""
    issues: list[ValidationIssue] = []

    required_fields = {
        "file_exists": ["path"],
        "file_modified": ["path"],
        "content_contains": ["path", "pattern"],
        "content_regex": ["path", "pattern"],
        "command_succeeds": ["command"],
        "path_in_scope": ["path"],
        "field_match": ["path", "field_path"],
        "file_sha256": ["path", "sha256"],
        "csv_unique_key": ["path", "key_field"],
    }

    for i, validation in enumerate(config.validations):
        required = required_fields.get(validation.type, [])
        missing = []

        for field in required:
            value = getattr(validation, field, None)
            if value is None or (isinstance(value, str) and not value.strip()):
                missing.append(field)

        if missing:
            issues.append(
                ValidationIssue(
                    check_id=self.check_id,
                    severity=self.severity,
                    message=(
                        f"Validation rule {i + 1} ({validation.type})"
                        f" missing required fields: {', '.join(missing)}"
                    ),
                    suggestion=f"Add {', '.join(missing)} to the validation rule",
                    metadata={
                        "validation_index": str(i),
                        "validation_type": validation.type,
                        "missing_fields": ",".join(missing),
                    },
                )
            )

        if validation.type == "field_match" and not (
            validation.has_expected_value_literal or validation.source_path
        ):
            issues.append(
                ValidationIssue(
                    check_id=self.check_id,
                    severity=self.severity,
                    message=(
                        f"Validation rule {i + 1} (field_match) missing "
                        "comparison value: expected_value or source_path"
                    ),
                    suggestion="Add expected_value or source_path to the validation rule",
                    metadata={
                        "validation_index": str(i),
                        "validation_type": validation.type,
                        "missing_fields": "expected_value_or_source_path",
                    },
                )
            )

    return issues

TimeoutRangeCheck

Check timeout values are reasonable (V103/V104).

Warns about very short timeouts (may cause failures) or very long timeouts (may waste resources).

Methods:
check
check(config, config_path, raw_yaml)

Check timeout values.

Source code in src/marianne/validation/checks/config.py
def check(
    self,
    config: JobConfig,
    config_path: Path,
    raw_yaml: str,
) -> list[ValidationIssue]:
    """Check timeout values."""
    issues: list[ValidationIssue] = []

    raw_timeout = config.instrument_config.get("timeout_seconds")
    if raw_timeout is None:
        return issues
    try:
        timeout = float(raw_timeout)
    except (TypeError, ValueError):
        return issues

    if timeout < self.MIN_REASONABLE_TIMEOUT:
        issues.append(
            ValidationIssue(
                check_id="V103",
                severity=ValidationSeverity.WARNING,
                message=f"Very short timeout ({timeout}s) may cause premature failures",
                line=find_line_in_yaml(raw_yaml, "timeout_seconds:"),
                suggestion=(
                    f"Consider timeout_seconds >="
                    f" {self.MIN_REASONABLE_TIMEOUT}"
                    f" for Claude CLI operations"
                ),
                metadata={
                    "timeout": str(timeout),
                    "threshold": str(self.MIN_REASONABLE_TIMEOUT),
                },
            )
        )

    if timeout > self.MAX_REASONABLE_TIMEOUT:
        issues.append(
            ValidationIssue(
                check_id="V104",
                severity=ValidationSeverity.INFO,
                message=(
                    f"Very long timeout ({timeout}s = {timeout / 3600:.1f}h)"
                    f" - consider if this is necessary"
                ),
                line=find_line_in_yaml(raw_yaml, "timeout_seconds:"),
                suggestion=(
                    "Long timeouts can tie up resources; consider breaking into smaller tasks"
                ),
                metadata={
                    "timeout": str(timeout),
                    "threshold": str(self.MAX_REASONABLE_TIMEOUT),
                },
            )
        )

    return issues

VersionReferenceCheck

Check that evolved scores don't reference previous version paths (V009).

When a score evolves (e.g., v20 → v21), the new score file should have all references updated to the new version. This catches cases where the name, workspace, or other paths still reference the old version.

Methods:
check
check(config, config_path, raw_yaml)

Check for stale version references in evolved scores.

Source code in src/marianne/validation/checks/config.py
def check(
    self,
    config: JobConfig,
    config_path: Path,
    raw_yaml: str,
) -> list[ValidationIssue]:
    """Check for stale version references in evolved scores."""
    issues: list[ValidationIssue] = []

    # Extract version from filename (e.g., v21 from marianne-opus-evolution-v21.yaml)
    filename = config_path.name
    version_match = re.search(r"-v(\d+)\.yaml$", filename)
    if not version_match:
        # Not a versioned score file, skip this check
        return issues

    current_version = int(version_match.group(1))
    if current_version <= 1:
        # v1 has no previous version to check against
        return issues

    previous_version = current_version - 1
    prev_patterns = [
        f"-v{previous_version}",  # e.g., -v20
        f"v{previous_version}.0",  # e.g., v20.0
        f"v{previous_version}/",  # e.g., workspace-v20/
        f"-v{previous_version}/",  # e.g., evolution-workspace-v20/
        f"evolution-v{previous_version}",  # e.g., evolution-v20
    ]

    # Check the job name
    if f"-v{previous_version}" in config.name:
        issues.append(
            ValidationIssue(
                check_id=self.check_id,
                severity=self.severity,
                message=(
                    f"Job name '{config.name}' references"
                    f" v{previous_version} but file is v{current_version}"
                ),
                line=find_line_in_yaml(raw_yaml, "name:"),
                suggestion=f"Update name to use v{current_version}",
                metadata={
                    "field": "name",
                    "current_version": str(current_version),
                    "previous_version": str(previous_version),
                },
            )
        )

    # Check the workspace path
    workspace_str = str(config.workspace)
    if f"-v{previous_version}" in workspace_str or f"v{previous_version}/" in workspace_str:
        issues.append(
            ValidationIssue(
                check_id=self.check_id,
                severity=self.severity,
                message=(
                    f"Workspace path references v{previous_version}"
                    f" but file is v{current_version}"
                ),
                line=find_line_in_yaml(raw_yaml, "workspace:"),
                context=workspace_str,
                suggestion=f"Update workspace to use v{current_version}",
                metadata={
                    "field": "workspace",
                    "current_version": str(current_version),
                    "previous_version": str(previous_version),
                },
            )
        )

    # Scan raw YAML for other references (in comments, descriptions, etc.)
    for i, line in enumerate(raw_yaml.split("\n"), 1):
        # Skip lines that are defining the version progression history
        if "VERSION PROGRESSION:" in line or "→" in line or "->" in line:
            continue
        # Skip lines in comments that are documenting history
        if line.strip().startswith("#") and ("v" + str(previous_version - 1) in line):
            continue

        for pattern in prev_patterns:
            if pattern in line:
                # Check if this is just historical documentation
                hist_markers = [
                    "EVOLUTION FROM",
                    "evolved from",
                    "LEARNINGS",
                ]
                if any(hist in line for hist in hist_markers):
                    continue
                # Check if it's in the version progression list
                if (
                    f"v{previous_version}→v{current_version}" in line
                    or f"v{previous_version}->v{current_version}" in line
                ):
                    continue

                issues.append(
                    ValidationIssue(
                        check_id=self.check_id,
                        severity=ValidationSeverity.WARNING,
                        message=(
                            f"Line {i} references v{previous_version}"
                            f" - verify this is intentional"
                        ),
                        line=i,
                        context=line.strip()[:80],
                        suggestion=(
                            f"Update to v{current_version} if this should"
                            f" reference the current version"
                        ),
                        metadata={
                            "pattern": pattern,
                            "current_version": str(current_version),
                            "previous_version": str(previous_version),
                        },
                    )
                )
                break  # Only one issue per line

    return issues

EmptyPatternCheck

Check content patterns that cannot match (V106).

An empty pattern matches anything. A content_contains pattern that carries regex syntax ([Pp]remise, A\|B, foo|bar, \s) is tested as a literal substring, so it matches nothing the prompt asked for: 63 such rules across two research examples failed every honest report (examples QA, 21 Oct, GH #480).

Methods:
check
check(config, config_path, raw_yaml)

Check for empty patterns.

Source code in src/marianne/validation/checks/config.py
def check(
    self,
    config: JobConfig,
    config_path: Path,
    raw_yaml: str,
) -> list[ValidationIssue]:
    """Check for empty patterns."""
    issues: list[ValidationIssue] = []

    for i, validation in enumerate(config.validations):
        if (
            validation.type in ("content_contains", "content_regex")
            and validation.pattern is not None
            and validation.pattern.strip() == ""
        ):
            issues.append(
                ValidationIssue(
                    check_id=self.check_id,
                    severity=self.severity,
                    message=(
                        f"Empty pattern in validation rule {i + 1} will match any content"
                    ),
                    suggestion="Add a meaningful pattern or remove this validation",
                    metadata={
                        "validation_index": str(i),
                    },
                )
            )
        elif (
            validation.type == "content_contains"
            and validation.pattern is not None
            and _REGEX_SYNTAX.search(validation.pattern)
        ):
            issues.append(
                ValidationIssue(
                    check_id=self.check_id,
                    severity=self.severity,
                    message=(
                        f"content_contains pattern in validation rule {i + 1} carries "
                        f"regex syntax but is matched as a literal substring: "
                        f"{validation.pattern!r}"
                    ),
                    line=find_line_in_yaml(raw_yaml, validation.pattern),
                    context=validation.pattern,
                    suggestion=(
                        "Use content_regex for a pattern, or the exact text for "
                        "content_contains"
                    ),
                    metadata={
                        "validation_index": str(i),
                        "pattern": validation.pattern,
                    },
                )
            )

    return issues

InteractiveSupportCheck

Check that interactive-mode opt-ins are runnable (V211).

interactive: true in any instrument_config requires the resolved instrument profile to carry a verified cli.interactive block — interactive mode drives the real TUI through screen patterns, which only exist for verified instruments. Without the block, dispatch fails; this check surfaces the problem at validation time instead.

Also warns when tmux is not on PATH (the interactive transport).

Severity is ERROR for a known profile without interactive support (fail-fast — the sheet cannot run), and the check skips unknown instrument names entirely (V210's domain).

Methods:
check
check(config, config_path, raw_yaml)

Validate every interactive: true opt-in against profile support.

Source code in src/marianne/validation/checks/config.py
def check(
    self,
    config: JobConfig,
    config_path: Path,
    raw_yaml: str,
) -> list[ValidationIssue]:
    """Validate every interactive: true opt-in against profile support."""
    # Collect (location, instrument_name_or_alias) for each opt-in scope.
    opt_ins: list[tuple[str, str | None]] = []
    if config.instrument_config.get("interactive"):
        opt_ins.append(("score-level instrument_config", config.instrument))
    if config.movements:
        for mov_num, mov_def in config.movements.items():
            if mov_def.instrument_config.get("interactive"):
                opt_ins.append(
                    (
                        f"movement {mov_num} instrument_config",
                        mov_def.instrument or config.instrument,
                    )
                )
    if config.sheet.per_sheet_instrument_config:
        for sheet_num, icfg in config.sheet.per_sheet_instrument_config.items():
            if icfg.get("interactive"):
                per_sheet = (config.sheet.per_sheet_instruments or {}).get(
                    sheet_num,
                )
                opt_ins.append(
                    (
                        f"sheet {sheet_num} instrument_config",
                        per_sheet or config.instrument,
                    )
                )
    for alias, instr_def in config.instruments.items():
        if instr_def.config.get("interactive"):
            for entry in instr_def.entries:
                opt_ins.append((f"instrument alias '{alias}'", entry.profile))

    if not opt_ins:
        return []

    issues: list[ValidationIssue] = []

    # tmux is the interactive transport — warn when absent.
    import shutil

    if shutil.which("tmux") is None:
        issues.append(
            ValidationIssue(
                check_id=self.check_id,
                severity=ValidationSeverity.WARNING,
                message=(
                    "interactive: true is set but tmux is not on PATH — "
                    "interactive sheets will fail their health check and "
                    "fall back to other instruments (or fail)."
                ),
                line=find_line_in_yaml(raw_yaml, "interactive:"),
                suggestion="Install tmux >= 3.2 to run interactive sheets.",
            )
        )

    # Load known profiles — gracefully degrade on failure (V210 pattern).
    try:
        from marianne.instruments.loader import load_all_profiles

        profiles = load_all_profiles()
    except Exception:  # noqa: BLE001 — a profile load failure skips this check, loudly
        _logger.warning(
            "validation.profiles_unavailable_skip", check="V211", exc_info=True,
        )
        return issues

    for location, name in opt_ins:
        # Resolve score-local aliases to their profile name.
        resolved = name
        if resolved in config.instruments:
            resolved = config.instruments[resolved].profile or resolved
        if resolved is None or resolved not in profiles:
            continue  # unknown name — V210's domain
        profile = profiles[resolved]
        if profile.cli is None or profile.cli.interactive is None:
            issues.append(
                ValidationIssue(
                    check_id=self.check_id,
                    severity=ValidationSeverity.ERROR,
                    message=(
                        f"{location} sets interactive: true, but instrument "
                        f"'{resolved}' has no cli.interactive block — its "
                        f"interactive behavior has not been verified, so "
                        f"interactive dispatch will fail."
                    ),
                    line=find_line_in_yaml(raw_yaml, "interactive:"),
                    suggestion=(
                        "Use an instrument with verified interactive support "
                        "(e.g. claude-code), add a cli.interactive block to "
                        "the instrument's profile, or remove interactive: true."
                    ),
                )
            )

    return issues

InstrumentNameCheck

Check that instrument names resolve (V210).

A name must be a loaded instrument profile, a score-level alias, or a capability class configured through the one class loader. Typos (e.g. 'clause-code' instead of 'claude-code') are caught at validation time; the suggestion searches profiles, aliases, classes, and the shipped class vocabulary (edit distance <= 2). Class-shaped names that resolve to nothing here (vocabulary-only, tombstoned) are V310's domain and are skipped here so one bad name is reported once.

Severity is ERROR (submit refusal for the same condition) since the S3 overhaul; the message names every namespace it searched.

Checks: - Top-level instrument: field - sheet.per_sheet_instruments per-sheet overrides - sheet.instrument_map batch assignments - movements.N.instrument per-movement overrides

Methods:
check
check(config, config_path, raw_yaml)

Check all instrument references against the loaded profile registry.

Source code in src/marianne/validation/checks/config.py
def check(
    self,
    config: JobConfig,
    config_path: Path,
    raw_yaml: str,
) -> list[ValidationIssue]:
    """Check all instrument references against the loaded profile registry."""
    # Load known instruments — gracefully degrade on failure
    try:
        from marianne.instruments.classes import CLASS_VOCABULARY, load_class_map
        from marianne.instruments.loader import load_all_profiles

        known = set(load_all_profiles().keys())
        class_map = load_class_map(profile_names=known)
        class_names = set(class_map.classes)
    except Exception:  # noqa: BLE001 — a profile load failure skips this check, loudly
        _logger.warning(
            "validation.profiles_unavailable_skip", check="V210", exc_info=True,
        )
        return []

    if not known:
        return []

    # Score-level instrument aliases are valid references — they resolve
    # to profile names at build time via config.instruments[name].profile.
    score_instruments = set(config.instruments.keys())
    all_valid = known | score_instruments | class_names
    # Class-shaped names that resolve to nothing here are V310's domain
    # (vocabulary-only, tombstoned): its message names the fix command.
    class_domain = (CLASS_VOCABULARY | class_map.tombstones) - class_names

    issues: list[ValidationIssue] = []

    # 1. Top-level instrument: field
    # Must check against all_valid (profiles + score aliases + classes), not just
    # known (profiles only). A score can define instrument: my-alias and
    # instruments: { my-alias: { profile: claude-code } } — that's valid.
    if (
        config.instrument
        and config.instrument not in all_valid
        and config.instrument not in class_domain
    ):
        issues.append(
            self._make_issue(
                config.instrument,
                "score-level instrument",
                find_line_in_yaml(raw_yaml, "instrument:"),
                all_valid,
            )
        )

    # 2. Per-sheet instruments
    if config.sheet.per_sheet_instruments:
        for sheet_num, instr_name in config.sheet.per_sheet_instruments.items():
            if instr_name not in all_valid and instr_name not in class_domain:
                issues.append(
                    self._make_issue(
                        instr_name,
                        f"sheet {sheet_num} instrument",
                        find_line_in_yaml(raw_yaml, f"{sheet_num}:"),
                        all_valid,
                    )
                )

    # 3. Instrument map
    if config.sheet.instrument_map:
        for instr_name in config.sheet.instrument_map:
            if instr_name not in all_valid and instr_name not in class_domain:
                issues.append(
                    self._make_issue(
                        instr_name,
                        "instrument_map entry",
                        find_line_in_yaml(raw_yaml, f"{instr_name}:"),
                        all_valid,
                    )
                )

    # 4. Movement-level instruments
    if config.movements:
        for mov_num, mov_def in config.movements.items():
            if (
                mov_def.instrument
                and mov_def.instrument not in all_valid
                and mov_def.instrument not in class_domain
            ):
                issues.append(
                    self._make_issue(
                        mov_def.instrument,
                        f"movement {mov_num} instrument",
                        find_line_in_yaml(raw_yaml, f"{mov_num}:"),
                        all_valid,
                    )
                )

    return issues

InstrumentFallbackCheck

Check that instrument_fallbacks references resolve (V211).

Same namespace as V210 — loaded profiles, score-level aliases, and capability classes through the one class loader. Class-shaped names that resolve to nothing here are V310's domain, skipped so one bad name is reported once. Severity ERROR, matching V210.

Checks: - Score-level instrument_fallbacks - movements.N.instrument_fallbacks per-movement fallbacks - sheet.per_sheet_fallbacks per-sheet fallback overrides

Methods:
check
check(config, config_path, raw_yaml)

Check all instrument fallback references against the loaded profile registry.

Source code in src/marianne/validation/checks/config.py
def check(
    self,
    config: JobConfig,
    config_path: Path,
    raw_yaml: str,
) -> list[ValidationIssue]:
    """Check all instrument fallback references against the loaded profile registry."""
    try:
        from marianne.instruments.classes import CLASS_VOCABULARY, load_class_map
        from marianne.instruments.loader import load_all_profiles

        known = set(load_all_profiles().keys())
        class_map = load_class_map(profile_names=known)
        class_names = set(class_map.classes)
    except Exception:  # noqa: BLE001 — a profile load failure skips this check, loudly
        _logger.warning(
            "validation.profiles_unavailable_skip", check="V211", exc_info=True,
        )
        return []

    if not known:
        return []

    # Score-level instrument aliases are valid fallback targets
    score_instruments = set(config.instruments.keys())
    all_valid = known | score_instruments | class_names
    # Class-shaped names that resolve to nothing here are V310's domain.
    class_domain = (CLASS_VOCABULARY | class_map.tombstones) - class_names

    issues: list[ValidationIssue] = []

    # 1. Score-level instrument_fallbacks
    for name in config.instrument_fallbacks:
        if name not in all_valid and name not in class_domain:
            issues.append(
                self._make_issue(
                    name,
                    "score-level instrument_fallbacks",
                    find_line_in_yaml(raw_yaml, name),
                    all_valid,
                )
            )

    # 2. Movement-level instrument_fallbacks
    for mov_num, mov_def in config.movements.items():
        for name in mov_def.instrument_fallbacks:
            if name not in all_valid and name not in class_domain:
                issues.append(
                    self._make_issue(
                        name,
                        f"movement {mov_num} instrument_fallbacks",
                        find_line_in_yaml(raw_yaml, name),
                        all_valid,
                    )
                )

    # 3. Per-sheet fallbacks
    for sheet_num, fallback_list in config.sheet.per_sheet_fallbacks.items():
        for name in fallback_list:
            if name not in all_valid and name not in class_domain:
                issues.append(
                    self._make_issue(
                        name,
                        f"sheet {sheet_num} per_sheet_fallbacks",
                        find_line_in_yaml(raw_yaml, name),
                        all_valid,
                    )
                )

    return issues

FoldedCommandScalarCheck

Detect folded YAML block scalars on command fields (V303, #106).

A folded scalar (>, >-, >+) collapses newlines into spaces, so a multi-line shell command — typically a python3 -c with several statements in a command_succeeds validation — becomes one physical line and fails with a SyntaxError at runtime. The validation can then never pass regardless of content. The bug is invisible in the parsed config (the newlines are already gone); only the raw YAML reveals the > scalar, so this check scans raw_yaml and warns, recommending a literal block scalar (|) which preserves newlines.

Methods:
check
check(config, config_path, raw_yaml)

Scan the raw YAML for folded command scalars.

Source code in src/marianne/validation/checks/config.py
def check(
    self,
    config: JobConfig,
    config_path: Path,
    raw_yaml: str,
) -> list[ValidationIssue]:
    """Scan the raw YAML for folded command scalars."""
    issues: list[ValidationIssue] = []
    for line_num, line in enumerate(raw_yaml.split("\n"), 1):
        if self._FOLDED_COMMAND.match(line):
            issues.append(
                ValidationIssue(
                    check_id="V303",
                    severity=ValidationSeverity.WARNING,
                    message=(
                        "Folded YAML scalar (>) on a command field collapses "
                        "newlines into spaces, which breaks multi-line shell "
                        "commands (e.g. python3 -c) at runtime — the validation "
                        "can never pass."
                    ),
                    line=line_num,
                    context=line.strip(),
                    suggestion=(
                        "Use a literal block scalar (|) instead of folded (>) "
                        "to preserve newlines in the command."
                    ),
                )
            )
    return issues

CodeExecutionSandboxCheck

V304: warn (loudly) when code execution is enabled but bwrap is unavailable, so agent-generated code would run UNSANDBOXED (#209).

Composer decision (2026-06-12): activate code mode opt-in and warn rather than require bwrap. If a score sets code_execution.require_sandbox: true, a missing sandbox is an ERROR instead (the score asked for isolation it cannot get).

NoUsableInstrumentCheck

Warn when a score's whole instrument chain looks unrunnable here (V212).

Targets the unknown-system onboarding case: a fresh install has no AI CLI, so even a deep fallback chain can resolve to nothing the system can actually run. An unavailable instrument costs one dispatch attempt before advancing; a chain with zero installed CLI binaries would advance through HTTP fallbacks (which need a running local server or an API key) — or exhaust entirely.

This surfaces that BEFORE the run: it resolves the score-level instrument chain (primary + fallbacks, through score aliases) and, when no CLI binary in it is on PATH, emits an actionable warning pointing at the free paths. A local HTTP instrument whose server answers and serves the profile's model counts as usable; a remote or silent one is noted, not counted. WARNING only — a remote conductor may have more.

ServedContextCheck

A local server's live context against the profile's declared one (V234).

The HTTP executor sizes max_tokens from the profile's context_window for the bound model; a local server (PolyStrata, llama-server) refuses a request above its real context with HTTP 400 before generating anything (GH #494). Both servers report the loaded model's context as default_generation_settings.n_ctx on GET /props, so the probe reads it and this check warns when the profile overstates it. Only the score's chain is probed, only loopback servers answer, and a server that does not expose /props is silent here, not wrong.

Functions: