Skip to main content

Module lint

Module lint 

Source
Expand description

Non-destructive structural diagnostics for a schema. Ported from ~/dev/omnist/omnist/ops/lint.py.

Schema::validate checks a document against a schema; lint checks the schema itself for structural problems that parse fine but mean parts of the schema can never do anything. It reports, never mutatesprune/normalize are the transforms that fix these issues; lint only diagnoses them.

Four checks:

  • lint.unsatisfiable-record (warning) – a reachable record no finite document can match (e.g. a mandatory ref cycle). Reuses super::prune::satisfiable_set (its complement), intersected with reachable.
  • lint.unreachable-record (warning) – a record defined in the env but not reachable from root by following any ref. A plain reachability walk (no pruning): every Ref-typed field is followed regardless of cardinality.
  • lint.duplicate-record (warning) – two or more structurally identical records under different names. Reuses super::minimize::equivalence_classes on the raw schema, so duplicates are reported as authored.
  • lint.any-field (info) – an inventory of every any-typed field, so a human can audit the schema’s deliberate openings. Advisory only; never affects a caller’s exit code on its own.

Structs§

LintFinding
One structural diagnostic. code is a stable machine-readable identifier (lint.unsatisfiable-record, lint.unreachable-record, lint.duplicate-record, lint.any-field); severity is warning or info; location is a record name (or Record.label for lint.any-field); message is a human-readable, actionable description.

Functions§

lint
Structural diagnostics for s – see the module doc comment for the checks. Returns findings sorted deterministically by (code, location). Never mutates s.