PtcRunner.Kernel.ContractSchemaDiagnostic (PtcRunner v0.14.0)

Copy Markdown View Source

Closed projection policy for rejected value-contract schema documents.

The supported schema profile is deliberately narrow, and its edges are not guessable from a bare refusal: an unsupported keyword, a misspelled type, an untyped node, and an unsatisfiable bound are four different authoring mistakes with four different fixes. Reporting them identically forces the author to bisect their own schema to find the boundary.

A rejection therefore carries a closed rule atom, rendered here from a fixed literal, and the segments locating the fault. Compiler prose never crosses the boundary, and the pointer is minted only after every segment is proven to resolve in the submitted document, so a diagnostic can never name a location that file does not carry.

Summary

Functions

Locates a rejection inside the named document it came from.

Renders one rule as its fixed message, or declines so the catalog literal stands.

Returns every rule the schema compiler can emit.

Types

detail()

@type detail() :: %{rule: atom(), path: PtcRunner.Kernel.CommandPath.t() | nil}

Functions

detail(name, document, arg3)

@spec detail(binary(), term(), term()) :: detail()

Locates a rejection inside the named document it came from.

The name and the document are taken together so a pointer can never be minted against one contract file and reported under another. The path is dropped rather than guessed when the segments do not resolve — a non-object contract document has no pointer at all — so the diagnostic degrades to a location-free rule instead of naming somewhere the author cannot open.

message(rule)

@spec message(term()) :: {:ok, binary()} | :error

Renders one rule as its fixed message, or declines so the catalog literal stands.

rules()

@spec rules() :: [atom()]

Returns every rule the schema compiler can emit.

Rules without a message fall back to the catalog literal; the set is exposed so a test can prove the vocabularies have not drifted apart.