Skip to content

status

status

Status commands for Marianne CLI.

This module implements job status display commands: - mzt status <job-id> - Show detailed status for a specific job - mzt list (list_jobs) - List all jobs in the workspace

★ Insight ───────────────────────────────────── 1. Dual output modes: Both JSON and Rich output are supported for all status commands. JSON mode enables scripting and CI/CD integration while Rich mode provides a human-friendly interactive experience.

  1. Watch mode implementation: The status --watch flag uses a polling loop with screen clearing. This is simpler than event-driven updates but works universally across state backends (JSON files or SQLite).

  2. Circuit breaker inference: The actual CircuitBreaker is a runtime object not persisted to state. We infer its likely state from failure patterns in the persisted sheet states to give operators visibility into retry behavior. ─────────────────────────────────────────────────

Attributes

Classes

CircuitBreakerInference

Bases: TypedDict

Inferred circuit breaker state from job failure patterns.

Functions:

format_instrument_with_fallback

format_instrument_with_fallback(sheet)

Format instrument name with fallback indicator if applicable.

Shows the current instrument and, when fallback history exists, annotates with the previous instrument and reason.

Examples:

"claude-code" (no fallback) "gemini-cli dim[/dim]"

Source code in src/marianne/cli/commands/status.py
def format_instrument_with_fallback(sheet: SheetState) -> str:
    """Format instrument name with fallback indicator if applicable.

    Shows the current instrument and, when fallback history exists,
    annotates with the previous instrument and reason.

    Examples:
        "claude-code"  (no fallback)
        "gemini-cli [dim](was claude-code: rate_limit_exhausted)[/dim]"
    """
    name = sheet.instrument_name or ""
    # #334: surface the per-sheet model override so two sheets sharing a
    # profile (e.g. two `instruments:` aliases over claude-code) but using
    # different models are distinguishable at a glance. Only the explicit
    # override is shown; a bare profile name means the profile default.
    if sheet.instrument_model:
        name = f"{name} ({sheet.instrument_model})"
    if sheet.instrument_resolution is not None:
        name = f"{sheet.instrument_resolution.requested} → {name}"
    if not sheet.instrument_fallback_history:
        return name
    last = sheet.instrument_fallback_history[-1]
    original = last.get("from", "")
    reason = last.get("reason", "fallback")
    # GH #434: say how long the previous instrument held the sheet. A
    # 1,800 s zero-output stall followed by a 69 s success must not read as
    # "69 s success" — the time went to the instrument that fell.
    spent = sum(
        float(a.get("duration_seconds") or 0.0)
        for a in sheet.attempt_history
        if a.get("instrument") == original
    )
    spent_str = f" after {format_duration(spent)}" if spent >= 1 else ""
    return f"{name} [dim](was {original}: {reason}{spent_str})[/dim]"

format_dispatch_wait

format_dispatch_wait(sheet)

Return a concise human label for a scheduler dispatch wait.

Source code in src/marianne/cli/commands/status.py
def format_dispatch_wait(sheet: SheetState) -> str | None:
    """Return a concise human label for a scheduler dispatch wait."""
    reason = getattr(sheet, "dispatch_blocked_reason", None)
    if not reason:
        return None
    details = getattr(sheet, "dispatch_blocked_details", {}) or {}
    if reason == "model_concurrency":
        model_key = details.get("model_key") or details.get("instrument") or "model"
        count = details.get("model_count")
        limit = details.get("model_limit")
        if count is not None and limit is not None:
            return f"waiting for model capacity: {model_key} ({count}/{limit})"
        return f"waiting for model capacity: {model_key}"
    if reason == "global_concurrency":
        running = details.get("global_running")
        limit = details.get("limit")
        if running is not None and limit is not None:
            return f"waiting for global capacity ({running}/{limit})"
        return "waiting for global capacity"
    if reason == "rate_limited":
        instrument = details.get("instrument") or sheet.instrument_name or "instrument"
        return f"waiting for rate limit: {instrument}"
    if reason == "circuit_breaker":
        instrument = details.get("instrument") or sheet.instrument_name or "instrument"
        return f"waiting for circuit breaker: {instrument}"
    if reason == "stagger":
        instrument = details.get("instrument") or sheet.instrument_name or "instrument"
        remaining = details.get("remaining_ms")
        if remaining is not None:
            return f"waiting for dispatch stagger: {instrument} ({remaining}ms)"
        return f"waiting for dispatch stagger: {instrument}"
    return f"waiting for dispatch: {reason}"

status

