Skip to content

clone

clone

Conductor clone support — isolated conductor instances for safe testing.

When --conductor-clone is passed to any Marianne CLI command, all daemon interactions are routed to a clone conductor instead of the production one. The clone has its own socket, PID file, state DB, and log file.

This enables safe testing of Marianne CLI commands and daemon features without risking the production conductor. The production conductor continues running undisturbed.

Usage

mzt start --conductor-clone # Start default clone mzt start --conductor-clone=staging # Start named clone mzt run score.yaml --conductor-clone # Submit to default clone mzt status --conductor-clone=staging # Query named clone

Architecture
  • A module-level _clone_name stores the active clone (set by CLI callback)
  • _resolve_socket_path() in detect.py checks get_clone_name() before falling back to SocketConfig defaults
  • resolve_clone_paths() computes all isolated paths from a clone name
  • build_clone_config() produces a DaemonConfig with clone-specific paths

Classes

ClonePaths dataclass

ClonePaths(socket, pid_file, state_db, log_file)

Isolated paths for a conductor clone instance.

Functions

set_clone_name

set_clone_name(name)

Set the active clone name. Called by CLI --conductor-clone callback.

Source code in src/marianne/daemon/clone.py
def set_clone_name(name: str | None) -> None:
    """Set the active clone name. Called by CLI --conductor-clone callback."""
    global _clone_name
    _clone_name = name

get_clone_name

get_clone_name()

Get the active clone name. None = production mode.

Source code in src/marianne/daemon/clone.py
def get_clone_name() -> str | None:
    """Get the active clone name. None = production mode."""
    return _clone_name

is_clone_active

is_clone_active()

Check if a clone is currently active.

Source code in src/marianne/daemon/clone.py
def is_clone_active() -> bool:
    """Check if a clone is currently active."""
    return _clone_name is not None

resolve_clone_paths

resolve_clone_paths(name)

Compute isolated paths for a clone instance.

Parameters:

Name Type Description Default
name str | None

Clone name (None or empty for default clone, string for named clone).

required

Returns:

Type Description
ClonePaths

ClonePaths with socket, PID, state DB, and log paths.

ClonePaths

All paths are in /tmp for socket/PID (matching production convention)

ClonePaths

and ~/.marianne for state DB/log.

Source code in src/marianne/daemon/clone.py
def resolve_clone_paths(name: str | None) -> ClonePaths:
    """Compute isolated paths for a clone instance.

    Args:
        name: Clone name (None or empty for default clone, string for named clone).

    Returns:
        ClonePaths with socket, PID, state DB, and log paths.
        All paths are in /tmp for socket/PID (matching production convention)
        and ~/.marianne for state DB/log.
    """
    suffix = _sanitize_name(name)
    tag = f"-{suffix}" if suffix else ""

    marianne_dir = Path.home() / ".marianne"

    return ClonePaths(
        socket=Path(f"/tmp/marianne-clone{tag}.sock"),
        pid_file=Path(f"/tmp/marianne-clone{tag}.pid"),
        state_db=marianne_dir / f"clone{tag}-state.db",
        log_file=Path(f"/tmp/marianne-clone{tag}.log"),
    )

build_clone_config

build_clone_config(name, *, base_config=None)

Build a DaemonConfig with clone-specific paths.

Inherits all non-path settings from base_config (or defaults). Overrides socket, PID file, and log paths with clone-specific values.

Parameters:

Name Type Description Default
name str | None

Clone name (None for default clone).

required
base_config DaemonConfig | None

Production DaemonConfig to inherit from.

None

Returns:

Type Description
DaemonConfig

A DaemonConfig with isolated clone paths.

Source code in src/marianne/daemon/clone.py
def build_clone_config(
    name: str | None,
    *,
    base_config: DaemonConfig | None = None,
) -> DaemonConfig:
    """Build a DaemonConfig with clone-specific paths.

    Inherits all non-path settings from base_config (or defaults).
    Overrides socket, PID file, and log paths with clone-specific values.

    Args:
        name: Clone name (None for default clone).
        base_config: Production DaemonConfig to inherit from.

    Returns:
        A DaemonConfig with isolated clone paths.
    """
    # Deferred import to avoid circular dependency
    from marianne.daemon.config import DaemonConfig, SocketConfig

    paths = resolve_clone_paths(name)

    if base_config is not None:
        # Clone from existing config — inherit non-path fields
        config_dict = base_config.model_dump()
        config_dict["socket"] = {"path": str(paths.socket)}
        config_dict["pid_file"] = str(paths.pid_file)
        config_dict["state_db_path"] = str(paths.state_db)
        return DaemonConfig.model_validate(config_dict)

    # Build from defaults with clone paths — all isolation fields must be set.
    # Missing state_db_path here caused F-132 (clone opened production DB).
    return DaemonConfig(
        socket=SocketConfig(path=paths.socket),
        pid_file=paths.pid_file,
        state_db_path=paths.state_db,
        log_file=paths.log_file,
    )