Threadline.Verify.CoveragePolicy (Threadline v0.11.1)

Copy Markdown View Source

Pure policy for comparing Threadline.Health.trigger_coverage/1 output with host-configured expected audited table names.

Intersection semantics: Only tables listed in expected_tables are evaluated. Each must appear in the coverage list as {:covered, name}. {:uncovered, name} for an expected name is a violation. If a name is not present in the coverage list at all (e.g. typo or table outside the catalog Health enumerates), that is reported as {:missing, name}.

An empty expected_tables list yields no violations; the Mix task fails closed before invoking this module when the configured list is missing or empty.

Findings

partition_findings/2 sorts Threadline.Health.Finding structs into three buckets so a CI gate can fail on the ones it is responsible for while still surfacing everything else: :error findings on an expected table gate the task, :error findings on a table the host never listed are informational only, and :warning findings never fail the task regardless of table.

Summary

Functions

Partitions Threadline.Health.Finding structs into gated, not-gated and warning buckets, given the host's expected-table positive list.

Counts expected tables vs how many are fully covered (no violation row).

Returns a sorted list of violations for tables the host expects to be covered.

Functions

partition_findings(findings, expected_tables)

@spec partition_findings([Threadline.Health.Finding.t()], [String.t()]) :: %{
  gated: [Threadline.Health.Finding.t()],
  not_gated: [Threadline.Health.Finding.t()],
  warnings: [Threadline.Health.Finding.t()]
}

Partitions Threadline.Health.Finding structs into gated, not-gated and warning buckets, given the host's expected-table positive list.

  • :gated — :error findings whose table is in expected_tables. These are the findings a CI gate must fail on.
  • :not_gated — :error findings whose table is not in expected_tables. Printed for visibility; never fails the task.
  • :warnings — every :warning finding, regardless of table.

Each bucket keeps the input list's order. Pure; does not read the database or call Mix.raise.

summary_counts(coverage, expected_tables)

Counts expected tables vs how many are fully covered (no violation row).

violations(coverage, expected_tables)

Returns a sorted list of violations for tables the host expects to be covered.

coverage is [{:covered | :uncovered, String.t()}] from Threadline.Health.trigger_coverage/1. expected_tables is a list of unique public table name strings.