status(job_id=Argument(None, help="The score's run id (job id) to check status for. Omit to see all active scores."), json_output=Option(False, '--json', '-j', help='Output status as JSON for machine parsing'), watch=Option(False, '--watch', '-W', help='Continuously monitor status with live updates'), watch_interval=Option(5, '--interval', '-i', help='Refresh interval in seconds for --watch mode (default: 5)'), workspace=Option(None, '--workspace', '-w', help='Workspace directory to search for score state (debug override)', hidden=True))

Show score status. Run with no arguments for an overview of all scores.

With no arguments: shows conductor status and all active scores. With a score ID: shows detailed status for that specific score.

Examples:

mzt status mzt status my-job mzt status my-job --json mzt status my-job --watch

Source code in src/marianne/cli/commands/status.py
def status(
    job_id: str | None = typer.Argument(
        None,
        help="The score's run id (job id) to check status for. "
        "Omit to see all active scores.",
    ),
    json_output: bool = typer.Option(
        False,
        "--json",
        "-j",
        help="Output status as JSON for machine parsing",
    ),
    watch: bool = typer.Option(
        False,
        "--watch",
        "-W",
        help="Continuously monitor status with live updates",
    ),
    watch_interval: int = typer.Option(
        5,
        "--interval",
        "-i",
        help="Refresh interval in seconds for --watch mode (default: 5)",
    ),
    workspace: Path | None = typer.Option(
        None,
        "--workspace",
        "-w",
        help="Workspace directory to search for score state (debug override)",
        hidden=True,
    ),
) -> None:
    """Show score status. Run with no arguments for an overview of all scores.

    With no arguments: shows conductor status and all active scores.
    With a score ID: shows detailed status for that specific score.

    Examples:
        mzt status
        mzt status my-job
        mzt status my-job --json
        mzt status my-job --watch
    """
    if job_id is None:
        asyncio.run(_status_overview(json_output))
        return

    from ._shared import validate_job_id

    job_id = validate_job_id(job_id)
    if watch:
        asyncio.run(_status_job_watch(job_id, json_output, watch_interval, workspace))
    else:
        asyncio.run(_status_job(job_id, json_output, workspace))

list_jobs

list_jobs(all_jobs=Option(False, '--all', '-a', help='Show all scores including completed, failed, and cancelled'), status_filter=Option(None, '--status', '-s', help='Filter by score status (queued, running, completed, failed, paused)'), limit=Option(20, '--limit', '-l', help='Maximum number of terminal (completed/failed/cancelled) scores to display; live scores (queued, running, paused) are always all shown'), json_output=Option(False, '--json', help='Output as JSON array for machine parsing'), workspace=Option(None, '--workspace', '-w', help='Reserved for future per-workspace filtering.', hidden=True))

List scores from the conductor.

By default shows only active scores (queued, running, paused). Use --all to include completed, failed, and cancelled scores.

Source code in src/marianne/cli/commands/status.py
def list_jobs(
    all_jobs: bool = typer.Option(
        False,
        "--all",
        "-a",
        help="Show all scores including completed, failed, and cancelled",
    ),
    status_filter: str | None = typer.Option(
        None,
        "--status",
        "-s",
        help="Filter by score status (queued, running, completed, failed, paused)",
    ),
    limit: int = typer.Option(
        20,
        "--limit",
        "-l",
        help="Maximum number of terminal (completed/failed/cancelled) scores to "
        "display; live scores (queued, running, paused) are always all shown",
    ),
    json_output: bool = typer.Option(
        False,
        "--json",
        help="Output as JSON array for machine parsing",
    ),
    workspace: Path | None = typer.Option(
        None,
        "--workspace",
        "-w",
        help="Reserved for future per-workspace filtering.",
        hidden=True,
    ),
) -> None:
    """List scores from the conductor.

    By default shows only active scores (queued, running, paused).
    Use --all to include completed, failed, and cancelled scores.
    """
    asyncio.run(_list_jobs(all_jobs, status_filter, limit, workspace, json_output))

protocol_mismatch_warning

protocol_mismatch_warning(daemon_protocol_version)

