RelayMark (relay_mark_elixir v0.6.1)

Copy Markdown View Source

Elixir adapter for RelayMark AST and manifest JSON.

This package intentionally models the portable RelayMark contract. Relay app persistence, authorization, and action execution belong in client projects.

Summary

Functions

Projects a canonical RelayMark document map into its portable manifest.

Validates a canonical, JSON-keyed RelayMark document map.

Validates and returns a canonical RelayMark document, raising on failure.

Validates a canonical, JSON-keyed RelayMark projection manifest map.

Validates one exact transported Agent Answer document/manifest JSON pair.

Functions

decode_document(json)

@spec decode_document(binary()) :: {:ok, RelayMark.Document.t()} | {:error, term()}

decode_layer_composition(json)

@spec decode_layer_composition(binary()) ::
  {:ok, RelayMark.Composition.t()} | {:error, term()}

decode_manifest(json)

@spec decode_manifest(binary()) :: {:ok, RelayMark.Manifest.t()} | {:error, term()}

project_manifest(document, diagnostics \\ [])

@spec project_manifest(map(), [map()]) :: map()

Projects a canonical RelayMark document map into its portable manifest.

Hosts should use this function instead of maintaining a parallel manifest projector so newly added portable directives remain consistent everywhere.

validate_document(document, validation_context \\ %{})

@spec validate_document(map(), map()) :: :ok | {:error, [RelayMark.Diagnostic.t()]}

Validates a canonical, JSON-keyed RelayMark document map.

Structural validation is compiled from the canonical JSON Schema 2020-12 document schema. Semantic validation applies the same directive, evidence, lifecycle, comparison, and identity rules as the reference runtime.

validate_document!(document, validation_context \\ %{})

@spec validate_document!(map(), map()) :: map()

Validates and returns a canonical RelayMark document, raising on failure.

validate_layer_composition(composition)

@spec validate_layer_composition(term()) :: :ok | {:error, [RelayMark.Diagnostic.t()]}

validate_manifest(manifest)

@spec validate_manifest(term()) :: :ok | {:error, [RelayMark.Diagnostic.t()]}

Validates a canonical, JSON-keyed RelayMark projection manifest map.

Structural validation is compiled from the canonical JSON Schema 2020-12 manifest and diagnostic schemas bundled in the package.

validate_transported_agent_answer_pair(document_json, manifest_json, validation_context \\ %{})

@spec validate_transported_agent_answer_pair(binary(), binary(), map()) ::
  {:ok, RelayMark.AgentAnswer.validated_pair()}
  | {:error, [RelayMark.Diagnostic.t()]}

Validates one exact transported Agent Answer document/manifest JSON pair.

Success returns decoded value models plus SHA-256 digests of the exact input bytes. Any semantic or canonical projection mismatch is rejected.