A2UICore.Validation.Topology (A2UICore v0.1.1)

Copy Markdown View Source

Component-graph validation: root presence, dangling references, self-references, cycles, depth, unreachable components, and catalog composition constraints.

All checks work on an A2UICore.State.Components set and an info_fun — a function from a component to what its catalog knows about the type (A2UICore.State.Component.info/0: the child RefSpec, allowed_parents, allowed_children; nil for an unknown type). They are pure and return :ok / {:ok, reachable} or {:error, %A2UICore.Error{}}.

Error categories follow the reference: a missing root, a dangling reference or an unreachable component is :integrity; a self-reference, a cycle or exceeding the depth limit is :recursion; a composition-constraint violation is :validation (UNALLOWED_PARENT / UNALLOWED_CHILD). Messages carry both the Python and TypeScript SDK phrasings, because conformance matches on message substrings.

Components are visited in sorted id order, so where a graph has several violations the one reported is deterministic (the reference follows insertion order).

Summary

Functions

Checks self-references, cycles and the depth limit, and (unless allow_orphan_components) that every component is reachable from the root. Returns the set of reachable ids.

Full topology validation: integrity, then reachability/cycles/depth. Empty component sets are valid.

Checks catalog allowedParents / allowedChildren constraints. A component constrained by allowed_parents that no component references is treated as a child of the surface itself.

Checks that the root exists (unless allow_missing_root) and that every referenced component exists (unless allow_dangling_references).

Types

info_fun()

(since 0.1.0)
@type info_fun() :: (A2UICore.State.Component.t() ->
                 A2UICore.State.Component.info() | nil)

Functions

analyze(components, info_fun, config)

(since 0.1.0)

Checks self-references, cycles and the depth limit, and (unless allow_orphan_components) that every component is reachable from the root. Returns the set of reachable ids.

validate(components, info_fun, config)

(since 0.1.0)

Full topology validation: integrity, then reachability/cycles/depth. Empty component sets are valid.

validate_composition(components, info_fun)

(since 0.1.0)
@spec validate_composition(A2UICore.State.Components.t(), info_fun()) ::
  :ok | {:error, A2UICore.Error.t()}

Checks catalog allowedParents / allowedChildren constraints. A component constrained by allowed_parents that no component references is treated as a child of the surface itself.

validate_integrity(components, info_fun, config)

(since 0.1.0)
@spec validate_integrity(
  A2UICore.State.Components.t(),
  info_fun(),
  A2UICore.Validation.Config.t()
) ::
  :ok | {:error, A2UICore.Error.t()}

Checks that the root exists (unless allow_missing_root) and that every referenced component exists (unless allow_dangling_references).