Build a warning when the conductor speaks a different IPC version (#265).

Parameters:

Name Type Description Default
daemon_protocol_version int

The protocol_version the conductor advertised (0 when an older conductor omitted the field).

required

Returns:

Type Description
str | None

A user-facing warning string, or None when versions match.

Source code in src/marianne/cli/commands/status.py
def protocol_mismatch_warning(daemon_protocol_version: int) -> str | None:
    """Build a warning when the conductor speaks a different IPC version (#265).

    Args:
        daemon_protocol_version: The ``protocol_version`` the conductor
            advertised (0 when an older conductor omitted the field).

    Returns:
        A user-facing warning string, or None when versions match.
    """
    from marianne.daemon.ipc.protocol import PROTOCOL_VERSION

    if daemon_protocol_version == PROTOCOL_VERSION:
        return None
    return (
        f"Conductor speaks IPC protocol v{daemon_protocol_version}, this CLI "
        f"expects v{PROTOCOL_VERSION} — responses may not parse correctly. "
        "Restart the conductor on the installed version: wait for active "
        "scores to finish, then `mzt stop && mzt start`."
    )

fermata_resolve_hint

fermata_resolve_hint(job_id, sheet_num, reason)

Lines telling the composer how to resolve a FERMATA'd sheet (#361).

FERMATA pauses a sheet for a composer decision; resolution is a marker file the baton polls. Surface the reason + the (workspace-relative) marker path + the decisions inline so mzt status is actionable without docs.

Source code in src/marianne/cli/commands/status.py
def fermata_resolve_hint(job_id: str, sheet_num: int, reason: str | None) -> list[str]:
    """Lines telling the composer how to resolve a FERMATA'd sheet (#361).

    FERMATA pauses a sheet for a composer decision; resolution is a marker file
    the baton polls. Surface the reason + the (workspace-relative) marker path +
    the decisions inline so `mzt status` is actionable without docs.
    """
    rel = f"markers/fermata/{job_id}/sheet-{sheet_num}"
    return [
        f"  Sheet {sheet_num}: [magenta]⏸ FERMATA — awaiting composer decision[/magenta]"
        + (f" ({reason})" if reason else ""),
        f"    Resolve: [bold]mzt resolve {job_id} {sheet_num} <decision>[/bold] —",
        "      [dim]retry[/dim]   re-run the sheet from scratch",
        "      [dim]skip[/dim]    skip it, continue dependents",
        "      [dim]accept[/dim]  accept the last attempt as success",
        "      [dim]fail[/dim]    fail it, propagate to dependents",
        f"    (or create a marker file under the job workspace: [dim]{rel}.<decision>[/dim])",
    ]

clear

clear(job=Option(None, '--score', '-j', help='Specific score ID(s) to clear. Can be repeated.'), status_filter=Option(None, '--status', '-s', help='Status(es) to clear: failed, completed, cancelled. Can be repeated. Defaults to all terminal statuses.'), older_than=Option(None, '--older-than', help='Only clear scores older than this many seconds.'), yes=Option(False, '--yes', '-y', help='Skip confirmation prompt.'))

Clear completed, failed, and cancelled scores from the conductor registry.

Removes completed, failed, and/or cancelled scores from the conductor's tracking. Running and queued scores are never cleared.

Examples:

mzt clear # Clear all terminal scores mzt clear --score conductor-fix # Clear a specific score mzt clear --status failed # Clear only failed scores mzt clear --status failed -s cancelled # Clear failed + cancelled mzt clear --older-than 3600 # Terminal scores older than 1h mzt clear -y # Skip confirmation

Source code in src/marianne/cli/commands/status.py
def clear(
    job: list[str] | None = typer.Option(
        None,
        "--score",
        "-j",
        help="Specific score ID(s) to clear. Can be repeated.",
    ),
    status_filter: list[str] | None = typer.Option(
        None,
        "--status",
        "-s",
        help="Status(es) to clear: failed, completed, cancelled. "
        "Can be repeated. Defaults to all terminal statuses.",
    ),
    older_than: float | None = typer.Option(
        None,
        "--older-than",
        help="Only clear scores older than this many seconds.",
    ),
    yes: bool = typer.Option(
        False,
        "--yes",
        "-y",
        help="Skip confirmation prompt.",
    ),
) -> None:
    """Clear completed, failed, and cancelled scores from the conductor registry.

    Removes completed, failed, and/or cancelled scores from the conductor's
    tracking. Running and queued scores are never cleared.

    Examples:
        mzt clear                                 # Clear all terminal scores
        mzt clear --score conductor-fix           # Clear a specific score
        mzt clear --status failed                 # Clear only failed scores
        mzt clear --status failed -s cancelled    # Clear failed + cancelled
        mzt clear --older-than 3600               # Terminal scores older than 1h
        mzt clear -y                              # Skip confirmation
    """
    asyncio.run(_clear_jobs(job, status_filter, older_than, yes))