# `MingaEditor.EffectScheduler`
[🔗](https://github.com/jsmestad/minga/blob/main/lib/minga_editor/effect_scheduler.ex#L1)

Editor-generation-owned process wrapper for bounded slow effects.

Work is serialized by stable resource identity while unrelated resources run
concurrently. Lifecycle, policy, admission, and worker transitions live in
`MingaEditor.EffectScheduler.Engine`.

# `admission`

```elixir
@type admission() :: MingaEditor.EffectScheduler.Engine.admission()
```

# `admission_error`

```elixir
@type admission_error() :: MingaEditor.EffectScheduler.Engine.admission_error()
```

# `cancel_error`

```elixir
@type cancel_error() :: :not_found | :scheduler_unavailable
```

# `claim`

```elixir
@type claim() :: MingaEditor.EffectScheduler.Engine.claim()
```

# `handoff`

```elixir
@type handoff() :: MingaEditor.EffectScheduler.Engine.handoff()
```

# `server`

```elixir
@type server() :: GenServer.server()
```

Scheduler server reference.

# `source`

```elixir
@type source() :: Minga.Extension.ContributionCleanup.contribution_source()
```

# `active?`

```elixir
@spec active?(server() | nil, module()) :: boolean()
```

Returns whether the scheduler has running or queued work for a domain handler.

# `active_activity?`

```elixir
@spec active_activity?(server() | nil, atom()) :: boolean()
```

Returns whether any queued, running, or pending request advertises an activity.

# `active_source?`

```elixir
@spec active_source?(server() | nil, source()) :: boolean()
```

Returns whether a source has queued, running, or pending work.

# `admitted?`

```elixir
@spec admitted?(server() | nil, MingaEditor.Effect.Request.id()) :: boolean()
```

Returns whether an exact request still holds scheduler admission.

# `attach`

```elixir
@spec attach(server(), pid()) :: :ok | {:error, :already_attached}
```

Attaches the single Editor owner for this scheduler generation.

# `cancel`

```elixir
@spec cancel(server(), MingaEditor.Effect.Request.id()) :: :ok | {:error, :not_found}
```

Cancels an admitted request by id.

# `cancel_operation`

```elixir
@spec cancel_operation(server() | nil, MingaEditor.State.Operation.id()) ::
  :ok | {:error, cancel_error()}
```

Cancels the admitted request correlated with a semantic operation.

# `cancel_resource`

```elixir
@spec cancel_resource(server() | nil, MingaEditor.Effect.Request.resource()) ::
  :ok | {:error, :scheduler_unavailable}
```

Cancels queued, running, and pending work for a semantic resource.

# `cancel_source`

```elixir
@spec cancel_source(server() | nil, source()) ::
  :ok | {:error, :scheduler_unavailable}
```

Cancels queued, running, and pending work attributed to a source.

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `claim`

```elixir
@spec claim(server(), MingaEditor.Effect.Outcome.t()) :: claim()
```

Claims a still-current candidate before its domain handler applies it.

# `finalize`

```elixir
@spec finalize(server(), MingaEditor.Effect.Outcome.t()) :: :ok
```

Finalizes the domain-applied terminal outcome exactly once.

# `finalize_and_schedule`

```elixir
@spec finalize_and_schedule(
  server(),
  MingaEditor.Effect.Outcome.t(),
  MingaEditor.Effect.Request.t()
) ::
  handoff()
```

Atomically finalizes one candidate and admits its typed follow-up request.

# `schedule`

```elixir
@spec schedule(server(), MingaEditor.Effect.Request.t()) :: admission()
```

Admits a typed effect request under its declared bounded policy.

# `start_link`

```elixir
@spec start_link(keyword()) :: GenServer.on_start()
```

Starts an effect scheduler.

# `stats`

```elixir
@spec stats(server()) :: %{
  resources: non_neg_integer(),
  running: non_neg_integer(),
  queued: non_neg_integer(),
  pending: non_neg_integer(),
  admitted: non_neg_integer(),
  capacity: pos_integer()
}
```

Returns bounded scheduler statistics without exposing queued payloads.

---

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