Skip to content

cli

cli

Static checks for raw shell prompt contracts.

Classes

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.

Functions: