# `Threadline.Health`
[🔗](https://github.com/szTheory/threadline/blob/v0.5.0/lib/threadline/health.ex#L1)

Health checks for Threadline infrastructure.

Queries the PostgreSQL system catalog to verify trigger installation status
for all user tables.

## Mix-task parity

See `mix threadline.health.coverage` for a viewer with `--json` and
`--schema=NAME` flags. The Mix task does not exit non-zero on uncovered
tables (it is a viewer, not a CI gate); use `mix threadline.verify_coverage`
for the positive-list CI gate.

## Telemetry

On every successful call, emits `[:threadline, :health, :checked]` with
measurements `%{covered: integer, uncovered: integer, expected_uncovered: integer}`.
The `expected_uncovered` measurement was added in Phase 66 (additive — old
subscribers reading only `covered`/`uncovered` keep working unchanged).

# `trigger_coverage`

Returns a list of tagged tuples indicating trigger coverage for all user
tables in the given schema (default `"public"`).

Audit tables (`audit_transactions`, `audit_changes`, `audit_actions`) are
excluded from the result — they are not expected to have triggers (CAP-10).

Phase 66 introduced a third tuple variant `{:expected_uncovered, name}` for
bookkeeping tables that are intentionally not audited (e.g. `schema_migrations`).
The bucket is computed from a hardcoded baseline plus
`config :threadline, :health, expected_uncovered_tables: [...]`, with
`:audit_anyway` removing entries from the union.

## Options

- `:repo` — required `Ecto.Repo` module
- `:schema` — optional schema name string (default `"public"`). Programmatic
  callers are responsible for sanitizing or trusting their own input —
  this function does NOT validate `:schema` against `pg_namespace`. Surfaces
  that take untrusted input (LV / Mix task) MUST validate at the edge.

Returns `[{:covered | :uncovered | :expected_uncovered, table_name}]`.

## Example

    Threadline.Health.trigger_coverage(repo: MyApp.Repo)
    #=> [{:covered, "users"}, {:expected_uncovered, "schema_migrations"}, {:uncovered, "orders"}]

---

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