Skip to content

Index

checks

Validation check implementations.

This module contains all the built-in validation checks organized by category: - jinja: Template syntax and undefined variable checks - paths: File and directory existence checks - config: Configuration structure and value checks

Classes

FanOutMessagingCheck

Warn when an explicit messaging mode has no concurrent siblings (V235).

FanOutWithoutDependenciesCheck

Check fan-out configs have dependencies (V206).

When fan-out stages are configured without dependencies, stages may execute out of order.

Methods:
check
check(config, config_path, raw_yaml)

Fire when fan-out is configured without dependencies.

Source code in src/marianne/validation/checks/best_practices.py
def check(
    self,
    config: JobConfig,
    config_path: Path,
    raw_yaml: str,
) -> list[ValidationIssue]:
    """Fire when fan-out is configured without dependencies."""
    if config.sheet.fan_out_stage_map is not None and not config.sheet.dependencies:
        return [
            ValidationIssue(
                check_id=self.check_id,
                severity=self.severity,
                message=(
                    "Fan-out is configured but no sheet dependencies"
                    " are declared — stages may run out of order"
                ),
                line=find_line_in_yaml(raw_yaml, "fan_out"),
                suggestion=("Add sheet.dependencies to control stage execution order"),
                metadata={},
            )
        ]
    return []

FanOutWithoutParallelCheck

Check fan-out configs enable parallel execution (V207).

Fan-out instances are designed to run concurrently, but will execute sequentially if parallel mode is disabled.

Methods:
check
check(config, config_path, raw_yaml)

Fire when fan-out is configured without parallel.

Source code in src/marianne/validation/checks/best_practices.py
def check(
    self,
    config: JobConfig,
    config_path: Path,
    raw_yaml: str,
) -> list[ValidationIssue]:
    """Fire when fan-out is configured without parallel."""
    if config.sheet.fan_out_stage_map is not None and config.parallel.enabled is False:
        return [
            ValidationIssue(
                check_id=self.check_id,
                severity=self.severity,
                message=(
                    "Fan-out is configured but parallel execution is"
                    " disabled — instances will run sequentially"
                ),
                line=find_line_in_yaml(raw_yaml, "parallel"),
                suggestion=(
                    "Enable parallel.enabled: true to run fan-out instances concurrently"
                ),
                metadata={},
            )
        ]
    return []

FileExistsOnlyCheck

Check for file_exists-only validations (V205).

file_exists alone cannot detect stale files left from a previous run. Adding file_modified or content checks is recommended.

Methods:
check
check(config, config_path, raw_yaml)

Fire when every validation is file_exists.

Source code in src/marianne/validation/checks/best_practices.py
def check(
    self,
    config: JobConfig,
    config_path: Path,
    raw_yaml: str,
) -> list[ValidationIssue]:
    """Fire when every validation is file_exists."""
    if not config.validations:
        return []

    all_file_exists = all(v.type == "file_exists" for v in config.validations)
    if all_file_exists:
        return [
            ValidationIssue(
                check_id=self.check_id,
                severity=self.severity,
                message=(
                    "All validations are file_exists — stale files from previous runs will pass"
                ),
                suggestion=(
                    "Consider adding file_modified or content checks to detect stale files"
                ),
                metadata={
                    "validation_count": str(len(config.validations)),
                },
            )
        ]
    return []

FormatSyntaxInTemplateCheck

Check for format-string syntax in Jinja templates (V202).

Prompt templates use Jinja ({{ name }}), not Python format strings ({name}). Only flags known built-in names to avoid false positives.

Methods:
check
check(config, config_path, raw_yaml)

Scan prompt template for {builtin_name} patterns.

Source code in src/marianne/validation/checks/best_practices.py
def check(
    self,
    config: JobConfig,
    config_path: Path,
    raw_yaml: str,
) -> list[ValidationIssue]:
    """Scan prompt template for ``{builtin_name}`` patterns."""
    issues: list[ValidationIssue] = []

    template = config.prompt.template
    if not template:
        return issues

    for match in self._PATTERN.finditer(template):
        name = match.group(1)
        issues.append(
            ValidationIssue(
                check_id=self.check_id,
                severity=self.severity,
                message=(
                    f"Format-string syntax '{{{name}}}' found in"
                    f" prompt template — use Jinja '{{{{ {name} }}}}'"
                ),
                line=find_line_in_yaml(raw_yaml, f"{{{name}}}"),
                context=match.group(0),
                suggestion=(f"Use {{{{ {name} }}}} not {{{name}}} in Jinja templates"),
                metadata={
                    "variable": name,
                },
            )
        )

    return issues

JinjaInValidationPathCheck

Check for Jinja syntax in validation paths and commands (V201).

Validation paths and commands use Python .format() syntax ({workspace}), not Jinja ({{ workspace }}). Jinja syntax renders literally with braces intact: a path never exists and a command runs cd {{ workspace }} (examples QA 21 Oct, prefabrication F16).

Methods:
check
check(config, config_path, raw_yaml)

