# `AshOnetime.Boundary.Query`
[🔗](https://github.com/baselabs/ash_onetime/blob/v1.9.2/lib/ash_onetime/boundary/query.ex#L1)

The context-boundary query expression and its validation.

A query is a boolean expression over tags and types — `{:tag, t}`, `{:type, t}`,
`{:any, [branch]}`, `{:all, [branch]}`, `{:not, inner}` — with branches as lists of
expressions. Validation enforces the package's size bounds and **tag-anchoring**:
every fact the query can match carries at least one tag the query names, which is
what makes `AshOnetime.Boundary.append_if/5`'s advisory-lock set cover the context
(any concurrent writer whose fact matches must lock one of those tags). A query
naming no tag — or whose matches could be satisfied by a type branch or a negation
alone — is refused.

# `expr`

```elixir
@type expr() ::
  {:tag, leaf()}
  | {:type, leaf()}
  | {:any, [expr()]}
  | {:all, [expr()]}
  | {:not, expr()}
```

# `leaf`

```elixir
@type leaf() :: binary()
```

# `t`

```elixir
@type t() :: %AshOnetime.Boundary.Query{expr: expr(), tags: [binary()]}
```

# `predicate`

```elixir
@spec predicate(t(), pos_integer()) :: {binary(), [binary()]}
```

Compiles the validated expression into a parameterized SQL predicate.

`start` is the 1-based index of the first parameter the predicate may claim;
returns the fragment and its parameter list.

# `validate`

```elixir
@spec validate(term()) :: {:ok, t()} | {:error, String.t()}
```

---

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