# `PtcRunner.Kernel.SelectionRules`
[🔗](https://github.com/andreasronge/ptc_runner/blob/main/lib/ptc_runner/kernel/selection_rules.ex#L1)

Sealed, non-executable provider-selection normalization rules.

Rules contain only bounded data: exact fields, scalar or unique-list types,
literal or named-set defaults, finite named sets, and the closed cross-rule
vocabulary `subset_of`, `required_when_set_nonempty`, and
`ceiling_of_context_limit`. They cannot contain functions, modules, MFAs,
regular expressions, or caller-owned schemas.

# `cross_rule`

```elixir
@type cross_rule() ::
  {:subset_of, binary(), binary()}
  | {:required_when_set_nonempty, binary(), binary()}
  | {:ceiling_of_context_limit, binary(), atom()}
```

# `default`

```elixir
@type default() ::
  term() | {:named_set, binary()} | {:intersection, binary(), binary()}
```

# `field`

```elixir
@type field() :: %{
  :type =&gt; scalar_type(),
  :input =&gt; boolean(),
  optional(:required) =&gt; boolean(),
  optional(:default) =&gt; default(),
  optional(:minimum) =&gt; integer(),
  optional(:maximum) =&gt; integer(),
  optional(:minimum_items) =&gt; non_neg_integer(),
  optional(:members) =&gt; binary()
}
```

# `rejection`

```elixir
@type rejection() ::
  :invalid_shape
  | :unknown_property
  | :invalid_selection
  | {:field, binary()}
  | {:members, binary()}
  | {:required, binary()}
  | {:subset_of, binary(), binary()}
  | {:required_when_set_nonempty, binary(), binary()}
  | {:ceiling, binary()}
```

# `scalar_type`

```elixir
@type scalar_type() :: :string | :integer | :boolean | {:unique_list, :string}
```

# `t`

```elixir
@type t() :: %PtcRunner.Kernel.SelectionRules{
  attestation: binary() | nil,
  cross_rules: [cross_rule()],
  fields: %{required(binary()) =&gt; field()},
  named_sets: %{required(binary()) =&gt; [binary()]}
}
```

# `explain`

```elixir
@spec explain(t(), term(), PtcRunner.Kernel.Limits.t()) ::
  {:ok, map()} | {:error, rejection()}
```

Normalizes a selection and names the closed rule that rejected it.

# `new`

```elixir
@spec new(keyword()) :: {:ok, t()} | {:error, :invalid_selection_rules}
```

Validates and seals one closed selection-rule program.

# `normalize`

```elixir
@spec normalize(t(), term(), PtcRunner.Kernel.Limits.t()) ::
  {:ok, map()} | {:error, :invalid_selection}
```

Purely normalizes one provider selection under the effective limits.

# `valid?`

```elixir
@spec valid?(term()) :: boolean()
```

Checks the complete data-only rule shape and its construction seal.

---

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