# `Noizu.Comms.Policy`
[🔗](https://github.com/noizu-labs-sdks/elixir-comms/blob/main/lib/lib/noizu/comms/policy.ex#L1)

Write policy: alias allow-list, raw-target gate, per-target rate limit.

* Alias targets (resolved from the targets YAML) must have
  `allow_write: true`.
* Raw URIs are refused unless `COMMS_ALLOW_RAW_TARGETS=1` (or app env
  `:noizu_comms, :allow_raw_targets, true`).
* Per-target token bucket, default 5 messages / 10 s (app env
  `:noizu_comms, :rate_limit, {cap, window_ms}`).

The bucket lives in a public ETS table with lazy refill; clock and sleep
are injectable via app env `:now_fn` / `:sleep_fn` for tests. Concurrent
senders may double-refill at the bucket boundary (bounded: at most
`cap - 1` extra messages per window under full contention).

# `check`

```elixir
@spec check(Noizu.Comms.Target.t(), atom()) :: :ok | {:error, Noizu.Comms.Error.t()}
```

Checks `target` for `action` (only `:write` is gated in v1).

# `reset`

```elixir
@spec reset() :: true
```

Drops the rate-limit table (test helper; recreated on next check).

---

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