Cerbero.Check.Judgment (cerbero v0.1.0)

Copy Markdown View Source

The shared judgment spine every scale-gated rule walks: born-silence -> scale/traffic -> Cerbero.Severity.assess/6 -> finding assembly (default relations, judged-lock metadata).

Rules parameterize the spine with their target selection and message text and keep their own wording; the spine owns the invariant mechanics, so a rule cannot accidentally skip born-silencing or forget to declare the lock it judged. Extracted from what Cerbero.Check.RawDDLSafety's private generic judge already was (issue #4 item 8).

Options:

  • :message (required) — zero-arity fun producing the finding message; lazy so suppressed verdicts never build strings.
  • :severity — post-processes the assessed severity; return :suppress to emit nothing. Default suppresses :none and keeps the rest. Rules use it for floors (TRUNCATE's unconditional :error) and stricter gates (strict_concurrent_index, fk's error/warning-only).
  • :also_assess — additional tables assessed with the same lock/cost (and the target's traffic); the most severe verdict wins. nil entries are ignored (unknown referenced table). Born-silencing applies to the target only — an FK onto a born table still scans the populated referenced side.
  • :relations — override the default [qualified_target].
  • :engine — engine tag on the finding (default nil).

Summary

Types

params()

@type params() :: %{
  table: String.t() | nil,
  lock: Cerbero.DDL.Effect.lock(),
  cost: Cerbero.DDL.Effect.cost(),
  line: integer() | nil
}

Functions

judge(check_module, params, migration, catalog, config, opts)