Check validation paths and commands for {{ markers.

Source code in src/marianne/validation/checks/best_practices.py
def check(
    self,
    config: JobConfig,
    config_path: Path,
    raw_yaml: str,
) -> list[ValidationIssue]:
    """Check validation paths and commands for ``{{`` markers."""
    issues: list[ValidationIssue] = []

    for i, validation in enumerate(config.validations):
        for field in ("path", "command"):
            value = getattr(validation, field, None)
            if not value or "{{" not in str(value):
                continue
            text = str(value)
            anchor = next(
                (ln for ln in text.splitlines() if "{{" in ln), text
            ).strip()
            issues.append(
                ValidationIssue(
                    check_id=self.check_id,
                    severity=self.severity,
                    message=(
                        f"Validation rule {i + 1} uses Jinja syntax in {field}: "
                        f"{anchor[:120]}"
                    ),
                    line=find_line_in_yaml(raw_yaml, anchor),
                    context=anchor,
                    suggestion=(
                        "Use {workspace} not {{ workspace }} in validation "
                        f"{field}s — they are format strings, not templates"
                    ),
                    metadata={
                        "validation_index": str(i),
                        "field": field,
                        field: text,
                    },
                )
            )

    return issues

NoValidationsCheck

Check that at least one validation rule exists (V203).

Without validations, sheets always "pass" and you learn nothing about execution quality.

Methods:
check
check(config, config_path, raw_yaml)

Fire when no validations are configured.

Source code in src/marianne/validation/checks/best_practices.py
def check(
    self,
    config: JobConfig,
    config_path: Path,
    raw_yaml: str,
) -> list[ValidationIssue]:
    """Fire when no validations are configured."""
    if len(config.validations) == 0:
        return [
            ValidationIssue(
                check_id=self.check_id,
                severity=self.severity,
                message="No validation rules configured",
                suggestion=(
                    "Add at least one validation rule — see docs/score-writing-guide.md"
                ),
                metadata={},
            )
        ]
    return []

PlaceholderQuotingCheck

A {placeholder} in a command is ONE shell-quoted word (V333).

The engine substitutes every placeholder with shlex.quote(value). Two command shapes can never work with that and fail only at runtime, with a value that needs quoting (GH #477):

  • a bash array literal, xs=({list}) — one element, never split;
  • a placeholder spliced inside an interpreter's string literal, python3 -c "open('{workspace}/x')" — the shell quotes survive inside the Python string, so '~/triage' reaches expanduser() with its quotes (issue-solver sheet 12, four attempts lost).

SkipWhenArchiveFreshCheck

Warn when skip_when unchanged is used with workspace_lifecycle.archive_on_fresh (V339).

archive_on_fresh archives .marianne/ and non-preserved outputs before dispatch, so unchanged rules find no record or missing products and never skip.

SkipWhenSheetRangeCheck

Check that skip_when keys are in-range (V212).

Each key in skip_when must satisfy 1 ≤ k ≤ total_sheets. Out-of-range keys are silently ignored at runtime — they will never fire. This is a WARNING (non-blocking) because the config is executable, just suspicious.

Methods:
check
check(config, config_path, raw_yaml)

Warn when skip_when keys are out of range.

Source code in src/marianne/validation/checks/best_practices.py
def check(
    self,
    config: JobConfig,
    config_path: Path,
    raw_yaml: str,
) -> list[ValidationIssue]:
    """Warn when skip_when keys are out of range."""
    issues: list[ValidationIssue] = []
    total = config.sheet.total_sheets

    for k in config.sheet.skip_when:
        if not (1 <= k <= total):
            issues.append(
                ValidationIssue(
                    check_id=self.check_id,
                    severity=self.severity,
                    message=(
                        f"skip_when key {k} is out of range "
                        f"(valid: 1\u2013{total}); this rule will never fire"
                    ),
                    suggestion=(f"Remove sheet {k} or adjust total_sheets / fan-out"),
                    metadata={SHEET_NUM_KEY: str(k), "source": "skip_when"},
                )
            )

    return issues

VariableShadowingCheck

Check for user variables that shadow built-ins (V208).

User-defined prompt variables that share names with Marianne's built-in variables will override the real values, causing unexpected behavior.

Methods:
check
check(config, config_path, raw_yaml)

Fire when prompt.variables shadows a built-in name.

Source code in src/marianne/validation/checks/best_practices.py
def check(
    self,
    config: JobConfig,
    config_path: Path,
    raw_yaml: str,
) -> list[ValidationIssue]:
    """Fire when prompt.variables shadows a built-in name."""
    issues: list[ValidationIssue] = []

    for name in config.prompt.variables:
        if name in FLOW_RESERVED_NAMES:
            issues.append(
                ValidationIssue(
                    check_id=self.check_id,
                    severity=self.severity,
                    message=(f"Variable '{name}' shadows the built-in {name}"),
                    line=find_line_in_yaml(raw_yaml, f"{name}:"),
                    suggestion=(
                        f"Rename variable '{name}'"
                        f" — it shadows the built-in {name}."
                        " This becomes an error in a later release."
                    ),
                    metadata={
                        "variable": name,
                    },
                )
            )

    return issues

AliasSelectCheck

V330 (WARNING): an alias select modifier that cannot act (#473).

cycle/spread rotate across an alias's entries; with one entry there is nothing to rotate. cheapest/widest order by the profile's model table; an entry whose profile has no row for its model keeps its authored place, so an alias where NO entry has a known metric is unordered. In both cases the score runs, on the authored order, and this says so.

AliasShadowsClassCheck

V322 (WARNING): an instruments key equals a capability-class name (V-CLS-05).

The alias wins under the §3.1 resolution order; the author should know their alias is masking the class of the same name.

Profile/class-map loading exceptions log validation.profiles_unavailable_skip at WARNING and return no findings.

ClassAliasProfileCheck

V321 (ERROR): an instrument alias names a class as its profile (V-CLS-04).

An alias must name a profile; a class there would nest a second chain inside one alias slot (§3.2). The conductor refuses the same condition at submit through resolve_job_classes.

Profile/class-map loading exceptions log validation.profiles_unavailable_skip at WARNING and return no findings.

ClassChainAvailabilityCheck

V311 (WARNING): part of a used class's chain cannot run here (V-CLS-03, V-CLS-08).

Per used class: k of n entries unresolvable or unavailable (binary not on PATH, execution_status unsupported, or unable to enforce a sheet's response_format) — the job still starts at the first available entry. When no entry can run here the row stays a WARNING that says so: availability is a fact about the machine, the conductor still admits the score (A-C5), and V310 is reserved for a chain with no REGISTERED entry (V-CLS-02).

Also warns when a name the score uses resolves to a profile that shadows a packaged-default class of the same name (V-CLS-08 WARN arm): the profile wins (§3.1) and the class is unreachable.

Profile/class-map loading exceptions log validation.profiles_unavailable_skip at WARNING and return no findings. A response-format collection exception also warns, then the remaining availability checks continue without those requests.

ClassChainSummaryCheck

V325 (INFO): what each used class resolved to and from which layer (V-CLS-11).

One row per used class; the --json summary block carries the per-sheet resolution and every layer path + sha256 the validator read (§2.1).

Profile/class-map loading exceptions log validation.profiles_unavailable_skip at WARNING and return no findings.

ClassesFileValidCheck

V324 (ERROR): a classes layer file failed validation while the score uses a class (V-CLS-07).

Renders ClassMap.failures exactly as the one loader recorded them (pydantic message included) — the way A4 renders FlowConfigError, never re-validating the file. File-level, gated on class usage so a broken user file stays silent for scores that never name a class.

Profile/class-map loading exceptions log validation.profiles_unavailable_skip at WARNING and return no findings.

ClassModelConfigCheck

V323 (ERROR): a model set in instrument_config against a class primary (V-CLS-06).

A model id cannot be honoured across heterogeneous profiles (§2.4); the conductor refuses the same condition at submit. Applies at score, movement and per-sheet scope, exactly as resolve_job_classes does.

Profile/class-map loading exceptions log validation.profiles_unavailable_skip at WARNING and return no findings. Class-snapshot exceptions likewise warn and skip this check.

ClassNameResolutionCheck

V310 (ERROR): a class-shaped name that cannot resolve on this machine (V-CLS-02).

Vocabulary-only classes (shipped names never configured here), tombstoned classes, and configured classes whose every entry names a profile not registered here are submit refusals (§4.3); this reports them at validate time with the fix command. Entirely unknown names stay V210/V211 — the loader already folds configured classes into their valid set.

Profile/class-map loading exceptions log validation.profiles_unavailable_skip at WARNING and return no findings.

CliSchemaShapeCheck

V332 (WARNING): a CLI schema sheet carries a shape the API refuses (GH #486).

V311 proves the profile CAN enforce a schema; V331 proves the sheet runs headless; this proves the schema's top level is one the CLI's tool input_schema accepts. All three must hold or the sheet fails at its first attempt with a 400 the job could not previously even quote.

SchemaSheetInteractiveCheck

V331 (WARNING): a schema sheet would run interactively (GH #478).

A sheet with instrument_config.response_format needs a headless backend (HTTP, or a CLI with json_schema_flag); the interactive tmux backend cannot enforce a schema and dispatch refuses it (adapter "cannot enforce instrument_config.response_format"). Score silence on interactive resolves to the profile's cli.interactive. enabled_by_default — true for claude-code and antigravity — so a schema sheet that does not say interactive: false passes V311 (the profile CAN enforce, headless) and fails at sheet 1. This names the sheet before the run.

CliRawPromptBashCheck

Render raw-prompt shell sheets and check the result before execution.

Methods:
check
check(config, config_path, raw_yaml)

Check every resolved raw-prompt shell sheet.

Profile loading exceptions log a WARNING and return no findings. Class-map loading exceptions warn and continue without custom class resolution. Both use validation.profiles_unavailable_skip.

Source code in src/marianne/validation/checks/cli.py
def check(
    self,
    config: JobConfig,
    config_path: Path,
    raw_yaml: str,
) -> list[ValidationIssue]:
    """Check every resolved raw-prompt shell sheet.

    Profile loading exceptions log a WARNING and return no findings.
    Class-map loading exceptions warn and continue without custom class
    resolution. Both use ``validation.profiles_unavailable_skip``.
    """
    try:
        from marianne.instruments.loader import load_all_profiles

        profiles = load_all_profiles()
    except Exception:  # noqa: BLE001 — unavailable profiles skip this check, loudly
        _logger.warning(
            "validation.profiles_unavailable_skip", check=self.check_id,
            operation="load_profiles", exc_info=True,
        )
        return []
    try:
        from marianne.instruments.classes import load_class_map

        class_map = load_class_map(profile_names=set(profiles))
    except Exception:  # noqa: BLE001 — shell checks continue without custom class resolution
        _logger.warning(
            "validation.profiles_unavailable_skip", check=self.check_id,
            operation="load_class_map", exc_info=True,
        )
        class_map = None

    issues: list[ValidationIssue] = []
    for sheet in build_sheets(config):
        profile = profiles.get(sheet.instrument_name)
        if not self._is_raw_shell_profile(profile):
            continue

        issues.extend(self._check_fallback_chain(sheet, profiles, class_map, raw_yaml))

        rendered, render_issue = self._render_raw_prompt(
            config,
            config_path,
            raw_yaml,
            sheet,
        )
        if render_issue is not None:
            issues.append(render_issue)
            continue
        if rendered is None:
            continue

        markdown_issues = self._check_markdown_markers(rendered, sheet, raw_yaml)
        issues.extend(markdown_issues)
        if markdown_issues:
            continue
        assert profile is not None
        issues.extend(self._check_bash_syntax(rendered, sheet, profile, raw_yaml))

    return issues

FanOutAssignmentCoverageCheck

Warn when fan-out voices get only partial concrete instrument coverage.

PromptValidationContractCheck

Warn when exact section-label validations are absent from the prompt.

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).

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

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

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

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

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

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.

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

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.

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

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

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

SheetEffortCheck

V335 (ERROR): instrument_config.effort the resolved profile cannot apply.

Refusals, one code: the profile declares no effort: mapping; the level is not mapped by the profile (or by the resolved model's effort_levels); the sheet is a schema sheet (response_format) and the level is outside effort.schema_levels (claude-code refuses max there: with --json-schema it emits nothing until the sheet timeout); or the sheet runs interactively on a mapping marked interactive: false. Dispatch refuses the same sheets, so this is an ERROR, not advice. An unregistered instrument name is V210's finding and is skipped here.

UnpinnedModelCheck

V336 (INFO): a model seat whose model nothing in the score names.

INFO, not WARNING: 54 of the 65 shipped examples leave a codex-cli or goose seat unpinned, and a WARNING fails mzt validate --strict on each of them. It rises to WARNING once the builtins or the examples name a model.

SheetToolsCheck

V337 (ERROR): instrument_config.tools the resolved profile cannot apply.

Refusals, one code: the profile declares no tools: mapping; a name is outside the profile's tools.known list; or the sheet runs interactively on a mapping marked interactive: false. Dispatch refuses the same sheets. An unregistered instrument name is V210's finding and is skipped.

BashArrayLengthCheck

Detect bash ${#...} length syntax in templates (V305, #362).

Jinja2 tokenizes the literal {# as a comment opener. Bash array/string length expansion (${#ARR[@]}, ${#var}) contains {#, so Jinja silently consumes everything from {# to the next #} — truncating the rendered prompt mid-token. The cli instrument then runs a broken script and dies with a bare "Exit code 2" and no stderr. There is no legitimate ${# in a Jinja template (it always opens a comment), so this scan is zero-false- positive and blocks validation. Recommends a length-free idiom.

Methods:
check
check(config, config_path, raw_yaml)

Scan prompt.template and template_file for the ${# collision.

Source code in src/marianne/validation/checks/jinja.py
def check(
    self,
    config: JobConfig,
    config_path: Path,
    raw_yaml: str,
) -> list[ValidationIssue]:
    """Scan prompt.template and template_file for the `${#` collision."""
    issues: list[ValidationIssue] = []
    sources: list[tuple[str, str]] = []
    if config.prompt.template:
        sources.append((config.prompt.template, "prompt.template"))
    if config.prompt.template_file:
        template_path = resolve_path(config.prompt.template_file, config_path)
        if template_path.exists():
            try:
                sources.append(
                    (template_path.read_text(), f"template_file ({template_path.name})")
                )
            except Exception:  # noqa: BLE001 — unreadable file is V101's concern
                pass

    for template_str, source_name in sources:
        if "${#" not in template_str:
            continue
        issues.append(
            ValidationIssue(
                check_id="V305",
                severity=self.severity,
                message=(
                    f"{source_name} contains bash '${{#...}}' length syntax. "
                    "Jinja reads the '{#' as a comment opener and silently "
                    "deletes the template from there to the next '#}', "
                    "truncating the rendered prompt — the cli instrument then "
                    "fails with a bare 'Exit code 2' and no stderr."
                ),
                line=find_line_in_yaml(raw_yaml, "${#"),
                context=source_name,
                suggestion=(
                    "Avoid '${#...}'. For array length use "
                    "`printf '%s\\n' \"${ARR[@]:-}\" | grep -c .` or "
                    "`find DIR -name PAT | wc -l`; for empty-check use "
                    "`[ -z \"${ARR[0]:-}\" ]`."
                ),
            )
        )
    return issues

FanOutStringFilterCheck

Detect dict[X | string] on int-normalized variable dicts (V102, #132).

A per-instance dict with int-like string keys ({"1": ...}) has its keys normalized to integers at render time (_normalize_dict_keys). A template that subscripts it with dict[instance | string] re-stringifies the int instance to "1", which no longer matches the int key 1 → UndefinedError on every fan-out instance.

Detection is CORRELATED, not pure-AST: | string is correct for genuinely string-keyed dicts, so the check fires ONLY when the subscripted base Name resolves to a prompt.variables dict whose keys are ALL integers after normalization (int, or int-normalizable strings). This gives zero false positives — a string index never matches an all-int-keyed dict. The filtered Name is not restricted: the dict's key types are the precondition, and | string always produces a string index regardless of what it filters.

Methods:
check
check(config, config_path, raw_yaml)

Flag dict[X | string] where dict has all-int-normalizable keys.

Source code in src/marianne/validation/checks/jinja.py
def check(
    self,
    config: JobConfig,
    config_path: Path,
    raw_yaml: str,
) -> list[ValidationIssue]:
    """Flag `dict[X | string]` where dict has all-int-normalizable keys."""
    issues: list[ValidationIssue] = []
    env = jinja2.Environment()
    variables = config.prompt.variables

    sources: list[tuple[str, str]] = []
    if config.prompt.template:
        sources.append((config.prompt.template, "prompt.template"))
    if config.prompt.template_file:
        template_path = resolve_path(config.prompt.template_file, config_path)
        if template_path.exists():
            try:
                sources.append(
                    (template_path.read_text(), f"template_file ({template_path.name})")
                )
            except Exception:  # noqa: BLE001 — unreadable file is V101's concern
                pass

    seen: set[str] = set()
    for template_str, source_name in sources:
        try:
            ast = env.parse(template_str)
        except jinja2.TemplateSyntaxError:
            continue  # Syntax errors are reported by V001.
        for getitem in ast.find_all(jinja2_nodes.Getitem):
            if not isinstance(getitem.node, jinja2_nodes.Name):
                continue
            if not self._chain_has_string_filter(getitem.arg):
                continue
            var_name = getitem.node.name
            value = variables.get(var_name)
            if not isinstance(value, dict) or not self._all_keys_int(value):
                continue
            key = f"{source_name}:{var_name}"
            if key in seen:
                continue
            seen.add(key)
            issues.append(
                ValidationIssue(
                    check_id=self.check_id,
                    severity=ValidationSeverity.WARNING,
                    message=(
                        f"'{var_name}[... | string]' will fail at render time: "
                        f"{var_name}'s int-like keys are normalized to integers, "
                        f"but '| string' produces a string index that never "
                        f"matches them — UndefinedError on every fan-out instance."
                    ),
                    line=find_line_in_yaml(raw_yaml, "| string"),
                    context=f"{source_name}: {var_name}[... | string]",
                    suggestion=(
                        f"Remove '| string' — use {var_name}[instance] directly; "
                        f"the engine normalizes the dict's keys to int to match "
                        f"the int fan-out variable."
                    ),
                    metadata={"variable": var_name},
                )
            )
    return issues

JinjaSyntaxCheck

Check for Jinja template syntax errors (V001).

Attempts to parse templates and reports syntax errors with line numbers and context. This catches issues like: - Unclosed blocks ({% if ... without {% endif %}) - Unclosed expressions ({{ ... without }}) - Invalid syntax inside blocks

Methods:
check
check(config, config_path, raw_yaml)

Check Jinja syntax in templates.

Source code in src/marianne/validation/checks/jinja.py
def check(
    self,
    config: JobConfig,
    config_path: Path,
    raw_yaml: str,
) -> list[ValidationIssue]:
    """Check Jinja syntax in templates."""
    issues: list[ValidationIssue] = []
    env = jinja2.Environment()

    # Check inline template
    if config.prompt.template:
        template_issues = self._check_template(
            config.prompt.template,
            "prompt.template",
            find_line_in_yaml(raw_yaml, "template:"),
            env,
        )
        issues.extend(template_issues)

    # Check external template file
    if config.prompt.template_file:
        template_path = resolve_path(config.prompt.template_file, config_path)
        if template_path.exists():
            try:
                template_content = template_path.read_text()
                template_issues = self._check_template(
                    template_content,
                    f"template_file ({template_path.name})",
                    None,
                    env,
                )
                issues.extend(template_issues)
            except Exception as e:  # noqa: BLE001 — template read failure is appended to returned validation issues
                issues.append(
                    ValidationIssue(
                        check_id=self.check_id,
                        severity=self.severity,
                        message=f"Could not read template file: {e}",
                        suggestion=f"Check file permissions for {template_path}",
                    )
                )

    return issues

JinjaUndefinedVariableCheck

Check for undefined template variables (V101).

Warns about variables used in templates that aren't defined in the config's variables section or the built-in sheet context. Uses fuzzy matching to suggest corrections for typos.

Methods:
check
check(config, config_path, raw_yaml)

Check for undefined variables in templates.

Source code in src/marianne/validation/checks/jinja.py
def check(
    self,
    config: JobConfig,
    config_path: Path,
    raw_yaml: str,
) -> list[ValidationIssue]:
    """Check for undefined variables in templates."""
    issues: list[ValidationIssue] = []
    env = jinja2.Environment()

    # Collect all defined variables
    defined_vars = set(self.BUILTIN_VARIABLES)
    defined_vars.update(config.prompt.variables.keys())
    # A declared loop index is emitted bare and under `loops.<index>`.
    defined_vars.update(loop.index for loop in (config.sheet.loops or {}).values())

    # Check inline template
    if config.prompt.template:
        var_issues = self._check_undefined_vars(
            config.prompt.template,
            "prompt.template",
            defined_vars,
            env,
        )
        issues.extend(var_issues)

    # Check external template file
    if config.prompt.template_file:
        template_path = resolve_path(config.prompt.template_file, config_path)
        if template_path.exists():
            try:
                template_content = template_path.read_text()
                var_issues = self._check_undefined_vars(
                    template_content,
                    f"template_file ({template_path.name})",
                    defined_vars,
                    env,
                )
                issues.extend(var_issues)
            except Exception as exc:  # noqa: BLE001 — template read failure is appended to returned validation issues
                issues.append(ValidationIssue(
                    check_id="V101",
                    severity=ValidationSeverity.WARNING,
                    message=f"Cannot read template file '{template_path.name}' "
                            f"for undefined variable check: {exc}",
                    suggestion="Ensure the template file is readable.",
                ))

    return issues

MemoryAccessInvalidCheck

Bases: _MemoryCheck

V346: access is neither inherit nor a grant reference.

MemoryCamSettingsCheck

Bases: _MemoryCheck

V350: a system: cam attachment may only name an endpoint the operator configured.

MemoryCapsInvalidCheck

Bases: _MemoryCheck

V345: caps out of range, a cap above the score default, or unknown provenance.

MemoryGrantUnknownCheck

Bases: _MemoryCheck

V347: a grant reference cannot resolve because no grant store exists yet.

MemoryPhasesInvalidCheck

Bases: _MemoryCheck

V342: a phases entry matches no phase rule.

MemoryProvenanceOffNote

Bases: _MemoryCheck

V349 (INFO): provenance: off was read as optional.

MemoryScopeInvalidCheck

Bases: _MemoryCheck

V344: scope fails the scope grammar.

MemorySystemUnknownCheck

Bases: _MemoryCheck

V340: system names a backend this release does not ship.

AbsoluteHomePathCheck

Flag machine-absolute paths under the user's home (V004).

Absolute /home/<user>/... (or equivalent) paths make scores non-portable and leak personal layout into shared artifacts. The portable forms are ~-relative, {workspace}/{score_dir} templates, and relative paths.

Judged against the RAW YAML, not the model: the model pre-resolves a ~/ workspace into an absolute-under-home Path at load time, which would false-positive the explicitly-portable tilde form. Movement cadenzas (movements.<n>.cadenzas) are scanned the same way (GH #571).

Methods:
check
check(config, config_path, raw_yaml)

Check workspace, prelude/cadenza paths, hook job_paths, variables.

Source code in src/marianne/validation/checks/paths.py
def check(
    self,
    config: JobConfig,
    config_path: Path,
    raw_yaml: str,
) -> list[ValidationIssue]:
    """Check workspace, prelude/cadenza paths, hook job_paths, variables."""
    data = parsed_document(raw_yaml)
    if data is None:
        return []

    home_prefix = str(Path.home())
    issues: list[ValidationIssue] = []

    def _is_home_absolute(value: str) -> bool:
        return value.startswith(home_prefix)

    def _flag(field: str, value: str) -> None:
        issues.append(
            ValidationIssue(
                check_id=self.check_id,
                severity=self.severity,
                message=(
                    f"Absolute home path in {field}: {value}. Scores must "
                    "stay portable — use ~, {score_dir}, {workspace}, or "
                    "a relative path."
                ),
                line=find_line_in_yaml(raw_yaml, value),
                suggestion=(
                    f"Replace the absolute path in {field} with a "
                    "portable form (~/, {score_dir}/, {workspace}/, or "
                    "score-relative)."
                ),
                metadata={"field": field, "path": value},
            )
        )

    def _scan_items(items: object, field: str) -> None:
        if not isinstance(items, list):
            return
        for item in items:
            if not isinstance(item, dict):
                continue
            for key in ("file", "directory"):
                val = item.get(key)
                if isinstance(val, str) and _is_home_absolute(val):
                    _flag(f"{field}.{key}", val)

    # workspace — judged from raw (model pre-resolves ~/ to absolute)
    ws = data.get("workspace")
    if isinstance(ws, str) and _is_home_absolute(ws):
        _flag("workspace", ws)

    sheet_cfg = data.get("sheet")
    if isinstance(sheet_cfg, dict):
        _scan_items(sheet_cfg.get("prelude"), "prelude")
        cadenzas = sheet_cfg.get("cadenzas")
        if isinstance(cadenzas, dict):
            for items in cadenzas.values():
                _scan_items(items, "cadenzas")
        stdout_to = sheet_cfg.get("stdout_to")
        if isinstance(stdout_to, dict):
            for num, target in stdout_to.items():
                if isinstance(target, str) and _is_home_absolute(target):
                    _flag(f"sheet.stdout_to.{num}", target)

    # Movement cadenzas (#571): scan the raw declarations too, so a
    # home-absolute path in a movement cadenza cannot escape V004.
    movements_cfg = data.get("movements")
    if isinstance(movements_cfg, dict):
        for stage, movement in movements_cfg.items():
            if not isinstance(movement, dict):
                continue
            movement_items = movement.get("cadenzas")
            if isinstance(movement_items, list):
                _scan_items(movement_items, f"movements.{stage}.cadenzas")

    prompt_cfg = data.get("prompt")
    if isinstance(prompt_cfg, dict):
        variables = prompt_cfg.get("variables")
        if isinstance(variables, dict):
            for key, val in variables.items():
                values = val if isinstance(val, list) else [val]
                for v in values:
                    if isinstance(v, str) and _is_home_absolute(v):
                        _flag(f"prompt.variables.{key}", v)

    hooks = data.get("on_success")
    if isinstance(hooks, list):
        for hook in hooks:
            if not isinstance(hook, dict):
                continue
            job_path = hook.get("job_path")
            if isinstance(job_path, str) and _is_home_absolute(job_path):
                _flag("on_success.job_path", job_path)

    return issues

CadenzaOrderingCheck

V109: a cadenza reads a file whose producer runs later (#137).

Uses three signals: - CONSUMER: cadenzas (which sheet injects/reads which file). A movement cadenza (movements.<n>.cadenzas, GH #571) is read by each voice it reaches, so it is judged per voice, with at most one finding per (stage, item). - PRODUCER: movement produces, stdout_to, or the sheet-gated file_exists proxy (in descending ownership priority). - ORDER: the dependency DAG (which sheet is guaranteed to run first).

Warns when a cadenza on sheet M reads a file F that some sheet P is declared to produce, but P is NOT a DAG-ancestor of M — so F is not guaranteed to exist when M's cadenza fires. WARNING only: declared output is not proof that a file exists at cadenza time. F is matched to the producers by file name as written, so a per-voice path such as unit-{{ voice }}.md matches only a producer declared under that same name.

InjectionSizeCheck

A static injection item already exceeds its max_bytes (V334).

The runtime refuses (required) or drops (optional) an over-cap item at every sheet; this is the same measurement taken once, before the run, for paths that need no templating. A snapshot, not the contract — a ledger that is under the cap now can cross it on sheet 40 (GH #474).

A REQUIRED item over its cap is an ERROR: the sheet cannot run, and a warning let nine fleet scores through every static gate to fail at sheet 1 (GH #515). An optional item stays a WARNING (it will be dropped). A movement cadenza item is measured once per declaration, under the source label cadenza (stage N) (GH #571).

PreludeCadenzaFileCheck

Check that prelude/cadenza files exist when paths are static (V108).

Only checks non-templated paths (no Jinja {{). Templated paths are resolved at execution time and cannot be validated statically. Definite input files must exist before execution.

Movement cadenzas (movements.<n>.cadenzas, GH #571) are checked like sheet cadenzas: once per (stage, item), under the source label cadenza (stage N), with the same declared-product exemption.

Methods:
check
check(config, config_path, raw_yaml)

Check prelude and cadenza file/directory paths.

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

    # Files a stage is declared to produce at runtime are not expected
    # on disk now — suppress the
    # not-found warning for them on cadenzas (#137 point 5). Whether they
    # are produced EARLY ENOUGH is V109's job, not this disk check's.
    produced = set(_infer_producers(config))

    for item in config.sheet.prelude:
        # Prelude injects before any sheet runs — no producer can precede
        # it, so no suppression applies.
        issues.extend(self._check_item(item, "prelude", config, config_path, raw_yaml, set()))
    for sheet_num, items in config.sheet.cadenzas.items():
        for item in items:
            issues.extend(
                self._check_item(
                    item,
                    f"cadenza (sheet {sheet_num})",
                    config,
                    config_path,
                    raw_yaml,
                    produced,
                )
            )
    for stage, movement_items in movement_cadenzas(config).items():
        # One finding per (stage, item) — not one per voice (#571).
        for movement_item in movement_items:
            issues.extend(
                self._check_item(
                    movement_item,
                    f"cadenza (stage {stage})",
                    config,
                    config_path,
                    raw_yaml,
                    produced,
                )
            )

    return issues

TemplateFileExistsCheck

Check that template_file exists if specified (V003).

Methods:
check
check(config, config_path, raw_yaml)

Check template_file exists.

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

    if config.prompt.template_file:
        template_path = resolve_path(config.prompt.template_file, config_path)

        if not template_path.exists():
            issues.append(
                ValidationIssue(
                    check_id=self.check_id,
                    severity=self.severity,
                    message=f"Template file not found: {template_path}",
                    line=find_line_in_yaml(raw_yaml, "template_file:"),
                    suggestion="Create the template file or fix the path",
                    metadata={
                        "expected_path": str(template_path),
                    },
                )
            )
        elif not template_path.is_file():
            issues.append(
                ValidationIssue(
                    check_id=self.check_id,
                    severity=self.severity,
                    message=f"Template path is not a file: {template_path}",
                    line=find_line_in_yaml(raw_yaml, "template_file:"),
                    suggestion="Ensure template_file points to a file, not a directory",
                )
            )

    return issues

ValidationPathScopeCheck

Check static path_in_scope rules resolve inside their allowed root (V306).

Methods:
check
check(config, config_path, raw_yaml)

Check path_in_scope rule paths when they are statically resolvable.

Source code in src/marianne/validation/checks/paths.py
def check(
    self,
    config: JobConfig,
    config_path: Path,
    raw_yaml: str,
) -> list[ValidationIssue]:
    """Check path_in_scope rule paths when they are statically resolvable."""
    issues: list[ValidationIssue] = []
    workspace = _workspace_path(config, config_path)

    for rule in config.validations:
        if rule.type != "path_in_scope" or not rule.path:
            continue
        scope_raw = rule.path_scope or "{workspace}"
        path = _expand_scope_template(rule.path, workspace)
        scope = _expand_scope_template(scope_raw, workspace)
        if path is None or scope is None:
            continue

        if not path.is_relative_to(scope):
            issues.append(
                ValidationIssue(
                    check_id=self.check_id,
                    severity=self.severity,
                    message=(
                        f"path_in_scope validation resolves outside its allowed scope: {path}"
                    ),
                    line=find_line_in_yaml(raw_yaml, rule.path),
                    suggestion=(
                        "Use a path under the workspace/scope, or fix "
                        "symlinks and '..' segments that resolve outside it"
                    ),
                    metadata={
                        "path": str(path),
                        "scope": str(scope),
                    },
                )
            )

    return issues

WorkspaceParentExistsCheck

Check that workspace parent directory exists (V002).

The workspace itself will be created, but its parent must exist. This is auto-fixable by creating the parent directories.

Methods:
check
check(config, config_path, raw_yaml)

Check workspace parent exists.

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

    workspace = resolve_path(config.workspace, config_path)
    parent = workspace.parent

    if not parent.exists():
        issues.append(
            ValidationIssue(
                check_id=self.check_id,
                severity=self.severity,
                message=f"Workspace parent directory does not exist: {parent}",
                line=find_line_in_yaml(raw_yaml, "workspace:"),
                suggestion=f"Create parent directory: mkdir -p {parent}",
                auto_fixable=True,
                metadata={
                    "path": str(parent),
                    "workspace": str(workspace),
                },
            )
        )

    return issues

DeprecatedSpellingCheck

V328: a score uses a renamed key's old spelling, or a deprecated key.

EnabledSettingsWarningCheck

V329: release-N warning for readable default-off sections.

ReservedKeyUseCheck

V327: a score sets a key no runtime code reads.

TechniqueMcpInstrumentCheck

Check MCP techniques target MCP-capable instruments (V302).

When a score declares MCP techniques, the primary instrument needs an MCP access path. Native MCP configuration is one path; the generated code-mode techniques_rt.py bridge is the portable fallback for CLI instruments.

Methods:
check
check(config, config_path, raw_yaml)

Check MCP techniques against instrument capabilities.

Built-in profile loading exceptions log validation.profiles_unavailable_skip at WARNING and return no findings without assessing capability.

Source code in src/marianne/validation/checks/techniques.py
def check(
    self,
    config: JobConfig,
    config_path: Path,
    raw_yaml: str,
) -> list[ValidationIssue]:
    """Check MCP techniques against instrument capabilities.

    Built-in profile loading exceptions log
    ``validation.profiles_unavailable_skip`` at WARNING and return no
    findings without assessing capability.
    """
    if not config.techniques:
        return []

    mcp_techniques = [
        name for name, tc in config.techniques.items()
        if tc.kind == TechniqueKind.MCP
    ]
    if not mcp_techniques:
        return []

    instrument_name = config.effective_instrument_name
    if not instrument_name:
        return []

    # Try loading the instrument profile to check for direct MCP config.
    try:
        profiles = _builtin_profiles()
        profile = profiles.get(instrument_name)
    except Exception:  # noqa: BLE001 — unavailable profiles skip the MCP check, loudly
        _logger.warning(
            "validation.profiles_unavailable_skip", check=self.check_id, exc_info=True,
        )
        return []

    if profile is None:
        # Unknown instrument — don't emit V302 since we can't verify
        return []

    has_native_mcp_config = bool(
        profile.cli
        and profile.cli.command
        and (
            profile.cli.command.mcp_config_flag
            or profile.cli.command.mcp_config_workspace_path
        )
    )
    has_code_bridge = bool(profile.kind == "cli" and profile.cli)

    if not (has_native_mcp_config or has_code_bridge):
        names_str = ", ".join(mcp_techniques)
        return [
            ValidationIssue(
                check_id=self.check_id,
                severity=self.severity,
                message=(
                    f"MCP techniques ({names_str}) declared but "
                    f"instrument '{instrument_name}' has no native MCP "
                    "config path or generated code-mode bridge support"
                ),
                line=find_line_in_yaml(raw_yaml, "techniques"),
                suggestion=(
                    "Use a CLI instrument supported by Marianne's shared "
                    "MCP bridge or remove the MCP techniques"
                ),
            ),
        ]
    return []

TechniqueSkillPathCheck

Check that skill techniques reference existing documents (V301).

When a skill technique declares a path in its config, the referenced file should exist. Missing skill docs mean the agent won't receive the methodology the score author intended.

Methods:
check
check(config, config_path, raw_yaml)

Check skill technique paths exist.

Source code in src/marianne/validation/checks/techniques.py
def check(
    self,
    config: JobConfig,
    config_path: Path,
    raw_yaml: str,
) -> list[ValidationIssue]:
    """Check skill technique paths exist."""
    if not config.techniques:
        return []

    issues: list[ValidationIssue] = []
    for name, tc in config.techniques.items():
        if tc.kind != TechniqueKind.SKILL:
            continue
        skill_path_str = tc.config.get("path")
        if skill_path_str is None:
            continue
        skill_path = Path(skill_path_str).expanduser()
        if not skill_path.is_absolute():
            skill_path = config_path.parent / skill_path
        if not skill_path.exists():
            issues.append(
                ValidationIssue(
                    check_id=self.check_id,
                    severity=self.severity,
                    message=(
                        f"Skill technique '{name}' references "
                        f"'{skill_path_str}' which does not exist"
                    ),
                    line=find_line_in_yaml(raw_yaml, name),
                    suggestion=(
                        f"Create the skill document at '{skill_path_str}' "
                        "or remove the path from the technique config"
                    ),
                ),
            )
    return issues