Bloccs.Validator (bloccs v0.1.0)

Copy Markdown View Source

Contract validator for parsed node + network manifests.

Accumulates every problem it finds rather than short-circuiting. Returns :ok or {:error, [%Bloccs.Validator.Issue{}]}.

Checks for a node:

  • effects use only known capabilities (http, db, time, random)
  • port schemas resolve in Bloccs.Schema (deferred until M5 with :require_schemas)
  • pure_core / effect_shell MFAs are well-formed
  • retry/timeout/idempotency keys are well-typed

Checks for a network:

  • every edge from/to references a known node port
  • edge schemas match across the wire
  • the graph is a DAG (no cycles; v0.1 = DAG-only)
  • [expose] references real node ports
  • supervision strategy ∈ valid set

Summary

Functions

Validate a parsed network manifest. Validates each contained node first; if any node fails, network-level checks still run so the user sees the whole picture.

Validate a parsed node manifest. By default the function existence is NOT checked (that's the macro's job at compile time). Pass :require_schemas if you want every port schema to be required-registered.

Return advisory warnings about manifest fields that are accepted by the parser but not yet honoured at runtime.

Functions

validate_network(network, opts \\ [])

@spec validate_network(
  Bloccs.Manifest.Network.t(),
  keyword()
) :: :ok | {:error, [Bloccs.Validator.Issue.t()]}

Validate a parsed network manifest. Validates each contained node first; if any node fails, network-level checks still run so the user sees the whole picture.

validate_node(node, opts \\ [])

@spec validate_node(
  Bloccs.Manifest.Node.t(),
  keyword()
) :: :ok | {:error, [Bloccs.Validator.Issue.t()]}

Validate a parsed node manifest. By default the function existence is NOT checked (that's the macro's job at compile time). Pass :require_schemas if you want every port schema to be required-registered.

warnings(node)

Return advisory warnings about manifest fields that are accepted by the parser but not yet honoured at runtime.

Returns a flat list of %Issue{level: :warning}. Callers decide how to surface them — Bloccs.Node __using__/1 emits IO.warn; the CLI tasks print a yellow block.

As of v0.4 + subgraph composition, every parsed manifest field is consumed: the node-level runtime fields ([contract].retry / timeout_ms / idempotency, [ports.in].<port>.buffer, [observability]) are wired, and [expose] now drives subgraph composition and the CLI intake. So this currently returns []. It is kept as the seam for any future parsed-but-unwired field; callers surface whatever it returns.