Skip to content

registry_backend

registry_backend

A StateBackend backed by the daemon registry DB (#111).

Lets offline readers (CLI commands when the conductor is down) get the current job state from the authoritative daemon DB (~/.marianne/daemon-state.db) instead of the stale, possibly-lossy per-workspace state files. The daemon DB is the source of truth; this adapter exposes it through the standard StateBackend interface so existing offline-read callers (which expect a (CheckpointState, StateBackend) pair) work unchanged.

Lives in daemon/ (not state/) because it bridges state.StateBackend onto daemon.JobRegistry — state/ must not import daemon/.

Attributes

Classes

RegistryStateBackend

RegistryStateBackend(registry)

Bases: StateBackend

Expose the daemon registry's checkpoint store as a StateBackend.

Wraps an already-open JobRegistry; close() closes it, matching the "caller closes the returned backend" contract of the offline-read helpers.

Source code in src/marianne/daemon/registry_backend.py
def __init__(self, registry: JobRegistry) -> None:
    self._registry = registry

RegistryFirstReadBackend

RegistryFirstReadBackend(workspace, *, db_path=None)

Bases: StateBackend

Read job state from the authoritative daemon DB — conductor-ONLY (#50).

For read-only consumers (the MCP server, the dashboard's offline fallback). #111 gave this class a per-workspace fallback; #50 removed it per the composer's ruling ("workspaces are for work to occur only, not for state tracking") — load() reads the daemon registry and NOTHING else. The registry is opened transiently per load (no long-lived handle to leak). A job absent from the registry does not exist as far as state is concerned.

The workspace constructor parameter is retained for call-signature stability but no longer consulted. Write/list operations raise — these consumers only ever read, and state writes belong to the conductor.

Source code in src/marianne/daemon/registry_backend.py
def __init__(self, workspace: Path, *, db_path: Path | None = None) -> None:
    del workspace  # #50: no workspace state access, ever
    self._db_path = (db_path or DAEMON_STATE_DB_PATH).expanduser()

Functions: