# `Spectre.Instance.Owner`
[🔗](https://github.com/elchemista/spectre/blob/0.4.0/lib/spectre/instance/owner.ex#L1)

Host contract for canonical Instance ownership and monotonic fencing.

A local Registry is routing, not distributed ownership. Hosts that may run
the same logical Instance on multiple nodes must supply an adapter backed by
a linearizable lease or route all work to one canonical owner. Losing or
superseding the lease blocks admission, activation commit, state commit,
Effect dispatch, and retry before dispatch.

# `config`

```elixir
@type config() :: module() | {module(), keyword()} | nil
```

# `claim`

```elixir
@callback claim(
  Spectre.Instance.Ref.t(),
  keyword()
) :: {:ok, Spectre.Instance.Owner.Lease.t()} | {:error, term()}
```

# `claim_maintenance`
*optional* 

```elixir
@callback claim_maintenance(Spectre.Instance.Ref.t(), atom(), keyword()) ::
  {:ok, Spectre.Instance.Owner.Lease.t()} | {:error, term()}
```

# `release`
*optional* 

```elixir
@callback release(Spectre.Instance.Ref.t(), Spectre.Instance.Owner.Lease.t(), keyword()) ::
  :ok | {:error, term()}
```

# `validate`

```elixir
@callback validate(Spectre.Instance.Ref.t(), Spectre.Instance.Owner.Lease.t(), keyword()) ::
  :ok | {:error, term()}
```

# `assert_current`

```elixir
@spec assert_current(
  config(),
  Spectre.Instance.Ref.t(),
  Spectre.Instance.Owner.Lease.t(),
  atom(),
  keyword()
) :: :ok | {:error, term()}
```

Validates a lease and classifies failure as an owner-fence loss for one
concrete operation.

# `claim`

```elixir
@spec claim(config(), Spectre.Instance.Ref.t(), keyword()) ::
  {:ok, {module(), keyword()}, Spectre.Instance.Owner.Lease.t()}
  | {:error, term()}
```

Claims ownership and validates the returned portable lease.

# `claim_maintenance`

```elixir
@spec claim_maintenance(config(), Spectre.Instance.Ref.t(), atom(), keyword()) ::
  {:ok, {module(), keyword()}, Spectre.Instance.Owner.Lease.t()}
  | {:error, term()}
```

Claims an unowned Instance for one offline maintenance operation.

Unlike an ordinary claim, an adapter must not supersede a live owner. The
callback is optional so existing adapters remain source compatible, but
maintenance operations fail with an explicit capability error when it is
absent. The local adapter is safe only after core has reserved the unique
local Registry key.

# `maintenance_capability`

```elixir
@spec maintenance_capability(config()) :: :ok | {:error, term()}
```

Checks whether an Owner can fence an offline maintenance operation.

# `normalize`

```elixir
@spec normalize(config()) :: {:ok, {module(), keyword()}} | {:error, term()}
```

Normalizes an ownership adapter; `nil` selects the local-only adapter.

# `release`

```elixir
@spec release(
  config(),
  Spectre.Instance.Ref.t(),
  Spectre.Instance.Owner.Lease.t(),
  keyword()
) ::
  :ok | {:error, term()}
```

Releases an owned lease when the adapter implements the callback.

# `validate`

```elixir
@spec validate(
  config(),
  Spectre.Instance.Ref.t(),
  Spectre.Instance.Owner.Lease.t(),
  keyword()
) ::
  :ok | {:error, term()}
```

Validates that a lease remains current at a guarded boundary.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
