Skip to content

recover

recover

Recover command for Marianne CLI.

This module implements the hidden mzt recover command for recovering sheets that completed work but were incorrectly marked as failed.

★ Insight ───────────────────────────────────── 1. Non-destructive recovery: The recover command re-runs validations without re-executing the backend. This is useful when work was completed but the process failed afterwards (e.g., transient network error after writing files).

  1. State machine transitions: The command can transition sheets from FAILED to COMPLETED, and the job from FAILED to PAUSED. This allows the job to be resumed normally after recovery.

  2. Dry-run safety: The --dry-run flag runs validations without modifying state. This lets users preview what would be recovered before committing. ─────────────────────────────────────────────────

Attributes

Classes

Functions

recover

recover(job_id=Argument(..., help='Score ID to recover'), sheet=Option(None, '--sheet', '-s', help='Specific sheet number to recover (default: all failed sheets)'), from_sheet=Option(None, '--from-sheet', '-f', help='Reset all FAILED sheets >= this number to PENDING (cascade recovery)'), dry_run=Option(False, '--dry-run', '-n', help='Check validations without modifying state'))

Recover sheets that completed work but were incorrectly marked as failed.

This command runs validations for failed sheets without re-executing them. If validations pass, the sheet is marked as complete.

This is useful when: - Claude CLI returned a non-zero exit code but the work was done - A transient error caused failure after files were created - You want to check if a failed sheet actually succeeded - A cascade failure wiped out downstream sheets after one failure

Examples:

mzt recover my-job # Recover all failed sheets mzt recover my-job --sheet 6 # Recover specific sheet mzt recover my-job --dry-run # Check without modifying mzt recover my-job --from-sheet 211 # Reset cascade from sheet 211+

Source code in src/marianne/cli/commands/recover.py
def recover(
    job_id: str = typer.Argument(..., help="Score ID to recover"),
    sheet: int | None = typer.Option(
        None,
        "--sheet",
        "-s",
        help="Specific sheet number to recover (default: all failed sheets)",
    ),
    from_sheet: int | None = typer.Option(
        None,
        "--from-sheet",
        "-f",
        help="Reset all FAILED sheets >= this number to PENDING (cascade recovery)",
    ),
    dry_run: bool = typer.Option(
        False,
        "--dry-run",
        "-n",
        help="Check validations without modifying state",
    ),
) -> None:
    """Recover sheets that completed work but were incorrectly marked as failed.

    This command runs validations for failed sheets without re-executing them.
    If validations pass, the sheet is marked as complete.

    This is useful when:
    - Claude CLI returned a non-zero exit code but the work was done
    - A transient error caused failure after files were created
    - You want to check if a failed sheet actually succeeded
    - A cascade failure wiped out downstream sheets after one failure

    Examples:
        mzt recover my-job                    # Recover all failed sheets
        mzt recover my-job --sheet 6         # Recover specific sheet
        mzt recover my-job --dry-run         # Check without modifying
        mzt recover my-job --from-sheet 211  # Reset cascade from sheet 211+
    """
    from ._shared import validate_job_id

    job_id = validate_job_id(job_id)

    if from_sheet is not None:
        asyncio.run(_recover_cascade(job_id, from_sheet, dry_run))
        return

    asyncio.run(_recover_job(job_id, sheet, dry_run))